changeset 60168:d96e54250eea

* 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.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 19 Feb 2005 19:32:47 +0000
parents a2a04ef4a221
children c396883e5069
files 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
diffstat 9 files changed, 148 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/ChangeLog	Sat Feb 19 19:32:47 2005 +0000
@@ -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
--- a/lisp/emulation/viper-cmd.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-cmd.el	Sat Feb 19 19:32:47 2005 +0000
@@ -1063,7 +1063,7 @@
 
     ;; 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 @@
   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 @@
   (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 @@
     (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 @@
 	   (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 @@
   (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 @@
   (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)
--- a/lisp/emulation/viper-ex.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-ex.el	Sat Feb 19 19:32:47 2005 +0000
@@ -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>
 
--- a/lisp/emulation/viper-init.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-init.el	Sat Feb 19 19:32:47 2005 +0000
@@ -70,6 +70,16 @@
    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 @@
 (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)))))
 
--- a/lisp/emulation/viper-keym.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-keym.el	Sat Feb 19 19:32:47 2005 +0000
@@ -455,6 +455,10 @@
 (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)
+
 
 
 ;;; Code
--- a/lisp/emulation/viper-macs.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-macs.el	Sat Feb 19 19:32:47 2005 +0000
@@ -329,6 +329,8 @@
 ;; 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 @@
 		       (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 @@
 
 
 ;; 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 @@
 	   (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 @@
 	(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)))
--- a/lisp/emulation/viper-util.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper-util.el	Sat Feb 19 19:32:47 2005 +0000
@@ -662,14 +662,8 @@
 
 
 ;; 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.
--- a/lisp/emulation/viper.el	Sat Feb 19 18:54:24 2005 +0000
+++ b/lisp/emulation/viper.el	Sat Feb 19 19:32:47 2005 +0000
@@ -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 @@
 	     (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 @@
     (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)
     )
--- a/man/viper.texi	Sat Feb 19 18:54:24 2005 +0000
+++ b/man/viper.texi	Sat Feb 19 19:32:47 2005 +0000
@@ -2285,7 +2285,7 @@
 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 @@
 @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 @@
 
 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 @@
 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 @@
 @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 @@
 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),