* net/ldap.el (ldap-search-internal): Tweak URL regexp.
[bpt/emacs.git] / lisp / emulation / viper.el
index bb3e4eb..e9b6f95 100644 (file)
@@ -4,20 +4,25 @@
 ;;              Viper Is also a Package for Emacs Rebels.
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Keywords: emulations
 
-(defconst viper-version "3.14 of August 18, 2007"
+;; 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"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,9 +30,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -403,7 +406,7 @@ widget."
   :group 'viper-misc)
 
 (defcustom viper-emacs-state-mode-list
-  '(custom-mode
+  '(Custom-mode
 
     dired-mode
     efs-mode
@@ -597,13 +600,14 @@ This startup message appears whenever you load Viper, unless you type `y' now."
                    ))
              (viper-set-expert-level 'dont-change-unless)))
 
-       (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))
-       )))
+       ))
+
+  (if (eq major-mode 'viper-mode)
+      (setq major-mode 'fundamental-mode))
+  )
 
 
 ;; Apply a little heuristic to invoke vi state on major-modes
@@ -857,7 +861,9 @@ It also can't undo some Viper settings."
               (modify-frame-parameters
                (selected-frame)
                (list (cons 'viper-vi-state-cursor-color
-                           (viper-get-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)
@@ -900,6 +906,7 @@ It also can't undo some Viper settings."
     (modify-frame-parameters
        (selected-frame)
        (list (cons 'viper-vi-state-cursor-color (ad-get-arg 0))))
+    (setq viper-vi-state-cursor-color (ad-get-arg 0))
     )
 
   (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
@@ -1019,64 +1026,64 @@ It also can't undo some Viper settings."
       (setq global-mode-string
            (append '("" viper-mode-string) (cdr global-mode-string))))
 
-  (viper-cond-compile-for-xemacs-or-emacs
-   ;; XEmacs
-   (defadvice describe-key (before viper-describe-key-ad protect activate)
-     "Force to read key via `viper-read-key-sequence'."
-     (interactive (list (viper-read-key-sequence "Describe key: "))))
-   ;; Emacs
-   (defadvice describe-key (before viper-describe-key-ad protect activate)
-     "Force to read key via `viper-read-key-sequence'."
-     (interactive (let (key)
-                   (setq key (viper-read-key-sequence
-                              "Describe key (or click or menu item): "))
-                   (list key
-                         (prefix-numeric-value current-prefix-arg)
-                         ;; If KEY is a down-event, read also the
-                         ;; corresponding up-event.
-                         (and (vectorp key)
-                              (let ((last-idx (1- (length key))))
-                                (and (eventp (aref key last-idx))
-                                     (memq 'down (event-modifiers
-                                                  (aref key last-idx)))))
-                              (or (and (eventp (aref key 0))
-                                       (memq 'down (event-modifiers
-                                                    (aref key 0)))
-                                       ;; For the C-down-mouse-2 popup menu,
-                                       ;; there is no subsequent up-event
-                                       (= (length key) 1))
-                                  (and (> (length key) 1)
-                                       (eventp (aref key 1))
-                                       (memq 'down (event-modifiers (aref key 1)))))
-                              (read-event))))))
-   ) ; viper-cond-compile-for-xemacs-or-emacs
-
-  (viper-cond-compile-for-xemacs-or-emacs
-   ;; XEmacs
-   (defadvice describe-key-briefly
-     (before viper-describe-key-briefly-ad protect activate)
-     "Force to read key via `viper-read-key-sequence'."
-     (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
-   ;; Emacs
-   (defadvice describe-key-briefly
-     (before viper-describe-key-briefly-ad protect activate)
-     "Force to read key via `viper-read-key-sequence'."
-     (interactive (let (key)
-                   (setq key (viper-read-key-sequence
-                              "Describe key (or click or menu item): "))
-                   ;; If KEY is a down-event, read and discard the
-                   ;; corresponding up-event.
-                   (and (vectorp key)
-                        (let ((last-idx (1- (length key))))
-                          (and (eventp (aref key last-idx))
-                               (memq 'down (event-modifiers (aref key last-idx)))))
-                        (read-event))
-                   (list key
-                         (if current-prefix-arg
-                             (prefix-numeric-value current-prefix-arg))
-                         1))))
-   ) ;; viper-cond-compile-for-xemacs-or-emacs
-
+  (if (featurep 'xemacs)
+      ;; XEmacs
+      (defadvice describe-key (before viper-describe-key-ad protect activate)
+       "Force to read key via `viper-read-key-sequence'."
+       (interactive (list (viper-read-key-sequence "Describe key: "))))
+    ;; Emacs
+    (defadvice describe-key (before viper-describe-key-ad protect activate)
+      "Force to read key via `viper-read-key-sequence'."
+      (interactive (let (key)
+                    (setq key (viper-read-key-sequence
+                               "Describe key (or click or menu item): "))
+                    (list key
+                          (prefix-numeric-value current-prefix-arg)
+                          ;; If KEY is a down-event, read also the
+                          ;; corresponding up-event.
+                          (and (vectorp key)
+                               (let ((last-idx (1- (length key))))
+                                 (and (eventp (aref key last-idx))
+                                      (memq 'down (event-modifiers
+                                                   (aref key last-idx)))))
+                               (or (and (eventp (aref key 0))
+                                        (memq 'down (event-modifiers
+                                                     (aref key 0)))
+                                        ;; For the C-down-mouse-2 popup menu,
+                                        ;; there is no subsequent up-event
+                                        (= (length key) 1))
+                                   (and (> (length key) 1)
+                                        (eventp (aref key 1))
+                                        (memq 'down (event-modifiers (aref key 1)))))
+                               (read-event))))))
+    ) ; (if (featurep 'xemacs)
+  
+  (if (featurep 'xemacs)
+      ;; XEmacs
+      (defadvice describe-key-briefly
+       (before viper-describe-key-briefly-ad protect activate)
+       "Force to read key via `viper-read-key-sequence'."
+       (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
+    ;; Emacs
+    (defadvice describe-key-briefly
+      (before viper-describe-key-briefly-ad protect activate)
+      "Force to read key via `viper-read-key-sequence'."
+      (interactive (let (key)
+                    (setq key (viper-read-key-sequence
+                               "Describe key (or click or menu item): "))
+                    ;; If KEY is a down-event, read and discard the
+                    ;; corresponding up-event.
+                    (and (vectorp key)
+                         (let ((last-idx (1- (length key))))
+                           (and (eventp (aref key last-idx))
+                                (memq 'down (event-modifiers (aref key last-idx)))))
+                         (read-event))
+                    (list key
+                          (if current-prefix-arg
+                              (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)