/[emacs]/emacs/lisp/emulation/viper.el
ViewVC logotype

Diff of /emacs/lisp/emulation/viper.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.73 by kifer, Tue Apr 16 05:49:11 2002 UTC revision 1.73.2.1 by miles, Fri Apr 4 06:20:20 2003 UTC
# Line 103  Line 103 
103  ;;  -----------------  ;;  -----------------
104  ;;  Bug reports and ideas contributed by many users have helped  ;;  Bug reports and ideas contributed by many users have helped
105  ;;  improve Viper and the various versions of VIP.  ;;  improve Viper and the various versions of VIP.
106  ;;  See the on-line manual for a complete list of contributors.  ;;  See the on-line manual for a complete list of contributors.
107  ;;  ;;
108  ;;  ;;
109  ;;; Notes:  ;;; Notes:
# Line 112  Line 112 
112  ;; In most cases, Viper handles major modes correctly, i.e., they come up  ;; In most cases, Viper handles major modes correctly, i.e., they come up
113  ;; in the right state (either  vi-state or emacs-state).  For instance, text  ;; in the right state (either  vi-state or emacs-state).  For instance, text
114  ;; files come up in vi-state, while, say, Dired appears in emacs-state by  ;; files come up in vi-state, while, say, Dired appears in emacs-state by
115  ;; default.  ;; default.
116  ;; However, some modes do not appear in the right mode in the beginning,  ;; However, some modes do not appear in the right mode in the beginning,
117  ;; usually because they neglect to follow Emacs conventions (e.g., they don't  ;; usually because they neglect to follow Emacs conventions (e.g., they don't
118  ;; use kill-all-local-variables when they start).  Some major modes  ;; use kill-all-local-variables when they start).  Some major modes
119  ;; may fail to come up in emacs-state if they call hooks, such as  ;; may fail to come up in emacs-state if they call hooks, such as
120  ;; text-hook, for no good reason.  ;; text-hook, for no good reason.
121  ;;  ;;
122  ;; As an immediate solution, you can hit C-z to bring about the right mode.  ;; As an immediate solution, you can hit C-z to bring about the right mode.
123  ;; An interim solution is to add an appropriate hook to the mode like this:  ;; An interim solution is to add an appropriate hook to the mode like this:
124  ;;  ;;
125  ;;     (add-hook 'your-favorite-mode 'viper-mode)  ;;     (add-hook 'your-favorite-mode 'viper-mode)
126  ;; or      ;; or
127  ;;     (add-hook 'your-favorite-mode 'viper-change-state-to-emacs)  ;;     (add-hook 'your-favorite-mode 'viper-change-state-to-emacs)
128  ;;  ;;
129  ;; whichever applies.  The right thing to do, however, is to complain to the  ;; whichever applies.  The right thing to do, however, is to complain to the
130  ;; author of the respective package. (Sometimes they also neglect to equip  ;; author of the respective package. (Sometimes they also neglect to equip
131  ;; their  modes with hooks, which is one more reason for complaining.)  ;; their  modes with hooks, which is one more reason for complaining.)
132  ;;  ;;
133  ;; 2. Keymap handling  ;; 2. Keymap handling
134  ;;    Each Viper state (insert, vi, replace) is implemented as a collection of  ;;    Each Viper state (insert, vi, replace) is implemented as a collection of
135  ;;    several minor modes, each with its own keymap.  ;;    several minor modes, each with its own keymap.
# Line 220  Line 220 
220  ;;  viper-insert-global-user-minor-mode can be set with the define-key command.  ;;  viper-insert-global-user-minor-mode can be set with the define-key command.
221  ;;  ;;
222  ;;  The next minor mode, viper-insert-kbd-minor-mode,  ;;  The next minor mode, viper-insert-kbd-minor-mode,
223  ;;  is used for keyboard VI-style macros defined with :map!.  ;;  is used for keyboard VI-style macros defined with :map!.
224  ;;  ;;
225  ;;  The fifth minor mode, viper-insert-state-modifier-minor-mode, is like  ;;  The fifth minor mode, viper-insert-state-modifier-minor-mode, is like
226  ;;  viper-vi-state-modifier-minor-mode, except that it is used in the Insert  ;;  viper-vi-state-modifier-minor-mode, except that it is used in the Insert
227  ;;  state; it can be used to modify keys in a mode-specific fashion.  ;;  state; it can be used to modify keys in a mode-specific fashion.
228  ;;  ;;
229  ;;  The minor mode viper-insert-diehard-minor-mode is in effect when  ;;  The minor mode viper-insert-diehard-minor-mode is in effect when
230  ;;  the user wants a high degree of Vi compatibility (a bad idea, really!).  ;;  the user wants a high degree of Vi compatibility (a bad idea, really!).
231  ;;  The last minor mode, viper-insert-basic-minor-mode, is always in effect  ;;  The last minor mode, viper-insert-basic-minor-mode, is always in effect
232  ;;  when Viper is in insert state.  It binds a small number of keys needed for  ;;  when Viper is in insert state.  It binds a small number of keys needed for
233  ;;  Viper's operation.  ;;  Viper's operation.
234  ;;  ;;
235  ;;  Finally, Viper provides minor modes for overriding bindings set by Emacs  ;;  Finally, Viper provides minor modes for overriding bindings set by Emacs
236  ;;  modes when Viper is in Emacs state:  ;;  modes when Viper is in Emacs state:
# Line 261  Line 261 
261  ;;     used in conjunction with the minor modes for insert-state, and its  ;;     used in conjunction with the minor modes for insert-state, and its
262  ;;     keymap overshadows the keymaps for insert minor modes.  ;;     keymap overshadows the keymaps for insert minor modes.
263  ;;  ;;
264  ;;  4. Defining buffer-local bindings in Vi and Insert modes.  ;;  4. Defining buffer-local bindings in Vi and Insert modes.
265  ;;  As mentioned before, sometimes, it is convenient to have  ;;  As mentioned before, sometimes, it is convenient to have
266  ;;  buffer-specific of mode-specific key bindings in Vi and insert modes.  ;;  buffer-specific of mode-specific key bindings in Vi and insert modes.
267  ;;  Viper provides a special function, viper-add-local-keys, to do precisely  ;;  Viper provides a special function, viper-add-local-keys, to do precisely
268  ;;  this.  For instance, is you need to add couple of mode-specific bindings  ;;  this.  For instance, is you need to add couple of mode-specific bindings
269  ;;  to Insert mode, you can put  ;;  to Insert mode, you can put
270  ;;  ;;
271  ;;       (viper-add-local-keys 'insert-state '((key1 . func1) (key2 .func2)))  ;;       (viper-add-local-keys 'insert-state '((key1 . func1) (key2 .func2)))
272  ;;  ;;
273  ;;  somewhere in a hook of this major mode.  If you put something like this  ;;  somewhere in a hook of this major mode.  If you put something like this
274  ;;  in your own elisp function, this will define bindings specific to the  ;;  in your own elisp function, this will define bindings specific to the
# Line 353  user decide when to invoke Viper in a ma Line 353  user decide when to invoke Viper in a ma
353  ;; Non-viper variables that need to be saved in case the user decides to  ;; Non-viper variables that need to be saved in case the user decides to
354  ;; de-viperize emacs.  ;; de-viperize emacs.
355  (defvar viper-saved-non-viper-variables nil)  (defvar viper-saved-non-viper-variables nil)
356                  
357  (defcustom viper-mode (cond (noninteractive nil)  (defcustom viper-mode (cond (noninteractive nil)
358                              (t 'ask))                              (t 'ask))
359    "To Viperize or not to Viperize.    "To Viperize or not to Viperize.
# Line 371  widget." Line 371  widget."
371    '(fundamental-mode    '(fundamental-mode
372      makefile-mode      makefile-mode
373      help-mode      help-mode
374        
375      awk-mode      awk-mode
376      m4-mode      m4-mode
377      xrdb-mode      xrdb-mode
378      winmgr-mode      winmgr-mode
379      autoconf-mode      autoconf-mode
380      cvs-edit-mode      cvs-edit-mode
381        
382      html-mode html-helper-mode      html-mode html-helper-mode
383      emacs-lisp-mode lisp-mode lisp-interaction-mode      emacs-lisp-mode lisp-mode lisp-interaction-mode
384                                      
385      jde-mode java-mode      jde-mode java-mode
386      cc-mode c-mode c++-mode objc-mode      cc-mode c-mode c++-mode objc-mode
387      fortran-mode f90-mode      fortran-mode f90-mode
388      basic-mode      basic-mode
# Line 395  widget." Line 395  widget."
395      text-mode indented-text-mode      text-mode indented-text-mode
396      tex-mode latex-mode bibtex-mode      tex-mode latex-mode bibtex-mode
397      ps-mode      ps-mode
398                                      
399      completion-list-mode      completion-list-mode
400      diff-mode      diff-mode
401      idl-mode      idl-mode
402        
403      perl-mode      perl-mode
404      cperl-mode      cperl-mode
405      javascript-mode      javascript-mode
406      tcl-mode      tcl-mode
407      python-mode      python-mode
408                                      
409      sh-mode ksh-mode csh-mode      sh-mode ksh-mode csh-mode
410                                      
411      gnus-article-mode      gnus-article-mode
412      mh-show-mode      mh-show-mode
413      )      )
# Line 422  widget." Line 422  widget."
422      efs-mode      efs-mode
423      tar-mode      tar-mode
424    
425        browse-kill-ring-mode
426        recentf-mode
427        occur-mode
428    
429      mh-folder-mode      mh-folder-mode
430      mail-mode      mail-mode
431      gnus-group-mode      gnus-group-mode
432      gnus-summary-mode      gnus-summary-mode
433        
434      Info-mode      Info-mode
435      Buffer-menu-mode      Buffer-menu-mode
436      compilation-mode      compilation-mode
437        
438      view-mode      view-mode
439      vm-mode      vm-mode
440      vm-summary-mode)      vm-summary-mode)
# Line 527  If Viper is enabled, turn it off.  Other Line 531  If Viper is enabled, turn it off.  Other
531            (setq viper-mode t)            (setq viper-mode t)
532            (load-library "viper"))            (load-library "viper"))
533    
534          (if viper-first-time ; Important check.  Prevents mix-up of startup          (if viper-first-time ; Important check.  Prevents mix-up of startup
535              (progn           ; and expert-level msgs when viper-mode recurses              (progn           ; and expert-level msgs when viper-mode recurses
536                (setq viper-first-time nil)                (setq viper-first-time nil)
537                (setq viper-vi-state-cursor-color                (setq viper-vi-state-cursor-color
# Line 549  and improving upon much of it. Line 553  and improving upon much of it.
553    
554     1. Viper supports Vi at several levels.  Level 1 is the closest to Vi,     1. Viper supports Vi at several levels.  Level 1 is the closest to Vi,
555        level 5 provides the most flexibility to depart from many Vi conventions.        level 5 provides the most flexibility to depart from many Vi conventions.
556          
557        You will be asked to specify your user level in a following screen.        You will be asked to specify your user level in a following screen.
558      
559        If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave        If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave
560        as in VI, to smooth transition to Viper for the beginners.  However, to        as in VI, to smooth transition to Viper for the beginners.  However, to
561        use Emacs productively, you are advised to reach user level 3 or higher.        use Emacs productively, you are advised to reach user level 3 or higher.
562          
563        At user level 2 or higher, ^X and ^C have Emacs, not Vi, bindings;        At user level 2 or higher, ^X and ^C have Emacs, not Vi, bindings;
564        ^Z toggles Vi/Emacs states; ^G is Emacs' keyboard-quit (like ^C in Vi).        ^Z toggles Vi/Emacs states; ^G is Emacs' keyboard-quit (like ^C in Vi).
565      
566     2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they     2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they
567        do not cause Emacs to quit, except at user level 1 (for a novice).        do not cause Emacs to quit, except at user level 1 (for a novice).
568     3. ^X^C EXITS EMACS.     3. ^X^C EXITS EMACS.
569     4. Viper supports multiple undo: `u' will undo.  Typing `.' will repeat     4. Viper supports multiple undo: `u' will undo.  Typing `.' will repeat
570        undo.  Another `u' changes direction.        undo.  Another `u' changes direction.
571      
572     6. Emacs Meta key is `C-\\' (in all modes) or `\\ ESC' (in Vi command mode).     6. Emacs Meta key is `C-\\' (in all modes) or `\\ ESC' (in Vi command mode).
573        On a window system, the best way is to use the Meta-key on your keyboard.        On a window system, the best way is to use the Meta-key on your keyboard.
574     7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if     7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if
575        something funny happens.  This would abort the current editing command.        something funny happens.  This would abort the current editing command.
576          
577  For more information on Viper:  For more information on Viper:
578    
579     a. Type `:help' in Vi command mode     a. Type `:help' in Vi command mode
# Line 580  To submit a bug report or to contact the Line 584  To submit a bug report or to contact the
584  command mode.  To shoo Viper away and return to pure Emacs (horror!), type:  command mode.  To shoo Viper away and return to pure Emacs (horror!), type:
585    
586     M-x viper-go-away     M-x viper-go-away
587        
588  This startup message appears whenever you load Viper, unless you type `y' now."  This startup message appears whenever you load Viper, unless you type `y' now."
589                        ))                        ))
590                      (goto-char (point-min))                      (goto-char (point-min))
# Line 604  This startup message appears whenever yo Line 608  This startup message appears whenever yo
608          (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi          (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi
609              (memq major-mode viper-insert-state-mode-list) ; don't switch              (memq major-mode viper-insert-state-mode-list) ; don't switch
610              (viper-change-state-to-vi)))))              (viper-change-state-to-vi)))))
611      
612    
613  ;; Apply a little heuristic to invoke vi state on major-modes  ;; Apply a little heuristic to invoke vi state on major-modes
614  ;; that are not listed in viper-vi-state-mode-list  ;; that are not listed in viper-vi-state-mode-list
# Line 657  remains buffer-local." Line 661  remains buffer-local."
661    ;; restore non-viper vars    ;; restore non-viper vars
662    (setq-default    (setq-default
663     next-line-add-newlines     next-line-add-newlines
664     (viper-standard-value     (viper-standard-value
665      'next-line-add-newlines viper-saved-non-viper-variables)      'next-line-add-newlines viper-saved-non-viper-variables)
666     require-final-newline     require-final-newline
667     (viper-standard-value     (viper-standard-value
668      'require-final-newline viper-saved-non-viper-variables)      'require-final-newline viper-saved-non-viper-variables)
669     scroll-step     scroll-step
670     (viper-standard-value 'scroll-step viper-saved-non-viper-variables)     (viper-standard-value 'scroll-step viper-saved-non-viper-variables)
671     mode-line-buffer-identification     mode-line-buffer-identification
672     (viper-standard-value     (viper-standard-value
673      'mode-line-buffer-identification viper-saved-non-viper-variables)      'mode-line-buffer-identification viper-saved-non-viper-variables)
# Line 676  remains buffer-local." Line 680  remains buffer-local."
680         (viper-standard-value         (viper-standard-value
681          'mark-even-if-inactive viper-saved-non-viper-variables)))          'mark-even-if-inactive viper-saved-non-viper-variables)))
682    
683    ;; Ideally, we would like to be able to de-localize local variables    ;; Ideally, we would like to be able to de-localize local variables
684    (viper-delocalize-var 'minor-mode-map-alist)    (viper-delocalize-var 'minor-mode-map-alist)
685    (viper-delocalize-var 'require-final-newline)    (viper-delocalize-var 'require-final-newline)
686    (if viper-xemacs-p (viper-delocalize-var 'bar-cursor))    (if viper-xemacs-p (viper-delocalize-var 'bar-cursor))
687    
688      
689    ;; deactivate all advices done by Viper.    ;; deactivate all advices done by Viper.
690    (ad-deactivate-regexp "viper-")    (ad-deactivate-regexp "viper-")
691    
# Line 691  remains buffer-local." Line 695  remains buffer-local."
695    (viper-delocalize-var 'viper-insert-minibuffer-minor-mode)    (viper-delocalize-var 'viper-insert-minibuffer-minor-mode)
696    (viper-delocalize-var 'viper-vi-intercept-minor-mode)    (viper-delocalize-var 'viper-vi-intercept-minor-mode)
697    (viper-delocalize-var 'viper-insert-intercept-minor-mode)    (viper-delocalize-var 'viper-insert-intercept-minor-mode)
698      
699    (viper-delocalize-var 'viper-vi-local-user-minor-mode)    (viper-delocalize-var 'viper-vi-local-user-minor-mode)
700    (viper-delocalize-var 'viper-vi-kbd-minor-mode)    (viper-delocalize-var 'viper-vi-kbd-minor-mode)
701    (viper-delocalize-var 'viper-vi-global-user-minor-mode)    (viper-delocalize-var 'viper-vi-global-user-minor-mode)
702    (viper-delocalize-var 'viper-vi-state-modifier-minor-mode)    (viper-delocalize-var 'viper-vi-state-modifier-minor-mode)
703    (viper-delocalize-var 'viper-vi-diehard-minor-mode)    (viper-delocalize-var 'viper-vi-diehard-minor-mode)
704    (viper-delocalize-var 'viper-vi-basic-minor-mode)    (viper-delocalize-var 'viper-vi-basic-minor-mode)
705            
706    (viper-delocalize-var 'viper-replace-minor-mode)    (viper-delocalize-var 'viper-replace-minor-mode)
707            
708    (viper-delocalize-var 'viper-insert-local-user-minor-mode)    (viper-delocalize-var 'viper-insert-local-user-minor-mode)
709    (viper-delocalize-var 'viper-insert-kbd-minor-mode)    (viper-delocalize-var 'viper-insert-kbd-minor-mode)
710    (viper-delocalize-var 'viper-insert-global-user-minor-mode)    (viper-delocalize-var 'viper-insert-global-user-minor-mode)
711    (viper-delocalize-var 'viper-insert-state-modifier-minor-mode)    (viper-delocalize-var 'viper-insert-state-modifier-minor-mode)
712    (viper-delocalize-var 'viper-insert-diehard-minor-mode)    (viper-delocalize-var 'viper-insert-diehard-minor-mode)
713    (viper-delocalize-var 'viper-insert-basic-minor-mode)    (viper-delocalize-var 'viper-insert-basic-minor-mode)
714      
715    (viper-delocalize-var 'viper-emacs-intercept-minor-mode)    (viper-delocalize-var 'viper-emacs-intercept-minor-mode)
716    (viper-delocalize-var 'viper-emacs-local-user-minor-mode)    (viper-delocalize-var 'viper-emacs-local-user-minor-mode)
717    (viper-delocalize-var 'viper-emacs-kbd-minor-mode)    (viper-delocalize-var 'viper-emacs-kbd-minor-mode)
# Line 721  remains buffer-local." Line 725  remains buffer-local."
725                  viper-insert-minibuffer-minor-mode     nil                  viper-insert-minibuffer-minor-mode     nil
726                  viper-vi-intercept-minor-mode          nil                  viper-vi-intercept-minor-mode          nil
727                  viper-insert-intercept-minor-mode      nil                  viper-insert-intercept-minor-mode      nil
728                    
729                  viper-vi-local-user-minor-mode         nil                  viper-vi-local-user-minor-mode         nil
730                  viper-vi-kbd-minor-mode                nil                  viper-vi-kbd-minor-mode                nil
731                  viper-vi-global-user-minor-mode        nil                  viper-vi-global-user-minor-mode        nil
732                  viper-vi-state-modifier-minor-mode     nil                  viper-vi-state-modifier-minor-mode     nil
733                  viper-vi-diehard-minor-mode            nil                  viper-vi-diehard-minor-mode            nil
734                  viper-vi-basic-minor-mode              nil                  viper-vi-basic-minor-mode              nil
735                    
736                  viper-replace-minor-mode               nil                  viper-replace-minor-mode               nil
737                    
738                  viper-insert-local-user-minor-mode     nil                  viper-insert-local-user-minor-mode     nil
739                  viper-insert-kbd-minor-mode            nil                  viper-insert-kbd-minor-mode            nil
740                  viper-insert-global-user-minor-mode    nil                  viper-insert-global-user-minor-mode    nil
# Line 800  remains buffer-local." Line 804  remains buffer-local."
804  (defun viper-major-mode-change-sentinel ()  (defun viper-major-mode-change-sentinel ()
805    (save-match-data    (save-match-data
806      (or (string-match "\*Minibuf-" (buffer-name))      (or (string-match "\*Minibuf-" (buffer-name))
807          (setq viper-new-major-mode-buffer-list          (setq viper-new-major-mode-buffer-list
808                (cons (current-buffer) viper-new-major-mode-buffer-list))))                (cons (current-buffer) viper-new-major-mode-buffer-list))))
809    ;; change the global value of hook    ;; change the global value of hook
810    (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t))    (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t))
# Line 817  remains buffer-local." Line 821  remains buffer-local."
821    ;; back to fundamental-mode.    ;; back to fundamental-mode.
822    (if (eq default-major-mode 'fundamental-mode)    (if (eq default-major-mode 'fundamental-mode)
823        (setq default-major-mode 'viper-mode))        (setq default-major-mode 'viper-mode))
824      
825    (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)    (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)
826    (add-hook 'find-file-hooks 'set-viper-state-in-major-mode)    (add-hook 'find-file-hooks 'set-viper-state-in-major-mode)
827    
828    ;; keep this because many modes we don't know about use this hook    ;; keep this because many modes we don't know about use this hook
829    (defvar text-mode-hook)    (defvar text-mode-hook)
830    (add-hook 'text-mode-hook 'viper-mode)    (add-hook 'text-mode-hook 'viper-mode)
831          
832    (defvar emerge-startup-hook)    (defvar emerge-startup-hook)
833    (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs)    (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs)
834    
# Line 851  remains buffer-local." Line 855  remains buffer-local."
855       '(defadvice vc-diff (after viper-vc-ad activate)       '(defadvice vc-diff (after viper-vc-ad activate)
856          "Force Vi state in VC diff buffer."          "Force Vi state in VC diff buffer."
857          (viper-change-state-to-vi))))          (viper-change-state-to-vi))))
858        
859    (eval-after-load    (eval-after-load
860     "emerge"     "emerge"
861     '(defadvice emerge-quit (after viper-emerge-advice activate)     '(defadvice emerge-quit (after viper-emerge-advice activate)
# Line 861  remains buffer-local." Line 865  remains buffer-local."
865    (defadvice emerge-quit (after viper-emerge-advice activate)    (defadvice emerge-quit (after viper-emerge-advice activate)
866      "Run `viper-change-state-to-vi' after quitting emerge."      "Run `viper-change-state-to-vi' after quitting emerge."
867      (viper-change-state-to-vi))      (viper-change-state-to-vi))
868      
869    ;; passwd.el sets up its own buffer, which turns up in Vi mode,    ;; passwd.el sets up its own buffer, which turns up in Vi mode,
870    ;; thus overriding the local map.  We don't need Vi mode here.    ;; thus overriding the local map.  We don't need Vi mode here.
871    (eval-after-load    (eval-after-load
# Line 869  remains buffer-local." Line 873  remains buffer-local."
873     '(defadvice read-passwd-1 (before viper-passwd-ad activate)     '(defadvice read-passwd-1 (before viper-passwd-ad activate)
874        "Switch to emacs state while reading password."        "Switch to emacs state while reading password."
875        (viper-change-state-to-emacs)))        (viper-change-state-to-emacs)))
876      
877    ;; Emacs shell, ange-ftp, and comint-based modes    ;; Emacs shell, ange-ftp, and comint-based modes
878    (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint    (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint
879    
# Line 883  remains buffer-local." Line 887  remains buffer-local."
887    
888    ;; Modify major modes according to viper-major-mode-modifier-list    ;; Modify major modes according to viper-major-mode-modifier-list
889    (viper-apply-major-mode-modifiers)    (viper-apply-major-mode-modifiers)
890      
891    ;; For RMAIL users.    ;; For RMAIL users.
892    ;; Put buf in Emacs state after edit.    ;; Put buf in Emacs state after edit.
893    (eval-after-load    (eval-after-load
# Line 905  remains buffer-local." Line 909  remains buffer-local."
909       "Set viper-automatic-iso-accents to iso-accents-mode."       "Set viper-automatic-iso-accents to iso-accents-mode."
910       (let ((arg (ad-get-arg 0)))       (let ((arg (ad-get-arg 0)))
911         ad-do-it         ad-do-it
912         (setq viper-automatic-iso-accents         (setq viper-automatic-iso-accents
913               (if (eq viper-current-state 'vi-state)               (if (eq viper-current-state 'vi-state)
914                   (if arg                   (if arg
915                       ;; if iso-accents-mode was called with positive arg, turn                       ;; if iso-accents-mode was called with positive arg, turn
# Line 950  remains buffer-local." Line 954  remains buffer-local."
954        (if (and viper-special-input-method (eq viper-current-state 'vi-state))        (if (and viper-special-input-method (eq viper-current-state 'vi-state))
955            (viper-inactivate-input-method)            (viper-inactivate-input-method)
956          ad-do-it)))          ad-do-it)))
957      
958    ) ; viper-set-hooks    ) ; viper-set-hooks
959    
960    
# Line 964  remains buffer-local." Line 968  remains buffer-local."
968    ;; different keymaps for different buffers.  Also, the keymaps associated    ;; different keymaps for different buffers.  Also, the keymaps associated
969    ;; with viper-vi/insert-state-modifier-minor-mode can be different.    ;; with viper-vi/insert-state-modifier-minor-mode can be different.
970    (make-variable-buffer-local 'minor-mode-map-alist)    (make-variable-buffer-local 'minor-mode-map-alist)
971      
972    ;; Viper changes the default mode-line-buffer-identification    ;; Viper changes the default mode-line-buffer-identification
973    (setq-default mode-line-buffer-identification '(" %b"))    (setq-default mode-line-buffer-identification '(" %b"))
974      
975    ;; setup emacs-supported vi-style feel    ;; setup emacs-supported vi-style feel
976    (setq next-line-add-newlines nil    (setq next-line-add-newlines nil
977          require-final-newline t)          require-final-newline t)
978      
979    (make-variable-buffer-local 'require-final-newline)    (make-variable-buffer-local 'require-final-newline)
980      
981    ;; don't bark when mark is inactive    ;; don't bark when mark is inactive
982    (if viper-emacs-p    (if viper-emacs-p
983        (setq mark-even-if-inactive t))        (setq mark-even-if-inactive t))
984      
985    (setq scroll-step 1)    (setq scroll-step 1)
986      
987    ;; Variable displaying the current Viper state in the mode line.    ;; Variable displaying the current Viper state in the mode line.
988    (viper-deflocalvar viper-mode-string viper-emacs-state-id)    (viper-deflocalvar viper-mode-string viper-emacs-state-id)
989    (or (memq 'viper-mode-string global-mode-string)    (or (memq 'viper-mode-string global-mode-string)
# Line 989  remains buffer-local." Line 993  remains buffer-local."
993    (defadvice describe-key (before viper-read-keyseq-ad protect activate)    (defadvice describe-key (before viper-read-keyseq-ad protect activate)
994      "Force to read key via `viper-read-key-sequence'."      "Force to read key via `viper-read-key-sequence'."
995      (interactive (list (viper-read-key-sequence "Describe key: "))))      (interactive (list (viper-read-key-sequence "Describe key: "))))
996      
997    (defadvice describe-key-briefly    (defadvice describe-key-briefly
998      (before viper-read-keyseq-ad protect activate)      (before viper-read-keyseq-ad protect activate)
999      "Force to read key via `viper-read-key-sequence'."      "Force to read key via `viper-read-key-sequence'."
1000      (interactive (list (viper-read-key-sequence "Describe key briefly: "))))      (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
1001      
1002      
1003    (defadvice find-file (before viper-add-suffix-advice activate)    (defadvice find-file (before viper-add-suffix-advice activate)
1004      "Use `read-file-name' for reading arguments."      "Use `read-file-name' for reading arguments."
1005      (interactive (cons (read-file-name "Find file: " nil default-directory)      (interactive (cons (read-file-name "Find file: " nil default-directory)
# Line 1008  remains buffer-local." Line 1012  remains buffer-local."
1012                               ((and viper-emacs-p (boundp 'find-file-wildcards))                               ((and viper-emacs-p (boundp 'find-file-wildcards))
1013                                     (list find-file-wildcards))))                                     (list find-file-wildcards))))
1014                   ))                   ))
1015      
1016    (defadvice find-file-other-window (before viper-add-suffix-advice activate)    (defadvice find-file-other-window (before viper-add-suffix-advice activate)
1017      "Use `read-file-name' for reading arguments."      "Use `read-file-name' for reading arguments."
1018      (interactive (cons (read-file-name "Find file in other window: "      (interactive (cons (read-file-name "Find file in other window: "
# Line 1022  remains buffer-local." Line 1026  remains buffer-local."
1026                               ((and viper-emacs-p (boundp 'find-file-wildcards))                               ((and viper-emacs-p (boundp 'find-file-wildcards))
1027                                (list find-file-wildcards))))                                (list find-file-wildcards))))
1028                   ))                   ))
1029      
1030    
1031    (defadvice find-file-other-frame (before viper-add-suffix-advice activate)    (defadvice find-file-other-frame (before viper-add-suffix-advice activate)
1032      "Use `read-file-name' for reading arguments."      "Use `read-file-name' for reading arguments."
# Line 1038  remains buffer-local." Line 1042  remains buffer-local."
1042                                (list find-file-wildcards))))                                (list find-file-wildcards))))
1043                   ))                   ))
1044    
1045      
1046    (defadvice read-file-name (around viper-suffix-advice activate)    (defadvice read-file-name (around viper-suffix-advice activate)
1047      "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook."      "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook."
1048      (let ((viper-minibuffer-exit-hook      (let ((viper-minibuffer-exit-hook
1049             (append viper-minibuffer-exit-hook             (append viper-minibuffer-exit-hook
1050                     '(viper-minibuffer-trim-tail viper-file-add-suffix))))                     '(viper-minibuffer-trim-tail viper-file-add-suffix))))
1051        ad-do-it))        ad-do-it))
1052      
1053    (defadvice start-kbd-macro (after viper-kbd-advice activate)    (defadvice start-kbd-macro (after viper-kbd-advice activate)
1054      "Remove Viper's intercepting bindings for C-x ).      "Remove Viper's intercepting bindings for C-x ).
1055    This may be needed if the previous `:map' command terminated abnormally."    This may be needed if the previous `:map' command terminated abnormally."
# Line 1059  remains buffer-local." Line 1063  remains buffer-local."
1063               (add-hook 'mouse-leave-frame-hook               (add-hook 'mouse-leave-frame-hook
1064                         'viper-remember-current-frame)                         'viper-remember-current-frame)
1065             (defadvice handle-switch-frame (before viper-frame-advice activate)             (defadvice handle-switch-frame (before viper-frame-advice activate)
1066               "Remember the selected frame before the switch-frame event."               "Remember the selected frame before the switch-frame event."
1067               (viper-remember-current-frame (selected-frame)))) )               (viper-remember-current-frame (selected-frame)))) )
1068    
1069    ) ; end viper-non-hook-settings    ) ; end viper-non-hook-settings
# Line 1077  Viper is a Package for Emacs Rebels and Line 1081  Viper is a Package for Emacs Rebels and
1081    
1082  It's time to decide: to Viperize or not to Viperize...  It's time to decide: to Viperize or not to Viperize...
1083    
1084  If you wish to Viperize AND make this your way of life, please put  If you wish to Viperize AND make this your way of life, please put
1085    
1086          (setq viper-mode t)          (setq viper-mode t)
1087          (require 'viper)          (require 'viper)
# Line 1098  These two lines must come in the order g Line 1102  These two lines must come in the order g
1102        ((eq viper-mode t))        ((eq viper-mode t))
1103        ;; Otherwise, it was asking Viper was not loaded through .emacs        ;; Otherwise, it was asking Viper was not loaded through .emacs
1104        ;; In this case, it was either through M-x viper-mode or via something        ;; In this case, it was either through M-x viper-mode or via something
1105        ;; else, like the custom widget.  If Viper was loaded through        ;; else, like the custom widget.  If Viper was loaded through
1106        ;; M-x viper-mode, then viper will kick in anyway.        ;; M-x viper-mode, then viper will kick in anyway.
1107        (t (setq viper-mode nil)))        (t (setq viper-mode nil)))
1108    
# Line 1125  These two lines must come in the order g Line 1129  These two lines must come in the order g
1129             (if viper-emacs-p             (if viper-emacs-p
1130                 (cons 'mark-even-if-inactive (list mark-even-if-inactive)))                 (cons 'mark-even-if-inactive (list mark-even-if-inactive)))
1131             )))             )))
1132          
1133          
1134  ;; Set some useful macros, advices  ;; Set some useful macros, advices
1135  ;; These must be BEFORE ~/.viper is loaded,  ;; These must be BEFORE ~/.viper is loaded,
1136  ;; so the user can unrecord them in ~/.viper.  ;; so the user can unrecord them in ~/.viper.
1137  (if viper-mode  (if viper-mode
1138      (progn      (progn
# Line 1143  These two lines must come in the order g Line 1147  These two lines must come in the order g
1147        (viper-record-kbd-macro        (viper-record-kbd-macro
1148         (vector viper-repeat-from-history-key '\2) 'vi-state         (vector viper-repeat-from-history-key '\2) 'vi-state
1149         [(meta x) v i p e r - r e p e a t - f r o m - h i s t o r y return] 't)         [(meta x) v i p e r - r e p e a t - f r o m - h i s t o r y return] 't)
1150          
1151        ;; set macros for toggling case sensitivity and regexp search        ;; set macros for toggling case sensitivity and regexp search
1152        (viper-set-searchstyle-toggling-macros nil)        (viper-set-searchstyle-toggling-macros nil)
1153        ;; Make %%% toggle parsing comments for matching parentheses        ;; Make %%% toggle parsing comments for matching parentheses
1154        (viper-set-parsing-style-toggling-macro nil)        (viper-set-parsing-style-toggling-macro nil)
1155    
1156        ;; ~/.viper is loaded if exists        ;; ~/.viper is loaded if exists
1157        (viper-load-custom-file)        (viper-load-custom-file)
1158      
1159        ;; should be after loading custom file to avoid the pesky msg that        ;; should be after loading custom file to avoid the pesky msg that
1160        ;; mouse-search/insert keys are already bound        ;; mouse-search/insert keys are already bound
1161        (viper-bind-mouse-search-key)        (viper-bind-mouse-search-key)
1162        (viper-bind-mouse-insert-key)        (viper-bind-mouse-insert-key)
1163        ))        ))
1164    
1165    
1166    
1167  ;; Applying Viper customization -- runs after (load .viper)  ;; Applying Viper customization -- runs after (load .viper)
1168    
1169  ;; Save user settings or Viper defaults for vars controlled by  ;; Save user settings or Viper defaults for vars controlled by
1170  ;; viper-expert-level  ;; viper-expert-level
1171  (if (null viper-saved-user-settings)  (if (null viper-saved-user-settings)
1172      (setq viper-saved-user-settings      (setq viper-saved-user-settings
1173            (list (cons 'viper-want-ctl-h-help (list viper-want-ctl-h-help))            (list (cons 'viper-want-ctl-h-help (list viper-want-ctl-h-help))
1174                  (cons 'viper-always (list viper-always))                  (cons 'viper-always (list viper-always))
1175                  (cons 'viper-no-multiple-ESC (list viper-no-multiple-ESC))                  (cons 'viper-no-multiple-ESC (list viper-no-multiple-ESC))
1176                  (cons 'viper-ex-style-motion (list viper-ex-style-motion))                  (cons 'viper-ex-style-motion (list viper-ex-style-motion))
1177                  (cons 'viper-ex-style-editing                  (cons 'viper-ex-style-editing
1178                        (list viper-ex-style-editing))                        (list viper-ex-style-editing))
1179                  (cons 'viper-want-emacs-keys-in-vi                  (cons 'viper-want-emacs-keys-in-vi
1180                        (list viper-want-emacs-keys-in-vi))                        (list viper-want-emacs-keys-in-vi))
1181                  (cons 'viper-electric-mode (list viper-electric-mode))                  (cons 'viper-electric-mode (list viper-electric-mode))
1182                  (cons 'viper-want-emacs-keys-in-insert                  (cons 'viper-want-emacs-keys-in-insert
1183                        (list viper-want-emacs-keys-in-insert))                        (list viper-want-emacs-keys-in-insert))
1184                  (cons 'viper-re-search (list viper-re-search)))))                  (cons 'viper-re-search (list viper-re-search)))))
1185                  
1186    
1187  (if viper-mode  (if viper-mode
1188      (progn      (progn
# Line 1187  These two lines must come in the order g Line 1191  These two lines must come in the order g
1191            (viper-buffer-search-enable))            (viper-buffer-search-enable))
1192        (viper-update-syntax-classes 'set-default)        (viper-update-syntax-classes 'set-default)
1193        ))        ))
1194      
1195    
1196  ;;; Familiarize Viper with some minor modes that have their own keymaps  ;;; Familiarize Viper with some minor modes that have their own keymaps
1197  (if viper-mode  (if viper-mode
# Line 1224  These two lines must come in the order g Line 1228  These two lines must come in the order g
1228  (define-key viper-vi-intercept-map viper-toggle-key 'viper-toggle-key-action)  (define-key viper-vi-intercept-map viper-toggle-key 'viper-toggle-key-action)
1229  (define-key  (define-key
1230    viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi)    viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi)
1231      
1232  ;;; Escape from Emacs and Insert modes to Vi for one command  ;;; Escape from Emacs and Insert modes to Vi for one command
1233  (define-key  (define-key
1234    viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)    viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)
1235  (define-key  (define-key
1236    viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)    viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
1237    
1238  (if viper-mode  (if viper-mode
# Line 1246  These two lines must come in the order g Line 1250  These two lines must come in the order g
1250    
1251    
1252  (if (and viper-mode  (if (and viper-mode
1253           (or viper-always           (or viper-always
1254               (and (< viper-expert-level 5) (> viper-expert-level 0))))               (and (< viper-expert-level 5) (> viper-expert-level 0))))
1255      (viper-set-hooks))      (viper-set-hooks))
1256        
1257  ;; Let all minor modes take effect after loading.  ;; Let all minor modes take effect after loading.
1258  ;; This may not be enough, so we also set default minor-mode-alist.  ;; This may not be enough, so we also set default minor-mode-alist.
1259  ;; Without setting the default, new buffers that come up in emacs mode have  ;; Without setting the default, new buffers that come up in emacs mode have

Legend:
Removed from v.1.73  
changed lines
  Added in v.1.73.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26