From 38685583801c774f1c17a32f02b29e426bdd0a96 Mon Sep 17 00:00:00 2001 From: Michael Kifer Date: Sat, 6 Aug 2005 16:58:54 +0000 Subject: [PATCH] 2005-08-06 Michael Kifer * 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\\". --- lisp/ChangeLog | 21 ++++++++++++++++ lisp/emulation/viper-cmd.el | 28 +++++++++++++-------- lisp/emulation/viper-init.el | 7 ++++++ lisp/emulation/viper-util.el | 2 +- lisp/emulation/viper.el | 48 +++++++++++++++++++++++++----------- man/viper.texi | 5 ++-- 6 files changed, 82 insertions(+), 29 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5548b8614c2..7550d1cd739 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,24 @@ +2005-08-06 Michael Kifer + + * 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 * cmuscheme.el (scheme-trace-command, scheme-untrace-command) diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index ce8b61fd022..99a130e7f1d 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -942,8 +942,10 @@ Suffixes such as .el or .elc should be stripped." ;; 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 @@ as a Meta key and any number of multiple escapes is allowed." (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 @@ as a Meta key and any number of multiple escapes is allowed." (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 @@ as a Meta key and any number of multiple escapes is allowed." (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 @@ as a Meta key and any number of multiple escapes is allowed." (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 @@ Null string will repeat previous search." 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 @@ Null string will repeat previous search." 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 diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index 3c984a3596e..9c1df1b0ad5 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el @@ -424,13 +424,20 @@ delete the text being replaced, as in standard Vi." "*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) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 5bd67e1735f..cc9f42b9800 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -360,7 +360,7 @@ (setq lis2 (delq elt lis2))) (setq temp (cdr temp))) - (nconc lis1 lis2))) + (append lis1 lis2))) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index edc1fb1e9de..52d0fefcd20 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -372,7 +372,6 @@ widget." (defcustom viper-vi-state-mode-list '(fundamental-mode makefile-mode - help-mode awk-mode m4-mode @@ -398,7 +397,7 @@ widget." tex-mode latex-mode bibtex-mode ps-mode - completion-list-mode + ;; completion-list-mode diff-mode idl-mode @@ -433,6 +432,9 @@ widget." gnus-group-mode gnus-summary-mode + completion-list-mode + help-mode + Info-mode Buffer-menu-mode compilation-mode @@ -523,7 +525,7 @@ If Viper is enabled, turn it off. Otherwise, turn it on." ;;;###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 @@ This function tries to do as good a job as possible. However, it may undo some 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 @@ remains buffer-local." '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 @@ remains buffer-local." 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 @@ remains buffer-local." ;; 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 @@ remains buffer-local." 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 @@ These two lines must come in the order given. (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 @@ These two lines must come in the order given. (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)) diff --git a/man/viper.texi b/man/viper.texi index 0156c4c6387..6d05d365f8b 100644 --- a/man/viper.texi +++ b/man/viper.texi @@ -507,9 +507,8 @@ modes designed for editing files, such as cc-mode or latex-mode, use key 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 -- 2.39.5