summaryrefslogtreecommitdiff
path: root/lisp/emulation
diff options
context:
space:
mode:
authorMichael Kifer <kifer@cs.stonybrook.edu>1999-11-01 07:16:15 +0000
committerMichael Kifer <kifer@cs.stonybrook.edu>1999-11-01 07:16:15 +0000
commit3af0304a614da0c7f9b049623c1d814926930f95 (patch)
treee2f2a8b028d538453e4242c7d72f52787448afcc /lisp/emulation
parent93b7ac65fc0e920bf11262f6b3eba4ae65c7a114 (diff)
downloademacs-3af0304a614da0c7f9b049623c1d814926930f95.tar.gz
*** empty log message ***
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/viper-cmd.el445
-rw-r--r--lisp/emulation/viper-ex.el158
-rw-r--r--lisp/emulation/viper-init.el101
-rw-r--r--lisp/emulation/viper-keym.el57
-rw-r--r--lisp/emulation/viper-macs.el89
-rw-r--r--lisp/emulation/viper-mous.el97
-rw-r--r--lisp/emulation/viper-util.el180
-rw-r--r--lisp/emulation/viper.el192
8 files changed, 719 insertions, 600 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 1f88554f3ce..c035b9f31f6 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -97,7 +97,7 @@
(defconst viper-movement-commands '(?b ?B ?e ?E ?f ?F ?G ?h ?H ?j ?k ?l
?H ?M ?L ?n ?t ?T ?w ?W ?$ ?%
?^ ?( ?) ?- ?+ ?| ?{ ?} ?[ ?] ?' ?`
- ?\; ?, ?0 ?? ?/ ?\C-m ?\
+ ?\; ?, ?0 ?? ?/ ?\ ?\C-m
space return
delete backspace
)
@@ -137,6 +137,10 @@
;; define viper-vi-command-p
(viper-test-com-defun viper-vi-command)
+;; Where viper saves mark. This mark is resurrected by m^
+(defvar viper-saved-mark nil)
+
+
;;; CODE
@@ -151,7 +155,9 @@
(run-hook-with-args 'viper-before-change-functions beg end))
(defsubst viper-post-command-sentinel ()
- (run-hooks 'viper-post-command-hooks))
+ (run-hooks 'viper-post-command-hooks)
+ (if (eq viper-current-state 'vi-state)
+ (viper-restore-cursor-color 'after-insert-mode)))
(defsubst viper-pre-command-sentinel ()
(run-hooks 'viper-pre-command-hooks))
@@ -163,15 +169,21 @@
viper-insert-point
(>= (point) viper-insert-point))
(setq viper-last-posn-while-in-insert-state (point-marker)))
- (if (eq viper-current-state 'insert-state)
+ (or (viper-overlay-p viper-replace-overlay)
(progn
- (or (stringp viper-saved-cursor-color)
+ (viper-set-replace-overlay (point-min) (point-min))
+ (viper-hide-replace-overlay)))
+ (if (eq viper-current-state 'insert-state)
+ (let ((has-saved-cursor-color-in-insert-mode
+ (stringp (viper-get-saved-cursor-color-in-insert-mode))))
+ (or has-saved-cursor-color-in-insert-mode
(string= (viper-get-cursor-color) viper-insert-state-cursor-color)
- (setq viper-saved-cursor-color (viper-get-cursor-color)))
- (if (stringp viper-saved-cursor-color)
- (viper-change-cursor-color viper-insert-state-cursor-color))
- ))
- (if (and (eq this-command 'dabbrev-expand)
+ ;; save current color, if not already saved
+ (viper-save-cursor-color 'before-insert-mode))
+ ;; set insert mode cursor color
+ (viper-change-cursor-color viper-insert-state-cursor-color)))
+
+ (if (and (memq this-command '(dabbrev-expand hippie-expand))
(integerp viper-pre-command-point)
(markerp viper-insert-point)
(marker-position viper-insert-point)
@@ -184,8 +196,8 @@
(memq (viper-event-key last-command-event)
'(up down left right (meta f) (meta b)
(control n) (control p) (control f) (control b)))
- (viper-restore-cursor-color-after-insert))
- (if (and (eq this-command 'dabbrev-expand)
+ (viper-restore-cursor-color 'after-insert-mode))
+ (if (and (memq this-command '(dabbrev-expand hippie-expand))
(markerp viper-insert-point)
(marker-position viper-insert-point))
(setq viper-pre-command-point (marker-position viper-insert-point))))
@@ -196,11 +208,11 @@
;; in another frame, the pre-command hook won't change cursor color to
;; default in that other frame. So, if the second frame cursor was red and
;; we set the point outside the replacement region, then the cursor color
- ;; will remain red. Restoring the default, below, prevents this.
+ ;; will remain red. Restoring the default, below, prevents this.
(if (and (<= (viper-replace-start) (point))
(<= (point) (viper-replace-end)))
(viper-change-cursor-color viper-replace-overlay-cursor-color)
- (viper-restore-cursor-color-after-replace)
+ (viper-restore-cursor-color 'after-replace-mode)
))
;; to speed up, don't change cursor color before self-insert
@@ -210,7 +222,7 @@
(memq (viper-event-key last-command-event)
'(up down left right (meta f) (meta b)
(control n) (control p) (control f) (control b)))
- (viper-restore-cursor-color-after-replace)))
+ (viper-restore-cursor-color 'after-replace-mode)))
(defun viper-replace-state-post-command-sentinel ()
;; Restoring cursor color is needed despite
@@ -218,13 +230,13 @@
;; in another frame, the pre-command hook won't change cursor color to
;; default in that other frame. So, if the second frame cursor was red and
;; we set the point outside the replacement region, then the cursor color
- ;; will remain red. Restoring the default, below, fixes this problem.
+ ;; will remain red. Restoring the default, below, fixes this problem.
;;
;; We optimize for self-insert-command's here, since they either don't change
;; cursor color or, if they terminate replace mode, the color will be changed
;; in viper-finish-change
(or (memq this-command '(self-insert-command))
- (viper-restore-cursor-color-after-replace))
+ (viper-restore-cursor-color 'after-replace-mode))
(cond
((eq viper-current-state 'replace-state)
;; delete characters to compensate for inserted chars.
@@ -279,8 +291,8 @@
;; move viper-last-posn-while-in-insert-state
;; This is a normal hook that is executed in insert/replace
- ;; states after each command. In Vi/Emacs state, it does
- ;; nothing. We need to execute it here to make sure that
+ ;; states after each command. In Vi/Emacs state, it does
+ ;; nothing. We need to execute it here to make sure that
;; the last posn was recorded when we hit ESC.
;; It may be left unrecorded if the last thing done in
;; insert/repl state was dabbrev-expansion or abbrev
@@ -564,6 +576,9 @@
(if (and viper-first-time (not (viper-is-in-minibuffer)))
(viper-mode)
(if overwrite-mode (overwrite-mode nil))
+ (or (viper-overlay-p viper-replace-overlay)
+ (viper-set-replace-overlay (point-min) (point-min)))
+ (viper-hide-replace-overlay)
(if abbrev-mode (expand-abbrev))
(if (and auto-fill-function (> (current-column) fill-column))
(funcall auto-fill-function))
@@ -578,7 +593,7 @@
(viper-adjust-undo)
(viper-change-state 'vi-state)
- (viper-restore-cursor-color-after-insert)
+ (viper-restore-cursor-color 'after-insert-mode)
;; Protect against user errors in hooks
(condition-case conds
@@ -590,16 +605,18 @@
"Change Viper state to Insert."
(interactive)
(viper-change-state 'insert-state)
-
- (or (stringp viper-saved-cursor-color)
- (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
- (setq viper-saved-cursor-color (viper-get-cursor-color)))
- ;; Commented out, because if viper-change-state-to-insert is executed
- ;; non-interactively then the old cursor color may get lost. Same old Emacs
- ;; bug related to local variables?
-;;;(if (stringp viper-saved-cursor-color)
-;;; (viper-change-cursor-color viper-insert-state-cursor-color))
+ (or (viper-overlay-p viper-replace-overlay)
+ (viper-set-replace-overlay (point-min) (point-min)))
+ (viper-hide-replace-overlay)
+
+ (let ((has-saved-cursor-color-in-insert-mode
+ (stringp (viper-get-saved-cursor-color-in-insert-mode))))
+ (or has-saved-cursor-color-in-insert-mode
+ (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
+ (viper-save-cursor-color 'before-insert-mode))
+ (viper-change-cursor-color viper-insert-state-cursor-color))
+
;; Protect against user errors in hooks
(condition-case conds
(run-hooks 'viper-insert-state-hook)
@@ -612,7 +629,7 @@
-;; Change to replace state. When the end of replacement region is reached,
+;; Change to replace state. When the end of replacement region is reached,
;; replace state changes to insert state.
(defun viper-change-state-to-replace (&optional non-R-cmd)
(viper-change-state 'replace-state)
@@ -632,6 +649,9 @@
(defun viper-change-state-to-emacs ()
"Change Viper state to Emacs."
(interactive)
+ (or (viper-overlay-p viper-replace-overlay)
+ (viper-set-replace-overlay (point-min) (point-min)))
+ (viper-hide-replace-overlay)
(viper-change-state 'emacs-state)
;; Protect agains user errors in hooks
@@ -654,7 +674,7 @@ EVENTS is a list of events, which become the beginning of the command."
(defun viper-escape-to-vi (arg)
"Escape from Emacs state to Vi state for one Vi 1-character command.
If the Vi command that the user types has a prefix argument, e.g., `d2w', then
-Vi's prefix argument will be used. Otherwise, the prefix argument passed to
+Vi's prefix argument will be used. Otherwise, the prefix argument passed to
`viper-escape-to-vi' is used."
(interactive "P")
(message "Switched to VI state for the next command...")
@@ -687,9 +707,9 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
(while (vectorp com) (setq com (key-binding com))))
nil)
;; Execute command com in the original Viper state, not in state
- ;; `state'. Otherwise, if we switch buffers while executing the
+ ;; `state'. Otherwise, if we switch buffers while executing the
;; escaped to command, Viper's mode vars will remain those of
- ;; `state'. When we return to the orig buffer, the bindings will be
+ ;; `state'. When we return to the orig buffer, the bindings will be
;; screwed up.
(viper-set-mode-vars-for viper-current-state)
@@ -750,7 +770,7 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
;; This is needed because minor modes sometimes override essential Viper
-;; bindings. By letting Viper know which files these modes are in, it will
+;; bindings. By letting Viper know which files these modes are in, it will
;; arrange to reorganize minor-mode-map-alist so that things will work right.
(defun viper-harness-minor-mode (load-file)
"Familiarize Viper with a minor mode defined in LOAD_FILE.
@@ -779,9 +799,9 @@ Suffixes such as .el or .elc should be stripped."
Prevents multiple escape keystrokes if viper-no-multiple-ESC is true.
If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
Other ESC sequences are emulated via the current Emacs's major mode
-keymap. This is more convenient on TTYs, since this won't block
-function keys such as up,down, etc. ESC will also will also work as
-a Meta key in this case. When viper-no-multiple-ESC is nil, ESC functions
+keymap. This is more convenient on TTYs, since this won't block
+function keys such as up,down, etc. ESC will also will also work as
+a Meta key in this case. When viper-no-multiple-ESC is nil, ESC functions
as a Meta key and any number of multiple escapes is allowed."
(interactive "P")
(let (char)
@@ -850,8 +870,8 @@ as a Meta key and any number of multiple escapes is allowed."
;;
;; If `first-key' is not an ESC event, we make it into the
;; last-command-event in order to pretend that this key was
- ;; pressed. This is needed to allow arrow keys to be bound to
- ;; macros. Otherwise, viper-exec-mapped-kbd-macro will think
+ ;; pressed. This is needed to allow arrow keys to be bound to
+ ;; macros. Otherwise, viper-exec-mapped-kbd-macro will think
;; that the last event was ESC and so it'll execute whatever is
;; bound to ESC. (Viper macros can't be bound to
;; ESC-sequences).
@@ -957,7 +977,7 @@ as a Meta key and any number of multiple escapes is allowed."
;; Compute numeric prefix arg value.
-;; Invoked by EVENT. COM is the command part obtained so far.
+;; Invoked by EVENT. COM is the command part obtained so far.
(defun viper-prefix-arg-value (event-char com)
(let ((viper-intermediate-command 'viper-digit-argument)
value func)
@@ -983,13 +1003,13 @@ as a Meta key and any number of multiple escapes is allowed."
;; confuse subsequent commands
(progn
;; last-command-char is the char we want emacs to think was typed
- ;; last. If com is not nil, the viper-digit-argument command was
+ ;; last. If com is not nil, the viper-digit-argument command was
;; called from within viper-prefix-arg command, such as `d', `w',
- ;; etc., i.e., the user typed, say, d2. In this case, `com' would be
+ ;; etc., i.e., the user typed, say, d2. In this case, `com' would be
;; `d', `w', etc. If viper-digit-argument was invoked by
;; viper-escape-to-vi (which is indicated by the fact that the
;; current state is not vi-state), then `event-char' represents the
- ;; vi command to be executed (e.g., `d', `w', etc). Again,
+ ;; vi command to be executed (e.g., `d', `w', etc). Again,
;; last-command-char must make emacs believe that this is the command
;; we typed.
(cond ((eq event-char 'return) (setq event-char ?\C-m))
@@ -1080,8 +1100,8 @@ as a Meta key and any number of multiple escapes is allowed."
(setq prefix-arg nil)
(cond
;; If we change ?C to ?c here, then cc will enter replacement mode
- ;; rather than deleting lines. However, it will affect 1 less line than
- ;; normal. We decided to not use replacement mode here and follow Vi,
+ ;; rather than deleting lines. However, it will affect 1 less line than
+ ;; normal. We decided to not use replacement mode here and follow Vi,
;; since replacement mode on n full lines can be achieved with nC.
((equal com '(?c . ?c)) (viper-line (cons value ?C)))
((equal com '(?d . ?d)) (viper-line (cons value ?D)))
@@ -1228,86 +1248,98 @@ as a Meta key and any number of multiple escapes is allowed."
(defun viper-exec-delete (m-com com)
(or (and (markerp viper-com-point) (marker-position viper-com-point))
(set-marker viper-com-point (point) (current-buffer)))
- (if viper-use-register
- (progn
- (cond ((viper-valid-register viper-use-register '(letter digit))
- (copy-to-register
- viper-use-register viper-com-point (point) nil))
- ((viper-valid-register viper-use-register '(Letter))
- (viper-append-to-register
- (downcase viper-use-register) viper-com-point (point)))
- (t (setq viper-use-register nil)
- (error viper-InvalidRegister viper-use-register)))
- (setq viper-use-register nil)))
- (setq last-command
- (if (eq last-command 'd-command) 'kill-region nil))
- (message "Deleted %d characters" (abs (- (point) viper-com-point)))
- (kill-region viper-com-point (point))
- (setq this-command 'd-command)
- (if viper-ex-style-motion
- (if (and (eolp) (not (bolp))) (backward-char 1))))
-
-(defun viper-exec-Delete (m-com com)
- (save-excursion
- (set-mark viper-com-point)
- (viper-enlarge-region (mark t) (point))
+ (let (chars-deleted)
(if viper-use-register
(progn
(cond ((viper-valid-register viper-use-register '(letter digit))
(copy-to-register
- viper-use-register (mark t) (point) nil))
+ viper-use-register viper-com-point (point) nil))
((viper-valid-register viper-use-register '(Letter))
(viper-append-to-register
- (downcase viper-use-register) (mark t) (point)))
+ (downcase viper-use-register) viper-com-point (point)))
(t (setq viper-use-register nil)
- (error viper-InvalidRegister viper-use-register)))
+ (error viper-InvalidRegister viper-use-register)))
(setq viper-use-register nil)))
(setq last-command
- (if (eq last-command 'D-command) 'kill-region nil))
- (message "Deleted %d lines" (count-lines (point) viper-com-point))
- (kill-region (mark t) (point))
- (if (eq m-com 'viper-line) (setq this-command 'D-command)))
- (back-to-indentation))
+ (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))
+ (kill-region viper-com-point (point))
+ (setq this-command 'd-command)
+ (if viper-ex-style-motion
+ (if (and (eolp) (not (bolp))) (backward-char 1)))))
+
+(defun viper-exec-Delete (m-com com)
+ (save-excursion
+ (set-mark viper-com-point)
+ (viper-enlarge-region (mark t) (point))
+ (let (lines-deleted)
+ (if viper-use-register
+ (progn
+ (cond ((viper-valid-register viper-use-register '(letter digit))
+ (copy-to-register
+ viper-use-register (mark t) (point) nil))
+ ((viper-valid-register viper-use-register '(Letter))
+ (viper-append-to-register
+ (downcase viper-use-register) (mark t) (point)))
+ (t (setq viper-use-register nil)
+ (error viper-InvalidRegister viper-use-register)))
+ (setq viper-use-register nil)))
+ (setq last-command
+ (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))
+ (kill-region (mark t) (point))
+ (if (eq m-com 'viper-line) (setq this-command 'D-command)))
+ (back-to-indentation)))
;; save region
(defun viper-exec-yank (m-com com)
(or (and (markerp viper-com-point) (marker-position viper-com-point))
(set-marker viper-com-point (point) (current-buffer)))
- (if viper-use-register
- (progn
- (cond ((viper-valid-register viper-use-register '(letter digit))
- (copy-to-register
- viper-use-register viper-com-point (point) nil))
- ((viper-valid-register viper-use-register '(Letter))
- (viper-append-to-register
- (downcase viper-use-register) viper-com-point (point)))
- (t (setq viper-use-register nil)
- (error viper-InvalidRegister viper-use-register)))
- (setq viper-use-register nil)))
- (setq last-command nil)
- (copy-region-as-kill viper-com-point (point))
- (message "Saved %d characters" (abs (- (point) viper-com-point)))
- (goto-char viper-com-point))
-
-;; save lines
-(defun viper-exec-Yank (m-com com)
- (save-excursion
- (set-mark viper-com-point)
- (viper-enlarge-region (mark t) (point))
+ (let (chars-saved)
(if viper-use-register
(progn
(cond ((viper-valid-register viper-use-register '(letter digit))
(copy-to-register
- viper-use-register (mark t) (point) nil))
+ viper-use-register viper-com-point (point) nil))
((viper-valid-register viper-use-register '(Letter))
(viper-append-to-register
- (downcase viper-use-register) (mark t) (point)))
+ (downcase viper-use-register) viper-com-point (point)))
(t (setq viper-use-register nil)
- (error viper-InvalidRegister viper-use-register)))
+ (error viper-InvalidRegister viper-use-register)))
(setq viper-use-register nil)))
(setq last-command nil)
- (copy-region-as-kill (mark t) (point))
- (message "Saved %d lines" (count-lines (mark t) (point))))
+ (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))
+ (goto-char viper-com-point)))
+
+;; save lines
+(defun viper-exec-Yank (m-com com)
+ (save-excursion
+ (set-mark viper-com-point)
+ (viper-enlarge-region (mark t) (point))
+ (let (lines-saved)
+ (if viper-use-register
+ (progn
+ (cond ((viper-valid-register viper-use-register '(letter digit))
+ (copy-to-register
+ viper-use-register (mark t) (point) nil))
+ ((viper-valid-register viper-use-register '(Letter))
+ (viper-append-to-register
+ (downcase viper-use-register) (mark t) (point)))
+ (t (setq viper-use-register nil)
+ (error viper-InvalidRegister viper-use-register)))
+ (setq viper-use-register nil)))
+ (setq last-command nil)
+ (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))))
(viper-deactivate-mark)
(goto-char viper-com-point))
@@ -1357,12 +1389,13 @@ as a Meta key and any number of multiple escapes is allowed."
(setq viper-s-string (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)
(viper-search viper-s-string viper-s-forward 1))
(defvar viper-exec-array (make-vector 128 nil))
;; Using a dispatch array allows adding functions like buffer search
-;; without affecting other functions. Buffer search can now be bound
+;; without affecting other functions. Buffer search can now be bound
;; to any character.
(aset viper-exec-array ?c 'viper-exec-change)
@@ -1380,7 +1413,7 @@ as a Meta key and any number of multiple escapes is allowed."
;; This function is called by various movement commands to execute a
-;; destructive command on the region specified by the movement command. For
+;; destructive command on the region specified by the movement command. For
;; instance, if the user types cw, then the command viper-forward-word will
;; call viper-execute-com to execute viper-exec-change, which eventually will
;; call viper-change to invoke the replace mode on the region.
@@ -1443,10 +1476,10 @@ If the prefix argument, ARG, is non-nil, it is used instead of `val'."
))
(viper-adjust-undo) ; take care of undo
;; If the prev cmd was rotating the command ring, this means that `.' has
- ;; just executed a command from that ring. So, push it on the ring again.
+ ;; just executed a command from that ring. So, push it on the ring again.
;; If we are just executing previous command , then don't push viper-d-com
;; because viper-d-com is not fully constructed in this case (its keys and
- ;; the inserted text may be nil). Besides, in this case, the command
+ ;; the inserted text may be nil). Besides, in this case, the command
;; executed by `.' is already on the ring.
(if (eq last-command 'viper-display-current-destructive-command)
(viper-push-onto-ring viper-d-com 'viper-command-ring))
@@ -1458,7 +1491,7 @@ If the prefix argument, ARG, is non-nil, it is used instead of `val'."
Doesn't change viper-command-ring in any way, so `.' will work as before
executing this command.
This command is supposed to be bound to a two-character Vi macro where
-the second character is a digit 0 to 9. The digit indicates which
+the second character is a digit 0 to 9. The digit indicates which
history command to execute. `<char>0' is equivalent to `.', `<char>1'
invokes the command before that, etc."
(interactive)
@@ -1486,7 +1519,7 @@ invokes the command before that, etc."
))
-;; The hash-command. It is invoked interactively by the key sequence #<char>.
+;; The hash-command. It is invoked interactively by the key sequence #<char>.
;; The chars that can follow `#' are determined by viper-hash-command-p
(defun viper-special-prefix-com (char)
(cond ((= char ?c)
@@ -1819,16 +1852,16 @@ Undo previous insertion and inserts new."
(defcustom viper-smart-suffix-list
- '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "P" "p")
+ '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "flr" "P" "p")
"*List of suffixes that Viper tries to append to filenames ending with a `.'.
This is useful when you the current directory contains files with the same
-prefix and many different suffixes. Usually, only one of the suffixes
-represents an editable file. However, file completion will stop at the `.'
+prefix and many different suffixes. Usually, only one of the suffixes
+represents an editable file. However, file completion will stop at the `.'
The smart suffix feature lets you hit RET in such a case, and Viper will
select the appropriate suffix.
Suffixes are tried in the order given and the first suffix for which a
-corresponding file exists is selected. If no file exists for any of the
+corresponding file exists is selected. If no file exists for any of the
suffixes, the user is asked to confirm.
To turn this feature off, set this variable to nil."
@@ -1892,7 +1925,7 @@ problems."
history-var default keymap
init-message)
;; Read string, prompting with PROMPT and inserting the INITIAL
- ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
+ ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
;; input is an empty string.
;; Default value is displayed until the user types something in the
;; minibuffer.
@@ -1900,19 +1933,18 @@ problems."
;; INIT-MESSAGE is the message temporarily displayed after entering the
;; minibuffer.
(let ((minibuffer-setup-hook
- (function
- (lambda ()
- (if (stringp init-message)
- (viper-tmp-insert-at-eob init-message))
- (if (stringp initial)
- (progn
- ;; don't wait if we have unread events or in kbd macro
- (or unread-command-events
- executing-kbd-macro
- (sit-for 840))
- (erase-buffer)
- (insert initial)))
- (viper-minibuffer-setup-sentinel))))
+ (lambda ()
+ (if (stringp init-message)
+ (viper-tmp-insert-at-eob init-message))
+ (if (stringp initial)
+ (progn
+ ;; don't wait if we have unread events or in kbd macro
+ (or unread-command-events
+ executing-kbd-macro
+ (sit-for 840))
+ (erase-buffer)
+ (insert initial)))
+ (viper-minibuffer-setup-sentinel)))
(val "")
(padding "")
temp-msg)
@@ -1938,7 +1970,7 @@ problems."
(set history-var (cdr (eval history-var))))
;; If the user enters nothing but the prev cmd wasn't viper-ex,
;; viper-command-argument, or `! shell-command', this probably means
- ;; that the user typed something then erased. Return "" in this case, not
+ ;; that the user typed something then erased. Return "" in this case, not
;; the default---the default is too confusing in this case.
(cond ((and (string= val "")
(not (string= prompt "!")) ; was a `! shell-command'
@@ -2144,12 +2176,13 @@ problems."
)
;; Invoked as an after-change-function to calculate how many chars have to be
-;; deleted. This function may be called several times within a single command,
-;; if this command performs several separate buffer changes. Therefore, if adds
-;; up the number of chars inserted and subtracts the number of chars deleted.
+;; deleted. This function may be called several times within a single command,
+;; if this command performs several separate buffer changes. Therefore, if
+;; adds up the number of chars inserted and subtracts the number of chars
+;; deleted.
(defun viper-replace-mode-spy-after (beg end length)
(if (memq viper-intermediate-command
- '(dabbrev-expand repeating-insertion-from-ring))
+ '(dabbrev-expand hippie-expand repeating-insertion-from-ring))
;; Take special care of text insertion from insertion ring inside
;; replacement overlays.
(progn
@@ -2174,11 +2207,12 @@ problems."
;; column-shift instead of the number of inserted chars
(max (viper-chars-in-region beg real-end)
;; This test accounts for Chinese/Japanese/... chars,
- ;; which occupy 2 columns instead of one. If we use
+ ;; which occupy 2 columns instead of one. If we use
;; column-shift here, we may delete two chars instead of
- ;; one when the user types one Chinese character. Deleting
- ;; two would be OK, if they were European chars, but it is
- ;; not OK if they are Chinese chars. Since it is hard to
+ ;; one when the user types one Chinese character.
+ ;; Deleting two would be OK, if they were European chars,
+ ;; but it is not OK if they are Chinese chars.
+ ;; Since it is hard to
;; figure out which characters are being deleted in any
;; given region, we decided to treat Eastern and European
;; characters equally, even though Eastern chars may
@@ -2227,7 +2261,7 @@ problems."
'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local)
(remove-hook
'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local)
- (viper-restore-cursor-color-after-replace)
+ (viper-restore-cursor-color 'after-replace-mode)
(setq viper-sitting-in-replace nil) ; just in case we'll need to know it
(save-excursion
(if (and viper-replace-overlay
@@ -2301,7 +2335,7 @@ These keys are ESC, RET, and LineFeed"
(interactive)
;; If Emacs start supporting overlay maps, as it currently supports
;; text-property maps, we could do away with viper-replace-minor-mode and
- ;; just have keymap attached to replace overlay. Then the "if part" of this
+ ;; just have keymap attached to replace overlay. Then the "if part" of this
;; statement can be deleted.
(if (or (< (point) (viper-replace-start))
(> (point) (viper-replace-end)))
@@ -2356,8 +2390,8 @@ These keys are ESC, RET, and LineFeed"
(viper-move-marker-locally 'viper-com-point (point))
(if (not (eobp))
(viper-next-line-carefully (1- val)))
- ;; this ensures that dd, cc, D, yy will do the right thing on the last
- ;; line of buffer when this line has no \n.
+ ;; the following ensures that dd, cc, D, yy will do the right thing on the
+ ;; last line of buffer when this line has no \n.
(viper-add-newline-at-eob-if-necessary)
(viper-execute-com 'viper-line val com))
(if (and (eobp) (not (bobp))) (forward-line -1))
@@ -2535,9 +2569,9 @@ On reaching beginning of line, stop and signal error."
;;; Word command
;; Words are formed from alpha's and nonalphas - <sp>,\t\n are separators for
-;; word movement. When executed with a destructive command, \n is usually left
+;; word movement. When executed with a destructive command, \n is usually left
;; untouched for the last word. Viper uses syntax table to determine what is a
-;; word and what is a separator. However, \n is always a separator. Also, if
+;; word and what is a separator. However, \n is always a separator. Also, if
;; viper-syntax-preference is 'vi, then `_' is part of the word.
;; skip only one \n
@@ -2549,7 +2583,7 @@ On reaching beginning of line, stop and signal error."
(progn
(forward-char)
(viper-skip-all-separators-forward 'within-line))))
- ;; check for eob and white space before it. move off of eob
+ ;; check for eob and white space before it. move off of eob
(if (and (eobp) (save-excursion
(viper-backward-char-carefully)
(viper-looking-at-separator)))
@@ -2572,7 +2606,7 @@ On reaching beginning of line, stop and signal error."
(viper-skip-separators t)))
(setq val (1- val))))
-;; first skip non-newline separators backward, then skip \n. Then, if TWICE is
+;; first skip non-newline separators backward, then skip \n. Then, if TWICE is
;; non-nil, skip non-\n back again, but don't overshoot the limit LIM.
(defun viper-separator-skipback-special (twice lim)
(let ((prev-char (viper-char-at-pos 'backward))
@@ -3107,6 +3141,7 @@ controlled by the sign of prefix numeric value."
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
+ (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
(move-to-window-line (1- val))
@@ -3125,14 +3160,11 @@ controlled by the sign of prefix numeric value."
"Go to middle window line."
(interactive "P")
(let ((val (viper-p-val arg))
- (com (viper-getCom arg))
- lines)
+ (com (viper-getCom arg)))
+ (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
- (if (not (pos-visible-in-window-p (point-max)))
- (move-to-window-line (+ (/ (1- (window-height)) 2) (1- val)))
- (setq lines (count-lines (window-start) (point-max)))
- (move-to-window-line (+ (/ lines 2) (1- val))))
+ (move-to-window-line (+ (/ (1- (window-height)) 2) (1- val)))
;; positioning is done twice: before and after command execution
(if (and (eobp) (bolp) (not (bobp))) (forward-line -1))
@@ -3149,6 +3181,7 @@ controlled by the sign of prefix numeric value."
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
+ (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
(move-to-window-line (- val))
@@ -3180,8 +3213,8 @@ controlled by the sign of prefix numeric value."
;; If point is within viper-search-scroll-threshold of window top or bottom,
;; scroll up or down 1/7 of window height, depending on whether we are at the
-;; bottom or at the top of the window. This function is called by viper-search
-;; (which is called from viper-search-forward/backward/next). If the value of
+;; bottom or at the top of the window. This function is called by viper-search
+;; (which is called from viper-search-forward/backward/next). If the value of
;; viper-search-scroll-threshold is negative - don't scroll.
(defun viper-adjust-window ()
(let ((win-height (if viper-emacs-p
@@ -3210,7 +3243,7 @@ controlled by the sign of prefix numeric value."
;; paren match
-;; must correct this to only match ( to ) etc. On the other hand
+;; must correct this to only match ( to ) etc. On the other hand
;; it is good that paren match gets confused, because that way you
;; catch _all_ imbalances.
@@ -3436,21 +3469,21 @@ controlled by the sign of prefix numeric value."
(defun viper-toggle-search-style (arg)
"Toggle the value of viper-case-fold-search/viper-re-search.
-Without prefix argument, will ask which search style to toggle. With prefix
+Without prefix argument, will ask which search style to toggle. With prefix
arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
Although this function is bound to \\[viper-toggle-search-style], the most
convenient way to use it is to bind `//' to the macro
`1 M-x viper-toggle-search-style' and `///' to
-`2 M-x viper-toggle-search-style'. In this way, hitting `//' quickly will
+`2 M-x viper-toggle-search-style'. In this way, hitting `//' quickly will
toggle case-fold-search and hitting `/' three times witth toggle regexp
-search. Macros are more convenient in this case because they don't affect
+search. Macros are more convenient in this case because they don't affect
the Emacs binding of `/'."
(interactive "P")
(let (msg)
(cond ((or (eq arg 1)
(and (null arg)
- (y-or-n-p (format "Search style: '%s'. Want '%s'? "
+ (y-or-n-p (format "Search style: '%s'. Want '%s'? "
(if viper-case-fold-search
"case-insensitive" "case-sensitive")
(if viper-case-fold-search
@@ -3462,7 +3495,7 @@ the Emacs binding of `/'."
(setq msg "Search becomes case-sensitive")))
((or (eq arg 2)
(and (null arg)
- (y-or-n-p (format "Search style: '%s'. Want '%s'? "
+ (y-or-n-p (format "Search style: '%s'. Want '%s'? "
(if viper-re-search
"regexp-search" "vanilla-search")
(if viper-re-search
@@ -3529,7 +3562,7 @@ 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.
If the optional prefix argument is non-nil and specifies a valid major mode,
-this sets the macros only in the macros in that major mode. Otherwise,
+this sets the macros only in the macros in that major mode. Otherwise,
the macros are set in the current major mode.
\(When unsetting the macros, the second argument has no effect.\)"
(interactive "P")
@@ -3715,7 +3748,11 @@ Null string will repeat previous search."
((null viper-buffer-search-char)
(setq viper-buffer-search-char ?g)))
(define-key viper-vi-basic-map
- (char-to-string viper-buffer-search-char) 'viper-command-argument)
+ (cond ((viper-characterp viper-buffer-search-char)
+ (char-to-string viper-buffer-search-char))
+ (t (error "viper-buffer-search-char: wrong value type, %s"
+ viper-buffer-search-char)))
+ 'viper-command-argument)
(aset viper-exec-array viper-buffer-search-char 'viper-exec-buffer-search)
(setq viper-prefix-commands
(cons viper-buffer-search-char viper-prefix-commands)))
@@ -3745,7 +3782,8 @@ Null string will repeat previous search."
(let ((other-buffer (other-buffer (current-buffer)))
buffer)
(setq buffer
- (read-buffer "Switch to buffer in this window: " other-buffer))
+ (funcall viper-read-buffer-function
+ "Switch to buffer in this window: " other-buffer))
(switch-to-buffer buffer)))
(defun viper-switch-to-buffer-other-window ()
@@ -3754,7 +3792,8 @@ Null string will repeat previous search."
(let ((other-buffer (other-buffer (current-buffer)))
buffer)
(setq buffer
- (read-buffer "Switch to buffer in another window: " other-buffer))
+ (funcall viper-read-buffer-function
+ "Switch to buffer in another window: " other-buffer))
(switch-to-buffer-other-window buffer)))
(defun viper-kill-buffer ()
@@ -3762,9 +3801,9 @@ Null string will repeat previous search."
(interactive)
(let (buffer buffer-name)
(setq buffer-name
- (read-buffer
- (format "Kill buffer \(%s\): "
- (buffer-name (current-buffer)))))
+ (funcall viper-read-buffer-function
+ (format "Kill buffer \(%s\): "
+ (buffer-name (current-buffer)))))
(setq buffer
(if (null buffer-name)
(current-buffer)
@@ -3783,7 +3822,7 @@ Null string will repeat previous search."
;; yank and pop
(defsubst viper-yank (text)
- "Yank TEXT silently. This works correctly with Emacs's yank-pop command."
+ "Yank TEXT silently. This works correctly with Emacs's yank-pop command."
(insert text)
(setq this-command 'yank))
@@ -3799,7 +3838,7 @@ Null string will repeat previous search."
(get-register (downcase viper-use-register)))
(t (error viper-InvalidRegister viper-use-register)))
(current-kill 0)))
- sv-point)
+ sv-point chars-inserted lines-inserted)
(if (null text)
(if viper-use-register
(let ((reg viper-use-register))
@@ -3820,9 +3859,12 @@ Null string will repeat previous search."
(list 'viper-put-back val nil viper-use-register nil nil))
(setq sv-point (point))
(viper-loop val (viper-yank text))
- (message "Inserted %d character(s), %d line(s)"
- (abs (- (point) sv-point))
- (abs (count-lines (point) sv-point))))
+ (setq chars-inserted (abs (- (point) sv-point))
+ 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)))
;; 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
@@ -3844,7 +3886,8 @@ Null string will repeat previous search."
((viper-valid-register viper-use-register)
(get-register (downcase viper-use-register)))
(t (error viper-InvalidRegister viper-use-register)))
- (current-kill 0))))
+ (current-kill 0)))
+ sv-point chars-inserted lines-inserted)
(if (null text)
(if viper-use-register
(let ((reg viper-use-register))
@@ -3856,7 +3899,14 @@ Null string will repeat previous search."
(viper-set-destructive-command
(list 'viper-Put-back val nil viper-use-register nil nil))
(set-marker (viper-mark-marker) (point) (current-buffer))
- (viper-loop val (viper-yank text)))
+ (setq sv-point (point))
+ (viper-loop val (viper-yank text))
+ (setq chars-inserted (abs (- (point) sv-point))
+ 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)))
;; 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
@@ -3908,7 +3958,7 @@ Null string will repeat previous search."
))
(defun viper-delete-backward-char (arg)
- "Delete previous character. On reaching beginning of line, stop and beep."
+ "Delete previous character. On reaching beginning of line, stop and beep."
(interactive "P")
(let ((val (viper-p-val arg))
end-del-pos)
@@ -3945,8 +3995,8 @@ Null string will repeat previous search."
(defun viper-del-backward-char-in-replace ()
"Delete one character in replace mode.
If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes
-charecters. If it is nil, then the cursor just moves backwards, similarly
-to Vi. The variable `viper-ex-style-editing', if t, doesn't let the
+charecters. If it is nil, then the cursor just moves backwards, similarly
+to Vi. The variable `viper-ex-style-editing', if t, doesn't let the
cursor move past the beginning of line."
(interactive)
(cond (viper-delete-backwards-in-replace
@@ -4031,10 +4081,10 @@ cursor move past the beginning of line."
viper-replace-region-start-delimiter
viper-replace-region-end-delimiter)
;; this move takes care of the last posn in the overlay, which
- ;; has to be shifted because of insert. We can't simply insert
+ ;; has to be shifted because of insert. We can't simply insert
;; "$" before-markers because then overlay-start will shift the
;; beginning of the overlay in case we are replacing a single
- ;; character. This fixes the bug with `s' and `cl' commands.
+ ;; character. This fixes the bug with `s' and `cl' commands.
(viper-move-replace-overlay (viper-replace-start) (point))
(goto-char (viper-replace-start))
(viper-change-state-to-replace t))
@@ -4145,6 +4195,7 @@ and regexp replace."
((= char ?>) (viper-mark-end-of-buffer))
((= char ?.) (viper-set-mark-if-necessary))
((= char ?,) (viper-cycle-through-mark-ring))
+ ((= char ?^) (push-mark viper-saved-mark t t))
((= char ?D) (mark-defun))
(t (error ""))
)))
@@ -4156,7 +4207,7 @@ and regexp replace."
;; So, if you hit '' or `` then you can return to p1.
;;
;; If repeated command, pop top elt from the ring into mark and
-;; jump there. This forgets the position, p1, and puts M1 back into mark.
+;; jump there. This forgets the position, p1, and puts M1 back into mark.
;; Then we save the current pos, which is M0, jump to M1 and pop M2 from
;; the ring into mark. Push M2 back on the ring and set mark to M0.
;; etc.
@@ -4165,12 +4216,12 @@ and regexp replace."
One can use `` and '' to temporarily jump 1 step back."
(let* ((sv-pt (point)))
;; if repeated `m,' command, pop the previously saved mark.
- ;; Prev saved mark is actually prev saved point. It is used if the
+ ;; Prev saved mark is actually prev saved point. It is used if the
;; user types `` or '' and is discarded
;; from the mark ring by the next `m,' command.
;; In any case, go to the previous or previously saved mark.
;; Then push the current mark (popped off the ring) and set current
- ;; point to be the mark. Current pt as mark is discarded by the next
+ ;; point to be the mark. Current pt as mark is discarded by the next
;; m, command.
(if (eq last-command 'viper-cycle-through-mark-ring)
()
@@ -4336,7 +4387,7 @@ One can use `` and '' to temporarily jump 1 step back."
;; Viewing registers
(defun viper-ket-function (arg)
- "Function called by \], the ket. View registers and call \]\]."
+ "Function called by \], the ket. View registers and call \]\]."
(interactive "P")
(let ((reg (read-char)))
(cond ((viper-valid-register reg '(letter Letter))
@@ -4353,7 +4404,7 @@ One can use `` and '' to temporarily jump 1 step back."
viper-InvalidRegister reg)))))
(defun viper-brac-function (arg)
- "Function called by \[, the brac. View textmarkers and call \[\["
+ "Function called by \[, the brac. View textmarkers and call \[\["
(interactive "P")
(let ((reg (read-char)))
(cond ((= ?\[ reg)
@@ -4532,7 +4583,7 @@ Please specify your level of familiarity with the venomous VI PERil
You can change it at any time by typing `M-x viper-set-expert-level RET'
1 -- BEGINNER: Almost all Emacs features are suppressed.
- Feels almost like straight Vi. File name completion and
+ Feels almost like straight Vi. File name completion and
command history in the minibuffer are thrown in as a bonus.
To use Emacs productively, you must reach level 3 or higher.
2 -- MASTER: C-c now has its standard Emacs meaning in Vi command state,
@@ -4542,10 +4593,10 @@ You can change it at any time by typing `M-x viper-set-expert-level RET'
in Viper's insert state.
4 -- GURU: Like 3, but user settings are respected for viper-no-multiple-ESC,
viper-ex-style-motion, viper-ex-style-editing, and
- viper-re-search variables. Adjust these settings to your taste.
+ viper-re-search variables. Adjust these settings to your taste.
5 -- WIZARD: Like 4, but user settings are also respected for viper-always,
viper-electric-mode, viper-want-ctl-h-help, viper-want-emacs-keys-in-vi,
- and viper-want-emacs-keys-in-insert. Adjust these to your taste.
+ and viper-want-emacs-keys-in-insert. Adjust these to your taste.
Please, specify your level now: ")
@@ -4705,10 +4756,10 @@ Before reporting a bug, please verify that it is related to Viper, and is
not cause by other packages you are using.
Don't report compilation warnings, unless you are certain that there is a
-problem. These warnings are normal and unavoidable.
+problem. These warnings are normal and unavoidable.
Please note that users should not modify variables and keymaps other than
-those advertised in the manual. Such `customization' is likely to crash
+those advertised in the manual. Such `customization' is likely to crash
Viper, as it would any other improperly customized Emacs package.
If you are reporting an error message received while executing one of the
@@ -4716,8 +4767,8 @@ Viper commands, type:
M-x set-variable <Return> debug-on-error <Return> t <Return>
-Then reproduce the error. The above command will cause Emacs to produce a
-back trace of the execution that leads to the error. Please include this
+Then reproduce the error. The above command will cause Emacs to produce a
+back trace of the execution that leads to the error. Please include this
trace in your bug report.
If you believe that one of Viper's commands goes into an infinite loop
@@ -4725,8 +4776,8 @@ If you believe that one of Viper's commands goes into an infinite loop
M-x set-variable <Return> debug-on-quit <Return> t <Return>
-Then reproduce the problem. Wait for a few seconds, then type C-g to abort
-the current command. Include the resulting back trace in the bug report.
+Then reproduce the problem. Wait for a few seconds, then type C-g to abort
+the current command. Include the resulting back trace in the bug report.
Mail anyway (y or n)? ")
(if (y-or-n-p "Mail anyway? ")
@@ -4748,12 +4799,12 @@ Mail anyway (y or n)? ")
;; Smoothes out the difference between Emacs' unread-command-events
-;; and XEmacs unread-command-event. Arg is a character, an event, a list of
+;; and XEmacs unread-command-event. Arg is a character, an event, a list of
;; events or a sequence of keys.
;;
;; Due to the way unread-command-events in Emacs (not XEmacs), a non-event
;; symbol in unread-command-events list may cause Emacs to turn this symbol
-;; into an event. Below, we delete nil from event lists, since nil is the most
+;; into an event. Below, we delete nil from event lists, since nil is the most
;; common symbol that might appear in this wrong context.
(defun viper-set-unread-command-events (arg)
(if viper-emacs-p
@@ -4786,12 +4837,12 @@ Mail anyway (y or n)? ")
;; list is assumed to be a list of events of characters
(defun viper-eventify-list-xemacs (lis)
(mapcar
- (function (lambda (elt)
- (cond ((viper-characterp elt) (character-to-event elt))
- ((eventp elt) elt)
- (t (error
- "viper-eventify-list-xemacs: can't convert to event, %S"
- elt)))))
+ (lambda (elt)
+ (cond ((viper-characterp elt) (character-to-event elt))
+ ((eventp elt) elt)
+ (t (error
+ "viper-eventify-list-xemacs: can't convert to event, %S"
+ elt))))
lis))
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index a4d5bea9613..ef57e8ceb95 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -68,7 +68,7 @@
;;; Variable completion in :set command
-;; The list of Ex commands. Used for completing command names.
+;; The list of Ex commands. Used for completing command names.
(defconst ex-token-alist
'(("!") ("=") (">") ("&") ("~")
("yank") ("xit") ("WWrite") ("Write") ("write") ("wq") ("visual")
@@ -77,8 +77,8 @@
("set") ("rewind") ("recover") ("read") ("quit") ("pwd")
("put") ("preserve") ("PreviousRelatedFile") ("RelatedFile")
("next") ("Next") ("move") ("mark") ("map") ("kmark") ("join")
- ("help") ("goto") ("global") ("file") ("edit") ("delete") ("copy")
- ("chdir") ("cd") ("Buffer") ("buffer") ("args")) )
+ ("help") ("goto") ("global") ("file") ("edit") ("delete") ("customize")
+ ("copy") ("chdir") ("cd") ("Buffer") ("buffer") ("args")) )
;; A-list of Ex variables that can be set using the :set command.
(defconst ex-variable-alist
@@ -108,8 +108,8 @@
(defvar ex-addresses nil)
;; This flag is supposed to be set only by `#', `print', and `list',
-;; none of which is implemented. So, it and the pices of the code it
-;; controls are dead weight. We keep it just in case this might be
+;; none of which is implemented. So, it and the pices of the code it
+;; controls are dead weight. We keep it just in case this might be
;; needed in the future.
(defvar ex-flag nil)
@@ -169,13 +169,23 @@ Don't put `-c' here, as it is added automatically."
:type 'string
:group 'viper-ex)
-(defvar ex-nontrivial-find-file-function
- (cond (ex-unix-type-shell 'viper-ex-nontrivial-find-file-unix)
- ((eq system-type 'emx) 'viper-ex-nontrivial-find-file-ms) ; OS/2
- (viper-ms-style-os-p 'viper-ex-nontrivial-find-file-ms) ; Microsoft OS
- (viper-vms-os-p 'viper-ex-nontrivial-find-file-unix) ; VMS
- (t 'viper-ex-nontrivial-find-file-unix) ; presumably UNIX
- ))
+(defcustom viper-glob-function
+ (cond (ex-unix-type-shell 'viper-glob-unix-files)
+ ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2
+ (viper-ms-style-os-p 'viper-glob-mswindows-files) ; Microsoft OS
+ (viper-vms-os-p 'viper-glob-unix-files) ; VMS
+ (t 'viper-glob-unix-files) ; presumably UNIX
+ )
+ "Expand the file spec containing wildcard symbols.
+The default tries to set this variable to work with Unix, Windows,
+OS/2, and VMS.
+
+However, if it doesn't work right for some types of Unix shells or some OS,
+the user should supply the appropriate function and set this variable to the
+corresponding function symbol."
+ :type 'symbol
+ :group 'viper-ex)
+
;; Remembers the previous Ex tag.
(defvar ex-tag nil)
@@ -198,12 +208,12 @@ Don't put `-c' here, as it is added automatically."
(defvar ex-cmdfile-args "")
;; flag used in viper-ex-read-file-name to indicate that we may be reading
-;; multiple file names. Used for :edit and :next
+;; multiple file names. Used for :edit and :next
(defvar viper-keep-reading-filename nil)
(defcustom ex-cycle-other-window t
"*If t, :n and :b cycles through files and buffers in other window.
-Then :N and :B cycles in the current window. If nil, this behavior is
+Then :N and :B cycles in the current window. If nil, this behavior is
reversed."
:type 'boolean
:group 'viper-ex)
@@ -250,6 +260,7 @@ reversed."
(cond ((looking-at "cd") (viper-check-sub "cd"))
((looking-at "ch") (viper-check-sub "chdir"))
((looking-at "co") (viper-check-sub "copy"))
+ ((looking-at "cu") (viper-check-sub "customize"))
(t (viper-check-sub "change"))))
((looking-at "d") (viper-check-sub "delete"))
((looking-at "b") (viper-check-sub "buffer"))
@@ -424,8 +435,8 @@ reversed."
(t
(error viper-BadExCommand))))))
-;; Reads Ex command. Tries to determine if it has to exit because command
-;; is complete or invalid. If not, keeps reading command.
+;; Reads Ex command. Tries to determine if it has to exit because command
+;; is complete or invalid. If not, keeps reading command.
(defun ex-cmd-read-exit ()
(interactive)
(setq viper-incomplete-ex-cmd t)
@@ -490,10 +501,10 @@ reversed."
(if (or (= dist 0)
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(viper-looking-back
- "^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*+[ \t]+[a-zA-Z!=>&~]+"))
+ "^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+"))
;; Preceding characters are not the ones allowed in an Ex command
;; or we have typed past command name.
- ;; Note: we didn't do parsing, so there may be surprises.
+ ;; Note: we didn't do parsing, so there can be surprises.
(if (or (viper-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*")
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(looking-at "[^ \t\n\C-m]"))
@@ -526,6 +537,10 @@ reversed."
;; Read Ex commands
+;; ARG is a prefix argument. If given, the ex command runs on the region
+;;(without the user having to specify the address :a,b
+;; STRING is the command to execute. If nil, then Viper asks you to enter the
+;; command.
(defun viper-ex (arg &optional string)
(interactive "P")
(or string
@@ -590,17 +605,19 @@ reversed."
(setq cont nil))
(t
(viper-execute-ex-command)
- (save-window-excursion
- (setq viper-ex-work-buf
- (get-buffer-create viper-ex-work-buf-name))
- (set-buffer viper-ex-work-buf)
- (skip-chars-forward " \t")
- (cond ((looking-at "|")
- (forward-char 1))
- ((looking-at "\n")
- (setq cont nil))
- (t (error "`%s': %s" ex-token viper-SpuriousText)))
- ))
+ (save-excursion
+ (save-window-excursion
+ (setq viper-ex-work-buf
+ (get-buffer-create viper-ex-work-buf-name))
+ (set-buffer viper-ex-work-buf)
+ (skip-chars-forward " \t")
+ (cond ((looking-at "|")
+ (forward-char 1))
+ ((looking-at "\n")
+ (setq cont nil))
+ (t (error
+ "`%s': %s" ex-token viper-SpuriousText)))
+ )))
))
((eq ex-token-type 'non-command)
(error "`%s': %s" ex-token viper-BadExCommand))
@@ -674,7 +691,7 @@ reversed."
(buffer-substring (1- (point)) (mark t))))
(backward-char 1)
;; if the user didn't insert the final pattern delimiter, we're
- ;; at newline now. In this case, insert the initial delimiter
+ ;; at newline now. In this case, insert the initial delimiter
;; specified in variable c
(if (eolp)
(progn
@@ -944,7 +961,7 @@ reversed."
(setq ex-file (buffer-substring (point) (1- (point-max))))
(setq ex-file
;; For :e, match multiple non-white strings separated
- ;; by white. For others, find the first non-white string
+ ;; by white. For others, find the first non-white string
(if (string-match
(if (string= ex-token "edit")
"[^ \t\n]+\\([ \t]+[^ \t\n]+\\)*"
@@ -979,7 +996,7 @@ reversed."
))
-;; Completes file name or exits minibuffer. If Ex command accepts multiple
+;; Completes file name or exits minibuffer. If Ex command accepts multiple
;; file names, arranges to re-enter the minibuffer.
(defun viper-complete-filename-or-exit ()
(interactive)
@@ -1056,6 +1073,7 @@ reversed."
(cond ((string= ex-token "args") (ex-args))
((string= ex-token "copy") (ex-copy nil))
((string= ex-token "cd") (ex-cd))
+ ((string= ex-token "customize") (customize-group "viper"))
((string= ex-token "chdir") (ex-cd))
((string= ex-token "delete") (ex-delete))
((string= ex-token "edit") (ex-edit))
@@ -1118,7 +1136,7 @@ reversed."
((or (string= ex-token "abbreviate")
(string= ex-token "unabbreviate"))
(error
- "`%s': Vi abbrevs are obsolete. Use the more powerful Emacs abbrevs"
+ "`%s': Vi abbrevs are obsolete. Use the more powerful Emacs abbrevs"
ex-token))
((or (string= ex-token "list")
(string= ex-token "print")
@@ -1129,18 +1147,17 @@ reversed."
(defun viper-undisplayed-files ()
(mapcar
- (function
- (lambda (b)
- (if (null (get-buffer-window b))
- (let ((f (buffer-file-name b)))
- (if f f
- (if ex-cycle-through-non-files
- (let ((s (buffer-name b)))
- (if (string= " " (substring s 0 1))
- nil
- s))
- nil)))
- nil)))
+ (lambda (b)
+ (if (null (get-buffer-window b))
+ (let ((f (buffer-file-name b)))
+ (if f f
+ (if ex-cycle-through-non-files
+ (let ((s (buffer-name b)))
+ (if (string= " " (substring s 0 1))
+ nil
+ s))
+ nil)))
+ nil))
(buffer-list)))
@@ -1166,7 +1183,7 @@ reversed."
(princ "\n\nPress any key to continue...\n\n"))
(viper-read-event))))))
-;; Ex cd command. Default directory of this buffer changes
+;; Ex cd command. Default directory of this buffer changes
(defun ex-cd ()
(viper-get-ex-file)
(if (string= ex-file "")
@@ -1242,9 +1259,9 @@ reversed."
;; Ex edit command
-;; In Viper, `e' and `e!' behave identically. In both cases, the user is
+;; In Viper, `e' and `e!' behave identically. In both cases, the user is
;; asked if current buffer should really be discarded.
-;; This command can take multiple file names. It replaces the current buffer
+;; This command can take multiple file names. It replaces the current buffer
;; with the first file in its argument list
(defun ex-edit (&optional file)
(if (not file)
@@ -1258,7 +1275,7 @@ reversed."
;;; (if buffer-file-name
;;; (cond ((buffer-modified-p)
;;; (setq msg
-;;; (format "Buffer %s is modified. Discard changes? "
+;;; (format "Buffer %s is modified. Discard changes? "
;;; (buffer-name))
;;; do-edit t))
;;; ((not (verify-visited-file-modtime (current-buffer)))
@@ -1278,7 +1295,10 @@ reversed."
(if (null (setq file (get-file-buffer ex-file)))
(progn
- (ex-find-file ex-file)
+ ;; this also does shell-style globbing
+ (ex-find-file
+ ;; replace # and % with the previous/current file
+ (ex-expand-filsyms ex-file (current-buffer)))
(or (eq major-mode 'dired-mode)
(viper-change-state-to-vi))
(goto-char (point-min)))
@@ -1298,12 +1318,12 @@ reversed."
;; Find-file FILESPEC if it appears to specify a single file.
;; Otherwise, assume that FILESPEC is a wildcard.
;; In this case, split it into substrings separated by newlines.
-;; Each line is assumed to be a file name. find-file's each file thus obtained.
+;; Each line is assumed to be a file name.
(defun ex-find-file (filespec)
(let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]"))
(cond ((file-exists-p filespec) (find-file filespec))
((string-match nonstandard-filename-chars filespec)
- (funcall ex-nontrivial-find-file-function filespec))
+ (mapcar 'find-file (funcall viper-glob-function filespec)))
(t (find-file filespec)))
))
@@ -1371,10 +1391,11 @@ reversed."
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
+ ;; com-str is the command string, i.e., g/pattern/ or v/pattern'
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while marks
(goto-char (car marks))
- (viper-ex com-str)
+ (viper-ex nil com-str)
(setq mark-count (1- mark-count))
(setq marks (cdr marks)))))
@@ -1384,7 +1405,8 @@ reversed."
(setq ex-addresses (cons (point) nil)))
(push-mark (point) t)
(goto-char (car ex-addresses))
- (beginning-of-line))
+ (beginning-of-line)
+ )
;; Ex line commands. COM is join, shift-right or shift-left
(defun ex-line (com)
@@ -1574,7 +1596,7 @@ reversed."
;; Ex quit command
(defun ex-quit ()
- ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
+ ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
(save-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
@@ -1585,6 +1607,9 @@ reversed."
;; Ex read command
+;; ex-read doesn't support wildcards, because file completion is a better
+;; mechanism. We also don't support # and % (except in :r <shell-command>
+;; because file history is a better mechanism.
(defun ex-read ()
(viper-get-ex-file)
(let ((point (if (null ex-addresses) (point) (car ex-addresses)))
@@ -1600,8 +1625,9 @@ reversed."
(if ex-cmdfile
(progn
(setq command
- (concat (ex-expand-filsyms ex-file (current-buffer))
- ex-cmdfile-args))
+ ;; replace # and % with the previous/current file
+ (ex-expand-filsyms (concat ex-file ex-cmdfile-args)
+ (current-buffer)))
(shell-command command t))
(insert-file-contents ex-file)))
(ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
@@ -1632,7 +1658,7 @@ reversed."
;; Tell that `rewind' is obsolete and to use `:next count' instead
(defun ex-rewind ()
(message
- "Use `:n <count>' instead. Counts are obtained from the `:args' command"))
+ "Use `:n <count>' instead. Counts are obtained from the `:args' command"))
;; read variable name for ex-set
@@ -1846,7 +1872,7 @@ reversed."
(defun ex-shell ()
(shell))
-;; Viper help. Invokes Info
+;; Viper help. Invokes Info
(defun ex-help ()
(condition-case nil
(progn
@@ -1863,7 +1889,7 @@ Please contact your system administrator. "
(if viper-xemacs-p "X" "")
))))))
-;; Ex source command. Loads the file specified as argument or `~/.viper'
+;; Ex source command. Loads the file specified as argument or `~/.viper'
(defun ex-source ()
(viper-get-ex-file)
(if (string= ex-file "")
@@ -1979,6 +2005,9 @@ Please contact your system administrator. "
(viper-message-conditions conds)))))
;; Ex write command
+;; ex-write doesn't support wildcards, because file completion is a better
+;; mechanism. We also don't support # and %
+;; because file history is a better mechanism.
(defun ex-write (q-flag)
(viper-default-ex-addresses t)
(viper-get-ex-file)
@@ -1999,7 +2028,7 @@ Please contact your system administrator. "
(if (and (string= ex-file "") (not (buffer-file-name)))
(setq ex-file
(read-file-name
- (format "Buffer %s isn't visiting any file. File to save in: "
+ (format "Buffer %s isn't visiting any file. File to save in: "
(buffer-name)))))
(setq writing-whole-file (and (= (point-min) beg) (= (point-max) end))
@@ -2031,7 +2060,7 @@ Please contact your system administrator. "
;; writing to non-visited file and it already exists
(if (and file-exists (not writing-same-file)
(not (yes-or-no-p
- (format "File %s exists. Overwrite? " ex-file))))
+ (format "File %s exists. Overwrite? " ex-file))))
(error "Quit"))
;; writing a region or whole buffer to non-visited file
(unwind-protect
@@ -2041,7 +2070,9 @@ Please contact your system administrator. "
;; create temp buffer for the region
(setq temp-buf (get-buffer-create " *ex-write*"))
(set-buffer temp-buf)
- (set-visited-file-name ex-file 'noquerry)
+ (if viper-xemacs-p
+ (set-visited-file-name ex-file)
+ (set-visited-file-name ex-file 'noquerry))
(erase-buffer)
(if (and file-exists ex-append)
(insert-file-contents ex-file))
@@ -2120,6 +2151,7 @@ Please contact your system administrator. "
(skip-chars-forward " \t")
(setq command (buffer-substring (point) (point-max)))
(end-of-line))
+ ;; replace # and % with the previous/current file
(setq command (ex-expand-filsyms command (current-buffer)))
(if (and (> (length command) 0) (string= "!" (substring command 0 1)))
(if viper-ex-last-shell-com
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 27217d83d15..a3c658bd088 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -208,8 +208,8 @@ the Ex command :map!.")
"Minor mode in effect in replace state (cw, C, and the like commands).")
;; Mode for vital things like \C-z and \C-x) This is set to t, when viper-mode
-;; is invoked. So, any new buffer will have C-z defined as switch to Vi, unless
-;; we switched states in this buffer
+;; is invoked. So, any new buffer will have C-z defined as switch to Vi,
+;; unless we switched states in this buffer
(viper-deflocalvar viper-emacs-intercept-minor-mode nil)
(viper-deflocalvar viper-emacs-local-user-minor-mode nil
@@ -225,7 +225,7 @@ state.")
(viper-deflocalvar viper-emacs-kbd-minor-mode nil
"Minor mode for Vi style macros in Emacs state.
The corresponding keymap stores key bindings of Vi macros defined with
-`viper-record-kbd-macro' command. There is no Ex-level command to do this
+`viper-record-kbd-macro' command. There is no Ex-level command to do this
interactively.")
(viper-deflocalvar viper-emacs-state-modifier-minor-mode nil
@@ -268,7 +268,7 @@ The minor mode viper-insert-diehard-minor-mode is in effect when
viper-expert-level is 1 or 2 or if viper-want-emacs-keys-in-insert is t.
Use `M-x viper-set-expert-level' to change this.")
-;; Max expert level supported by Viper. This is NOT a user option.
+;; Max expert level supported by Viper. This is NOT a user option.
;; It is here to make it hard for the user from resetting it.
(defconst viper-max-expert-level 5)
@@ -277,9 +277,9 @@ Use `M-x viper-set-expert-level' to change this.")
;; If non-nil, ISO accents will be turned on in insert/replace emacs states and
;; turned off in vi-state. For some users, this behavior may be too
-;; primitive. In this case, use insert/emacs/vi state hooks.
+;; primitive. In this case, use insert/emacs/vi state hooks.
(viper-deflocalvar viper-automatic-iso-accents nil "")
-;; Set iso-accents-mode to ARG. Check if it is bound first
+;; Set iso-accents-mode to ARG. Check if it is bound first
(defsubst viper-set-iso-accents-mode (arg)
(if (boundp 'iso-accents-mode)
(setq iso-accents-mode arg)))
@@ -287,7 +287,7 @@ Use `M-x viper-set-expert-level' to change this.")
;; Internal flag used to control when viper mule hooks are run.
;; Don't change this!
(defvar viper-mule-hook-flag t)
-;; If non-nil, the default intl. input method is turned on.
+;; If non-nil, the default intl. input method is turned on.
(viper-deflocalvar viper-special-input-method nil "")
;; viper hook to run on input-method activation
@@ -357,13 +357,13 @@ Use `M-x viper-set-expert-level' to change this.")
(put 'viper-undo-needs-adjustment 'permanent-local t)
;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a
-;; complex command that must be undone atomically. If inserted, it is
+;; complex command that must be undone atomically. If inserted, it is
;; erased by viper-change-state-to-vi and viper-repeat.
(defconst viper-buffer-undo-list-mark 'viper)
(defcustom viper-keep-point-on-undo nil
"*Non-nil means not to move point while undoing commands.
-This style is different from Emacs and Vi. Try it to see if
+This style is different from Emacs and Vi. Try it to see if
it better fits your working style."
:type 'boolean
:tag "Preserve Position of Point After Undo"
@@ -376,8 +376,9 @@ it better fits your working style."
;; This is used to pass the right Vi command key sequence to
;; viper-set-destructive-command whenever (this-command-keys) doesn't give the
-;; right result. For instance, in commands like c/bla<RET>, (this-command-keys)
-;; will return ^M, which invoked exit-minibuffer, while we need "c/"
+;; right result. For instance, in commands like c/bla<RET>,
+;; (this-command-keys) will return ^M, which invoked exit-minibuffer, while we
+;; need "c/"
(defconst viper-this-command-keys nil)
;; Indicates that the current destructive command has started in replace mode.
@@ -400,8 +401,8 @@ delete the text being replaced, as in standard Vi."
:type 'string
:group 'viper)
-;; place to save cursor colow when switching to insert mode
-(viper-deflocalvar viper-saved-cursor-color nil "")
+;; internal var, used to remember the default cursor color of emacs frames
+(defvar viper-vi-state-cursor-color nil)
(viper-deflocalvar viper-replace-overlay nil "")
(put 'viper-replace-overlay 'permanent-local t)
@@ -423,9 +424,14 @@ is non-nil."
(and viper-xemacs-p (eq (viper-device-type) 'tty)))
"*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and
`viper-replace-region-start-delimiter' to delimit replacement regions, even on
-color displays. By default, the delimiters are used only on TTYs."
+color displays. By default, the delimiters are used only on TTYs."
:type 'boolean
:group 'viper)
+
+(defcustom viper-read-buffer-function 'read-buffer
+ "Function to use for prompting the user for a buffer name."
+ :type 'symbol
+ :group 'viper)
;; XEmacs requires glyphs
(if viper-xemacs-p
@@ -456,7 +462,7 @@ color displays. By default, the delimiters are used only on TTYs."
;; mode to compensate for the inserted characters.
(viper-deflocalvar viper-replace-chars-to-delete 0 "")
;; This variable is used internally by the before/after changed functions to
-;; determine how many chars were deleted by the change. This can't be
+;; determine how many chars were deleted by the change. This can't be
;; determined inside after-change-functions because those get the length of the
;; deleted region, not the number of chars deleted (which are two different
;; things under MULE).
@@ -471,7 +477,7 @@ text."
:group 'viper-misc)
;; The insertion ring.
(defvar viper-insertion-ring nil)
-;; This is temp insertion ring. Used to do rotation for display purposes.
+;; This is temp insertion ring. Used to do rotation for display purposes.
;; When rotation just started, it is initialized to viper-insertion-ring.
(defvar viper-temp-insertion-ring nil)
(defvar viper-last-inserted-string-from-insertion-ring "")
@@ -482,14 +488,14 @@ text."
:group 'viper-misc)
;; The command ring.
(defvar viper-command-ring nil)
-;; This is temp command ring. Used to do rotation for display purposes.
+;; This is temp command ring. Used to do rotation for display purposes.
;; When rotation just started, it is initialized to viper-command-ring.
(defvar viper-temp-command-ring nil)
;; Fast keyseq and ESC keyseq timeouts
(defcustom viper-fast-keyseq-timeout 200
"*Key sequence separated by no more than this many milliseconds is viewed as a Vi-style macro, if such a macro is defined.
-Setting this too high may slow down your typing. Setting this value too low
+Setting this too high may slow down your typing. Setting this value too low
will make it hard to use Vi-stile timeout macros."
:type 'integer
:group 'viper-misc)
@@ -497,7 +503,7 @@ will make it hard to use Vi-stile timeout macros."
(defcustom viper-ESC-keyseq-timeout (if (viper-window-display-p)
0 viper-fast-keyseq-timeout)
"*Key sequence beginning with ESC and separated by no more than this many milliseconds is considered to be generated by a keyboard function key.
-Setting this too high may slow down switching from insert to vi state. Setting
+Setting this too high may slow down switching from insert to vi state. Setting
this value too low will make it impossible to use function keys in insert mode
on a dumb terminal."
:type 'integer
@@ -533,7 +539,7 @@ This is a buffer-local variable."
Currently, this only electrifies auto-indentation, making it appropriate to the
mode of the buffer.
This means that auto-indentation will depart from standard Vi and will indent
-appropriate to the mode of the buffer. This is especially useful for editing
+appropriate to the mode of the buffer. This is especially useful for editing
programs and LaTeX documents."
:type 'boolean
:group 'viper)
@@ -565,17 +571,17 @@ to a new place after repeating previous Vi command."
;; back to viper-pre-command-point.
;; The reason this is needed is because dabbrev-expand (and possibly
;; others) may jump to before the insertion point, delete something and
-;; then reinsert a bigger piece. For instance: bla^blo
+;; then reinsert a bigger piece. For instance: bla^blo
;; If dabbrev-expand is called after `blo' and ^ undicates viper-insert-point,
-;; then point jumps to the beginning of `blo'. If expansion is found, `blablo'
-;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand
+;; then point jumps to the beginning of `blo'. If expansion is found, `blablo'
+;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand
;; will insert the expansion, and we get: blablo^
;; Whatever we insert next goes before the ^, i.e., before the
-;; viper-insert-point marker. So, Viper will think that nothing was
-;; inserted. Remembering the orig position of the marker circumvents the
+;; viper-insert-point marker. So, Viper will think that nothing was
+;; inserted. Remembering the orig position of the marker circumvents the
;; problem.
;; We don't know of any command, except dabbrev-expand, that has the same
-;; problem. However, the same trick can be used if such a command is
+;; problem. However, the same trick can be used if such a command is
;; discovered later.
;;
(viper-deflocalvar viper-pre-command-point nil)
@@ -588,7 +594,7 @@ to a new place after repeating previous Vi command."
(defvar viper-last-replace-region "")
;; Remember com point as a marker.
-;; This is a local marker. Should be moved with `viper-move-marker-locally'
+;; This is a local marker. Should be moved with `viper-move-marker-locally'
(viper-deflocalvar viper-com-point nil)
;; If non-nil, the value is a list (M-COM VAL COM REG inserted-text cmd-keys)
@@ -666,7 +672,7 @@ negative number."
:group 'viper-search)
(defcustom viper-re-replace t
- "*If t, do regexp replace. nil means do string replace."
+ "*If t, do regexp replace. nil means do string replace."
:type 'boolean
:tag "Regexp Replace"
:group 'viper-search)
@@ -689,7 +695,7 @@ If nil, these commands cross line boundaries."
`Backspace' and `Delete' don't cross line boundaries in insert.
`X' and `x' can't delete characters across line boundary in Vi, etc.
Note: this doesn't preclude `Backspace' and `Delete' from deleting characters
-by moving past the insertion point. This is a feature, not a bug.
+by moving past the insertion point. This is a feature, not a bug.
If nil, the above commands can work across lines."
:type 'boolean
@@ -710,7 +716,7 @@ If nil, the cursor will move backwards without deleting anything."
:group 'viper)
(defcustom viper-buffer-search-char nil
- "*Key used for buffer-searching. Must be a character type, e.g., ?g."
+ "*Key used for buffer-searching. Must be a character type, e.g., ?g."
:type '(choice (const nil) character)
:group 'viper-search)
@@ -744,7 +750,7 @@ Related buffers can be cycled through via :R and :P commands."
"^\\\\[sb][a-z]*{.*}\\s-*$\\|" ; latex
"^@node\\|@table\\|^@m?enu\\|^@itemize\\|^@if\\|" ; texinfo
"^.+:-") ; prolog
- "*Regexps for Headings. Used by \[\[ and \]\].")
+ "*Regexps for Headings. Used by \[\[ and \]\].")
(defvar viper-heading-end
(concat "^}\\|" ; C/C++
@@ -752,7 +758,7 @@ Related buffers can be cycled through via :R and :P commands."
"^@end \\|" ; texinfo
")\n\n[ \t\n]*\\|" ; lisp
"\\.\\s-*$") ; prolog
- "*Regexps to end Headings/Sections. Used by \[\].")
+ "*Regexps to end Headings/Sections. Used by \[\].")
;; These two vars control the interaction of jumps performed by ' and `.
@@ -781,7 +787,7 @@ Related buffers can be cycled through via :R and :P commands."
(defvar viper-shell-history nil)
-;; Last shell command. There are two of these, one for Ex (in viper-ex)
+;; Last shell command. There are two of these, one for Ex (in viper-ex)
;; and one for Vi.
;; Last shell command executed with ! command.
@@ -806,10 +812,10 @@ Related buffers can be cycled through via :R and :P commands."
(t (:underline t :stipple "gray3")))
"*Face used to flash out the search pattern."
:group 'viper-highlighting)
-;; An internal variable. Viper takes the face from here.
+;; An internal variable. Viper takes the face from here.
(defvar viper-search-face 'viper-search-face
"Face used to flash out the search pattern.
-DO NOT CHANGE this variable. Instead, use the customization widget
+DO NOT CHANGE this variable. Instead, use the customization widget
to customize the actual face object `viper-search-face'
this variable represents.")
(viper-hide-face 'viper-search-face)
@@ -820,10 +826,10 @@ this variable represents.")
(t (:underline t :stipple "gray3")))
"*Face for highlighting replace regions on a window display."
:group 'viper-highlighting)
-;; An internal variable. Viper takes the face from here.
+;; An internal variable. Viper takes the face from here.
(defvar viper-replace-overlay-face 'viper-replace-overlay-face
"Face for highlighting replace regions on a window display.
-DO NOT CHANGE this variable. Instead, use the customization widget
+DO NOT CHANGE this variable. Instead, use the customization widget
to customize the actual face object `viper-replace-overlay-face'
this variable represents.")
(viper-hide-face 'viper-replace-overlay-face)
@@ -834,10 +840,10 @@ this variable represents.")
(t (:bold t)))
"Face used in the Minibuffer when it is in Emacs state."
:group 'viper-highlighting)
-;; An internal variable. Viper takes the face from here.
+;; An internal variable. Viper takes the face from here.
(defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face
"Face used in the Minibuffer when it is in Emacs state.
-DO NOT CHANGE this variable. Instead, use the customization widget
+DO NOT CHANGE this variable. Instead, use the customization widget
to customize the actual face object `viper-minibuffer-emacs-face'
this variable represents.")
(viper-hide-face 'viper-minibuffer-emacs-face)
@@ -848,10 +854,10 @@ this variable represents.")
(t (:italic t)))
"Face used in the Minibuffer when it is in Insert state."
:group 'viper-highlighting)
-;; An internal variable. Viper takes the face from here.
+;; An internal variable. Viper takes the face from here.
(defvar viper-minibuffer-insert-face 'viper-minibuffer-insert-face
"Face used in the Minibuffer when it is in Insert state.
-DO NOT CHANGE this variable. Instead, use the customization widget
+DO NOT CHANGE this variable. Instead, use the customization widget
to customize the actual face object `viper-minibuffer-insert-face'
this variable represents.")
(viper-hide-face 'viper-minibuffer-insert-face)
@@ -862,10 +868,10 @@ this variable represents.")
(t (:inverse-video t)))
"Face used in the Minibuffer when it is in Vi state."
:group 'viper-highlighting)
-;; An internal variable. Viper takes the face from here.
+;; An internal variable. Viper takes the face from here.
(defvar viper-minibuffer-vi-face 'viper-minibuffer-vi-face
"Face used in the Minibuffer when it is in Vi state.
-DO NOT CHANGE this variable. Instead, use the customization widget
+DO NOT CHANGE this variable. Instead, use the customization widget
to customize the actual face object `viper-minibuffer-vi-face'
this variable represents.")
(viper-hide-face 'viper-minibuffer-vi-face)
@@ -890,6 +896,14 @@ this variable represents.")
:type 'string
:group 'viper-misc)
+(defcustom viper-change-notification-threshold 1
+ "Notify the user when this many lines or characters have been deleted/yanked.
+For line-deleting/yanking commands (like `dd', `yy'), the value denotes the
+number of lines. For character-based commands (such as `x', `dw', etc.), the
+value refers to the number of characters affected."
+ :type 'integer
+ :group 'viper-misc)
+
;; Minibuffer
(defcustom viper-vi-style-in-minibuffer t
@@ -900,6 +914,7 @@ Should be set in `~/.viper' file."
;; overlay used in the minibuffer to indicate which state it is in
(viper-deflocalvar viper-minibuffer-overlay nil)
+(put 'viper-minibuffer-overlay 'permanent-local t)
;; Hook, specific to Viper, which is run just *before* exiting the minibuffer.
;; This is needed because beginning with Emacs 19.26, the standard
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index c0e7f980acc..c76c5511627 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -74,7 +74,7 @@ Full Vi compatibility is not recommended for power use of Viper."
(defcustom viper-no-multiple-ESC t
"*If true, multiple ESC in Vi mode will cause bell to ring.
This is set to t on a windowing terminal and to 'twice on a dumb
-terminal (unless the user level is 1, 2, or 5). On a dumb terminal, this
+terminal (unless the user level is 1, 2, or 5). On a dumb terminal, this
enables cursor keys and is generally more convenient, as terminals usually
don't have a convenient Meta key.
Setting viper-no-multiple-ESC to nil will allow as many multiple ESC,
@@ -104,7 +104,7 @@ as is allowed by the major mode in effect."
"Keymap for user-defined local bindings.
Useful for changing bindings such as ZZ in certain major modes.
For instance, in letter-mode, one may want to bind ZZ to
-mh-send-letter. In a newsreader such as gnus, tin, or rn, ZZ could be bound
+mh-send-letter. In a newsreader such as gnus, tin, or rn, ZZ could be bound
to save-buffers-kill-emacs then post article, etc.")
(put 'viper-vi-local-user-map 'permanent-local t)
@@ -121,7 +121,7 @@ This map is global, shared by all buffers.")
(defvar viper-vi-diehard-map (make-sparse-keymap)
"This keymap is in use when the user asks Viper to simulate Vi very closely.
-This happens when viper-expert-level is 1 or 2. See viper-set-expert-level.")
+This happens when viper-expert-level is 1 or 2. See viper-set-expert-level.")
(viper-deflocalvar viper-insert-local-user-map (make-sparse-keymap)
@@ -136,8 +136,8 @@ This happens when viper-expert-level is 1 or 2. See viper-set-expert-level.")
(defvar viper-insert-diehard-map (make-keymap)
"Map used when user wants vi-style keys in insert mode.
-Most of the Emacs keys are suppressed. This map overshadows
-viper-insert-basic-map. Not recommended, except for novice users.")
+Most of the Emacs keys are suppressed. This map overshadows
+viper-insert-basic-map. Not recommended, except for novice users.")
(defvar viper-insert-kbd-map (make-sparse-keymap)
"This keymap keeps VI-style kbd macros for insert mode.")
@@ -159,7 +159,7 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(defvar viper-empty-keymap (make-sparse-keymap))
;; This was the main Vi mode in old versions of VIP which may have been
-;; extensively used by VIP users. We declare it as a global var
+;; extensively used by VIP users. We declare it as a global var
;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map.
(defvar viper-mode-map (make-sparse-keymap))
@@ -185,17 +185,17 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(defvar viper-emacs-state-modifier-alist nil)
;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new
-;; buffers. Not a user option.
+;; buffers. Not a user option.
(viper-deflocalvar viper-need-new-vi-local-map t "")
(put 'viper-need-new-vi-local-map 'permanent-local t)
;; Tells viper-add-local-keys to create a new viper-insert-local-user-map for
-;; new buffers. Not a user option.
+;; new buffers. Not a user option.
(viper-deflocalvar viper-need-new-insert-local-map t "")
(put 'viper-need-new-insert-local-map 'permanent-local t)
;; Tells viper-add-local-keys to create a new viper-emacs-local-user-map for
-;; new buffers. Not a user option.
+;; new buffers. Not a user option.
(viper-deflocalvar viper-need-new-emacs-local-map t "")
(put 'viper-need-new-emacs-local-map 'permanent-local t)
@@ -260,8 +260,8 @@ viper-insert-basic-map. Not recommended, except for novice users.")
;; Vi keymaps
-(define-key viper-vi-basic-map "\C-^"
- (function (lambda () (interactive) (viper-ex "e#"))))
+(define-key viper-vi-basic-map "\C-^" (lambda ()
+ (interactive) (viper-ex nil "e#")))
(define-key viper-vi-basic-map "\C-b" 'viper-scroll-screen-back)
(define-key viper-vi-basic-map "\C-d" 'viper-scroll-up)
(define-key viper-vi-basic-map "\C-e" 'viper-scroll-up-one)
@@ -272,7 +272,7 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(define-key viper-vi-basic-map "\C-s" 'viper-isearch-forward)
(define-key viper-vi-basic-map "\C-r" 'viper-isearch-backward)
(define-key viper-vi-basic-map "\C-c/" 'viper-toggle-search-style)
-(define-key viper-vi-basic-map "\C-cg" 'viper-info-on-file)
+(define-key viper-vi-basic-map "\C-c\C-g" 'viper-info-on-file)
(define-key viper-vi-basic-map "\C-c\M-p" 'viper-prev-destructive-command)
(define-key viper-vi-basic-map "\C-c\M-n" 'viper-next-destructive-command)
@@ -284,8 +284,8 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(define-key viper-vi-basic-map "#" 'viper-command-argument)
(define-key viper-vi-basic-map "$" 'viper-goto-eol)
(define-key viper-vi-basic-map "%" 'viper-paren-match)
-(define-key viper-vi-basic-map "&"
- (function (lambda () (interactive) (viper-ex "&"))))
+(define-key viper-vi-basic-map "&" (lambda ()
+ (interactive) (viper-ex nil "&")))
(define-key viper-vi-basic-map "'" 'viper-goto-mark-and-skip-white)
(define-key viper-vi-basic-map "(" 'viper-backward-sentence)
(define-key viper-vi-basic-map ")" 'viper-forward-sentence)
@@ -390,7 +390,7 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(define-key viper-vi-basic-map "\C-?" 'viper-backward-char)
(define-key viper-vi-basic-map "_" 'viper-nil)
-;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on.
+;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on.
(define-key viper-vi-diehard-map "\C-a" 'viper-nil)
(define-key viper-vi-diehard-map "\C-c" 'viper-nil)
@@ -484,7 +484,7 @@ Usage:
map viper-emacs-local-user-map))
(t
(error
- "Invalid state in viper-add-local-keys: %S. Valid states: vi-state, insert-state or emacs-state" state)))
+ "Invalid state in viper-add-local-keys: %S. Valid states: vi-state, insert-state or emacs-state" state)))
(viper-modify-keymap map alist)
(viper-normalize-minor-mode-map-alist)
@@ -510,9 +510,9 @@ sanity."
If the default for a major mode is emacs-state, then modifications to this
major mode may not take effect until the buffer switches state to Vi,
-Insert or Emacs. If this happens, add viper-change-state-to-emacs to this
-major mode's hook. If no such hook exists, you may have to put an advice on
-the function that invokes the major mode. See viper-set-hooks for hints.
+Insert or Emacs. If this happens, add viper-change-state-to-emacs to this
+major mode's hook. If no such hook exists, you may have to put an advice on
+the function that invokes the major mode. See viper-set-hooks for hints.
The above needs not to be done for major modes that come up in Vi or Insert
state by default.
@@ -529,7 +529,7 @@ Arguments: (major-mode viper-state keymap)"
;; Normalization usually doesn't help here, since one needs to
;; normalize in the actual buffer where changes to the keymap are
- ;; to take place. However, it doesn't hurt, and it helps whenever this
+ ;; to take place. However, it doesn't hurt, and it helps whenever this
;; function is actually called from within the affected buffer.
(viper-normalize-minor-mode-map-alist)
@@ -611,22 +611,17 @@ Arguments: (major-mode viper-state keymap)"
;;; Keymap utils
(defun viper-add-keymap (mapsrc mapdst)
- "Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse."
+ "Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse."
(if viper-xemacs-p
- (map-keymap (function (lambda (key binding)
- (define-key mapdst key binding)))
+ (map-keymap (lambda (key binding) (define-key mapdst key binding))
mapsrc)
- (mapcar
- (function (lambda (p)
- (define-key mapdst (vector (car p)) (cdr p))
- ))
- (cdr mapsrc))))
+ (mapcar (lambda (p) (define-key mapdst (vector (car p)) (cdr p)))
+ (cdr mapsrc))))
(defun viper-modify-keymap (map alist)
- "Modifies MAP with bindings specified in the ALIST. The alist has the
+ "Modifies MAP with bindings specified in the ALIST. The alist has the
form ((key . function) (key . function) ... )."
- (mapcar (function (lambda (p)
- (define-key map (eval (car p)) (cdr p))))
+ (mapcar (lambda (p) (define-key map (eval (car p)) (cdr p)))
alist))
diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el
index 3b28721f6bf..92f5f013093 100644
--- a/lisp/emulation/viper-macs.el
+++ b/lisp/emulation/viper-macs.el
@@ -75,10 +75,10 @@
(defcustom viper-repeat-from-history-key 'f12
"Prefix key for accessing previously typed Vi commands.
-The previous command is accessible, as usual, via `.'. The command before this
+The previous command is accessible, as usual, via `.'. The command before this
can be invoked as `<this key> 1', and the command before that, and the command
before that one is accessible as `<this key> 2'.
-The notation for these keys is borrowed from XEmacs. Basically,
+The notation for these keys is borrowed from XEmacs. Basically,
a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
`(meta control f1)'."
:type 'sexp
@@ -113,7 +113,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
(define-key viper-vi-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
(define-key viper-insert-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
(define-key viper-emacs-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
- (message "Mapping %S in %s state. Hit `C-x )' to complete the mapping"
+ (message "Mapping %S in %s state. Hit `C-x )' to complete the mapping"
(viper-display-macro macro-name)
(if ins "Insert" "Vi")))
))
@@ -159,7 +159,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
;; We expect macro-name to be a vector, a string, or a quoted string.
;; In the second case, it will emerge as a symbol when read from
- ;; the above read-from-string. So we need to convert it into a string
+ ;; the above read-from-string. So we need to convert it into a string
(if macro-name
(cond ((vectorp macro-name) nil)
((stringp macro-name)
@@ -322,14 +322,14 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
;;; Recording, unrecording, executing
-;; accepts as macro names: strings and vectors.
+;; 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
+;; in canonic form. The canonic form is essentially the form used in XEmacs
(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
-either `vi-state' or `insert-state'. It specifies the Viper state in which to
-define the macro. MACRO-BODY is a string that represents the keyboard macro.
+ "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
+either `vi-state' or `insert-state'. It specifies the Viper state in which to
+define the macro. MACRO-BODY is a string that represents the keyboard macro.
Optional SCOPE says whether the macro should be global \(t\), mode-specific
\(a major-mode symbol\), or buffer-specific \(buffer name, a string\).
If SCOPE is nil, the user is asked to specify the scope."
@@ -354,8 +354,9 @@ If SCOPE is nil, the user is asked to specify the scope."
(if (= (length macro-name) 0)
(error "Can't map an empty macro name"))
- ;; Macro-name is usually a vector. However, command history or macros
- ;; recorded in ~/.viper may be recorded as strings. So, convert to vectors.
+ ;; Macro-name is usually a vector. However, command history or macros
+ ;; recorded in ~/.viper may be recorded as strings. So, convert to
+ ;; vectors.
(setq macro-name (viper-fixup-macro macro-name))
(if (viper-char-array-p macro-name)
(setq macro-name (viper-char-array-to-macro macro-name)))
@@ -481,11 +482,11 @@ If SCOPE is nil, the user is asked to specify the scope."
;; macro name must be a vector of viper-style keys
(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
+MACRO-NAME must be a vector of viper-style keys. This command is used by Viper
internally, but the user can also use it in ~/.viper to delete pre-defined
-macros supplied with Viper. The best way to avoid mistakes in macro names to be
-passed to this function is to use viper-describe-kbd-macros and copy the name
-from there."
+macros supplied with Viper. The best way to avoid mistakes in macro names to
+be passed to this function is to use viper-describe-kbd-macros and copy the
+name from there."
(let* (state-name keymap
(macro-alist-var
(cond ((eq state 'vi-state)
@@ -504,8 +505,8 @@ from there."
buf-mapping mode-mapping global-mapping
macro-pair macro-entry)
- ;; Macro-name is usually a vector. However, command history or macros
- ;; recorded in ~/.viper may appear as strings. So, convert to vectors.
+ ;; Macro-name is usually a vector. However, command history or macros
+ ;; recorded in ~/.viper may appear as strings. So, convert to vectors.
(setq macro-name (viper-fixup-macro macro-name))
(if (viper-char-array-p macro-name)
(setq macro-name (viper-char-array-to-macro macro-name)))
@@ -564,7 +565,7 @@ from there."
))
;; Check if MACRO-ALIST has an entry for a macro name starting with
-;; CHAR. If not, this indicates that the binding for this char
+;; CHAR. If not, this indicates that the binding for this char
;; in viper-vi/insert-kbd-map can be released.
(defun viper-can-release-key (char macro-alist)
(let ((lis macro-alist)
@@ -627,7 +628,7 @@ from there."
(viper-set-unread-command-events event-seq)
;; if the user typed arg, then use it if prefix arg is not set by
;; some other command (setting prefix arg can happen if we do, say,
- ;; 2dw and there is a macro starting with 2. Then control will go to
+ ;; 2dw and there is a macro starting with 2. Then control will go to
;; this routine
(or prefix-arg (setq prefix-arg count))
(setq command (key-binding (read-key-sequence nil)))
@@ -681,8 +682,7 @@ from there."
(let ((converted-seq (viper-events-to-macro seq)))
(eval (cons 'or
(mapcar
- (function (lambda (elt)
- (viper-prefix-subseq-p converted-seq elt)))
+ (lambda (elt) (viper-prefix-subseq-p converted-seq elt))
(viper-this-buffer-macros alist))))))
;; whether SEQ1 is a prefix of SEQ2
@@ -704,9 +704,7 @@ from there."
(setq len (apply 'min (mapcar 'length seqs))))
(while (< idx len)
(if (eval (cons 'and
- (mapcar (function (lambda (s)
- (equal (elt first idx)
- (elt s idx))))
+ (mapcar (lambda (s) (equal (elt first idx) (elt s idx)))
rest)))
(setq pref (vconcat pref (vector (elt first idx)))))
(setq idx (1+ idx)))
@@ -714,9 +712,7 @@ from there."
;; get all sequences that match PREFIX from a given A-LIST
(defun viper-extract-matching-alist-members (pref alist)
- (delq nil (mapcar (function (lambda (elt)
- (if (viper-prefix-subseq-p pref elt)
- elt)))
+ (delq nil (mapcar (lambda (elt) (if (viper-prefix-subseq-p pref elt) elt))
(viper-this-buffer-macros alist))))
(defun viper-do-sequence-completion (seq alist compl-message)
@@ -781,18 +777,17 @@ from there."
(defun viper-this-buffer-macros (macro-alist)
(let (candidates)
(setq candidates
- (mapcar (function
- (lambda (elt)
- (if (or (viper-kbd-buf-definition elt)
- (viper-kbd-mode-definition elt)
- (viper-kbd-global-definition elt))
- (car elt))))
+ (mapcar (lambda (elt)
+ (if (or (viper-kbd-buf-definition elt)
+ (viper-kbd-mode-definition elt)
+ (viper-kbd-global-definition elt))
+ (car elt)))
macro-alist))
(setq candidates (delq nil candidates))))
;; if seq of Viper key symbols (representing a macro) can be converted to a
-;; string--do so. Otherwise, do nothing.
+;; string--do so. Otherwise, do nothing.
(defun viper-display-macro (macro-name-or-body)
(cond ((viper-char-symbol-sequence-p macro-name-or-body)
(mapconcat 'symbol-name macro-name-or-body ""))
@@ -804,16 +799,15 @@ from there."
;; Viper's macro, which is a vector of the form
;; [ desc desc ... ]
;; Each desc is either a symbol of (meta symb), (shift symb), etc.
-;; Here we purge events that happen to be lists. In most cases, these events
+;; Here we purge events that happen to be lists. In most cases, these events
;; got into a macro definition unintentionally; say, when the user moves mouse
;; during a macro definition, then something like (switch-frame ...) might get
-;; in. Another reason for purging lists-events is that we can't store them in
+;; in. Another reason for purging lists-events is that we can't store them in
;; textual form (say, in .emacs) and then read them back.
(defun viper-events-to-macro (event-seq)
- (vconcat (delq nil (mapcar (function (lambda (elt)
- (if (consp elt)
- nil
- (viper-event-key elt))))
+ (vconcat (delq nil (mapcar (lambda (elt) (if (consp elt)
+ nil
+ (viper-event-key elt)))
event-seq))))
;; convert strings or arrays of characters to Viper macro form
@@ -870,10 +864,9 @@ from there."
(sequencep vec)
(eval
(cons 'and
- (mapcar
- (function (lambda (elt)
- (and (symbolp elt) (= (length (symbol-name elt)) 1))))
- vec)))))
+ (mapcar (lambda (elt)
+ (and (symbolp elt) (= (length (symbol-name elt)) 1)))
+ vec)))))
;; Check if vec is a vector of key-press events representing characters
@@ -886,7 +879,7 @@ from there."
;;; Reading fast key sequences
;; Assuming that CHAR was the first character in a fast succession of key
-;; strokes, read the rest. Return the vector of keys that was entered in
+;; strokes, read the rest. Return the vector of keys that was entered in
;; this fast succession of key strokes.
;; A fast keysequence is one that is terminated by a pause longer than
;; viper-fast-keyseq-timeout.
@@ -907,10 +900,10 @@ from there."
;; sets register to last-kbd-macro carefully.
(defun viper-set-register-macro (reg)
(if (get-register reg)
- (if (y-or-n-p "Register contains data. Overwrite? ")
+ (if (y-or-n-p "Register contains data. Overwrite? ")
()
(error
- "Macro not saved in register. Can still be invoked via `C-x e'")))
+ "Macro not saved in register. Can still be invoked via `C-x e'")))
(set-register reg last-kbd-macro))
(defun viper-register-macro (count)
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index ada680d3975..aaa8adb2745 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -57,7 +57,7 @@
;; Variable used for catching the switch-frame event.
;; If non-nil, indicates that previous-frame should be the selected
-;; one. Used by viper-mouse-click-get-word. Not a user option.
+;; one. Used by viper-mouse-click-get-word. Not a user option.
(defvar viper-frame-of-focus nil)
;; Frame that was selected before the switch-frame event.
@@ -68,7 +68,7 @@
Takes two parameters: a COUNT, indicating how many words to return,
and CLICK-COUNT, telling whether this is the first click, a double-click,
or a tripple-click."
- :type 'boolean
+ :type 'symbol
:group 'viper-mouse)
;; time interval in millisecond within which successive clicks are
@@ -150,13 +150,13 @@ If CLICK-COUNT is 1, `word' is a word in Vi sense.
If CLICK-COUNT is 2,then `word' is a Word in Vi sense.
If the character clicked on is a non-separator and is non-alphanumeric but
is adjacent to an alphanumeric symbol, then it is considered alphanumeric
-for the purpose of this command. If this character has a matching
+for the purpose of this command. If this character has a matching
character, such as `\(' is a match for `\)', then the matching character is
also considered alphanumeric.
For convenience, in Lisp modes, `-' is considered alphanumeric.
If CLICK-COUNT is 3 or more, returns the line clicked on with leading and
-trailing space and tabs removed. In that case, the first argument, COUNT,
+trailing space and tabs removed. In that case, the first argument, COUNT,
is ignored."
(let ((modifiers "_")
beg skip-flag result
@@ -228,7 +228,7 @@ is ignored."
(defun viper-mouse-click-get-word (click count click-count)
"Returns word surrounding the position of a mouse click.
-Click may be in another window. Current window and buffer isn't changed.
+Click may be in another window. Current window and buffer isn't changed.
On single or double click, returns the word as determined by
`viper-surrounding-word-function'."
@@ -261,11 +261,12 @@ See `viper-surrounding-word' for the definition of a word in this case."
(interactive "e\nP")
(if viper-frame-of-focus ;; to handle clicks in another frame
(select-frame viper-frame-of-focus))
- (if (or (not (eq (key-binding viper-mouse-down-insert-key-parsed)
- 'viper-mouse-catch-frame-switch))
- (not (eq (key-binding viper-mouse-up-insert-key-parsed)
- 'viper-mouse-click-insert-word))
- (and viper-xemacs-p (not (event-over-text-area-p click))))
+ (if (save-excursion
+ (or (not (eq (key-binding viper-mouse-down-insert-key-parsed)
+ 'viper-mouse-catch-frame-switch))
+ (not (eq (key-binding viper-mouse-up-insert-key-parsed)
+ 'viper-mouse-click-insert-word))
+ (and viper-xemacs-p (not (event-over-text-area-p click)))))
() ; do nothing, if binding isn't right or not over text
;; turn arg into a number
(cond ((integerp arg) nil)
@@ -303,42 +304,56 @@ See `viper-surrounding-word' for the definition of a word in this case."
(viper-set-unread-command-events interrupting-event))
)))))
-;; arg is an event. accepts symbols and numbers, too
+;; Arg is an event. Accepts symbols and numbers, too
(defun viper-mouse-event-p (event)
(if (eventp event)
(string-match "\\(mouse-\\|frame\\|screen\\|track\\)"
(prin1-to-string (viper-event-key event)))))
-;; XEmacs has no double-click events. So, we must simulate.
+;; XEmacs has no double-click events. So, we must simulate.
;; So, we have to simulate event-click-count.
(defun viper-event-click-count (click)
(if viper-xemacs-p
- (progn
- ;; if more than 1 second
- (if (> (- (event-timestamp click) viper-last-click-event-timestamp)
- viper-multiclick-timeout)
- (setq viper-current-click-count 0))
- (setq viper-last-click-event-timestamp (event-timestamp click)
- viper-current-click-count (1+ viper-current-click-count)))
+ (viper-event-click-count-xemacs click)
(event-click-count click)))
-
+;; kind of semaphore for updating viper-current-click-count
+(defvar viper-counting-clicks-p nil)
+(defun viper-event-click-count-xemacs (click)
+ (let ((time-delta (- (event-timestamp click)
+ viper-last-click-event-timestamp))
+ inhibit-quit)
+ (while viper-counting-clicks-p
+ (ignore))
+ (setq viper-counting-clicks-p t)
+ (if (> time-delta viper-multiclick-timeout)
+ (setq viper-current-click-count 0))
+ (discard-input)
+ (setq viper-current-click-count (1+ viper-current-click-count)
+ viper-last-click-event-timestamp (event-timestamp click))
+ (setq viper-counting-clicks-p nil)
+ (if (viper-sit-for-short viper-multiclick-timeout t)
+ viper-current-click-count
+ 0)
+ ))
+
(defun viper-mouse-click-search-word (click arg)
- "Find the word clicked or double-clicked on. Word may be in another window.
+ "Find the word clicked or double-clicked on. Word may be in another window.
With prefix argument, N, search for N-th occurrence.
-This command must be bound to a mouse click. The double-click action of the
+This command must be bound to a mouse click. The double-click action of the
same button must not be bound \(or it must be bound to the same function\).
See `viper-surrounding-word' for the details on what constitutes a word for
this command."
(interactive "e\nP")
(if viper-frame-of-focus ;; to handle clicks in another frame
(select-frame viper-frame-of-focus))
- (if (or (not (eq (key-binding viper-mouse-down-search-key-parsed)
- 'viper-mouse-catch-frame-switch))
- (not (eq (key-binding viper-mouse-up-search-key-parsed)
- 'viper-mouse-click-search-word))
- (and viper-xemacs-p (not (event-over-text-area-p click))))
+ (if (save-excursion
+ (or (not (eq (key-binding viper-mouse-down-search-key-parsed)
+ 'viper-mouse-catch-frame-switch))
+ (not (eq (key-binding viper-mouse-up-search-key-parsed)
+ 'viper-mouse-click-search-word))
+ (and viper-xemacs-p (not (event-over-text-area-p click)))))
() ; do nothing, if binding isn't right or not over text
(let ((previous-search-string viper-s-string)
click-word click-count)
@@ -353,10 +368,10 @@ this command."
(viper-read-event)
(viper-mouse-event-p last-input-event)))
(progn ; interrupted wait
- (setq viper-global-prefix-argument
- (or viper-global-prefix-argument arg))
- ;; remember command that was before the multiclick
- (setq this-command last-command)
+ (setq viper-global-prefix-argument (or viper-global-prefix-argument
+ arg)
+ ;; remember command that was before the multiclick
+ this-command last-command)
;; make sure we counted this event---needed for XEmacs only
(viper-event-click-count click))
;; uninterrupted wait
@@ -423,7 +438,7 @@ this command."
(message "`%s': String not found in %s"
viper-s-string (buffer-name (current-buffer)))
(message
- "`%s': Last occurrence in %s. Back to beginning of search"
+ "`%s': Last occurrence in %s. Back to beginning of search"
click-word (buffer-name (current-buffer)))
(setq arg 1) ;; to terminate the loop
(sit-for 2))
@@ -437,7 +452,7 @@ this command."
(defun viper-mouse-catch-frame-switch (event arg)
"Catch the event of switching frame.
-Usually is bound to a `down-mouse' event to work properly. See sample
+Usually is bound to a `down-mouse' event to work properly. See sample
bindings in the Viper manual."
(interactive "e\nP")
(setq viper-frame-of-focus nil)
@@ -448,19 +463,19 @@ bindings in the Viper manual."
;; make Emacs forget that it executed viper-mouse-catch-frame-switch
(setq this-command last-command))
-;; Called just before switching frames. Saves the old selected frame.
+;; Called just before switching frames. Saves the old selected frame.
;; Sets last-command to handle-switch-frame (this is done automatically in
;; Emacs.
;; The semantics of switching frames is different in Emacs and XEmacs.
;; In Emacs, if you select-frame A while mouse is over frame B and then
;; start typing, input goes to frame B, which becomes selected.
-;; In XEmacs, input will go to frame A. This may be a bug in one of the
+;; In XEmacs, input will go to frame A. This may be a bug in one of the
;; Emacsen, but also may be a design decision.
;; Also, in Emacs sending input to frame B generates handle-switch-frame
;; event, while in XEmacs it doesn't.
;; All this accounts for the difference in the behavior of
;; viper-mouse-click-* commands when you click in a frame other than the one
-;; that was the last to receive input. In Emacs, focus will be in frame A
+;; that was the last to receive input. In Emacs, focus will be in frame A
;; until you do something other than viper-mouse-click-* command.
;; In XEmacs, you have to manually select frame B (with the mouse click) in
;; order to shift focus to frame B.
@@ -471,7 +486,7 @@ bindings in the Viper manual."
;; The key is of the form (MODIFIER ... BUTTON-NUMBER)
;; Converts into a valid mouse button spec for the appropriate version of
-;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
+;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
;; returns button-down key.
(defun viper-parse-mouse-key (key-var event-type)
(let ((key (eval key-var))
@@ -555,14 +570,14 @@ bindings in the Viper manual."
(not (eq (key-binding viper-mouse-up-search-key-parsed)
'viper-mouse-click-search-word)))
(message
- "%S already bound to a mouse event. Viper mouse-search feature disabled"
+ "%S already bound to a mouse event. Viper mouse-search feature disabled"
viper-mouse-up-search-key-parsed))
((and (null force)
(key-binding viper-mouse-down-search-key-parsed)
(not (eq (key-binding viper-mouse-down-search-key-parsed)
'viper-mouse-catch-frame-switch)))
(message
- "%S already bound to a mouse event. Viper mouse-search feature disabled"
+ "%S already bound to a mouse event. Viper mouse-search feature disabled"
viper-mouse-down-search-key-parsed))
(t
(global-set-key viper-mouse-up-search-key-parsed
@@ -584,14 +599,14 @@ bindings in the Viper manual."
(not (eq (key-binding viper-mouse-up-insert-key-parsed)
'viper-mouse-click-insert-word)))
(message
- "%S already bound to a mouse event. Viper mouse-insert feature disabled"
+ "%S already bound to a mouse event. Viper mouse-insert feature disabled"
viper-mouse-up-insert-key-parsed))
((and (null force)
(key-binding viper-mouse-down-insert-key-parsed)
(not (eq (key-binding viper-mouse-down-insert-key-parsed)
'viper-mouse-catch-frame-switch)))
(message
- "%S already bound to a mouse event. Viper mouse-insert feature disabled"
+ "%S already bound to a mouse event. Viper mouse-insert feature disabled"
viper-mouse-down-insert-key-parsed))
(t
(global-set-key viper-mouse-up-insert-key-parsed
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 111edd10b6a..b8fdf3365ba 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -114,7 +114,7 @@
;; OS/2
(cond ((eq (viper-device-type) 'pm)
(fset 'viper-color-defined-p
- (function (lambda (color) (assoc color pm-color-alist))))))
+ (lambda (color) (assoc color pm-color-alist)))))
;; cursor colors
@@ -125,20 +125,48 @@
(modify-frame-parameters
(selected-frame) (list (cons 'cursor-color new-color)))))
-(defun viper-save-cursor-color ()
+;; By default, saves current frame cursor color in the
+;; viper-saved-cursor-color-in-replace-mode property of viper-replace-overlay
+(defun viper-save-cursor-color (before-which-mode)
(if (and (viper-window-display-p) (viper-color-display-p))
(let ((color (viper-get-cursor-color)))
(if (and (stringp color) (viper-color-defined-p color)
(not (string= color viper-replace-overlay-cursor-color)))
- (viper-overlay-put viper-replace-overlay 'viper-cursor-color color)))))
+ (modify-frame-parameters
+ (selected-frame)
+ (list
+ (cons
+ (if (eq before-which-mode 'before-replace-mode)
+ 'viper-saved-cursor-color-in-replace-mode
+ 'viper-saved-cursor-color-in-insert-mode)
+ color)))
+ ))))
-;; restore cursor color from replace overlay
-(defsubst viper-restore-cursor-color-after-replace ()
- (viper-change-cursor-color
- (viper-overlay-get viper-replace-overlay 'viper-cursor-color)))
-(defsubst viper-restore-cursor-color-after-insert ()
- (viper-change-cursor-color viper-saved-cursor-color))
+
+(defsubst viper-get-saved-cursor-color-in-replace-mode ()
+ (or
+ (funcall
+ (if viper-emacs-p 'frame-parameter 'frame-property)
+ (selected-frame)
+ 'viper-saved-cursor-color-in-replace-mode)
+ viper-vi-state-cursor-color))
+
+(defsubst viper-get-saved-cursor-color-in-insert-mode ()
+ (or
+ (funcall
+ (if viper-emacs-p 'frame-parameter 'frame-property)
+ (selected-frame)
+ 'viper-saved-cursor-color-in-insert-mode)
+ viper-vi-state-cursor-color))
+;; restore cursor color from replace overlay
+(defun viper-restore-cursor-color(after-which-mode)
+ (if (viper-overlay-p viper-replace-overlay)
+ (viper-change-cursor-color
+ (if (eq after-which-mode 'after-replace-mode)
+ (viper-get-saved-cursor-color-in-replace-mode)
+ (viper-get-saved-cursor-color-in-insert-mode))
+ )))
;; Check the current version against the major and minor version numbers
@@ -148,7 +176,7 @@
;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the
;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value
;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be
-;; incorrect. However, this gives correct result in our cases, since we are
+;; incorrect. However, this gives correct result in our cases, since we are
;; testing for sufficiently high Emacs versions.
(defun viper-check-version (op major minor &optional type-of-emacs)
(if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version))
@@ -177,9 +205,9 @@
;; Return line position.
;; If pos is 'start then returns position of line start.
-;; If pos is 'end, returns line end. If pos is 'mid, returns line center.
+;; If pos is 'end, returns line end. If pos is 'mid, returns line center.
;; Pos = 'indent returns beginning of indentation.
-;; Otherwise, returns point. Current point is not moved in any case."
+;; Otherwise, returns point. Current point is not moved in any case."
(defun viper-line-pos (pos)
(let ((cur-pos (point))
(result))
@@ -198,7 +226,7 @@
result))
;; Emacs counts each multibyte character as several positions in the buffer, so
-;; we use Emacs' chars-in-region. XEmacs is counting each char as just one pos,
+;; we use Emacs' chars-in-region. XEmacs is counting each char as just one pos,
;; so we can simply subtract.
(defun viper-chars-in-region (beg end &optional preserve-sign)
(let ((count (abs (if (fboundp 'chars-in-region)
@@ -256,7 +284,7 @@
(setq alst (cdr alst)))
lst))
-;; Filter ALIST using REGEXP. Return alist whose elements match the regexp.
+;; Filter ALIST using REGEXP. Return alist whose elements match the regexp.
(defun viper-filter-alist (regexp alst)
(interactive "s x")
(let ((outalst) (inalst alst))
@@ -266,7 +294,7 @@
(setq inalst (cdr inalst)))
outalst))
-;; Filter LIST using REGEXP. Return list whose elements match the regexp.
+;; Filter LIST using REGEXP. Return list whose elements match the regexp.
(defun viper-filter-list (regexp lst)
(interactive "s x")
(let ((outlst) (inlst lst))
@@ -294,15 +322,11 @@
(nconc lis1 lis2)))
-;;; Support for :e and file globbing
-
-(defun viper-ex-nontrivial-find-file-unix (filespec)
- "Glob the file spec and visit all files matching the spec.
-This function is designed to work under Unix. It may also work under VMS.
+;;; Support for :e, :r, :w file globbing
-Users who prefer other types of shells should write their own version of this
-function and set the variable `ex-nontrivial-find-file-function'
-appropriately."
+;; Glob the file spec.
+;; This function is designed to work under Unix. It might also work under VMS.
+(defun viper-glob-unix-files (filespec)
(let ((gshell
(cond (ex-unix-type-shell shell-file-name)
((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VAX VMS
@@ -313,7 +337,7 @@ appropriately."
))
(command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec))
(t (format "ls -1 -d %s" filespec))))
- file-list status)
+ status)
(save-excursion
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
(erase-buffer)
@@ -340,27 +364,7 @@ appropriately."
(buffer-substring (point) (viper-line-pos 'end)))
))
(goto-char (point-min))
- (setq file-list (viper-get-filenames-from-buffer 'one-per-line)))
-
- (mapcar 'find-file file-list)
- ))
-
-(defun viper-ex-nontrivial-find-file-ms (filespec)
- "Glob the file spec and visit all files matching the spec.
-This function is designed to work under MS type systems, such as NT, W95, and
-DOS. It may also work under OS/2.
-
-The users of Unix-type shells should be able to use
-`viper-ex-nontrivial-find-file-unix', making it into the value of the variable
-`ex-nontrivial-find-file-function'. If this doesn't work, the user may have
-to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
- (save-excursion
- (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
- (erase-buffer)
- (insert filespec)
- (goto-char (point-min))
- (mapcar 'find-file
- (viper-glob-ms-windows-files (viper-get-filenames-from-buffer)))
+ (viper-get-filenames-from-buffer 'one-per-line))
))
@@ -410,29 +414,34 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
;; glob windows files
;; LIST is expected to be in reverse order
-(defun viper-glob-ms-windows-files (list)
- (let ((tmp list)
- (case-fold-search t)
- tmp2)
- (while tmp
- (setq tmp2 (cons (directory-files
- ;; the directory part
- (or (file-name-directory (car tmp))
- "")
- t ; return full names
- ;; the regexp part: globs the file names
- (concat "^"
- (viper-wildcard-to-regexp
- (file-name-nondirectory (car tmp)))
- "$"))
- tmp2))
- (setq tmp (cdr tmp)))
- (reverse (apply 'append tmp2))))
+(defun viper-glob-mswindows-files (filespec)
+ (let ((case-fold-search t)
+ tmp tmp2)
+ (save-excursion
+ (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
+ (erase-buffer)
+ (insert filespec)
+ (goto-char (point-min))
+ (setq tmp (viper-get-filenames-from-buffer))
+ (while tmp
+ (setq tmp2 (cons (directory-files
+ ;; the directory part
+ (or (file-name-directory (car tmp))
+ "")
+ t ; return full names
+ ;; the regexp part: globs the file names
+ (concat "^"
+ (viper-wildcard-to-regexp
+ (file-name-nondirectory (car tmp)))
+ "$"))
+ tmp2))
+ (setq tmp (cdr tmp)))
+ (reverse (apply 'append tmp2)))))
;;; Insertion ring
-;; Rotate RING's index. DIRection can be positive or negative.
+;; Rotate RING's index. DIRection can be positive or negative.
(defun viper-ring-rotate1 (ring dir)
(if (and (ring-p ring) (> (ring-length ring) 0))
(progn
@@ -460,7 +469,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(if (and (ring-p ring) (> (ring-length ring) 0))
(aref (cdr (cdr ring)) (mod (- (car ring) 1 n) (ring-length ring)))))
-;; push item onto ring. the second argument is a ring-variable, not value.
+;; Push item onto ring. The second argument is a ring-variable, not value.
(defun viper-push-onto-ring (item ring-var)
(or (ring-p (eval ring-var))
(set ring-var (make-ring (eval (intern (format "%S-size" ring-var))))))
@@ -470,7 +479,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
;; Since viper-set-destructive-command checks if we are inside
;; viper-repeat, we don't check whether this-command-keys is a `.'. The
;; cmd viper-repeat makes a call to the current function only if `.' is
- ;; executing a command from the command history. It doesn't call the
+ ;; executing a command from the command history. It doesn't call the
;; push-onto-ring function if `.' is simply repeating the last
;; destructive command. We only check for ESC (which happens when we do
;; insert with a prefix argument, or if this-command-keys doesn't give
@@ -594,7 +603,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(message "")))
))
-;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that
+;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that
;; match this pattern.
(defun viper-save-string-in-file (string custom-file &optional pattern)
(let ((buf (find-file-noselect (substitute-in-file-name custom-file))))
@@ -647,8 +656,11 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(defsubst viper-file-checked-in-p (file)
- (and (vc-backend file)
+ (and (featurep 'vc-hooks)
+ ;; CVS files are considered not checked in
+ (not (memq (vc-backend file) '(nil CVS)))
(not (vc-locking-user file))))
+
;; checkout if visited file is checked in
(defun viper-maybe-checkout (buf)
(let ((file (expand-file-name (buffer-file-name buf)))
@@ -657,7 +669,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(or (beep 1) t)
(y-or-n-p
(format
- "File %s is checked in. Check it out? "
+ "File %s is checked in. Check it out? "
(viper-abbreviate-file-name file))))
(with-current-buffer buf
(command-execute checkout-function)))))
@@ -711,7 +723,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(if (viper-has-face-support-p)
(viper-overlay-put
viper-replace-overlay 'face viper-replace-overlay-face))
- (viper-save-cursor-color)
+ (viper-save-cursor-color 'before-replace-mode)
(viper-change-cursor-color viper-replace-overlay-cursor-color)
)
@@ -726,8 +738,8 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(defun viper-hide-replace-overlay ()
(viper-set-replace-overlay-glyphs nil nil)
- (viper-restore-cursor-color-after-replace)
- (viper-restore-cursor-color-after-insert)
+ (viper-restore-cursor-color 'after-replace-mode)
+ (viper-restore-cursor-color 'after-insert-mode)
(if (viper-has-face-support-p)
(viper-overlay-put viper-replace-overlay 'face nil)))
@@ -786,7 +798,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
;; XEmacs requires addl argument
(abbreviate-file-name file t)))
-;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg
+;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg
;; in sit-for, so this function smoothes out the differences.
(defsubst viper-sit-for-short (val &optional nodisp)
(if viper-xemacs-p
@@ -817,10 +829,11 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
;; is the same as (mark t).
(defsubst viper-set-mark-if-necessary ()
(setq mark-ring (delete (viper-mark-marker) mark-ring))
- (set-mark-command nil))
+ (set-mark-command nil)
+ (setq viper-saved-mark (point)))
;; In transient mark mode (zmacs mode), it is annoying when regions become
-;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless
+;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless
;; the user explicitly wants highlighting, e.g., by hitting '' or ``
(defun viper-deactivate-mark ()
(if viper-xemacs-p
@@ -870,7 +883,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
))
;; This function lets function-key-map convert key sequences into logical
-;; keys. This does a better job than viper-read-event when it comes to kbd
+;; keys. This does a better job than viper-read-event when it comes to kbd
;; macros, since it enables certain macros to be shared between X and TTY modes
;; by correctly mapping key sequences for Left/Right/... (one an ascii
;; terminal) into logical keys left, right, etc.
@@ -908,7 +921,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(t
;; Emacs doesn't handle capital letters correctly, since
;; \S-a isn't considered the same as A (it behaves as
- ;; plain `a' instead). So we take care of this here
+ ;; plain `a' instead). So we take care of this here
(cond ((and (viper-characterp event) (<= ?A event) (<= event ?Z))
(setq mod nil
event event))
@@ -985,8 +998,8 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
;; Args can be a sequence of events, a string, or a Viper macro. Will try to
;; convert events to keys and, if all keys are regular printable
-;; characters, will return a string. Otherwise, will return a string
-;; representing a vector of converted events. If the input was a Viper macro,
+;; characters, will return a string. Otherwise, will return a string
+;; representing a vector of converted events. If the input was a Viper macro,
;; will return a string that represents this macro as a vector.
(defun viper-array-to-string (event-seq)
(let (temp temp2)
@@ -1010,8 +1023,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(defun viper-key-press-events-to-chars (events)
(mapconcat (if viper-emacs-p
'char-to-string
- (function
- (lambda (elt) (char-to-string (event-to-character elt)))))
+ (lambda (elt) (char-to-string (event-to-character elt))))
events
""))
@@ -1055,7 +1067,7 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'."
(defun viper-setup-master-buffer (&rest other-files-or-buffers)
"Set up the current buffer as a master buffer.
-Arguments become related buffers. This function should normally be used in
+Arguments become related buffers. This function should normally be used in
the `Local variables' section of a file."
(setq viper-related-files-and-buffers-ring
(make-ring (1+ (length other-files-or-buffers))))
@@ -1117,11 +1129,11 @@ Usually contains ` ', linefeed, TAB or formfeed.")
))
;; SYMBOL is used because customize requires it, but it is ignored, unless it
-;; is `nil'. If nil, use setq.
+;; is `nil'. If nil, use setq.
(defun viper-set-syntax-preference (&optional symbol value)
"Set Viper syntax preference.
If called interactively or if SYMBOL is nil, sets syntax preference in current
-buffer. If called non-interactively, preferably via the customization widget,
+buffer. If called non-interactively, preferably via the customization widget,
sets the default value."
(interactive)
(or value
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 9972f2c49d5..4e95448ab2b 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -1,4 +1,4 @@
-;;; viper.el --- A full-featured Vi emulator for Emacs.
+;;; viper.el --- A full-featured Vi emulator for GNU Emacs and XEmacs,
;; a VI Plan for Emacs Rescue,
;; and a venomous VI PERil.
;; Viper Is also a Package for Emacs Rebels.
@@ -6,9 +6,9 @@
;; Keywords: emulations
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1994 -- 1999 Free Software Foundation, Inc.
-(defconst viper-version "3.03 (Polyglot) of May 21, 1998"
+(defconst viper-version "3.08 of October 31, 1999"
"The current version of Viper")
;; This file is part of GNU Emacs.
@@ -30,11 +30,11 @@
;;; Commentary:
-;; Viper is a full-featured Vi emulator for Emacs and XEmacs. It emulates and
+;; Viper is a full-featured Vi emulator for Emacs and XEmacs. It emulates and
;; improves upon the standard features of Vi and, at the same time, allows
;; full access to all Emacs facilities. Viper supports multiple undo,
;; file name completion, command, file, and search history and it extends
-;; Vi in many other ways. Viper is highly customizable through the various
+;; Vi in many other ways. Viper is highly customizable through the various
;; hooks, user variables, and keymaps. It is implemented as a collection
;; of minor modes and it is designed to provide full access to all Emacs
;; major and minor modes.
@@ -44,11 +44,11 @@
;; Viper is a new name for a package formerly known as VIP-19,
;; which was a successor of VIP version 3.5 by Masahiko Sato
;; <ms@sail.stanford.edu> and VIP version 4.2 by Aamod Sane
-;; <sane@cs.uiuc.edu>. Some ideas from vip 4.4.2 by Aamod Sane
+;; <sane@cs.uiuc.edu>. Some ideas from vip 4.4.2 by Aamod Sane
;; were also shamelessly plagiarized.
;;
;; Viper maintains some degree of compatibility with these older
-;; packages. See the documentation for customization.
+;; packages. See the documentation for customization.
;;
;; The main difference between Viper and these older packages are:
;;
@@ -82,9 +82,9 @@
;; 9. Viper has Vi-style keyboard macros, which enhances the similar
;; facility in the original Vi.
;; First, one can execute any Emacs command while defining a
-;; macro, not just the Vi commands. Second, macros are defined in a
+;; macro, not just the Vi commands. Second, macros are defined in a
;; WYSYWYG mode, using an interface to Emacs' WYSIWYG style of defining
-;; macros. Third, in Viper, one can define macros that are specific to
+;; macros. Third, in Viper, one can define macros that are specific to
;; a given buffer, a given major mode, or macros defined for all buffers.
;; The same macro name can have several different definitions:
;; one global, several definitions for various major modes, and
@@ -110,12 +110,12 @@
;;
;; 1. Major modes.
;; In most cases, Viper handles major modes correctly, i.e., they come up
-;; in the right state (either vi-state or emacs-state). For instance, text
+;; in the right state (either vi-state or emacs-state). For instance, text
;; files come up in vi-state, while, say, Dired appears in emacs-state by
;; default.
;; However, some modes do not appear in the right mode in the beginning,
;; usually because they neglect to follow Emacs conventions (e.g., they don't
-;; use kill-all-local-variables when they start). Some major modes
+;; use kill-all-local-variables when they start). Some major modes
;; may fail to come up in emacs-state if they call hooks, such as
;; text-hook, for no good reason.
;;
@@ -126,7 +126,7 @@
;; or
;; (add-hook 'your-favorite-mode 'viper-change-state-to-emacs)
;;
-;; whichever applies. The right thing to do, however, is to complain to the
+;; whichever applies. The right thing to do, however, is to complain to the
;; author of the respective package. (Sometimes they also neglect to equip
;; their modes with hooks, which is one more reason for complaining.)
;;
@@ -148,47 +148,47 @@
;; the second, which, in turn, overshadows those done to the third, etc.
;;
;; The last viper-vi-basic-minor-mode contains most of the usual Vi bindings
-;; in its edit mode. This mode provides access to all Emacs facilities.
+;; in its edit mode. This mode provides access to all Emacs facilities.
;; Novice users, however, may want to set their viper-expert-level to 1
-;; in their .viper file. This will enable viper-vi-diehard-minor-mode. This
+;; in their .viper file. This will enable viper-vi-diehard-minor-mode. This
;; minor mode's bindings make Viper simulate the usual Vi very closely.
;; For instance, C-c will not have its standard Emacs binding
;; and so many of the goodies of Emacs are not available.
;;
-;; A skilled user should set viper-expert-level to at least 3. This will
+;; A skilled user should set viper-expert-level to at least 3. This will
;; enable `C-c' and many Emacs facilities will become available.
;; In this case, viper-vi-diehard-minor-mode is inactive.
;;
;; Viper gurus should have at least
;; (setq viper-expert-level 4)
-;; in their ~/.viper files. This will unsuppress all Emacs keys that are not
+;; in their ~/.viper files. This will unsuppress all Emacs keys that are not
;; essential for VI-style editing.
;; Pick-and-choose users may want to put
;; (setq viper-expert-level 5)
-;; in ~/.viper. Viper will then leave it up to the user to set the variables
+;; in ~/.viper. Viper will then leave it up to the user to set the variables
;; viper-want-* See viper-set-expert-level for details.
;;
;; The very first minor mode, viper-vi-intercept-minor-mode, is of no
-;; concern for the user. It is needed to bind Viper's vital keys, such as
+;; concern for the user. It is needed to bind Viper's vital keys, such as
;; ESC and C-z.
;;
;; The second mode, viper-vi-local-user-minor-mode, usually has an
-;; empty keymap. However, the user can set bindings in this keymap, which
+;; empty keymap. However, the user can set bindings in this keymap, which
;; will overshadow the corresponding bindings in the other two minor
-;; modes. This is useful, for example, for setting up ZZ in gnus,
+;; modes. This is useful, for example, for setting up ZZ in gnus,
;; rmail, mh-e, etc., to send message instead of saving it in a file.
;; Likewise, in Dired mode, you may want to bind ZN and ZP to commands
;; that would visit the next or the previous file in the Dired buffer.
-;; Setting local keys is tricky, so don't do it directly. Instead, use
+;; Setting local keys is tricky, so don't do it directly. Instead, use
;; viper-add-local-keys function (see its doc).
;;
;; The third minor mode, viper-vi-global-user-minor-mode, is also intended
;; for the users but, unlike viper-vi-local-user-minor-mode, its key
-;; bindings are seen in all Viper buffers. This mode keys can be done
+;; bindings are seen in all Viper buffers. This mode keys can be done
;; with define-key command.
;;
;; The fourth minor mode, viper-vi-kbd-minor-mode, is used by keyboard
-;; macros. Users are NOT supposed to modify this keymap directly.
+;; macros. Users are NOT supposed to modify this keymap directly.
;;
;; The fifth mode, viper-vi-state-modifier-minor-mode, can be used to set
;; key bindings that are visible in some major modes but not in others.
@@ -212,11 +212,11 @@
;; to be changed by the user.
;;
;; The next mode, viper-insert-local-user-minor-mode, is used to customize
-;; bindings in the insert state of Viper. The third mode,
+;; bindings in the insert state of Viper. The third mode,
;; viper-insert-global-user-minor-mode is like
;; viper-insert-local-user-minor-mode, except that its bindings are seen in
-;; all Viper buffers. As with viper-vi-local-user-minor-mode, its bindings
-;; should be done via the function viper-add-local-keys. Bindings for
+;; all Viper buffers. As with viper-vi-local-user-minor-mode, its bindings
+;; should be done via the function viper-add-local-keys. Bindings for
;; viper-insert-global-user-minor-mode can be set with the define-key command.
;;
;; The next minor mode, viper-insert-kbd-minor-mode,
@@ -229,7 +229,7 @@
;; The minor mode viper-insert-diehard-minor-mode is in effect when
;; the user wants a high degree of Vi compatibility (a bad idea, really!).
;; The last minor mode, viper-insert-basic-minor-mode, is always in effect
-;; when Viper is in insert state. It binds a small number of keys needed for
+;; when Viper is in insert state. It binds a small number of keys needed for
;; Viper's operation.
;;
;; Finally, Viper provides minor modes for overriding bindings set by Emacs
@@ -240,24 +240,24 @@
;; viper-emacs-kbd-minor-mode
;; viper-emacs-state-modifier-minor-mode
;;
-;; These minor modes are in effect when Viper is in Emacs state. The keymap
+;; These minor modes are in effect when Viper is in Emacs state. The keymap
;; associated with viper-emacs-global-user-minor-mode,
;; viper-emacs-global-user-map, overrides the global and local keymaps as
-;; well as the minor mode keymaps set by other modes. The keymap of
+;; well as the minor mode keymaps set by other modes. The keymap of
;; viper-emacs-local-user-minor-mode, viper-emacs-local-user-map, overrides
;; everything, but it is used on a per buffer basis.
;; The keymap associated with viper-emacs-state-modifier-minor-mode
-;; overrides keys on a per-major-mode basis. The mode
+;; overrides keys on a per-major-mode basis. The mode
;; viper-emacs-kbd-minor-mode is used to define Vi-style macros in Emacs
;; state.
;;
;; 3. There is also one minor mode that is used when Viper is in its
-;; replace-state (used for commands like cw, C, etc.). This mode is
+;; replace-state (used for commands like cw, C, etc.). This mode is
;; called
;;
;; viper-replace-minor-mode
;;
-;; and its keymap is viper-replace-map. Replace minor mode is always
+;; and its keymap is viper-replace-map. Replace minor mode is always
;; used in conjunction with the minor modes for insert-state, and its
;; keymap overshadows the keymaps for insert minor modes.
;;
@@ -265,32 +265,32 @@
;; As mentioned before, sometimes, it is convenient to have
;; buffer-specific of mode-specific key bindings in Vi and insert modes.
;; Viper provides a special function, viper-add-local-keys, to do precisely
-;; this. For instance, is you need to add couple of mode-specific bindings
+;; this. For instance, is you need to add couple of mode-specific bindings
;; to Insert mode, you can put
;;
;; (viper-add-local-keys 'insert-state '((key1 . func1) (key2 .func2)))
;;
-;; somewhere in a hook of this major mode. If you put something like this
+;; somewhere in a hook of this major mode. If you put something like this
;; in your own elisp function, this will define bindings specific to the
;; buffer that was current at the time of the call to viper-add-local-keys.
;; The only thing to make sure here is that the major mode of this buffer
;; is written according to Emacs conventions, which includes a call to
-;; (kill-all-local-variables). See viper-add-local-keys for more details.
+;; (kill-all-local-variables). See viper-add-local-keys for more details.
;;
;;
;; TO DO (volunteers?):
;;
;; 1. Some of the code that is inherited from VIP-3.5 is rather
-;; convoluted. Instead of viper-command-argument, keymaps should bind the
-;; actual commands. E.g., "dw" should be bound to a generic command
+;; convoluted. Instead of viper-command-argument, keymaps should bind the
+;; actual commands. E.g., "dw" should be bound to a generic command
;; viper-delete that will delete things based on the value of
-;; last-command-char. This would greatly simplify the logic and the code.
+;; last-command-char. This would greatly simplify the logic and the code.
;;
;; 2. Somebody should venture to write a customization package a la
;; options.el that would allow the user to change values of variables
;; that meet certain specs (e.g., match a regexp) and whose doc string
-;; starts with a '*'. Then, the user should be offered to save
-;; variables that were changed. This will make user's customization job
+;; starts with a '*'. Then, the user should be offered to save
+;; variables that were changed. This will make user's customization job
;; much easier.
;;
@@ -360,7 +360,7 @@ user decide when to invoke Viper in a major mode."
(defcustom viper-mode (cond (noninteractive nil)
(t 'ask))
"To Viperize or not to Viperize.
-If t, viperize emacs. If nil -- don't. If `ask', ask the user.
+If t, viperize emacs. If nil -- don't. If `ask', ask the user.
This variable is used primatily when Viper is being loaded.
Must be set in `~/.emacs' before Viper is loaded.
@@ -377,22 +377,27 @@ widget."
awk-mode
m4-mode
+ xrdb-mode
+ winmgr-mode
+ autoconf-mode
+ cvs-edit-mode
html-mode html-helper-mode
emacs-lisp-mode lisp-mode lisp-interaction-mode
- java-mode cc-mode c-mode c++-mode
+ jde-mode java-mode
+ cc-mode c-mode c++-mode objc-mode
fortran-mode f90-mode
basic-mode
bat-mode
asm-mode
prolog-mode
+ flora-mode
text-mode indented-text-mode
tex-mode latex-mode bibtex-mode
completion-list-mode
- compilation-mode
perl-mode
javascript-mode
@@ -421,6 +426,7 @@ widget."
Info-mode
Buffer-menu-mode
+ compilation-mode
view-mode
vm-mode
@@ -428,8 +434,8 @@ widget."
"*A list of major modes that should come up in Emacs state.
Normally, Viper would bring buffers up in Emacs state, unless the corresponding
major mode has been placed on `viper-vi-state-mode-list' or
-`viper-insert-state-mode-list'. So, don't place a new mode on this list, unless
-it is coming up in a wrong Viper state."
+`viper-insert-state-mode-list'. So, don't place a new mode on this list,
+unless it is coming up in a wrong Viper state."
:type '(repeat symbol)
:group 'viper-misc)
@@ -444,10 +450,9 @@ it is coming up in a wrong Viper state."
(defun viper-apply-major-mode-modifiers (&optional symbol value)
(if symbol
(set symbol value))
- (mapcar (function
- (lambda (triple)
- (viper-modify-major-mode
- (nth 0 triple) (nth 1 triple) (eval (nth 2 triple)))))
+ (mapcar (lambda (triple)
+ (viper-modify-major-mode
+ (nth 0 triple) (nth 1 triple) (eval (nth 2 triple))))
viper-major-mode-modifier-list))
(defcustom viper-major-mode-modifier-list
@@ -470,12 +475,12 @@ it is coming up in a wrong Viper state."
)
"List specifying how to modify the various major modes to enable some Viperisms.
The list has the structure: ((mode viper-state keymap) (mode viper-state
-keymap) ...). If `mode' is on the list, the `kemap' will be made active (on the
-minor-mode-map-alist) in the specified viper state.
+keymap) ...). If `mode' is on the list, the `kemap' will be made active (on
+the minor-mode-map-alist) in the specified viper state.
If you change this list, have to restart emacs for the change to take effect.
However, if you did the change through the customization widget, then emacs
needs to be restarted only if you deleted a triple mode-state-keymap from the
-list. No need to restart emacs in case of insertion or modification of an
+list. No need to restart emacs in case of insertion or modification of an
existing triple."
:type '(repeat
(list symbol
@@ -493,7 +498,7 @@ existing triple."
;;;###autoload
(defun toggle-viper-mode ()
"Toggle Viper on/off.
-If Viper is enabled, turn it off. Otherwise, turn it on."
+If Viper is enabled, turn it off. Otherwise, turn it on."
(interactive)
(if (eq viper-mode t)
(viper-go-away)
@@ -512,9 +517,11 @@ If Viper is enabled, turn it off. Otherwise, turn it on."
(setq viper-mode t)
(load-library "viper"))
- (if viper-first-time ; Important check. Prevents mix-up of startup and
- (progn ; expert-level msgs when viper-mode recurses
+ (if viper-first-time ; Important check. Prevents mix-up of startup
+ (progn ; and expert-level msgs when viper-mode recurses
(setq viper-first-time nil)
+ (setq viper-vi-state-cursor-color
+ (viper-get-cursor-color))
(if (not viper-inhibit-startup-message)
(save-window-excursion
(setq viper-inhibit-startup-message t)
@@ -530,13 +537,13 @@ Incidentally, Viper emulates Vi under GNU Emacs 20 and XEmacs 20.
It supports all of what is good in Vi and Ex, while extending
and improving upon much of it.
- 1. Viper supports Vi at several levels. Level 1 is the closest to Vi,
+ 1. Viper supports Vi at several levels. Level 1 is the closest to Vi,
level 5 provides the most flexibility to depart from many Vi conventions.
You will be asked to specify your user level in a following screen.
If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave
- as in VI, to smooth transition to Viper for the beginners. However, to
+ as in VI, to smooth transition to Viper for the beginners. However, to
use Emacs productively, you are advised to reach user level 3 or higher.
At user level 2 or higher, ^X and ^C have Emacs, not Vi, bindings;
@@ -545,13 +552,13 @@ and improving upon much of it.
2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they
do not cause Emacs to quit, except at user level 1 (for a novice).
3. ^X^C EXITS EMACS.
- 4. Viper supports multiple undo: `u' will undo. Typing `.' will repeat
- undo. Another `u' changes direction.
+ 4. Viper supports multiple undo: `u' will undo. Typing `.' will repeat
+ undo. Another `u' changes direction.
6. Emacs Meta key is `C-\\' (in all modes) or `\\ ESC' (in Vi command mode).
On a window system, the best way is to use the Meta-key on your keyboard.
7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if
- something funny happens. This would abort the current editing command.
+ something funny happens. This would abort the current editing command.
For more information on Viper:
@@ -560,7 +567,7 @@ For more information on Viper:
c. Print the Quick Reference, found in ./etc/viperCard.dvi
To submit a bug report or to contact the author, type :submitReport in Vi
-command mode. To shoo Viper away and return to pure Emacs (horror!), type:
+command mode. To shoo Viper away and return to pure Emacs (horror!), type:
M-x viper-go-away
@@ -606,20 +613,19 @@ This startup message appears whenever you load Viper, unless you type `y' now."
;; Remove local value in all existing buffers
;; This doesn't delocalize vars (which would have been desirable)
(defun viper-delocalize-var (symbol)
- (mapcar (function (lambda (buf)
- (save-excursion
- (set-buffer buf)
- (kill-local-variable symbol))))
+ (mapcar (lambda (buf) (save-excursion
+ (set-buffer buf)
+ (kill-local-variable symbol)))
(buffer-list)))
(defun viper-go-away ()
"De-Viperize Emacs.
-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
+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'
+It also doesn't undo some Viper settings. For instance, `minor-mode-map-alist'
remains buffer-local."
(interactive)
@@ -740,24 +746,23 @@ remains buffer-local."
;; set appropriate Viper state in buffers that changed major mode
(defun set-viper-state-in-major-mode ()
(mapcar
- (function
- (lambda (buf)
- (if (viper-buffer-live-p buf)
- (with-current-buffer buf
- (cond ((and (memq major-mode viper-vi-state-mode-list)
- (eq viper-current-state 'emacs-state))
- (viper-mode))
- ((memq major-mode viper-emacs-state-mode-list)
- ;; not checking (eq viper-current-state 'emacs-state)
- ;; because viper-current-state could have gotten it by
- ;; default. we need viper-change-state-to-emacs here to have
- ;; the keymaps take effect.
- (viper-change-state-to-emacs))
- ((and (memq major-mode viper-insert-state-mode-list)
- (not (eq viper-current-state 'insert-state)))
- (viper-change-state-to-insert))
- )) ; with-current-buffer
- ))) ; function
+ (lambda (buf)
+ (if (viper-buffer-live-p buf)
+ (with-current-buffer buf
+ (cond ((and (memq major-mode viper-vi-state-mode-list)
+ (eq viper-current-state 'emacs-state))
+ (viper-mode))
+ ((memq major-mode viper-emacs-state-mode-list)
+ ;; not checking (eq viper-current-state 'emacs-state)
+ ;; because viper-current-state could have gotten it by
+ ;; default. We need viper-change-state-to-emacs here to have
+ ;; the keymaps take effect.
+ (viper-change-state-to-emacs))
+ ((and (memq major-mode viper-insert-state-mode-list)
+ (not (eq viper-current-state 'insert-state)))
+ (viper-change-state-to-insert))
+ )) ; with-current-buffer
+ )) ; function
viper-new-major-mode-buffer-list)
;; clear the list of bufs that changed major mode
(setq viper-new-major-mode-buffer-list nil)
@@ -817,7 +822,7 @@ remains buffer-local."
(viper-change-state-to-vi))
;; passwd.el sets up its own buffer, which turns up in Vi mode,
- ;; thus overriding the local map. We don't need Vi mode here.
+ ;; thus overriding the local map. We don't need Vi mode here.
(eval-after-load
"passwd"
'(defadvice read-passwd-1 (before viper-passwd-ad activate)
@@ -913,7 +918,7 @@ remains buffer-local."
;; This var is not local in Emacs, so we make it local. It must be local
;; because although the stack of minor modes can be the same for all buffers,
- ;; the associated *keymaps* can be different. In Viper,
+ ;; the associated *keymaps* can be different. In Viper,
;; 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.
@@ -941,7 +946,7 @@ remains buffer-local."
(append '("" viper-mode-string) (cdr global-mode-string))))
(defadvice read-key-sequence (around viper-read-keyseq-ad activate)
- "Harness to work for Viper. This advice is harmless---don't worry!"
+ "Harness to work for Viper. This advice is harmless---don't worry!"
(let (inhibit-quit event keyseq)
(setq keyseq ad-do-it)
(setq event (if viper-xemacs-p
@@ -1078,11 +1083,11 @@ These two lines must come in the order given.
(message "")
(kill-buffer " *viper-info*")))
- ;; If viper-mode is t, then just continue. Viper will kick in.
+ ;; If viper-mode is t, then just continue. Viper will kick in.
((eq viper-mode t))
;; Otherwise, it was asking Viper was not loaded through .emacs
;; In this case, it was either through M-x viper-mode or via something
- ;; else, like the custom widget. If Viper was loaded through
+ ;; else, like the custom widget. If Viper was loaded through
;; M-x viper-mode, then viper will kick in anyway.
(t (setq viper-mode nil)))
@@ -1094,8 +1099,8 @@ These two lines must come in the order given.
-;; Get viper standard value of SYMBOL. If symbol is customized, get its
-;; standard value. Otherwise, get the value saved in the alist STORAGE. If
+;; Get viper standard value of SYMBOL. If symbol is customized, get its
+;; standard value. Otherwise, get the value saved in the alist STORAGE. If
;; STORAGE is nil, use viper-saved-user-settings.
(defun viper-standard-value (symbol &optional storage)
(or (eval (car (get symbol 'customized-value)))
@@ -1197,6 +1202,7 @@ These two lines must come in the order given.
(viper-harness-minor-mode "view-less")
(viper-harness-minor-mode "view")
(viper-harness-minor-mode "reftex")
+ (viper-harness-minor-mode "flyspell")
))