changeset 64750:fbdb9482b6fc

2005-08-06 Michael Kifer <kifer@cs.stonybrook.edu> * viper-cmd.el (viper-harness-minor-mode,viper-exec-delete, viper-exec-yank,viper-put-back): don't display modification msg if in the minibuffer. * viper-init.el (viper-replace-overlay-cursor-color, viper-insert-state-cursor-color,viper-vi-state-cursor-color): make variables frame local. * viper-util.el (viper-append-filter-alist): use append instead of nconc. * viper.el (viper-vi-state-mode-list,viper-emacs-state-mode-list): move help-mode and completion-list-mode from the first list to the second. (viper-mode): docstring. (viper-go-away,viper-non-hook-settings): don't localize minor-mode-alist in newer emacsen. Add advice to set-cursor-color. Don't bind "\C-c\\".
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 06 Aug 2005 16:58:54 +0000
parents 5e716228ee1e
children 5b1a238fcbb4
files lisp/ChangeLog lisp/emulation/viper-cmd.el lisp/emulation/viper-init.el lisp/emulation/viper-util.el lisp/emulation/viper.el man/viper.texi
diffstat 6 files changed, 82 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Aug 06 16:20:52 2005 +0000
+++ b/lisp/ChangeLog	Sat Aug 06 16:58:54 2005 +0000
@@ -1,3 +1,24 @@
+2005-08-06  Michael Kifer  <kifer@cs.stonybrook.edu>
+	
+	* viper-cmd.el (viper-harness-minor-mode,viper-exec-delete,
+	viper-exec-yank,viper-put-back): don't display modification msg if in
+	the minibuffer.
+	
+	* viper-init.el (viper-replace-overlay-cursor-color,
+	viper-insert-state-cursor-color,viper-vi-state-cursor-color): make
+	variables frame local.
+	
+	* viper-util.el (viper-append-filter-alist): use append instead of
+	nconc.
+	
+	* viper.el (viper-vi-state-mode-list,viper-emacs-state-mode-list): move
+	help-mode and completion-list-mode from the first list to the second.
+	(viper-mode): docstring.
+	(viper-go-away,viper-non-hook-settings): don't localize
+	minor-mode-alist in newer emacsen.
+	Add advice to set-cursor-color.
+	Don't bind "\C-c\\".
+	
 2005-08-06  Emilio C. Lopes  <eclig@gmx.net>
 
 	* cmuscheme.el (scheme-trace-command, scheme-untrace-command)
--- a/lisp/emulation/viper-cmd.el	Sat Aug 06 16:20:52 2005 +0000
+++ b/lisp/emulation/viper-cmd.el	Sat Aug 06 16:58:54 2005 +0000
@@ -942,8 +942,10 @@
 
   ;; Change the default for minor-mode-map-alist each time a harnessed minor
   ;; mode adds its own keymap to the a-list.
-  (eval-after-load
-   load-file '(setq-default minor-mode-map-alist minor-mode-map-alist))
+  (unless
+      (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
+    (eval-after-load
+	load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)))
   )
 
 
@@ -1421,7 +1423,8 @@
 	  (if (eq last-command 'd-command) 'kill-region nil))
     (setq chars-deleted (abs (- (point) viper-com-point)))
     (if (> chars-deleted viper-change-notification-threshold)
-	(message "Deleted %d characters" chars-deleted))
+	(unless (viper-is-in-minibuffer)
+	  (message "Deleted %d characters" chars-deleted)))
     (kill-region viper-com-point (point))
     (setq this-command 'd-command)
     (if viper-ex-style-motion
@@ -1447,7 +1450,8 @@
 	    (if (eq last-command 'D-command) 'kill-region nil))
       (setq lines-deleted (count-lines (point) viper-com-point))
       (if (> lines-deleted viper-change-notification-threshold)
-	  (message "Deleted %d lines" lines-deleted))
+	  (unless (viper-is-in-minibuffer)
+	    (message "Deleted %d lines" lines-deleted)))
       (kill-region (mark t) (point))
       (if (eq m-com 'viper-line) (setq this-command 'D-command)))
     (back-to-indentation)))
@@ -1472,7 +1476,8 @@
     (copy-region-as-kill viper-com-point (point))
     (setq chars-saved (abs (- (point) viper-com-point)))
     (if (> chars-saved viper-change-notification-threshold)
-	(message "Saved %d characters" chars-saved))
+	(unless (viper-is-in-minibuffer)
+	  (message "Saved %d characters" chars-saved)))
     (goto-char viper-com-point)))
 
 ;; save lines
@@ -1496,7 +1501,8 @@
       (copy-region-as-kill (mark t) (point))
       (setq lines-saved (count-lines (mark t) (point)))
       (if (> lines-saved viper-change-notification-threshold)
-	  (message "Saved %d lines" lines-saved))))
+	  (unless (viper-is-in-minibuffer)
+	    (message "Saved %d lines" lines-saved)))))
   (viper-deactivate-mark)
   (goto-char viper-com-point))
 
@@ -4020,8 +4026,9 @@
 	  lines-inserted (abs (count-lines (point) sv-point)))
     (if (or (> chars-inserted viper-change-notification-threshold)
 	    (> lines-inserted viper-change-notification-threshold))
-	(message "Inserted %d character(s), %d line(s)"
-		 chars-inserted lines-inserted)))
+	(unless (viper-is-in-minibuffer)
+	  (message "Inserted %d character(s), %d line(s)"
+		   chars-inserted lines-inserted))))
   ;; Vi puts cursor on the last char when the yanked text doesn't contain a
   ;; newline; it leaves the cursor at the beginning when the text contains
   ;; a newline
@@ -4062,8 +4069,9 @@
 	  lines-inserted (abs (count-lines (point) sv-point)))
     (if (or (> chars-inserted viper-change-notification-threshold)
 	    (> lines-inserted viper-change-notification-threshold))
-	(message "Inserted %d character(s), %d line(s)"
-		 chars-inserted lines-inserted)))
+	(unless (viper-is-in-minibuffer)
+	  (message "Inserted %d character(s), %d line(s)"
+		   chars-inserted lines-inserted))))
   ;; Vi puts cursor on the last char when the yanked text doesn't contain a
   ;; newline; it leaves the cursor at the beginning when the text contains
   ;; a newline
--- a/lisp/emulation/viper-init.el	Sat Aug 06 16:20:52 2005 +0000
+++ b/lisp/emulation/viper-init.el	Sat Aug 06 16:58:54 2005 +0000
@@ -424,13 +424,20 @@
   "*Cursor color when Viper is in Replace state."
   :type 'string
   :group 'viper)
+(if (fboundp 'make-variable-frame-local)
+    (make-variable-frame-local 'viper-replace-overlay-cursor-color))
+
 (defcustom viper-insert-state-cursor-color "Green"
   "Cursor color when Viper is in insert state."
   :type 'string
   :group 'viper)
+(if (fboundp 'make-variable-frame-local)
+    (make-variable-frame-local 'viper-insert-state-cursor-color))
 
 ;; internal var, used to remember the default cursor color of emacs frames
 (defvar viper-vi-state-cursor-color nil)
+(if (fboundp 'make-variable-frame-local)
+    (make-variable-frame-local 'viper-vi-state-cursor-color))
 
 (viper-deflocalvar viper-replace-overlay nil "")
 (put 'viper-replace-overlay 'permanent-local t)
--- a/lisp/emulation/viper-util.el	Sat Aug 06 16:20:52 2005 +0000
+++ b/lisp/emulation/viper-util.el	Sat Aug 06 16:58:54 2005 +0000
@@ -360,7 +360,7 @@
 	(setq lis2 (delq elt lis2)))
       (setq temp (cdr temp)))
 
-    (nconc lis1 lis2)))
+    (append lis1 lis2)))
 
 
 
--- a/lisp/emulation/viper.el	Sat Aug 06 16:20:52 2005 +0000
+++ b/lisp/emulation/viper.el	Sat Aug 06 16:58:54 2005 +0000
@@ -372,7 +372,6 @@
 (defcustom viper-vi-state-mode-list
   '(fundamental-mode
     makefile-mode
-    help-mode
 
     awk-mode
     m4-mode
@@ -398,7 +397,7 @@
     tex-mode latex-mode bibtex-mode
     ps-mode
 
-    completion-list-mode
+    ;; completion-list-mode
     diff-mode
     idl-mode
 
@@ -433,6 +432,9 @@
     gnus-group-mode
     gnus-summary-mode
 
+    completion-list-mode
+    help-mode
+
     Info-mode
     Buffer-menu-mode
     compilation-mode
@@ -523,7 +525,7 @@
 
 ;;;###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
@@ -656,8 +658,7 @@
 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
@@ -683,7 +684,9 @@
 	'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))
 
@@ -889,6 +892,14 @@
       ad-do-it
       ))
 
+  (defadvice set-cursor-color (after viper-set-cursor-color-ad activate)
+    "Change cursor color in VI state."
+    ;;(setq viper-vi-state-cursor-color (ad-get-arg 0))
+    (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
@@ -993,7 +1004,10 @@
   ;; 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)
+  ;; ***This is needed only in case emulation-mode-map-alists is not defined
+  (unless
+      (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
+    (make-variable-buffer-local 'minor-mode-map-alist))
 
   ;; Viper changes the default mode-line-buffer-identification
   (setq-default mode-line-buffer-identification '(" %b"))
@@ -1088,9 +1102,11 @@
 			     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)
@@ -1264,11 +1280,10 @@
 (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
@@ -1296,7 +1311,10 @@
 (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))
--- a/man/viper.texi	Sat Aug 06 16:20:52 2005 +0000
+++ b/man/viper.texi	Sat Aug 06 16:58:54 2005 +0000
@@ -507,9 +507,8 @@
 sequences that begin with @kbd{C-x} and @kbd{C-c}.
 
 There is also a key that lets you temporarily escape to Vi command state
-from Emacs or Insert states: typing @kbd{C-c \} will let you execute a
-single Vi command while staying in Viper's Emacs or Insert state.
-In Insert state, the same can also be achieved by typing @kbd{C-z}.
+from the Insert state: typing @kbd{C-z} will let you execute a
+single Vi command while staying in Viper's Insert state.
 
 
 @node Vi State, Insert State, Emacs State, States in Viper