]> git.eshelyaron.com Git - emacs.git/commitdiff
* viper-cmd.el (viper-prefix-commands): make into a defconst.
authorMichael Kifer <kifer@cs.stonybrook.edu>
Sat, 19 Feb 2005 19:32:47 +0000 (19:32 +0000)
committerMichael Kifer <kifer@cs.stonybrook.edu>
Sat, 19 Feb 2005 19:32:47 +0000 (19:32 +0000)
(viper-exec-buffer-search): use regexp-quote to quote the buffer
string.
(viper-minibuffer-setup-sentinel): make some variables buffer-local.
(viper-skip-separators): bug fix.
(viper-set-searchstyle-toggling-macros): allow to unset macros in a
particular major mode.
(viper-del-backward-char-in-replace): don't put deleted char on the
kill ring.

* viper-ex.el (viper-color-display-p): new function.
(viper-has-face-support-p): use viper-color-display-p.

* viper-keym.el (viper-gnus-modifier-map): new keymap.

* viper-macs.el (viper-unrecord-kbd-macro): bug fix.

* viper-util.el (viper-glob-unix-files): fix shell status check.
(viper-file-remote-p): make equivalent to file-remote-p.

* viper.el (viper-major-mode-modifier-list): use
viper-gnus-modifier-map.

lisp/ChangeLog
lisp/emulation/viper-cmd.el
lisp/emulation/viper-ex.el
lisp/emulation/viper-init.el
lisp/emulation/viper-keym.el
lisp/emulation/viper-macs.el
lisp/emulation/viper-util.el
lisp/emulation/viper.el
man/viper.texi

index fe1947e1247c0f1eae1fe693e1db8866131d6e9c..cddef68d455118b096674226352de6103acfdb2a 100644 (file)
@@ -1,3 +1,28 @@
+2005-02-19  Michael Kifer  <kifer@cs.stonybrook.edu>
+       
+       * viper-cmd.el (viper-prefix-commands): make into a defconst.
+       (viper-exec-buffer-search): use regexp-quote to quote the buffer
+       string.
+       (viper-minibuffer-setup-sentinel): make some variables buffer-local.
+       (viper-skip-separators): bug fix.
+       (viper-set-searchstyle-toggling-macros): allow to unset macros in a
+       particular major mode.
+       (viper-del-backward-char-in-replace): don't put deleted char on the
+       kill ring.
+       
+       * viper-ex.el (viper-color-display-p): new function.
+       (viper-has-face-support-p): use viper-color-display-p.
+       
+       * viper-keym.el (viper-gnus-modifier-map): new keymap.
+       
+       * viper-macs.el (viper-unrecord-kbd-macro): bug fix.
+       
+       * viper-util.el (viper-glob-unix-files): fix shell status check.
+       (viper-file-remote-p): make equivalent to file-remote-p.
+       
+       * viper.el (viper-major-mode-modifier-list): use
+       viper-gnus-modifier-map.
+       
 2005-02-19  David Kastrup  <dak@gnu.org>
 
        * subr.el (subregexp-context-p): Fix garbled doc string by adding
index eb5e5ede4c7f530a48e8b88534afc1ffc0328956..8023336b18bc56515ab7a72cf4475f0cbe23ea5f 100644 (file)
@@ -1063,7 +1063,7 @@ as a Meta key and any number of multiple escapes is allowed."
 
     ;; call the actual function to execute ESC (if no other symbols followed)
     ;; or the key bound to the ESC sequence (if the sequence was issued
-    ;; with very short delay between characters.
+    ;; with very short delay between characters).
     (if (eq cmd 'viper-intercept-ESC-key)
        (setq cmd
              (cond ((eq viper-current-state 'vi-state)
@@ -1529,7 +1529,8 @@ as a Meta key and any number of multiple escapes is allowed."
   nil)
 
 (defun viper-exec-buffer-search (m-com com)
-  (setq viper-s-string (buffer-substring (point) viper-com-point))
+  (setq viper-s-string
+       (regexp-quote (buffer-substring (point) viper-com-point)))
   (setq viper-s-forward t)
   (setq viper-search-history (cons viper-s-string viper-search-history))
   (setq viper-intermediate-command 'viper-exec-buffer-search)
@@ -1982,6 +1983,16 @@ Undo previous insertion and inserts new."
   (let ((hook (if viper-vi-style-in-minibuffer
                  'viper-change-state-to-insert
                'viper-change-state-to-emacs)))
+    ;; making buffer-local variables so that normal buffers won't affect the
+    ;; minibuffer and vice versa. Otherwise, command arguments will affect
+    ;; minibuffer ops and insertions from the minibuffer will change those in
+    ;; the normal buffers
+    (make-local-variable 'viper-d-com)
+    (make-local-variable 'viper-last-insertion)
+    (make-local-variable 'viper-command-ring)
+    (setq viper-d-com nil
+         viper-last-insertion nil
+         viper-command-ring nil)
     (funcall hook)
     ))
 
@@ -2707,7 +2718,7 @@ On reaching beginning of line, stop and signal error."
     (viper-backward-char-carefully)
     (if (looking-at "\n")
        (viper-skip-all-separators-backward 'within-line)
-      (or (bobp) (forward-char)))))
+      (or (viper-looking-at-separator) (forward-char)))))
 
 
 (defun viper-forward-word-kernel (val)
@@ -3630,33 +3641,39 @@ the Emacs binding of `/'."
           (setq msg "Search style remains unchanged")))
     (princ msg t)))
 
-(defun viper-set-searchstyle-toggling-macros (unset)
+(defun viper-set-searchstyle-toggling-macros (unset &optional major-mode)
   "Set the macros for toggling the search style in Viper's vi-state.
 The macro that toggles case sensitivity is bound to `//', and the one that
 toggles regexp search is bound to `///'.
-With a prefix argument, this function unsets the macros. "
+With a prefix argument, this function unsets the macros.
+If MAJOR-MODE is set, set the macros only in that major mode."
   (interactive "P")
-  (or noninteractive
-      (if (not unset)
-         (progn
-           ;; toggle case sensitivity in search
-           (viper-record-kbd-macro
-            "//" 'vi-state
-            [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
-            't)
-           ;; toggle regexp/vanila search
-           (viper-record-kbd-macro
-            "///" 'vi-state
-            [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
-            't)
-           (if (interactive-p)
-               (message
-                "// and /// now toggle case-sensitivity and regexp search")))
-       (viper-unrecord-kbd-macro "//" 'vi-state)
-       (sit-for 2)
-       (viper-unrecord-kbd-macro "///" 'vi-state))))
-
-
+  (let (scope)
+    (if (and major-mode (symbolp major-mode))
+       (setq scope major-mode)
+      (setq scope 't))
+    (or noninteractive
+       (if (not unset)
+           (progn
+             ;; toggle case sensitivity in search
+             (viper-record-kbd-macro
+              "//" 'vi-state
+              [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
+              scope)
+             ;; toggle regexp/vanila search
+             (viper-record-kbd-macro
+              "///" 'vi-state
+              [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
+              scope)
+             (if (interactive-p)
+                 (message
+                  "// and /// now toggle case-sensitivity and regexp search")))
+         (viper-unrecord-kbd-macro "//" 'vi-state)
+         (sit-for 2)
+         (viper-unrecord-kbd-macro "///" 'vi-state)))
+    ))
+  
+  
 (defun viper-set-parsing-style-toggling-macro (unset)
   "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses.
 This is used in conjunction with the `%' command.
@@ -4112,7 +4129,8 @@ Null string will repeat previous search."
   (interactive)
   (if (and viper-ex-style-editing (bolp))
       (beep 1)
-    (delete-backward-char 1 t)))
+    ;; don't put on kill ring
+    (delete-backward-char 1 nil)))
 
 
 (defun viper-del-backward-char-in-replace ()
@@ -4124,13 +4142,15 @@ cursor move past the beginning of line."
   (interactive)
   (cond (viper-delete-backwards-in-replace
         (cond ((not (bolp))
-               (delete-backward-char 1 t))
+               ;; don't put on kill ring
+               (delete-backward-char 1 nil))
               (viper-ex-style-editing
                (beep 1))
               ((bobp)
                (beep 1))
               (t
-               (delete-backward-char 1 t))))
+               ;; don't put on kill ring
+               (delete-backward-char 1 nil))))
        (viper-ex-style-editing
         (if (bolp)
             (beep 1)
index c94edf54bc2811ae4d80c81c60d273d962101cc7..90b006ffb65ea3e62d42d87906f2161531a35213 100644 (file)
@@ -1,6 +1,6 @@
 ;;; viper-ex.el --- functions implementing the Ex commands for Viper
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 04 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 04, 05 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
index 2a13f00535e6137af23e393c8736448ac11dca29..4f08f1b6cc105b4e58678830e68163e2ee127dbb 100644 (file)
    window-system
    ))
 
+(defun viper-color-display-p ()
+  (condition-case nil
+      (viper-cond-compile-for-xemacs-or-emacs
+       (eq (device-class (selected-device)) 'color) ; xemacs form
+       (if (fboundp 'display-color-p) ; emacs form
+          (display-color-p)
+        (x-display-color-p))
+       )
+    (error nil)))
+
 ;; in XEmacs: device-type is tty on tty and stream in batch.
 (defun viper-window-display-p ()
   (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc)))))
@@ -97,6 +107,7 @@ In all likelihood, you don't need to bother with this setting."
 (defun viper-has-face-support-p ()
   (cond ((viper-window-display-p))
        (viper-force-faces)
+       ((viper-color-display-p))
        (viper-emacs-p (memq (viper-device-type) '(pc)))
        (viper-xemacs-p (memq (viper-device-type) '(tty pc)))))
 
index 146b54b7034751225fcf95e7aa25f7fd14a63186..e5074b95838225fa131d304d785c2da5b5208820 100644 (file)
@@ -455,6 +455,10 @@ Useful in some modes, such as Gnus, MH, etc.")
 (define-key viper-dired-modifier-map ":" 'viper-ex)
 (define-key viper-dired-modifier-map "/" 'viper-search-forward)
 
+(defvar viper-gnus-modifier-map (make-sparse-keymap)
+  "This map modifies Gnus behavior.")
+(define-key viper-gnus-modifier-map ":" 'viper-ex)
+
 
 \f
 ;;; Code
index c6a3fdfe1fe8cbe0ef89f5b155aa01a1749e81fd..df0e37e7c2514e5e9704a182572aa7c4257d6770 100644 (file)
@@ -329,6 +329,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
 ;; Accepts as macro names: strings and vectors.
 ;; strings must be strings of characters; vectors must be vectors of keys
 ;; in canonic form.  The canonic form is essentially the form used in XEmacs
+;; More general definitions are inherited by more specific scopes:
+;; global->major mode->buffer. More specific definitions override more general
 (defun viper-record-kbd-macro (macro-name state macro-body &optional scope)
   "Record a Vi macro.  Can be used in `.viper' file to define permanent macros.
 MACRO-NAME is a string of characters or a vector of keys.  STATE is
@@ -451,22 +453,22 @@ If SCOPE is nil, the user is asked to specify the scope."
                       (list (list (cons scope nil)) nil (cons t nil))))))
     (setq old-elt (assoc macro-name (eval macro-alist-var)))
 
-      (if (null old-elt)
-         (progn
-           ;; insert new-elt in macro-alist-var and keep the list sorted
-           (define-key
-             keymap
-             (vector (viper-key-to-emacs-key (aref macro-name 0)))
-             'viper-exec-mapped-kbd-macro)
-           (setq lis (eval macro-alist-var))
-           (while (and lis (string< (viper-array-to-string (car (car lis)))
-                                    (viper-array-to-string macro-name)))
-             (setq lis2 (cons (car lis) lis2))
-             (setq lis (cdr lis)))
-
-           (setq lis2 (reverse lis2))
-           (set macro-alist-var (append lis2 (cons new-elt lis)))
-           (setq old-elt new-elt)))
+    (if (null old-elt)
+       (progn
+         ;; insert new-elt in macro-alist-var and keep the list sorted
+         (define-key
+           keymap
+           (vector (viper-key-to-emacs-key (aref macro-name 0)))
+           'viper-exec-mapped-kbd-macro)
+         (setq lis (eval macro-alist-var))
+         (while (and lis (string< (viper-array-to-string (car (car lis)))
+                                  (viper-array-to-string macro-name)))
+           (setq lis2 (cons (car lis) lis2))
+           (setq lis (cdr lis)))
+         
+         (setq lis2 (reverse lis2))
+         (set macro-alist-var (append lis2 (cons new-elt lis)))
+         (setq old-elt new-elt)))
     (setq old-sub-elt
          (cond ((eq scope t) (viper-kbd-global-pair old-elt))
                ((symbolp scope) (assoc scope (viper-kbd-mode-alist old-elt)))
@@ -484,6 +486,11 @@ If SCOPE is nil, the user is asked to specify the scope."
 
 
 ;; macro name must be a vector of viper-style keys
+;; viper-unrecord-kbd-macro doesn't have scope. Macro definitions are inherited
+;; from global -> major mode -> buffer
+;; More specific definition overrides more general
+;; Can't unrecord definition for more specific, if a more general definition is
+;; in effect
 (defun viper-unrecord-kbd-macro (macro-name state)
   "Delete macro MACRO-NAME from Viper STATE.
 MACRO-NAME must be a vector of viper-style keys.  This command is used by Viper
@@ -546,7 +553,7 @@ name from there."
           (setq macro-pair mode-mapping)
           (message "%S is unmapped for %s in %S"
                    (viper-display-macro macro-name) state-name major-mode))
-         ((cdr (setq macro-pair (viper-kbd-global-pair macro-entry)))
+         ((cdr (setq macro-pair global-mapping))
           (message
            "Global mapping for %S in %s is removed"
            (viper-display-macro macro-name) state-name))
@@ -560,7 +567,7 @@ name from there."
        (progn
          (set macro-alist-var (delq macro-entry (eval macro-alist-var)))
          (if (viper-can-release-key (aref macro-name 0)
-                                  (eval macro-alist-var))
+                                    (eval macro-alist-var))
              (define-key
                keymap
                (vector (viper-key-to-emacs-key (aref macro-name 0)))
index 5e533e5f5452a53c008a718528abcd5726644453..527a04084e2d6a8fbb83a2a973c58a915816c072 100644 (file)
 
 
 ;; define remote file test
-(or (fboundp 'viper-file-remote-p) ; user supplied his own function: use it
-    (defun viper-file-remote-p (file-name)
-      (car (cond ((featurep 'efs-auto) (efs-ftp-path file-name))
-                ((fboundp 'file-remote-p) (file-remote-p file-name))
-                (t (require 'ange-ftp)
-                   ;; Can happen only in Emacs, since XEmacs has file-remote-p
-                   (ange-ftp-ftp-name file-name))))))
-
+(defun viper-file-remote-p (file-name)
+  (file-remote-p file-name))
 
 
 ;; This is a simple-minded check for whether a file is under version control.
index 15ec74b41f1926d3704c9f0a6041f857f1f8cf17..be5a8e3467ab9396788df944abda22e7a08b1d1b 100644 (file)
@@ -3,12 +3,12 @@
 ;;              and a venomous VI PERil.
 ;;              Viper Is also a Package for Emacs Rebels.
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 05 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Keywords: emulations
 
-(defconst viper-version "3.11.2 of January 4, 2002"
+(defconst viper-version "3.11.4 of February 19, 2005"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
@@ -466,7 +466,7 @@ unless it is coming up in a wrong Viper state."
             (nth 0 triple) (nth 1 triple) (eval (nth 2 triple))))
          viper-major-mode-modifier-list))
 
-;; We change standard bindings in some major mode, making them slightly
+;; We change standard bindings in some major modes, making them slightly
 ;; different than in "normal" vi/insert/emacs states
 (defcustom viper-major-mode-modifier-list
   '((help-mode emacs-state viper-slash-and-colon-map)
@@ -482,8 +482,8 @@ unless it is coming up in a wrong Viper state."
     (dired-mode emacs-state viper-dired-modifier-map)
     (tar-mode emacs-state viper-slash-and-colon-map)
     (mh-folder-mode emacs-state viper-slash-and-colon-map)
-    (gnus-group-mode emacs-state viper-slash-and-colon-map)
-    (gnus-summary-mode emacs-state viper-slash-and-colon-map)
+    (gnus-group-mode emacs-state viper-gnus-modifier-map)
+    (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)
     )
index 654f6c9355f77132bd6e0569bff277d2ea2a0d6c..7b3a888c8ca46954c6fc93fd7291826d24829234 100644 (file)
@@ -2285,7 +2285,7 @@ It is also possible to impose Vi on some major modes, even though they may
 bind common keys to specialized commands.  This might make sense for modes
 that bind only a small number of common keys.  For instance, Viper subverts
 the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} using
-@code{viper-add-local-keys} described in section on customization
+@code{viper-add-local-keys} described in the section on customization
 (@pxref{Customization}).
 
 In some cases, some @emph{minor} modes might override certain essential
@@ -2294,7 +2294,7 @@ can happen only in the beginning, when the minor mode kicks in.  Typing
 @code{M-x viper-mode} will correct the situation.  Viper knows about
 several such minor modes and takes care of them, so the above trick
 is usually not necessary.  If you find that some minor mode, e.g.,
-@code{nasty-mode.el} interferes with Viper, putting the following in
+@code{nasty-mode} interferes with Viper, putting the following in
 @file{.viper} should fix the problem:
 @lisp
 (viper-harness-minor-mode "nasty-mode")
@@ -2305,7 +2305,7 @@ offending minor mode with the suffixes @file{.el} and @file{.elc} removed.
 
 It may not be always obvious which minor mode is at fault.  The only
 guidance here is to look into the file that defines the minor mode you are
-suspecting, say @code{nasty-mode.el}, and see if it has a variable called
+suspecting, say @file{nasty-mode.el}, and see if it has a variable called
 @code{nasty-mode-map}.  Then check if there is a statement of the form
 @lisp
 (define-key nasty-mode-map key function)
@@ -2316,6 +2316,18 @@ keys.  If so, use the above line to harness @code{nasty-mode}.  If your
 suspicion is wrong, no harm is done if you harness a minor mode that
 doesn't need to be harnessed.
 
+It is recommended to harness even those minor modes that don't override
+Viper keys, but still have their own keymaps. A general way to
+make a minor mode, @code{my-mode},
+compatible with Viper is to have the file @file{my-mode.el} include the following code:
+
+@lisp
+(when (fboundp 'viper-harness-minor-mode)
+  (let ((lib (file-name-sans-extension
+               (file-name-nondirectory load-file-name))))
+    (viper-harness-minor-mode lib)))
+@end lisp
+
 @vindex @code{viper-want-emacs-keys-in-vi}
 @vindex @code{viper-want-emacs-keys-in-insert}
 @vindex @code{viper-always}
@@ -2371,11 +2383,19 @@ this in @file{~/.viper}:
 @end example
 @findex @code{viper-set-searchstyle-toggling-macros}
 
+If you don't like this feature as a default, but would still like to have
+it in some major modes, you can do so by first unsetting it globally, as
+shown above, and then setting it in the desired major modes as follows:
+@example
+(viper-set-searchstyle-toggling-macros nil 'c-mode)
+(viper-set-searchstyle-toggling-macros nil 'lisp-mode)
+@end example
+
 @item Vi-isms in Emacs state
 Some people find it useful to use the Vi-style search key, `/', to invoke
 search in modes which Viper leaves in emacs-state.  These modes are:
-@code{dired-mode}, @code{mh-folder-mode}, @code{gnus-group-mode},
-@code{gnus-summary-mode}, @code{Info-mode}, and @code{Buffer-menu-mode}
+@code{dired-mode}, @code{mh-folder-mode},
+@code{Info-mode}, and @code{Buffer-menu-mode}
 (more may be added in the future).  So, in the above modes, Viper binds `/'
 so that it will behave Vi-style.  Furthermore, in those major modes, Viper
 binds `:' to invoke ex-style commands, like in vi-state.  And, as described
@@ -4470,6 +4490,7 @@ gviswana@@cs.wisc.edu (Guhan Viswanathan),
 gvr@@halcyon.com (George V.@: Reilly),
 hatazaki@@bach.convex.com (Takao Hatazaki),
 hpz@@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld),
+irie@@t.email.ne.jp (Irie Tetsuya),
 jackr@@dblues.engr.sgi.com (Jack Repenning),
 jamesm@@bga.com (D.J.@: Miller II),
 jjm@@hplb.hpl.hp.com (Jean-Jacques Moreau),