]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper.el
Update maintainer's email address.
[gnu-emacs] / lisp / emulation / viper.el
index 3a95fa268350f9399c72332537cd944d81a545c2..fd1a8aa92ea84a86876cd012bbccc5a81ae8aadb 100644 (file)
@@ -3,12 +3,13 @@
 ;;              and a venomous VI PERil.
 ;;              Viper Is also a Package for Emacs Rebels.
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Keywords: emulations
 
-(defconst viper-version "3.11.5 of July 8, 2005"
+(defconst viper-version "3.13.1 of October 23, 2006"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
@@ -358,7 +359,7 @@ user decide when to invoke Viper in a major mode."
 (defcustom viper-mode (cond (noninteractive nil)
                            (t 'ask))
   "To Viperize or not to Viperize.
-If t, viperize emacs.  If nil -- don't.  If `ask', ask the user.
+If t, viperize Emacs.  If nil -- don't.  If `ask', ask the user.
 This variable is used primatily when Viper is being loaded.
 
 Must be set in `~/.emacs' before Viper is loaded.
@@ -371,7 +372,6 @@ widget."
 (defcustom viper-vi-state-mode-list
   '(fundamental-mode
     makefile-mode
-    help-mode
 
     awk-mode
     m4-mode
@@ -397,7 +397,7 @@ widget."
     tex-mode latex-mode bibtex-mode
     ps-mode
 
-    completion-list-mode
+    ;; completion-list-mode
     diff-mode
     idl-mode
 
@@ -425,17 +425,24 @@ widget."
 
     browse-kill-ring-mode
     recentf-mode
+    recentf-dialog-mode
     occur-mode
 
     mh-folder-mode
-    mail-mode
     gnus-group-mode
     gnus-summary-mode
 
+    completion-list-mode
+    help-mode
+
     Info-mode
     Buffer-menu-mode
     compilation-mode
 
+    rcirc-mode
+
+    jde-javadoc-checker-report-mode
+
     view-mode
     vm-mode
     vm-summary-mode)
@@ -451,6 +458,7 @@ unless it is coming up in a wrong Viper state."
   '(internal-ange-ftp-mode
     comint-mode
     inferior-emacs-lisp-mode
+    erc-mode
     eshell-mode
     shell-mode)
   "*A list of major modes that should come up in Vi Insert state."
@@ -487,15 +495,17 @@ unless it is coming up in a wrong Viper state."
     (gnus-summary-mode emacs-state viper-gnus-modifier-map)
     (Info-mode emacs-state viper-slash-and-colon-map)
     (Buffer-menu-mode emacs-state viper-slash-and-colon-map)
+    (erc-mode insert-state viper-comint-mode-modifier-map)
+    (erc-mode vi-state viper-comint-mode-modifier-map)
     )
   "List specifying how to modify the various major modes to enable some Viperisms.
 The list has the structure: ((mode viper-state keymap) (mode viper-state
 keymap) ...).  If `mode' is on the list, the `kemap' will be made active (on
 the minor-mode-map-alist) in the specified viper state.
-If you change this list, have to restart emacs for the change to take effect.
-However, if you did the change through the customization widget, then emacs
+If you change this list, have to restart Emacs for the change to take effect.
+However, if you did the change through the customization widget, then Emacs
 needs to be restarted only if you deleted a triple mode-state-keymap from the
-list.  No need to restart emacs in case of insertion or modification of an
+list.  No need to restart Emacs in case of insertion or modification of an
 existing triple."
   :type '(repeat
          (list symbol
@@ -522,7 +532,7 @@ If Viper is enabled, turn it off.  Otherwise, turn it on."
 
 ;;;###autoload
 (defun viper-mode ()
-  "Turn on Viper emulation of Vi."
+  "Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Viper'."
   (interactive)
   (if (not noninteractive)
       (progn
@@ -535,8 +545,6 @@ If Viper is enabled, turn it off.  Otherwise, turn it on."
        (if viper-first-time ; Important check.  Prevents mix-up of startup
            (progn           ; and expert-level msgs when viper-mode recurses
              (setq viper-first-time nil)
-             (setq viper-vi-state-cursor-color
-                   (viper-get-cursor-color))
              (if (not viper-inhibit-startup-message)
                  (save-window-excursion
                    (setq viper-inhibit-startup-message t)
@@ -601,14 +609,13 @@ This startup message appears whenever you load Viper, unless you type `y' now."
                    ))
              (viper-set-expert-level 'dont-change-unless)))
 
-       (if viper-xemacs-p
-           (make-variable-buffer-local 'bar-cursor))
        (if (eq major-mode 'viper-mode)
            (setq major-mode 'fundamental-mode))
 
        (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi
            (memq major-mode viper-insert-state-mode-list) ; don't switch
-           (viper-change-state-to-vi)))))
+           (viper-change-state-to-vi))
+       )))
 
 
 ;; Apply a little heuristic to invoke vi state on major-modes
@@ -623,8 +630,8 @@ This startup message appears whenever you load Viper, unless you type `y' now."
 \f
 ;; This hook designed to enable Vi-style editing in comint-based modes."
 (defun viper-comint-mode-hook ()
-  (setq require-final-newline nil
-       viper-ex-style-editing nil
+  (set (make-local-variable 'require-final-newline) nil)
+  (setq viper-ex-style-editing nil
        viper-ex-style-motion nil)
   (viper-change-state-to-insert))
 
@@ -655,8 +662,7 @@ This function tries to do as good a job as possible.  However, it may undo some
 user customization, unrelated to Viper.  For instance, if the user advised
 `read-file-name', `describe-key', and some others, then this advice will be
 undone.
-It also doesn't undo some Viper settings.  For instance, `minor-mode-map-alist'
-remains buffer-local."
+It also can't undo some Viper settings."
   (interactive)
 
   ;; restore non-viper vars
@@ -682,7 +688,9 @@ remains buffer-local."
        'mark-even-if-inactive viper-saved-non-viper-variables)))
 
   ;; Ideally, we would like to be able to de-localize local variables
-  (viper-delocalize-var 'minor-mode-map-alist)
+  (unless
+      (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
+    (viper-delocalize-var 'minor-mode-map-alist))
   (viper-delocalize-var 'require-final-newline)
   (if viper-xemacs-p (viper-delocalize-var 'bar-cursor))
 
@@ -762,8 +770,10 @@ remains buffer-local."
   ;; remove all hooks set by viper
   (mapatoms 'viper-remove-hooks)
   (remove-hook 'comint-mode-hook 'viper-comint-mode-hook)
+  (remove-hook 'erc-mode-hook 'viper-comint-mode-hook)
   (remove-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)
   (remove-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)
+  (remove-hook 'post-command-hook 'viper-minibuffer-post-command-hook)
 
   ;; unbind Viper mouse bindings
   (viper-unbind-mouse-search-key)
@@ -849,8 +859,11 @@ remains buffer-local."
   ;; info about the display and windows until emacs initialization is complete
   ;; So do it via the window-setup-hook
   (add-hook 'window-setup-hook
-           '(lambda ()
-              (setq viper-vi-state-cursor-color (viper-get-cursor-color))))
+           '(lambda ()
+              (modify-frame-parameters
+               (selected-frame)
+               (list (cons 'viper-vi-state-cursor-color
+                           (viper-get-cursor-color))))))
 
   ;; Tell vc-diff to put *vc* in Vi mode
   (if (featurep 'vc)
@@ -878,7 +891,7 @@ remains buffer-local."
   (eval-after-load
    "passwd"
    '(defadvice read-passwd-1 (before viper-passwd-ad activate)
-      "Switch to emacs state while reading password."
+      "Switch to Emacs state while reading password."
       (viper-change-state-to-emacs)))
 
   (defadvice self-insert-command (around viper-self-insert-ad activate)
@@ -888,6 +901,13 @@ remains buffer-local."
       ad-do-it
       ))
 
+  (defadvice set-cursor-color (after viper-set-cursor-color-ad activate)
+    "Change cursor color in VI state."
+    (modify-frame-parameters
+       (selected-frame)
+       (list (cons 'viper-vi-state-cursor-color (ad-get-arg 0))))
+    )
+
   (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
     ;; needs to be as early as possible
     (add-to-ordered-list
@@ -898,6 +918,7 @@ remains buffer-local."
 
   ;; Emacs shell, ange-ftp, and comint-based modes
   (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint
+  (add-hook 'erc-mode-hook 'viper-comint-mode-hook) ; ERC
 
   (add-hook 'eshell-mode-hook
            (lambda () (setq viper-auto-indent nil)))
@@ -918,7 +939,7 @@ remains buffer-local."
   (eval-after-load
    "rmailedit"
    '(defadvice rmail-cease-edit (after viper-rmail-advice activate)
-      "Switch to emacs state when done editing message."
+      "Switch to Emacs state when done editing message."
       (viper-change-state-to-emacs)))
   ;; In case RMAIL was loaded before Viper.
   (defadvice rmail-cease-edit (after viper-rmail-advice activate)
@@ -930,55 +951,55 @@ remains buffer-local."
   ;; the advice.
   (eval-after-load
    "iso-acc"
-   (defadvice iso-accents-mode (around viper-iso-accents-advice activate)
-     "Set viper-automatic-iso-accents to iso-accents-mode."
-     (let ((arg (ad-get-arg 0)))
-       ad-do-it
-       (setq viper-automatic-iso-accents
-            (if (eq viper-current-state 'vi-state)
-                (if arg
-                    ;; if iso-accents-mode was called with positive arg, turn
-                    ;; accents on
-                    (> (prefix-numeric-value arg) 0)
-                  ;; else: toggle viper-automatic-iso-accents
-                  (not viper-automatic-iso-accents))
-              ;; other states: accept what iso-accents-mode has done
-              iso-accents-mode))
-       ;; turn off ISO accents in vi-state
-       (if (eq viper-current-state 'vi-state)
-          (viper-set-iso-accents-mode nil))
-       (if (memq viper-current-state '(vi-state insert-state replace-state))
-          (message "Viper ISO accents mode: %s"
-                   (if viper-automatic-iso-accents "on" "off")))
-       )))
+   '(defadvice iso-accents-mode (around viper-iso-accents-advice activate)
+      "Set viper-automatic-iso-accents to iso-accents-mode."
+      (let ((arg (ad-get-arg 0)))
+       ad-do-it
+       (setq viper-automatic-iso-accents
+             (if (eq viper-current-state 'vi-state)
+                 (if arg
+                     ;; if iso-accents-mode was called with positive arg, turn
+                     ;; accents on
+                     (> (prefix-numeric-value arg) 0)
+                   ;; else: toggle viper-automatic-iso-accents
+                   (not viper-automatic-iso-accents))
+               ;; other states: accept what iso-accents-mode has done
+               iso-accents-mode))
+       ;; turn off ISO accents in vi-state
+       (if (eq viper-current-state 'vi-state)
+           (viper-set-iso-accents-mode nil))
+       (if (memq viper-current-state '(vi-state insert-state replace-state))
+           (message "Viper ISO accents mode: %s"
+                    (if viper-automatic-iso-accents "on" "off")))
+       )))
 
   ;; International input methods
   (if viper-emacs-p
       (eval-after-load "mule-cmds"
-       (progn
-         (defadvice inactivate-input-method (after viper-mule-advice activate)
-           "Set viper-special-input-method to disable intl. input methods."
-           (viper-inactivate-input-method-action))
-         (defadvice activate-input-method (after viper-mule-advice activate)
-           "Set viper-special-input-method to enable intl. input methods."
-           (viper-activate-input-method-action))
-         ))
+       '(progn
+          (defadvice inactivate-input-method (after viper-mule-advice activate)
+            "Set viper-special-input-method to disable intl. input methods."
+            (viper-inactivate-input-method-action))
+          (defadvice activate-input-method (after viper-mule-advice activate)
+            "Set viper-special-input-method to enable intl. input methods."
+            (viper-activate-input-method-action))
+          ))
     ;; XEmacs Although these hooks exist in Emacs, they don't seem to be always
     ;; called on input-method activation/deactivation, so we the above advise
     ;; functions instead.
     (eval-after-load "mule-cmds"
-      (progn
-       (add-hook 'input-method-activate-hook
-                 'viper-activate-input-method-action t)
-       (add-hook 'input-method-inactivate-hook
-                 'viper-inactivate-input-method-action t)))
+      '(progn
+        (add-hook 'input-method-activate-hook
+                  'viper-activate-input-method-action t)
+        (add-hook 'input-method-inactivate-hook
+                  'viper-inactivate-input-method-action t)))
     )
   (eval-after-load "mule-cmds"
-    (defadvice toggle-input-method (around viper-mule-advice activate)
-      "Adjust input-method toggling in vi-state."
-      (if (and viper-special-input-method (eq viper-current-state 'vi-state))
-         (viper-inactivate-input-method)
-       ad-do-it)))
+    '(defadvice toggle-input-method (around viper-mule-advice activate)
+       "Adjust input-method toggling in vi-state."
+       (if (and viper-special-input-method (eq viper-current-state 'vi-state))
+          (viper-inactivate-input-method)
+        ad-do-it)))
 
   ) ; viper-set-hooks
 
@@ -986,23 +1007,13 @@ remains buffer-local."
 ;; these are primarily advices and Vi-ish variable settings
 (defun viper-non-hook-settings ()
 
-  ;; This var is not local in Emacs, so we make it local.  It must be local
-  ;; because although the stack of minor modes can be the same for all buffers,
-  ;; the associated *keymaps* can be different.  In Viper,
-  ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have
-  ;; different keymaps for different buffers.  Also, the keymaps associated
-  ;; with viper-vi/insert-state-modifier-minor-mode can be different.
-  (make-variable-buffer-local 'minor-mode-map-alist)
-
-  ;; Viper changes the default mode-line-buffer-identification
-  (setq-default mode-line-buffer-identification '(" %b"))
+  ;;;; Viper changes the default mode-line-buffer-identification
+  ;;(setq-default mode-line-buffer-identification '(" %b"))
 
   ;; setup emacs-supported vi-style feel
   (setq next-line-add-newlines nil
        require-final-newline t)
 
-  (make-variable-buffer-local 'require-final-newline)
-
   ;; don't bark when mark is inactive
   (if viper-emacs-p
       (setq mark-even-if-inactive t))
@@ -1010,7 +1021,6 @@ remains buffer-local."
   (setq scroll-step 1)
 
   ;; Variable displaying the current Viper state in the mode line.
-  (viper-deflocalvar viper-mode-string viper-emacs-state-id)
   (or (memq 'viper-mode-string global-mode-string)
       (setq global-mode-string
            (append '("" viper-mode-string) (cdr global-mode-string))))
@@ -1087,9 +1097,11 @@ remains buffer-local."
                             viper-advice-add-minor-mode
                             (toggle name &optional keymap after toggle-fun)
                             activate)
-  "Run viper-normalize-minor-mode-map-alist after adding a minor mode."
-  (viper-normalize-minor-mode-map-alist)
-  (setq-default minor-mode-map-alist minor-mode-map-alist))
+    "Run viper-normalize-minor-mode-map-alist after adding a minor mode."
+    (viper-normalize-minor-mode-map-alist)
+    (unless
+       (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
+      (setq-default minor-mode-map-alist minor-mode-map-alist)))
 
   ;; catch frame switching event
   (if (viper-window-display-p)
@@ -1109,7 +1121,7 @@ remains buffer-local."
        (save-window-excursion
         (with-output-to-temp-buffer " *viper-info*"
           (princ "
-You have loaded Viper, and are about to Viperize your emacs!
+You have loaded Viper, and are about to Viperize your Emacs!
 
 Viper is a Package for Emacs Rebels and a venomous VI PERil,
 
@@ -1263,11 +1275,10 @@ These two lines must come in the order given.
 (define-key
   viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi)
 
+;;; Removed to avoid bad interaction with cua-mode.
 ;;; Escape from Emacs and Insert modes to Vi for one command
-(define-key
-  viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)
-(define-key
-  viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
+;;(define-key viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)
+;;(define-key viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
 
 (if viper-mode
     (setq-default viper-emacs-intercept-minor-mode t
@@ -1295,7 +1306,10 @@ These two lines must come in the order given.
 (if (and viper-mode (eq viper-current-state 'emacs-state))
     (progn
       (viper-change-state-to-emacs)
-      (setq-default minor-mode-map-alist minor-mode-map-alist)
+      (unless
+         (and (fboundp 'add-to-ordered-list)
+              (boundp 'emulation-mode-map-alists))
+       (setq-default minor-mode-map-alist minor-mode-map-alist))
       ))
 
 (if (and viper-mode (this-major-mode-requires-vi-state major-mode))
@@ -1315,9 +1329,9 @@ These two lines must come in the order given.
 (provide 'viper)
 
 
-;;; Local Variables:
-;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
-;;; End:
+;; Local Variables:
+;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
+;; End:
 
-;;; arch-tag: 5f3e844c-c4e6-4bbd-9b73-63bdc14e7d79
+;; arch-tag: 5f3e844c-c4e6-4bbd-9b73-63bdc14e7d79
 ;;; viper.el ends here