]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper.el
* progmodes/cfengine.el: Add CFEngine 3.x syntax highlighting and support.
[gnu-emacs] / lisp / emulation / viper.el
index e9b6f95b90a7cffe866b368ca03525097a189d67..3704725b8dd25b4681409c5e8667accd898b3c13 100644 (file)
@@ -1,20 +1,20 @@
-;;; viper.el --- A full-featured Vi emulator for GNU Emacs and XEmacs,
+;;; viper.el --- A full-featured Vi emulator for Emacs and XEmacs,
 ;;              a VI Plan for Emacs Rescue,
 ;;              and a venomous VI PERil.
 ;;              Viper Is also a Package for Emacs Rebels.
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2011 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Keywords: emulations
+;; Version: 3.14.1
 
 ;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
 ;; file on 20/3/2008, and the maintainer agreed that when a bug is
 ;; filed in the Emacs bug reporting system against this file, a copy
 ;; of the bug report be sent to the maintainer's email address.
 
-(defconst viper-version "3.14 of April 06, 2008"
+(defconst viper-version "3.14.1 of August 15, 2009"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
 ;;    convoluted.  Instead of viper-command-argument, keymaps should bind the
 ;;    actual commands.  E.g., "dw" should be bound to a generic command
 ;;    viper-delete that will delete things based on the value of
-;;    last-command-char.  This would greatly simplify the logic and the code.
+;;    last-command-event.  This would greatly simplify the logic and the code.
 ;;
 ;; 2. Somebody should venture to write a customization package a la
 ;;    options.el that would allow the user to change values of variables
@@ -491,7 +491,7 @@ unless it is coming up in a wrong Viper state."
     )
   "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
+keymap) ...).  If `mode' is on the list, the `keymap' 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
@@ -547,7 +547,7 @@ If Viper is enabled, turn it off.  Otherwise, turn it on."
                      "Viper Is a Package for Emacs Rebels,
 a VI Plan for Emacs Rescue, and a venomous VI PERil.
 
-Incidentally, Viper emulates Vi under GNU Emacs 20 and XEmacs 20.
+Incidentally, Viper emulates Vi under Emacs/XEmacs 20.
 It supports all of what is good in Vi and Ex, while extending
 and improving upon much of it.
 
@@ -647,10 +647,9 @@ This startup message appears whenever you load Viper, unless you type `y' now."
 ;; Remove local value in all existing buffers
 ;; This doesn't delocalize vars (which would have been desirable)
 (defun viper-delocalize-var (symbol)
-  (mapcar (lambda (buf) (save-excursion
-                         (set-buffer buf)
-                         (kill-local-variable symbol)))
-         (buffer-list)))
+  (dolist (buf (buffer-list))
+    (with-current-buffer buf
+      (kill-local-variable symbol))))
 
 
 (defun viper-go-away ()
@@ -678,8 +677,9 @@ It also can't undo some Viper settings."
    global-mode-string
    (delq 'viper-mode-string global-mode-string))
 
-  (setq default-major-mode
-       (viper-standard-value 'default-major-mode viper-saved-non-viper-variables))
+  (setq-default major-mode
+                (viper-standard-value 'default-major-mode
+                                      viper-saved-non-viper-variables))
 
   (if (featurep 'emacs)
       (setq-default
@@ -777,7 +777,7 @@ It also can't undo some Viper settings."
   (viper-unbind-mouse-search-key)
   (viper-unbind-mouse-insert-key)
   ;; In emacs, we have to advice handle-switch-frame
-  ;; This advice is undone earlier, when all advices matchine "viper-" are
+  ;; This advice is undone earlier, when all advices matching "viper-" are
   ;; deactivated.
   (if (featurep 'xemacs)
       (remove-hook 'mouse-leave-frame-hook 'viper-remember-current-frame))
@@ -834,8 +834,8 @@ It also can't undo some Viper settings."
   ;; in Fundamental Mode and Vi state.
   ;; When viper-mode is executed in such a case, it will set the major mode
   ;; back to fundamental-mode.
-  (if (eq default-major-mode 'fundamental-mode)
-      (setq default-major-mode 'viper-mode))
+  (if (eq (default-value 'major-mode) 'fundamental-mode)
+      (setq-default major-mode 'viper-mode))
 
   (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)
   (add-hook 'find-file-hooks 'set-viper-state-in-major-mode)
@@ -850,41 +850,34 @@ It also can't undo some Viper settings."
   ;; Zap bad bindings in flyspell-mouse-map, which prevent ESC from working
   ;; over misspelled words (due to the overlay keymaps)
   (defvar flyspell-mode-hook)
+  (defvar flyspell-mouse-map)
   (add-hook 'flyspell-mode-hook
-           '(lambda ()
-              (define-key flyspell-mouse-map viper-ESC-key nil)))
+           (lambda ()
+              (define-key flyspell-mouse-map viper-ESC-key nil)))
   ;; if viper is started from .emacs, it might be impossible to get certain
   ;; 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 ()
-              (modify-frame-parameters
-               (selected-frame)
-               (list (cons 'viper-vi-state-cursor-color
-                           (viper-get-cursor-color))))
-              (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))))
+              (setq viper-vi-state-cursor-color (viper-get-cursor-color))
+              ))
 
   ;; Tell vc-diff to put *vc* in Vi mode
-  (if (featurep 'vc)
-      (defadvice vc-diff (after viper-vc-ad activate)
-       "Force Vi state in VC diff buffer."
-       (viper-change-state-to-vi))
-    (eval-after-load
-     "vc"
-     '(defadvice vc-diff (after viper-vc-ad activate)
-       "Force Vi state in VC diff buffer."
-       (viper-change-state-to-vi))))
+  (eval-after-load
+      "vc"
+    '(defadvice vc-diff (after viper-vc-ad activate)
+       "Force Vi state in VC diff buffer."
+       (viper-change-state-to-vi)))
 
   (eval-after-load
    "emerge"
    '(defadvice emerge-quit (after viper-emerge-advice activate)
       "Run `viper-change-state-to-vi' after quitting emerge."
       (viper-change-state-to-vi)))
-  ;; In case Emerge was loaded before Viper.
-  (defadvice emerge-quit (after viper-emerge-advice activate)
-    "Run `viper-change-state-to-vi' after quitting emerge."
-    (viper-change-state-to-vi))
 
   ;; passwd.el sets up its own buffer, which turns up in Vi mode,
   ;; thus overriding the local map.  We don't need Vi mode here.
@@ -896,7 +889,11 @@ It also can't undo some Viper settings."
 
   (defadvice self-insert-command (around viper-self-insert-ad activate)
     "Ignore all self-inserting keys in the vi-state."
-    (if (and (eq viper-current-state 'vi-state) (interactive-p))
+    (if (and (eq viper-current-state 'vi-state)
+            ;; Do not use called-interactively-p here. XEmacs does not have it
+            ;; and interactive-p is just fine.
+            ;; (called-interactively-p 'interactive))
+            (interactive-p))
        (beep 1)
       ad-do-it
       ))
@@ -942,10 +939,6 @@ It also can't undo some Viper settings."
    '(defadvice rmail-cease-edit (after viper-rmail-advice activate)
       "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)
-    "Switch to emacs state when done editing message."
-    (viper-change-state-to-emacs))
 
   ;; ISO accents
   ;; Need to do it after loading iso-acc, or else this loading will wipe out
@@ -1057,7 +1050,7 @@ It also can't undo some Viper settings."
                                         (memq 'down (event-modifiers (aref key 1)))))
                                (read-event))))))
     ) ; (if (featurep 'xemacs)
-  
+
   (if (featurep 'xemacs)
       ;; XEmacs
       (defadvice describe-key-briefly
@@ -1083,7 +1076,7 @@ It also can't undo some Viper settings."
                               (prefix-numeric-value current-prefix-arg))
                           1))))
     ) ; (if (featurep 'xemacs)
-  
+
   (defadvice find-file (before viper-add-suffix-advice activate)
     "Use `read-file-name' for reading arguments."
     (interactive (cons (read-file-name "Find file: " nil default-directory)
@@ -1214,7 +1207,7 @@ These two lines must come in the order given.
 (if (null viper-saved-non-viper-variables)
     (setq viper-saved-non-viper-variables
          (list
-          (cons 'default-major-mode (list default-major-mode))
+          (cons 'default-major-mode (list (default-value 'major-mode)))
           (cons 'next-line-add-newlines (list next-line-add-newlines))
           (cons 'require-final-newline (list require-final-newline))
           (cons 'scroll-step (list scroll-step))
@@ -1382,5 +1375,4 @@ These two lines must come in the order given.
 ;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
 ;; End:
 
-;; arch-tag: 5f3e844c-c4e6-4bbd-9b73-63bdc14e7d79
 ;;; viper.el ends here