Mercurial > emacs
changeset 19079:dfbef8117c6a
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Sat, 02 Aug 1997 07:40:22 +0000 |
parents | 46326a66c27c |
children | 0d238726e4c3 |
files | lisp/emulation/viper-cmd.el lisp/emulation/viper-ex.el lisp/emulation/viper-init.el lisp/emulation/viper-keym.el lisp/emulation/viper-macs.el lisp/emulation/viper-mous.el lisp/emulation/viper-util.el lisp/emulation/viper.el |
diffstat | 8 files changed, 2275 insertions(+), 2152 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emulation/viper-cmd.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-cmd.el Sat Aug 02 07:40:22 1997 +0000 @@ -1557,8 +1557,12 @@ (message " `.' runs %s%s" (concat "`" (viper-array-to-string keys) "'") - (viper-abbreviate-string text max-text-len - " inserting `" "'" " .......")) + (viper-abbreviate-string + (if viper-xemacs-p + (replace-in-string text "\n" "^J") + text) + max-text-len + " inserting `" "'" " .......")) ))
--- a/lisp/emulation/viper-ex.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-ex.el Sat Aug 02 07:40:22 1997 +0000 @@ -25,15 +25,15 @@ ;; Compiler pacifier (defvar read-file-name-map) -(defvar vip-use-register) -(defvar vip-s-string) -(defvar vip-shift-width) -(defvar vip-ex-history) -(defvar vip-related-files-and-buffers-ring) -(defvar vip-local-search-start-marker) +(defvar viper-use-register) +(defvar viper-s-string) +(defvar viper-shift-width) +(defvar viper-ex-history) +(defvar viper-related-files-and-buffers-ring) +(defvar viper-local-search-start-marker) (defvar viper-expert-level) -(defvar vip-custom-file-name) -(defvar vip-case-fold-search) +(defvar viper-custom-file-name) +(defvar viper-case-fold-search) (defvar explicit-shell-file-name) ;; loading happens only in non-interactive compilation @@ -61,9 +61,9 @@ ;;; Variables -(defconst vip-ex-work-buf-name " *ex-working-space*") -(defconst vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) -(defconst vip-ex-tmp-buf-name " *ex-tmp*") +(defconst viper-ex-work-buf-name " *ex-working-space*") +(defconst viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) +(defconst viper-ex-tmp-buf-name " *ex-tmp*") ;;; Variable completion in :set command @@ -168,11 +168,11 @@ :group 'viper-ex) (defvar ex-nontrivial-find-file-function - (cond (ex-unix-type-shell 'vip-ex-nontrivial-find-file-unix) - ((eq system-type 'emx) 'vip-ex-nontrivial-find-file-ms) ; OS/2 - (vip-ms-style-os-p 'vip-ex-nontrivial-find-file-ms) ; a Microsoft OS - (vip-vms-os-p 'vip-ex-nontrivial-find-file-unix) ; VMS - (t 'vip-ex-nontrivial-find-file-unix) ; presumably UNIX + (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 )) ;; Remembers the previous Ex tag. @@ -194,9 +194,9 @@ ;; e.g., :r !date (defvar ex-cmdfile nil) -;; flag used in vip-ex-read-file-name to indicate that we may be reading +;; flag used in viper-ex-read-file-name to indicate that we may be reading ;; multiple file names. Used for :edit and :next -(defvar vip-keep-reading-filename nil) +(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. @@ -211,19 +211,19 @@ :group 'viper-ex) ;; Last shell command executed with :! command. -(defvar vip-ex-last-shell-com nil) +(defvar viper-ex-last-shell-com nil) ;; Indicates if Minibuffer was exited temporarily in Ex-command. -(defvar vip-incomplete-ex-cmd nil) +(defvar viper-incomplete-ex-cmd nil) ;; Remembers the last ex-command prompt. -(defvar vip-last-ex-prompt "") +(defvar viper-last-ex-prompt "") ;;; Code ;; Check if ex-token is an initial segment of STR -(defun vip-check-sub (str) +(defun viper-check-sub (str) (let ((length (length ex-token))) (if (and (<= length (length str)) (string= ex-token (substring str 0 length))) @@ -231,7 +231,7 @@ (setq ex-token-type 'non-command)))) ;; Get a complete ex command -(defun vip-get-ex-com-subr () +(defun viper-get-ex-com-subr () (let (case-fold-search) (set-mark (point)) (re-search-forward "[a-zA-Z][a-zA-Z]*") @@ -239,98 +239,98 @@ (setq ex-token (buffer-substring (point) (mark t))) (exchange-point-and-mark) (cond ((looking-at "a") - (cond ((looking-at "ab") (vip-check-sub "abbreviate")) - ((looking-at "ar") (vip-check-sub "args")) - (t (vip-check-sub "append")))) - ((looking-at "h") (vip-check-sub "help")) + (cond ((looking-at "ab") (viper-check-sub "abbreviate")) + ((looking-at "ar") (viper-check-sub "args")) + (t (viper-check-sub "append")))) + ((looking-at "h") (viper-check-sub "help")) ((looking-at "c") - (cond ((looking-at "cd") (vip-check-sub "cd")) - ((looking-at "ch") (vip-check-sub "chdir")) - ((looking-at "co") (vip-check-sub "copy")) - (t (vip-check-sub "change")))) - ((looking-at "d") (vip-check-sub "delete")) - ((looking-at "b") (vip-check-sub "buffer")) - ((looking-at "B") (vip-check-sub "Buffer")) + (cond ((looking-at "cd") (viper-check-sub "cd")) + ((looking-at "ch") (viper-check-sub "chdir")) + ((looking-at "co") (viper-check-sub "copy")) + (t (viper-check-sub "change")))) + ((looking-at "d") (viper-check-sub "delete")) + ((looking-at "b") (viper-check-sub "buffer")) + ((looking-at "B") (viper-check-sub "Buffer")) ((looking-at "e") - (if (looking-at "ex") (vip-check-sub "ex") - (vip-check-sub "edit"))) - ((looking-at "f") (vip-check-sub "file")) - ((looking-at "g") (vip-check-sub "global")) - ((looking-at "i") (vip-check-sub "insert")) - ((looking-at "j") (vip-check-sub "join")) - ((looking-at "l") (vip-check-sub "list")) + (if (looking-at "ex") (viper-check-sub "ex") + (viper-check-sub "edit"))) + ((looking-at "f") (viper-check-sub "file")) + ((looking-at "g") (viper-check-sub "global")) + ((looking-at "i") (viper-check-sub "insert")) + ((looking-at "j") (viper-check-sub "join")) + ((looking-at "l") (viper-check-sub "list")) ((looking-at "m") - (cond ((looking-at "map") (vip-check-sub "map")) - ((looking-at "mar") (vip-check-sub "mark")) - (t (vip-check-sub "move")))) + (cond ((looking-at "map") (viper-check-sub "map")) + ((looking-at "mar") (viper-check-sub "mark")) + (t (viper-check-sub "move")))) ((looking-at "k[a-z][^a-z]") (setq ex-token "kmark") (forward-char 1) (exchange-point-and-mark)) ; this is canceled out by another ; exchange-point-and-mark at the end - ((looking-at "k") (vip-check-sub "kmark")) + ((looking-at "k") (viper-check-sub "kmark")) ((looking-at "n") (if (looking-at "nu") - (vip-check-sub "number") - (vip-check-sub "next"))) - ((looking-at "N") (vip-check-sub "Next")) - ((looking-at "o") (vip-check-sub "open")) + (viper-check-sub "number") + (viper-check-sub "next"))) + ((looking-at "N") (viper-check-sub "Next")) + ((looking-at "o") (viper-check-sub "open")) ((looking-at "p") - (cond ((looking-at "pre") (vip-check-sub "preserve")) - ((looking-at "pu") (vip-check-sub "put")) - ((looking-at "pw") (vip-check-sub "pwd")) - (t (vip-check-sub "print")))) - ((looking-at "P") (vip-check-sub "PreviousRelatedFile")) - ((looking-at "R") (vip-check-sub "RelatedFile")) - ((looking-at "q") (vip-check-sub "quit")) + (cond ((looking-at "pre") (viper-check-sub "preserve")) + ((looking-at "pu") (viper-check-sub "put")) + ((looking-at "pw") (viper-check-sub "pwd")) + (t (viper-check-sub "print")))) + ((looking-at "P") (viper-check-sub "PreviousRelatedFile")) + ((looking-at "R") (viper-check-sub "RelatedFile")) + ((looking-at "q") (viper-check-sub "quit")) ((looking-at "r") - (cond ((looking-at "rec") (vip-check-sub "recover")) - ((looking-at "rew") (vip-check-sub "rewind")) - (t (vip-check-sub "read")))) + (cond ((looking-at "rec") (viper-check-sub "recover")) + ((looking-at "rew") (viper-check-sub "rewind")) + (t (viper-check-sub "read")))) ((looking-at "s") - (cond ((looking-at "se") (vip-check-sub "set")) - ((looking-at "sh") (vip-check-sub "shell")) - ((looking-at "so") (vip-check-sub "source")) - ((looking-at "sr") (vip-check-sub "sr")) - ((looking-at "st") (vip-check-sub "stop")) - ((looking-at "sus") (vip-check-sub "suspend")) - ((looking-at "subm") (vip-check-sub "submitReport")) - (t (vip-check-sub "substitute")))) + (cond ((looking-at "se") (viper-check-sub "set")) + ((looking-at "sh") (viper-check-sub "shell")) + ((looking-at "so") (viper-check-sub "source")) + ((looking-at "sr") (viper-check-sub "sr")) + ((looking-at "st") (viper-check-sub "stop")) + ((looking-at "sus") (viper-check-sub "suspend")) + ((looking-at "subm") (viper-check-sub "submitReport")) + (t (viper-check-sub "substitute")))) ((looking-at "t") - (if (looking-at "ta") (vip-check-sub "tag") - (vip-check-sub "transfer"))) + (if (looking-at "ta") (viper-check-sub "tag") + (viper-check-sub "transfer"))) ((looking-at "u") - (cond ((looking-at "una") (vip-check-sub "unabbreviate")) - ((looking-at "unm") (vip-check-sub "unmap")) - (t (vip-check-sub "undo")))) + (cond ((looking-at "una") (viper-check-sub "unabbreviate")) + ((looking-at "unm") (viper-check-sub "unmap")) + (t (viper-check-sub "undo")))) ((looking-at "v") - (cond ((looking-at "ve") (vip-check-sub "version")) - ((looking-at "vi") (vip-check-sub "visual")) - (t (vip-check-sub "vglobal")))) + (cond ((looking-at "ve") (viper-check-sub "version")) + ((looking-at "vi") (viper-check-sub "visual")) + (t (viper-check-sub "vglobal")))) ((looking-at "w") - (if (looking-at "wq") (vip-check-sub "wq") - (vip-check-sub "write"))) + (if (looking-at "wq") (viper-check-sub "wq") + (viper-check-sub "write"))) ((looking-at "W") (if (looking-at "WW") - (vip-check-sub "WWrite") - (vip-check-sub "Write"))) - ((looking-at "x") (vip-check-sub "xit")) - ((looking-at "y") (vip-check-sub "yank")) - ((looking-at "z") (vip-check-sub "z"))) + (viper-check-sub "WWrite") + (viper-check-sub "Write"))) + ((looking-at "x") (viper-check-sub "xit")) + ((looking-at "y") (viper-check-sub "yank")) + ((looking-at "z") (viper-check-sub "z"))) (exchange-point-and-mark) )) ;; Get an ex-token which is either an address or a command. ;; A token has a type, \(command, address, end-mark\), and a value -(defun vip-get-ex-token () +(defun viper-get-ex-token () (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (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 "#") (setq ex-token-type 'command) (setq ex-token (char-to-string (following-char))) (forward-char 1)) - ((looking-at "[a-z]") (vip-get-ex-com-subr)) + ((looking-at "[a-z]") (viper-get-ex-com-subr)) ((looking-at "\\.") (forward-char 1) (setq ex-token-type 'dot)) @@ -358,7 +358,7 @@ (forward-char 1) (setq ex-token-type 'plus)) (t - (error vip-BadAddress)))) + (error viper-BadAddress)))) ((looking-at "-") (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]")) (forward-char 1) @@ -369,7 +369,7 @@ (forward-char 1) (setq ex-token-type 'minus)) (t - (error vip-BadAddress)))) + (error viper-BadAddress)))) ((looking-at "/") (forward-char 1) (set-mark (point)) @@ -377,7 +377,7 @@ (while (and (not (eolp)) cont) ;;(re-search-forward "[^/]*/") (re-search-forward "[^/]*\\(/\\|\n\\)") - (if (not (vip-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/")) + (if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/")) (setq cont nil)))) (backward-char 1) (setq ex-token (buffer-substring (point) (mark t))) @@ -390,7 +390,7 @@ (while (and (not (eolp)) cont) ;;(re-search-forward "[^\\?]*\\?") (re-search-forward "[^\\?]*\\(\\?\\|\n\\)") - (if (not (vip-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?")) + (if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?")) (setq cont nil)) (backward-char 1) (if (not (looking-at "\n")) (forward-char 1)))) @@ -417,13 +417,13 @@ (setq ex-token-type 'end-mark) (setq ex-token "goto")) (t - (error vip-BadExCommand))))) + (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. (defun ex-cmd-read-exit () (interactive) - (setq vip-incomplete-ex-cmd t) + (setq viper-incomplete-ex-cmd t) (let ((quit-regex1 (concat "\\(" "set[ \t]*" "\\|" "edit[ \t]*" @@ -459,12 +459,12 @@ "!*"))) (save-window-excursion ;; put cursor at the end of the Ex working buffer - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (goto-char (point-max))) - (cond ((vip-looking-back quit-regex1) (exit-minibuffer)) - ((vip-looking-back stay-regex) (insert " ")) - ((vip-looking-back quit-regex2) (exit-minibuffer)) + (cond ((viper-looking-back quit-regex1) (exit-minibuffer)) + ((viper-looking-back stay-regex) (insert " ")) + ((viper-looking-back quit-regex2) (exit-minibuffer)) (t (insert " "))))) ;; complete Ex command @@ -477,45 +477,45 @@ save-pos (point))) (if (or (= dist 0) - (vip-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") - (vip-looking-back + (viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") + (viper-looking-back "^[ \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. - (if (or (vip-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*") - (vip-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") + (if (or (viper-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*") + (viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") (looking-at "[^ \t\n\C-m]")) nil (with-output-to-temp-buffer "*Completions*" (display-completion-list - (vip-alist-to-list ex-token-alist)))) + (viper-alist-to-list ex-token-alist)))) ;; Preceding chars may be part of a command name (setq string-to-complete (buffer-substring save-pos (point))) (setq completion-result (try-completion string-to-complete ex-token-alist)) (cond ((eq completion-result t) ; exact match--do nothing - (vip-tmp-insert-at-eob " (Sole completion)")) + (viper-tmp-insert-at-eob " (Sole completion)")) ((eq completion-result nil) - (vip-tmp-insert-at-eob " (No match)")) + (viper-tmp-insert-at-eob " (No match)")) (t ;; partial completion (goto-char save-pos) (delete-region (point) (point-max)) (insert completion-result) (let (case-fold-search) (setq compl-list - (vip-filter-alist (concat "^" completion-result) + (viper-filter-alist (concat "^" completion-result) ex-token-alist))) (if (> (length compl-list) 1) (with-output-to-temp-buffer "*Completions*" (display-completion-list - (vip-alist-to-list (reverse compl-list))))))) + (viper-alist-to-list (reverse compl-list))))))) ))) ;; Read Ex commands -(defun vip-ex (&optional string) +(defun viper-ex (&optional string) (interactive) (or string (setq ex-g-flag nil @@ -526,25 +526,25 @@ (dot (point)) prev-token-type com-str) - (vip-add-keymap vip-ex-cmd-map map) + (viper-add-keymap viper-ex-cmd-map map) - (setq com-str (or string (vip-read-string-with-history + (setq com-str (or string (viper-read-string-with-history ":" nil - 'vip-ex-history - (car vip-ex-history) + 'viper-ex-history + (car viper-ex-history) map))) (save-window-excursion ;; just a precaution - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (delete-region (point-min) (point-max)) (insert com-str "\n") (goto-char (point-min))) (setq ex-token-type nil ex-addresses nil) (while cont - (vip-get-ex-token) + (viper-get-ex-token) (cond ((memq ex-token-type '(command end-mark)) (if address (setq ex-addresses (cons address ex-addresses))) (cond ((string= ex-token "global") @@ -554,21 +554,21 @@ (ex-global t) (setq cont nil)) (t - (vip-execute-ex-command) + (viper-execute-ex-command) (save-window-excursion - (setq vip-ex-work-buf - (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (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 vip-SpuriousText))) + (t (error "`%s': %s" ex-token viper-SpuriousText))) )) )) ((eq ex-token-type 'non-command) - (error "`%s': %s" ex-token vip-BadExCommand)) + (error "`%s': %s" ex-token viper-BadExCommand)) ((eq ex-token-type 'whole) (setq address nil) (setq ex-addresses @@ -586,16 +586,16 @@ (if address (setq dot address)) (setq ex-addresses (cons (if (null address) (point) address) ex-addresses))) - (t (let ((ans (vip-get-ex-address-subr address dot))) + (t (let ((ans (viper-get-ex-address-subr address dot))) (if ans (setq address ans))))) (setq prev-token-type ex-token-type)))) ;; Get a regular expression and set `ex-variant', if found -(defun vip-get-ex-pat () +(defun viper-get-ex-pat () (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (if (looking-at "!") (progn @@ -618,7 +618,7 @@ (error "Missing closing delimiter for global regexp") (goto-char (point-max)))) - (if (not (vip-looking-back + (if (not (viper-looking-back (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c))) (setq cont nil)))) (setq ex-token @@ -637,26 +637,26 @@ c))) ;; get an ex command -(defun vip-get-ex-command () +(defun viper-get-ex-command () (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (if (looking-at "/") (forward-char 1)) (skip-chars-forward " \t") (cond ((looking-at "[a-z]") - (vip-get-ex-com-subr) + (viper-get-ex-com-subr) (if (eq ex-token-type 'non-command) - (error "`%s': %s" ex-token vip-BadExCommand))) + (error "`%s': %s" ex-token viper-BadExCommand))) ((looking-at "[!=><&~]") (setq ex-token (char-to-string (following-char))) (forward-char 1)) - (t (error vip-BadExCommand))))) + (t (error viper-BadExCommand))))) ;; Get an Ex option g or c -(defun vip-get-ex-opt-gc (c) +(defun viper-get-ex-opt-gc (c) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (if (looking-at (format "%c" c)) (forward-char 1)) (skip-chars-forward " \t") (cond ((looking-at "g") @@ -670,7 +670,7 @@ (t nil)))) ;; Compute default addresses. WHOLE-FLAG means use the whole buffer -(defun vip-default-ex-addresses (&optional whole-flag) +(defun viper-default-ex-addresses (&optional whole-flag) (cond ((null ex-addresses) (setq ex-addresses (if whole-flag @@ -681,13 +681,13 @@ (cons (car ex-addresses) ex-addresses))))) ;; Get an ex-address as a marker and set ex-flag if a flag is found -(defun vip-get-ex-address () +(defun viper-get-ex-address () (let ((address (point-marker)) (cont t)) (setq ex-token "") (setq ex-flag nil) (while cont - (vip-get-ex-token) + (viper-get-ex-token) (cond ((eq ex-token-type 'command) (if (member ex-token '("print" "list" "#")) (progn @@ -699,13 +699,13 @@ ((eq ex-token-type 'whole) (error "Trailing address expected")) ((eq ex-token-type 'comma) - (error "`%s': %s" ex-token vip-SpuriousText)) - (t (let ((ans (vip-get-ex-address-subr address (point-marker)))) + (error "`%s': %s" ex-token viper-SpuriousText)) + (t (let ((ans (viper-get-ex-address-subr address (point-marker)))) (if ans (setq address ans)))))) address)) ;; Returns an address as a point -(defun vip-get-ex-address-subr (old-address dot) +(defun viper-get-ex-address-subr (old-address dot) (let ((address nil)) (if (null old-address) (setq old-address dot)) (cond ((eq ex-token-type 'dot) @@ -742,7 +742,7 @@ (save-excursion (if (null ex-token) (exchange-point-and-mark) - (goto-char (vip-register-to-point + (goto-char (viper-register-to-point (1+ (- ex-token ?a)) 'enforce-buffer))) (setq address (point-marker))))) address)) @@ -751,10 +751,10 @@ ;; Search pattern and set address (defun ex-search-address (forward) (if (string= ex-token "") - (if (null vip-s-string) - (error vip-NoPrevSearch) - (setq ex-token vip-s-string)) - (setq vip-s-string ex-token)) + (if (null viper-s-string) + (error viper-NoPrevSearch) + (setq ex-token viper-s-string)) + (setq viper-s-string ex-token)) (if forward (progn (forward-line 1) @@ -763,13 +763,13 @@ (re-search-backward ex-token))) ;; Get a buffer name and set `ex-count' and `ex-flag' if found -(defun vip-get-ex-buffer () +(defun viper-get-ex-buffer () (setq ex-buffer nil) (setq ex-count nil) (setq ex-flag nil) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (if (looking-at "[a-zA-Z]") (progn @@ -787,15 +787,15 @@ (setq ex-flag t) (forward-char 1))) (if (not (looking-at "[\n|]")) - (error "`%s': %s" ex-token vip-SpuriousText)))) + (error "`%s': %s" ex-token viper-SpuriousText)))) -(defun vip-get-ex-count () +(defun viper-get-ex-count () (setq ex-variant nil ex-count nil ex-flag nil) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (if (looking-at "!") (progn @@ -814,7 +814,8 @@ (forward-char 1))) (if (not (looking-at "[\n|]")) (error "`%s': %s" - (buffer-substring (point-min) (1- (point-max))) vip-BadExCommand)))) + (buffer-substring + (point-min) (1- (point-max))) viper-BadExCommand)))) ;; Expand \% and \# in ex command (defun ex-expand-filsyms (cmd buf) @@ -828,14 +829,14 @@ (if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd)) (error "No alternate file to substitute for `#'")) (save-excursion - (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) + (set-buffer (get-buffer-create viper-ex-tmp-buf-name)) (erase-buffer) (insert cmd) (goto-char (point-min)) (while (re-search-forward "%\\|#" nil t) (let ((data (match-data)) (char (buffer-substring (match-beginning 0) (match-end 0)))) - (if (vip-looking-back (concat "\\\\" char)) + (if (viper-looking-back (concat "\\\\" char)) (replace-match char) (store-match-data data) (if (string= char "%") @@ -847,7 +848,7 @@ ret)) ;; Get a file name and set ex-variant, `ex-append' and `ex-offset' if found -(defun vip-get-ex-file () +(defun viper-get-ex-file () (let (prompt) (setq ex-file nil ex-variant nil @@ -856,11 +857,11 @@ ex-cmdfile nil) (save-excursion (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (if (looking-at "!") - (if (and (not (vip-looking-back "[ \t]")) + (if (and (not (viper-looking-back "[ \t]")) ;; read doesn't have a corresponding :r! form, so ! is ;; immediately interpreted as a shell command. (not (string= ex-token "read"))) @@ -902,7 +903,7 @@ (progn ;; if file name comes from history, don't leave ;; minibuffer when the user types space - (setq vip-incomplete-ex-cmd nil) + (setq viper-incomplete-ex-cmd nil) ;; this must be the last clause in this progn (substring ex-file (match-beginning 0) (match-end 0)) ) @@ -916,11 +917,11 @@ (setq prompt (buffer-substring (point-min) (point))) )) - (setq vip-last-ex-prompt prompt) + (setq viper-last-ex-prompt prompt) ;; If we just finished reading command, redisplay prompt - (if vip-incomplete-ex-cmd - (setq ex-file (vip-ex-read-file-name (format ":%s " prompt))) + (if viper-incomplete-ex-cmd + (setq ex-file (viper-ex-read-file-name (format ":%s " prompt))) ;; file was typed in-line (setq ex-file (or ex-file ""))) )) @@ -928,24 +929,24 @@ ;; Completes file name or exits minibuffer. If Ex command accepts multiple ;; file names, arranges to re-enter the minibuffer. -(defun vip-complete-filename-or-exit () +(defun viper-complete-filename-or-exit () (interactive) - (setq vip-keep-reading-filename t) + (setq viper-keep-reading-filename t) ;; don't exit if directory---ex-commands don't (cond ((ex-cmd-accepts-multiple-files-p ex-token) (exit-minibuffer)) ;; apparently the argument to an Ex command is ;; supposed to be a shell command - ((vip-looking-back "^[ \t]*!.*") + ((viper-looking-back "^[ \t]*!.*") (setq ex-cmdfile t) (insert " ")) (t (setq ex-cmdfile nil) (minibuffer-complete-word)))) -(defun vip-handle-! () +(defun viper-handle-! () (interactive) (if (and (string= - (buffer-string) (vip-abbreviate-file-name default-directory)) + (buffer-string) (viper-abbreviate-file-name default-directory)) (member ex-token '("read" "write"))) (erase-buffer)) (insert "!")) @@ -955,20 +956,20 @@ ;; If user doesn't enter anything, then "" is returned, i.e., the ;; prompt-directory is not returned. -(defun vip-ex-read-file-name (prompt) +(defun viper-ex-read-file-name (prompt) (let* ((str "") (minibuffer-local-completion-map (copy-keymap minibuffer-local-completion-map)) beg end cont val) - (vip-add-keymap ex-read-filename-map - (if vip-emacs-p + (viper-add-keymap ex-read-filename-map + (if viper-emacs-p minibuffer-local-completion-map read-file-name-map)) - (setq cont (setq vip-keep-reading-filename t)) + (setq cont (setq viper-keep-reading-filename t)) (while cont - (setq vip-keep-reading-filename nil + (setq viper-keep-reading-filename nil val (read-file-name (concat prompt str) nil default-directory)) (if (string-match " " val) (setq val (concat "\\\"" val "\\\""))) @@ -976,9 +977,9 @@ val (if (equal val "") "" " "))) ;; Only edit, next, and Next commands accept multiple files. - ;; vip-keep-reading-filename is set in the anonymous function that is + ;; viper-keep-reading-filename is set in the anonymous function that is ;; bound to " " in ex-read-filename-map. - (setq cont (and vip-keep-reading-filename + (setq cont (and viper-keep-reading-filename (ex-cmd-accepts-multiple-files-p ex-token))) ) @@ -990,19 +991,20 @@ (progn (setq ex-cmdfile t) (setq beg (1+ beg)) - (setq vip-last-ex-prompt (concat vip-last-ex-prompt " !"))))) + (setq viper-last-ex-prompt + (concat viper-last-ex-prompt " !"))))) (substring str (or beg 0) end))) ;; Execute ex command using the value of addresses -(defun vip-execute-ex-command () - (vip-deactivate-mark) +(defun viper-execute-ex-command () + (viper-deactivate-mark) (cond ((string= ex-token "args") (ex-args)) ((string= ex-token "copy") (ex-copy nil)) ((string= ex-token "cd") (ex-cd)) ((string= ex-token "chdir") (ex-cd)) ((string= ex-token "delete") (ex-delete)) ((string= ex-token "edit") (ex-edit)) - ((string= ex-token "file") (vip-info-on-file)) + ((string= ex-token "file") (viper-info-on-file)) ((string= ex-token "goto") (ex-goto)) ((string= ex-token "help") (ex-help)) ((string= ex-token "join") (ex-line "join")) @@ -1021,7 +1023,7 @@ ((string= ex-token "read") (ex-read)) ((string= ex-token "recover") (ex-recover)) ((string= ex-token "rewind") (ex-rewind)) - ((string= ex-token "submitReport") (vip-submit-report)) + ((string= ex-token "submitReport") (viper-submit-report)) ((string= ex-token "set") (ex-set)) ((string= ex-token "shell") (ex-shell)) ((string= ex-token "source") (ex-source)) @@ -1031,15 +1033,15 @@ ((string= ex-token "stop") (suspend-emacs)) ((string= ex-token "transfer") (ex-copy nil)) ((string= ex-token "buffer") (if ex-cycle-other-window - (vip-switch-to-buffer-other-window) - (vip-switch-to-buffer))) + (viper-switch-to-buffer-other-window) + (viper-switch-to-buffer))) ((string= ex-token "Buffer") (if ex-cycle-other-window - (vip-switch-to-buffer) - (vip-switch-to-buffer-other-window))) + (viper-switch-to-buffer) + (viper-switch-to-buffer-other-window))) ((string= ex-token "tag") (ex-tag)) - ((string= ex-token "undo") (vip-undo)) + ((string= ex-token "undo") (viper-undo)) ((string= ex-token "unmap") (ex-unmap)) - ((string= ex-token "version") (vip-version)) + ((string= ex-token "version") (viper-version)) ((string= ex-token "visual") (ex-edit)) ((string= ex-token "write") (ex-write nil)) ((string= ex-token "Write") (save-some-buffers)) @@ -1068,9 +1070,9 @@ (string= ex-token "z") (string= ex-token "#")) (error "`%s': Command not implemented in Viper" ex-token)) - (t (error "`%s': %s" ex-token vip-BadExCommand)))) + (t (error "`%s': %s" ex-token viper-BadExCommand)))) -(defun vip-undisplayed-files () +(defun viper-undisplayed-files () (mapcar (function (lambda (b) @@ -1088,7 +1090,7 @@ (defun ex-args () - (let ((l (vip-undisplayed-files)) + (let ((l (viper-undisplayed-files)) (args "") (file-count 1)) (while (not (null l)) @@ -1100,31 +1102,31 @@ (message "All files are already displayed") (save-excursion (save-window-excursion - (with-output-to-temp-buffer " *vip-info*" + (with-output-to-temp-buffer " *viper-info*" (princ "\n\nThese files are not displayed in any window.\n") (princ "\n=============\n") (princ args) (princ "\n=============\n") (princ "\nThe numbers can be given as counts to :next. ") (princ "\n\nPress any key to continue...\n\n")) - (vip-read-event)))))) + (viper-read-event)))))) ;; Ex cd command. Default directory of this buffer changes (defun ex-cd () - (vip-get-ex-file) + (viper-get-ex-file) (if (string= ex-file "") (setq ex-file "~")) (setq default-directory (file-name-as-directory (expand-file-name ex-file)))) ;; Ex copy and move command. DEL-FLAG means delete (defun ex-copy (del-flag) - (vip-default-ex-addresses) - (let ((address (vip-get-ex-address)) + (viper-default-ex-addresses) + (let ((address (viper-get-ex-address)) (end (car ex-addresses)) (beg (car (cdr ex-addresses)))) (goto-char end) (save-excursion (push-mark beg t) - (vip-enlarge-region (mark t) (point)) + (viper-enlarge-region (mark t) (point)) (if del-flag (kill-region (point) (mark t)) (copy-region-as-kill (point) (mark t))) @@ -1149,19 +1151,19 @@ ;; Ex delete command (defun ex-delete () - (vip-default-ex-addresses) - (vip-get-ex-buffer) + (viper-default-ex-addresses) + (viper-get-ex-buffer) (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) - (if (> beg end) (error vip-FirstAddrExceedsSecond)) + (if (> beg end) (error viper-FirstAddrExceedsSecond)) (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (exchange-point-and-mark) (if ex-count (progn (set-mark (point)) (forward-line (1- ex-count))) (set-mark end)) - (vip-enlarge-region (point) (mark t)) + (viper-enlarge-region (point) (mark t)) (if ex-flag ;; show text to be deleted and ask for confirmation (progn @@ -1174,12 +1176,12 @@ (error ""))) (save-excursion (kill-buffer " *delete text*"))) (if ex-buffer - (cond ((vip-valid-register ex-buffer '(Letter)) - (vip-append-to-register + (cond ((viper-valid-register ex-buffer '(Letter)) + (viper-append-to-register (downcase ex-buffer) (point) (mark t))) - ((vip-valid-register ex-buffer) + ((viper-valid-register ex-buffer) (copy-to-register ex-buffer (point) (mark t) nil)) - (t (error vip-InvalidRegister ex-buffer)))) + (t (error viper-InvalidRegister ex-buffer)))) (kill-region (point) (mark t)))))) @@ -1191,11 +1193,11 @@ ;; with the first file in its argument list (defun ex-edit (&optional file) (if (not file) - (vip-get-ex-file)) + (viper-get-ex-file)) (cond ((and (string= ex-file "") buffer-file-name) - (setq ex-file (vip-abbreviate-file-name (buffer-file-name)))) + (setq ex-file (viper-abbreviate-file-name (buffer-file-name)))) ((string= ex-file "") - (error vip-NoFileSpecified))) + (error viper-NoFileSpecified))) (let (msg do-edit) (if buffer-file-name @@ -1223,20 +1225,20 @@ (progn (ex-find-file ex-file) (or (eq major-mode 'dired-mode) - (vip-change-state-to-vi)) + (viper-change-state-to-vi)) (goto-char (point-min))) (switch-to-buffer file)) (if ex-offset (progn (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (delete-region (point-min) (point-max)) (insert ex-offset "\n") (goto-char (point-min))) - (goto-char (vip-get-ex-address)) + (goto-char (viper-get-ex-address)) (beginning-of-line))) - (ex-fixup-history vip-last-ex-prompt ex-file)) + (ex-fixup-history viper-last-ex-prompt ex-file)) ;; Find-file FILESPEC if it appears to specify a single file. ;; Otherwise, assume that FILES{EC is a wildcard. @@ -1269,33 +1271,33 @@ ex-g-variant t) (setq ex-g-flag t ex-g-variant nil))) - (vip-get-ex-pat) + (viper-get-ex-pat) (if (null ex-token) (error "`%s': Missing regular expression" gcommand))) (if (string= ex-token "") - (if (null vip-s-string) - (error vip-NoPrevSearch) - (setq ex-g-pat vip-s-string)) + (if (null viper-s-string) + (error viper-NoPrevSearch) + (setq ex-g-pat viper-s-string)) (setq ex-g-pat ex-token - vip-s-string ex-token)) + viper-s-string ex-token)) (if (null ex-addresses) (setq ex-addresses (list (point-max) (point-min))) - (vip-default-ex-addresses)) + (viper-default-ex-addresses)) (let ((marks nil) (mark-count 0) (end (car ex-addresses)) (beg (car (cdr ex-addresses))) com-str) - (if (> beg end) (error vip-FirstAddrExceedsSecond)) + (if (> beg end) (error viper-FirstAddrExceedsSecond)) (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (exchange-point-and-mark) (let ((cont t) (limit (point-marker))) (exchange-point-and-mark) ;; skip the last line if empty (beginning-of-line) - (if (eobp) (vip-backward-char-carefully)) + (if (eobp) (viper-backward-char-carefully)) (while (and cont (not (bobp)) (>= (point) limit)) (beginning-of-line) (set-mark (point)) @@ -1312,12 +1314,12 @@ (forward-line -1) (end-of-line))))) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (setq com-str (buffer-substring (1+ (point)) (1- (point-max))))) (while marks (goto-char (car marks)) - (vip-ex com-str) + (viper-ex com-str) (setq mark-count (1- mark-count)) (setq marks (cdr marks))))) @@ -1331,12 +1333,12 @@ ;; Ex line commands. COM is join, shift-right or shift-left (defun ex-line (com) - (vip-default-ex-addresses) - (vip-get-ex-count) + (viper-default-ex-addresses) + (viper-get-ex-count) (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))) point) - (if (> beg end) (error vip-FirstAddrExceedsSecond)) + (if (> beg end) (error viper-FirstAddrExceedsSecond)) (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (exchange-point-and-mark) (if ex-count (progn @@ -1371,10 +1373,10 @@ ((or (string= com "right") (string= com "left")) (indent-rigidly (min beg end) (max beg end) - (if (string= com "right") vip-shift-width (- vip-shift-width))) + (if (string= com "right") viper-shift-width (- viper-shift-width))) (goto-char (max beg end)) (end-of-line) - (vip-forward-char-carefully)))) + (viper-forward-char-carefully)))) ;; Ex mark command @@ -1384,8 +1386,8 @@ (setq ex-addresses (cons (point) nil))) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (if (looking-at "[a-z]") (progn @@ -1393,7 +1395,7 @@ (forward-char 1) (skip-chars-forward " \t") (if (not (looking-at "[\n|]")) - (error "`%s': %s" ex-token vip-SpuriousText))) + (error "`%s': %s" ex-token viper-SpuriousText))) (error "`%s' requires a following letter" ex-token))) (save-excursion (goto-char (car ex-addresses)) @@ -1407,7 +1409,7 @@ (let (count l) (if (not find-alt-file) (progn - (vip-get-ex-file) + (viper-get-ex-file) (if (or (char-or-string-p ex-offset) (and (not (string= "" ex-file)) (not (string-match "^[0-9]+$" ex-file)))) @@ -1418,7 +1420,7 @@ (if (= count 0) (setq count 1)) (if (< count 0) (error "Usage: `next <count>' (count >= 0)")))) (setq count 1)) - (setq l (vip-undisplayed-files)) + (setq l (viper-undisplayed-files)) (while (> count 0) (while (and (not (null l)) (null (car l))) (setq l (cdr l))) @@ -1434,22 +1436,22 @@ (set-window-buffer w (get-file-buffer (car l))) (bury-buffer b) ;; this puts "next <count>" in the ex-command history - (ex-fixup-history vip-last-ex-prompt ex-file)) + (ex-fixup-history viper-last-ex-prompt ex-file)) (error "Not that many undisplayed files"))))))) (defun ex-next-related-buffer (direction &optional no-recursion) - (vip-ring-rotate1 vip-related-files-and-buffers-ring direction) + (viper-ring-rotate1 viper-related-files-and-buffers-ring direction) (let ((file-or-buffer-name - (vip-current-ring-item vip-related-files-and-buffers-ring)) - (old-ring vip-related-files-and-buffers-ring) + (viper-current-ring-item viper-related-files-and-buffers-ring)) + (old-ring viper-related-files-and-buffers-ring) (old-win (selected-window)) skip-rest buf wind) - (or (and (ring-p vip-related-files-and-buffers-ring) - (> (ring-length vip-related-files-and-buffers-ring) 0)) + (or (and (ring-p viper-related-files-and-buffers-ring) + (> (ring-length viper-related-files-and-buffers-ring) 0)) (error "This buffer has no related files or buffers")) (or (stringp file-or-buffer-name) @@ -1461,10 +1463,10 @@ (find-file-noselect file-or-buffer-name)) )) - (if (not (vip-buffer-live-p buf)) + (if (not (viper-buffer-live-p buf)) (error "Didn't find buffer %S or file %S" file-or-buffer-name - (vip-abbreviate-file-name + (viper-abbreviate-file-name (expand-file-name file-or-buffer-name)))) (if (equal buf (current-buffer)) @@ -1477,12 +1479,12 @@ (if skip-rest () ;; setup buffer - (if (setq wind (vip-get-visible-buffer-window buf)) + (if (setq wind (viper-get-visible-buffer-window buf)) () - (setq wind (get-lru-window (if vip-xemacs-p nil 'visible))) + (setq wind (get-lru-window (if viper-xemacs-p nil 'visible))) (set-window-buffer wind buf)) - (if (vip-window-display-p) + (if (viper-window-display-p) (progn (raise-frame (window-frame wind)) (if (equal (window-frame wind) (window-frame old-win)) @@ -1492,9 +1494,9 @@ (save-excursion (set-buffer buf) - (setq vip-related-files-and-buffers-ring old-ring)) + (setq viper-related-files-and-buffers-ring old-ring)) - (setq vip-local-search-start-marker (point-marker)) + (setq viper-local-search-start-marker (point-marker)) ))) @@ -1506,10 +1508,10 @@ ;; Ex put (defun ex-put () (let ((point (if (null ex-addresses) (point) (car ex-addresses)))) - (vip-get-ex-buffer) - (setq vip-use-register ex-buffer) + (viper-get-ex-buffer) + (setq viper-use-register ex-buffer) (goto-char point) - (if (bobp) (vip-Put-back 1) (vip-put-back 1)))) + (if (bobp) (viper-Put-back 1) (viper-put-back 1)))) ;; Ex print working directory (defun ex-pwd () @@ -1519,8 +1521,8 @@ (defun ex-quit () ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc. (save-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (if (looking-at "!") (forward-char 1))) (if (< viper-expert-level 3) (save-buffers-kill-emacs) @@ -1529,35 +1531,35 @@ ;; Ex read command (defun ex-read () - (vip-get-ex-file) + (viper-get-ex-file) (let ((point (if (null ex-addresses) (point) (car ex-addresses))) command) (goto-char point) - (vip-add-newline-at-eob-if-necessary) + (viper-add-newline-at-eob-if-necessary) (if (not (or (bobp) (eobp))) (forward-line 1)) (if (and (not ex-variant) (string= ex-file "")) (progn (if (null buffer-file-name) - (error vip-NoFileSpecified)) + (error viper-NoFileSpecified)) (setq ex-file buffer-file-name))) (if ex-cmdfile (progn (setq command (ex-expand-filsyms ex-file (current-buffer))) (shell-command command t)) (insert-file-contents ex-file))) - (ex-fixup-history vip-last-ex-prompt ex-file)) + (ex-fixup-history viper-last-ex-prompt ex-file)) ;; this function fixes ex-history for some commands like ex-read, ex-edit (defun ex-fixup-history (&rest args) - (setq vip-ex-history - (cons (mapconcat 'identity args " ") (cdr vip-ex-history)))) + (setq viper-ex-history + (cons (mapconcat 'identity args " ") (cdr viper-ex-history)))) ;; Ex recover from emacs \#file\# (defun ex-recover () - (vip-get-ex-file) + (viper-get-ex-file) (if (or ex-append ex-offset) - (error "`recover': %s" vip-SpuriousText)) + (error "`recover': %s" viper-SpuriousText)) (if (string= ex-file "") (progn (if (null buffer-file-name) @@ -1585,11 +1587,11 @@ (define-key minibuffer-local-completion-map " " 'minibuffer-complete-and-exit) (define-key minibuffer-local-completion-map "=" 'exit-minibuffer) - (if (vip-set-unread-command-events + (if (viper-set-unread-command-events (ex-get-inline-cmd-args "[ \t]*[a-zA-Z]*[ \t]*" nil "\C-m")) (progn (setq batch t) - (vip-set-unread-command-events ?\C-m))) + (viper-set-unread-command-events ?\C-m))) (message ":set <Variable> [= <Value>]") (or batch (sit-for 2)) @@ -1598,7 +1600,7 @@ (completing-read ":set " ex-variable-alist))) (message ":set <Variable> [= <Value>]") ;; if there are unread events, don't wait - (or (vip-set-unread-command-events "") (sit-for 2)) + (or (viper-set-unread-command-events "") (sit-for 2)) ) ; while str)) @@ -1610,7 +1612,7 @@ (ask-if-save t) (auto-cmd-label "; don't touch or else...") (delete-turn-on-auto-fill-pattern - "([ \t]*add-hook[ \t]+'vip-insert-state-hooks[ \t]+'turn-on-auto-fill.*)") + "([ \t]*add-hook[ \t]+'viper-insert-state-hooks[ \t]+'turn-on-auto-fill.*)") actual-lisp-cmd lisp-cmd-del-pattern val2 orig-var) (setq orig-var var) @@ -1618,35 +1620,35 @@ (setq ask-if-save nil set-cmd nil)) ((member var '("ai" "autoindent")) - (setq var "vip-auto-indent" + (setq var "viper-auto-indent" set-cmd "setq" ask-if-save nil val "t")) ((member var '("ai-g" "autoindent-global")) - (kill-local-variable 'vip-auto-indent) - (setq var "vip-auto-indent" + (kill-local-variable 'viper-auto-indent) + (setq var "viper-auto-indent" set-cmd "setq-default" val "t")) ((member var '("noai" "noautoindent")) - (setq var "vip-auto-indent" + (setq var "viper-auto-indent" ask-if-save nil val "nil")) ((member var '("noai-g" "noautoindent-global")) - (kill-local-variable 'vip-auto-indent) - (setq var "vip-auto-indent" + (kill-local-variable 'viper-auto-indent) + (setq var "viper-auto-indent" set-cmd "setq-default" val "nil")) ((member var '("ic" "ignorecase")) - (setq var "vip-case-fold-search" + (setq var "viper-case-fold-search" val "t")) ((member var '("noic" "noignorecase")) - (setq var "vip-case-fold-search" + (setq var "viper-case-fold-search" val "nil")) ((member var '("ma" "magic")) - (setq var "vip-re-search" + (setq var "viper-re-search" val "t")) ((member var '("noma" "nomagic")) - (setq var "vip-re-search" + (setq var "viper-re-search" val "nil")) ((member var '("ro" "readonly")) (setq var "buffer-read-only" @@ -1661,16 +1663,16 @@ (setq var "blink-matching-paren" val "nil")) ((member var '("ws" "wrapscan")) - (setq var "vip-search-wrap-around-t" + (setq var "viper-search-wrap-around-t" val "t")) ((member var '("nows" "nowrapscan")) - (setq var "vip-search-wrap-around-t" + (setq var "viper-search-wrap-around-t" val "nil"))) (if (and set-cmd (eq val 0)) ; value must be set by the user (let ((cursor-in-echo-area t)) (message ":set %s = <Value>" var) ;; if there are unread events, don't wait - (or (vip-set-unread-command-events "") (sit-for 2)) + (or (viper-set-unread-command-events "") (sit-for 2)) (setq val (read-string (format ":set %s = " var))) (ex-fixup-history "set" orig-var val) @@ -1688,7 +1690,7 @@ (cond ((member var '("sw" "shiftwidth")) - (setq var "vip-shift-width")) + (setq var "viper-shift-width")) ((member var '("ts" "tabstop")) ;; make it take effect in curr buff and new bufs (setq var "tab-width" @@ -1718,24 +1720,24 @@ (if (and ask-if-save (y-or-n-p (format "Do you want to save this setting in %s " - vip-custom-file-name))) + viper-custom-file-name))) (progn - (vip-save-string-in-file - actual-lisp-cmd vip-custom-file-name + (viper-save-string-in-file + actual-lisp-cmd viper-custom-file-name ;; del pattern lisp-cmd-del-pattern) (if (string= var "fill-column") (if (> val2 0) - (vip-save-string-in-file + (viper-save-string-in-file (concat - "(add-hook 'vip-insert-state-hooks 'turn-on-auto-fill) " + "(add-hook 'viper-insert-state-hooks 'turn-on-auto-fill) " auto-cmd-label) - vip-custom-file-name + viper-custom-file-name delete-turn-on-auto-fill-pattern) - (vip-save-string-in-file - nil vip-custom-file-name delete-turn-on-auto-fill-pattern) - (vip-save-string-in-file - nil vip-custom-file-name + (viper-save-string-in-file + nil viper-custom-file-name delete-turn-on-auto-fill-pattern) + (viper-save-string-in-file + nil viper-custom-file-name ;; del pattern lisp-cmd-del-pattern) )) @@ -1761,8 +1763,8 @@ ;; special meaning (defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str) (save-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (goto-char (point-min)) (re-search-forward regex-forw nil t) (let ((beg (point)) @@ -1778,7 +1780,7 @@ (if replace-str (while (re-search-forward " +" nil t) (replace-match replace-str nil t) - (vip-forward-char-carefully))) + (viper-forward-char-carefully))) (goto-char end) (buffer-substring beg end)))) @@ -1792,53 +1794,53 @@ (condition-case nil (progn (pop-to-buffer (get-buffer-create "*info*")) - (info (if vip-xemacs-p "viper.info" "viper")) + (info (if viper-xemacs-p "viper.info" "viper")) (message "Type `i' to search for a specific topic")) (error (beep 1) - (with-output-to-temp-buffer " *vip-info*" + (with-output-to-temp-buffer " *viper-info*" (princ (format " The Info file for Viper does not seem to be installed. This file is part of the standard distribution of %sEmacs. Please contact your system administrator. " - (if vip-xemacs-p "X" "") + (if viper-xemacs-p "X" "") )))))) -;; Ex source command. Loads the file specified as argument or `~/.vip' +;; Ex source command. Loads the file specified as argument or `~/.viper' (defun ex-source () - (vip-get-ex-file) + (viper-get-ex-file) (if (string= ex-file "") - (load vip-custom-file-name) + (load viper-custom-file-name) (load ex-file))) ;; Ex substitute command -;; If REPEAT use previous regexp which is ex-reg-exp or vip-s-string +;; If REPEAT use previous regexp which is ex-reg-exp or viper-s-string (defun ex-substitute (&optional repeat r-flag) (let ((opt-g nil) (opt-c nil) (matched-pos nil) - (case-fold-search vip-case-fold-search) + (case-fold-search viper-case-fold-search) delim pat repl) - (if repeat (setq ex-token nil) (setq delim (vip-get-ex-pat))) + (if repeat (setq ex-token nil) (setq delim (viper-get-ex-pat))) (if (null ex-token) (progn - (setq pat (if r-flag vip-s-string ex-reg-exp)) + (setq pat (if r-flag viper-s-string ex-reg-exp)) (or (stringp pat) (error "No previous pattern to use in substitution")) (setq repl ex-repl delim (string-to-char pat))) - (setq pat (if (string= ex-token "") vip-s-string ex-token)) - (setq vip-s-string pat + (setq pat (if (string= ex-token "") viper-s-string ex-token)) + (setq viper-s-string pat ex-reg-exp pat) - (setq delim (vip-get-ex-pat)) + (setq delim (viper-get-ex-pat)) (if (null ex-token) (setq ex-token "" ex-repl "") (setq repl ex-token ex-repl ex-token))) - (while (vip-get-ex-opt-gc delim) + (while (viper-get-ex-opt-gc delim) (if (string= ex-token "g") (setq opt-g t) (setq opt-c t))) - (vip-get-ex-count) + (viper-get-ex-count) (if ex-count (save-excursion (if ex-addresses (goto-char (car ex-addresses))) @@ -1854,7 +1856,7 @@ (end (car (cdr ex-addresses))) eol-mark) (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (let ((limit (save-excursion (goto-char (max (point) (mark t))) (point-marker)))) @@ -1874,7 +1876,7 @@ (error "Can't perform Ex substitution: No previous replacement pattern")) (replace-match repl t)))) (end-of-line) - (vip-forward-char-carefully)) + (viper-forward-char-carefully)) (if (null pat) (error "Can't repeat Ex substitution: No previous regular expression")) @@ -1886,7 +1888,7 @@ (error "Can't perform Ex substitution: No previous replacement pattern")) (replace-match repl t))) (end-of-line) - (vip-forward-char-carefully)))))) + (viper-forward-char-carefully)))))) (if matched-pos (goto-char matched-pos)) (beginning-of-line) (if opt-c (message "done")))) @@ -1895,28 +1897,28 @@ (defun ex-tag () (let (tag) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (set-mark (point)) (skip-chars-forward "^ |\t\n") (setq tag (buffer-substring (mark t) (point)))) (if (not (string= tag "")) (setq ex-tag tag)) - (vip-change-state-to-emacs) + (viper-change-state-to-emacs) (condition-case conds (progn (if (string= tag "") (find-tag ex-tag t) (find-tag-other-window ex-tag)) - (vip-change-state-to-vi)) + (viper-change-state-to-vi)) (error - (vip-change-state-to-vi) - (vip-message-conditions conds))))) + (viper-change-state-to-vi) + (viper-message-conditions conds))))) ;; Ex write command (defun ex-write (q-flag) - (vip-default-ex-addresses t) - (vip-get-ex-file) + (viper-default-ex-addresses t) + (viper-get-ex-file) (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))) (orig-buf (current-buffer)) @@ -1925,10 +1927,10 @@ (buff-changed-p (buffer-modified-p)) temp-buf writing-same-file region file-exists writing-whole-file) - (if (> beg end) (error vip-FirstAddrExceedsSecond)) + (if (> beg end) (error viper-FirstAddrExceedsSecond)) (if ex-cmdfile (progn - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (shell-command-on-region (point) (mark t) ex-file)) (if (and (string= ex-file "") (not (buffer-file-name))) (setq ex-file @@ -1987,7 +1989,7 @@ (t ; writing a region (unwind-protect (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (setq region (buffer-substring (point) (mark t))) ;; create temp buffer for the region (setq temp-buf (get-buffer-create " *ex-write*")) @@ -2022,19 +2024,19 @@ (defun ex-write-info (exists file-name beg end) (message "`%s'%s %d lines, %d characters" - (vip-abbreviate-file-name file-name) + (viper-abbreviate-file-name file-name) (if exists "" " [New file]") (count-lines beg (min (1+ end) (point-max))) (- end beg))) ;; Ex yank command (defun ex-yank () - (vip-default-ex-addresses) - (vip-get-ex-buffer) + (viper-default-ex-addresses) + (viper-get-ex-buffer) (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) - (if (> beg end) (error vip-FirstAddrExceedsSecond)) + (if (> beg end) (error viper-FirstAddrExceedsSecond)) (save-excursion - (vip-enlarge-region beg end) + (viper-enlarge-region beg end) (exchange-point-and-mark) (if (or ex-g-flag ex-g-variant) (error "Can't execute `yank' within `global'")) @@ -2043,32 +2045,33 @@ (set-mark (point)) (forward-line (1- ex-count))) (set-mark end)) - (vip-enlarge-region (point) (mark t)) - (if ex-flag (error "`yank': %s" vip-SpuriousText)) + (viper-enlarge-region (point) (mark t)) + (if ex-flag (error "`yank': %s" viper-SpuriousText)) (if ex-buffer - (cond ((vip-valid-register ex-buffer '(Letter)) - (vip-append-to-register + (cond ((viper-valid-register ex-buffer '(Letter)) + (viper-append-to-register (downcase ex-buffer) (point) (mark t))) - ((vip-valid-register ex-buffer) + ((viper-valid-register ex-buffer) (copy-to-register ex-buffer (point) (mark t) nil)) - (t (error vip-InvalidRegister ex-buffer)))) + (t (error viper-InvalidRegister ex-buffer)))) (copy-region-as-kill (point) (mark t))))) ;; Execute shell command (defun ex-command () (let (command) (save-window-excursion - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) - (set-buffer vip-ex-work-buf) + (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) + (set-buffer viper-ex-work-buf) (skip-chars-forward " \t") (setq command (buffer-substring (point) (point-max))) (end-of-line)) (setq command (ex-expand-filsyms command (current-buffer))) (if (and (> (length command) 0) (string= "!" (substring command 0 1))) - (if vip-ex-last-shell-com - (setq command (concat vip-ex-last-shell-com (substring command 1))) + (if viper-ex-last-shell-com + (setq command + (concat viper-ex-last-shell-com (substring command 1))) (error "No previous shell command"))) - (setq vip-ex-last-shell-com command) + (setq viper-ex-last-shell-com command) (if (null ex-addresses) (shell-command command) (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) @@ -2076,7 +2079,7 @@ (save-excursion (goto-char beg) (set-mark end) - (vip-enlarge-region (point) (mark t)) + (viper-enlarge-region (point) (mark t)) (shell-command-on-region (point) (mark t) command t)) (goto-char beg))))) @@ -2088,14 +2091,14 @@ (if (null ex-addresses) (point-max) (car ex-addresses)))))) ;; Give information on the file visited by the current buffer -(defun vip-info-on-file () +(defun viper-info-on-file () (interactive) - (let ((pos1 (vip-line-pos 'start)) - (pos2 (vip-line-pos 'end)) + (let ((pos1 (viper-line-pos 'start)) + (pos2 (viper-line-pos 'end)) lines file info) - (setq lines (count-lines (point-min) (vip-line-pos 'end)) + (setq lines (count-lines (point-min) (viper-line-pos 'end)) file (if (buffer-file-name) - (concat (vip-abbreviate-file-name (buffer-file-name)) ":") + (concat (viper-abbreviate-file-name (buffer-file-name)) ":") (concat (buffer-name) " [Not visiting any file]:")) info (format "line=%d/%d pos=%d/%d col=%d %s" (if (= pos1 pos2) @@ -2109,27 +2112,27 @@ (window-width (minibuffer-window))) (message (concat file " " info)) (save-window-excursion - (with-output-to-temp-buffer " *vip-info*" + (with-output-to-temp-buffer " *viper-info*" (princ (concat "\n" file "\n\n\t" info "\n\n\nPress any key to continue...\n\n"))) - (vip-read-event) - (kill-buffer " *vip-info*"))) + (viper-read-event) + (kill-buffer " *viper-info*"))) )) ;; display all variables set through :set (defun ex-show-vars () - (with-output-to-temp-buffer " *vip-info*" - (princ (if vip-auto-indent + (with-output-to-temp-buffer " *viper-info*" + (princ (if viper-auto-indent "autoindent (local)\n" "noautoindent (local)\n")) - (princ (if (default-value 'vip-auto-indent) + (princ (if (default-value 'viper-auto-indent) "autoindent (global) \n" "noautoindent (global) \n")) - (princ (if vip-case-fold-search "ignorecase\n" "noignorecase\n")) - (princ (if vip-re-search "magic\n" "nomagic\n")) + (princ (if viper-case-fold-search "ignorecase\n" "noignorecase\n")) + (princ (if viper-re-search "magic\n" "nomagic\n")) (princ (if buffer-read-only "readonly\n" "noreadonly\n")) (princ (if blink-matching-paren "showmatch\n" "noshowmatch\n")) - (princ (if vip-search-wrap-around-t "wrapscan\n" "nowrapscan\n")) - (princ (format "shiftwidth \t\t= %S\n" vip-shift-width)) + (princ (if viper-search-wrap-around-t "wrapscan\n" "nowrapscan\n")) + (princ (format "shiftwidth \t\t= %S\n" viper-shift-width)) (princ (format "tabstop (local) \t= %S\n" tab-width)) (princ (format "tabstop (global) \t= %S\n" (default-value 'tab-width))) (princ (format "wrapmargin (local) \t= %S\n"
--- a/lisp/emulation/viper-init.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-init.el Sat Aug 02 07:40:22 1997 +0000 @@ -27,7 +27,6 @@ (defvar mark-even-if-inactive) (defvar viper-version) (defvar viper-expert-level) -(defvar vip-expert-level) ;; end pacifier @@ -35,33 +34,32 @@ (defun viper-version () (interactive) (message "Viper version is %s" viper-version)) -(defalias 'vip-version 'viper-version) ;; Is it XEmacs? -(defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version)) +(defconst viper-xemacs-p (string-match "XEmacs" emacs-version)) ;; Is it Emacs? -(defconst vip-emacs-p (not vip-xemacs-p)) +(defconst viper-emacs-p (not viper-xemacs-p)) ;; Tell whether we are running as a window application or on a TTY -(defsubst vip-device-type () - (if vip-emacs-p +(defsubst viper-device-type () + (if viper-emacs-p window-system (device-type (selected-device)))) ;; in XEmacs: device-type is tty on tty and stream in batch. -(defun vip-window-display-p () - (and (vip-device-type) (not (memq (vip-device-type) '(tty stream pc))))) +(defun viper-window-display-p () + (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc))))) -(defcustom vip-ms-style-os-p (memq system-type '(ms-dos windows-nt windows-95)) +(defcustom viper-ms-style-os-p (memq system-type '(ms-dos windows-nt windows-95)) "Tells if Emacs is running under an MS-style OS: ms-dos, windows-nt, W95." :type 'boolean :tag "Is it Microsoft-made OS?" :group 'viper) -(defcustom vip-vms-os-p (memq system-type '(vax-vms axp-vms)) +(defcustom viper-vms-os-p (memq system-type '(vax-vms axp-vms)) "Tells if Emacs is running under VMS." :type 'boolean :tag "Is it VMS?" :group 'viper) -(defcustom vip-force-faces nil +(defcustom viper-force-faces nil "If t, Viper will think that it is running on a display that supports faces. This is provided as a temporary relief for users of graphics-capable terminals that Viper doesn't know about. @@ -69,189 +67,183 @@ :type 'boolean :group 'viper) -(defun vip-has-face-support-p () - (cond ((vip-window-display-p)) - (vip-force-faces) - (vip-emacs-p (memq (vip-device-type) '(pc))) - (vip-xemacs-p (memq (vip-device-type) '(tty pc))))) - -(defun vip-convert-standard-file-name (fname) - (if vip-emacs-p - (convert-standard-filename fname) - ;; hopefully, XEmacs adds this functionality - fname)) +(defun viper-has-face-support-p () + (cond ((viper-window-display-p)) + (viper-force-faces) + (viper-emacs-p (memq (viper-device-type) '(pc))) + (viper-xemacs-p (memq (viper-device-type) '(tty pc))))) ;;; Macros -(defmacro vip-deflocalvar (var default-value &optional documentation) +(defmacro viper-deflocalvar (var default-value &optional documentation) (` (progn (defvar (, var) (, default-value) (, (format "%s\n\(buffer local\)" documentation))) (make-variable-buffer-local '(, var)) ))) -(defmacro vip-loop (count body) - "(vip-loop COUNT BODY) Execute BODY COUNT times." +(defmacro viper-loop (count body) + "(viper-loop COUNT BODY) Execute BODY COUNT times." (list 'let (list (list 'count count)) (list 'while '(> count 0) body '(setq count (1- count)) ))) -(defmacro vip-buffer-live-p (buf) +(defmacro viper-buffer-live-p (buf) (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) ;; return buffer-specific macro definition, given a full macro definition -(defmacro vip-kbd-buf-alist (macro-elt) +(defmacro viper-kbd-buf-alist (macro-elt) (` (nth 1 (, macro-elt)))) ;; get a pair: (curr-buffer . macro-definition) -(defmacro vip-kbd-buf-pair (macro-elt) - (` (assoc (buffer-name) (vip-kbd-buf-alist (, macro-elt))))) +(defmacro viper-kbd-buf-pair (macro-elt) + (` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt))))) ;; get macro definition for current buffer -(defmacro vip-kbd-buf-definition (macro-elt) - (` (cdr (vip-kbd-buf-pair (, macro-elt))))) +(defmacro viper-kbd-buf-definition (macro-elt) + (` (cdr (viper-kbd-buf-pair (, macro-elt))))) ;; return mode-specific macro definitions, given a full macro definition -(defmacro vip-kbd-mode-alist (macro-elt) +(defmacro viper-kbd-mode-alist (macro-elt) (` (nth 2 (, macro-elt)))) ;; get a pair: (major-mode . macro-definition) -(defmacro vip-kbd-mode-pair (macro-elt) - (` (assoc major-mode (vip-kbd-mode-alist (, macro-elt))))) +(defmacro viper-kbd-mode-pair (macro-elt) + (` (assoc major-mode (viper-kbd-mode-alist (, macro-elt))))) ;; get macro definition for the current major mode -(defmacro vip-kbd-mode-definition (macro-elt) - (` (cdr (vip-kbd-mode-pair (, macro-elt))))) +(defmacro viper-kbd-mode-definition (macro-elt) + (` (cdr (viper-kbd-mode-pair (, macro-elt))))) ;; return global macro definition, given a full macro definition -(defmacro vip-kbd-global-pair (macro-elt) +(defmacro viper-kbd-global-pair (macro-elt) (` (nth 3 (, macro-elt)))) ;; get global macro definition from an elt of macro-alist -(defmacro vip-kbd-global-definition (macro-elt) - (` (cdr (vip-kbd-global-pair (, macro-elt))))) +(defmacro viper-kbd-global-definition (macro-elt) + (` (cdr (viper-kbd-global-pair (, macro-elt))))) ;; last elt of a sequence -(defsubst vip-seq-last-elt (seq) +(defsubst viper-seq-last-elt (seq) (elt seq (1- (length seq)))) -(defvar vip-minibuffer-overlay-priority 300) -(defvar vip-replace-overlay-priority 400) -(defvar vip-search-overlay-priority 500) +(defvar viper-minibuffer-overlay-priority 300) +(defvar viper-replace-overlay-priority 400) +(defvar viper-search-overlay-priority 500) ;;; Viper minor modes ;; Mode for vital things like \e, C-z. -(vip-deflocalvar vip-vi-intercept-minor-mode nil) +(viper-deflocalvar viper-vi-intercept-minor-mode nil) -(vip-deflocalvar vip-vi-basic-minor-mode nil +(viper-deflocalvar viper-vi-basic-minor-mode nil "Viper's minor mode for Vi bindings.") -(vip-deflocalvar vip-vi-local-user-minor-mode nil +(viper-deflocalvar viper-vi-local-user-minor-mode nil "Auxiliary minor mode for user-defined local bindings in Vi state.") -(vip-deflocalvar vip-vi-global-user-minor-mode nil +(viper-deflocalvar viper-vi-global-user-minor-mode nil "Auxiliary minor mode for user-defined global bindings in Vi state.") -(vip-deflocalvar vip-vi-state-modifier-minor-mode nil +(viper-deflocalvar viper-vi-state-modifier-minor-mode nil "Minor mode used to make major-mode-specific modification to Vi state.") -(vip-deflocalvar vip-vi-diehard-minor-mode nil +(viper-deflocalvar viper-vi-diehard-minor-mode nil "This minor mode is in effect when the user wants Viper to be Vi.") -(vip-deflocalvar vip-vi-kbd-minor-mode nil +(viper-deflocalvar viper-vi-kbd-minor-mode nil "Minor mode for Ex command macros in Vi state. The corresponding keymap stores key bindings of Vi macros defined with the Ex command :map.") ;; Mode for vital things like \e, C-z. -(vip-deflocalvar vip-insert-intercept-minor-mode nil) +(viper-deflocalvar viper-insert-intercept-minor-mode nil) -(vip-deflocalvar vip-insert-basic-minor-mode nil +(viper-deflocalvar viper-insert-basic-minor-mode nil "Viper's minor mode for bindings in Insert mode.") -(vip-deflocalvar vip-insert-local-user-minor-mode nil +(viper-deflocalvar viper-insert-local-user-minor-mode nil "Auxiliary minor mode for buffer-local user-defined bindings in Insert state. This is a way to overshadow normal Insert mode bindings locally to certain designated buffers.") -(vip-deflocalvar vip-insert-global-user-minor-mode nil +(viper-deflocalvar viper-insert-global-user-minor-mode nil "Auxiliary minor mode for global user-defined bindings in Insert state.") -(vip-deflocalvar vip-insert-state-modifier-minor-mode nil +(viper-deflocalvar viper-insert-state-modifier-minor-mode nil "Minor mode used to make major-mode-specific modification to Insert state.") -(vip-deflocalvar vip-insert-diehard-minor-mode nil +(viper-deflocalvar viper-insert-diehard-minor-mode nil "Minor mode that simulates Vi very closely. Not recommened, except for the novice user.") -(vip-deflocalvar vip-insert-kbd-minor-mode nil +(viper-deflocalvar viper-insert-kbd-minor-mode nil "Minor mode for Ex command macros Insert state. The corresponding keymap stores key bindings of Vi macros defined with the Ex command :map!.") -(vip-deflocalvar vip-replace-minor-mode nil +(viper-deflocalvar viper-replace-minor-mode nil "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 t, by default. So, any new buffer will have C-z defined as ;; switch to Vi, unless we switched states in this buffer -(vip-deflocalvar vip-emacs-intercept-minor-mode t) +(viper-deflocalvar viper-emacs-intercept-minor-mode t) -(vip-deflocalvar vip-emacs-local-user-minor-mode t +(viper-deflocalvar viper-emacs-local-user-minor-mode t "Minor mode for local user bindings effective in Emacs state. Users can use it to override Emacs bindings when Viper is in its Emacs state.") -(vip-deflocalvar vip-emacs-global-user-minor-mode t +(viper-deflocalvar viper-emacs-global-user-minor-mode t "Minor mode for global user bindings in effect in Emacs state. Users can use it to override Emacs bindings when Viper is in its Emacs state.") -(vip-deflocalvar vip-emacs-kbd-minor-mode t +(viper-deflocalvar viper-emacs-kbd-minor-mode t "Minor mode for Vi style macros in Emacs state. The corresponding keymap stores key bindings of Vi macros defined with -`vip-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.") -(vip-deflocalvar vip-emacs-state-modifier-minor-mode t +(viper-deflocalvar viper-emacs-state-modifier-minor-mode t "Minor mode used to make major-mode-specific modification to Emacs state. For instance, a Vi purist may want to bind `dd' in Dired mode to a function that deletes a file.") -(vip-deflocalvar vip-vi-minibuffer-minor-mode nil +(viper-deflocalvar viper-vi-minibuffer-minor-mode nil "Minor mode that forces Vi-style when the Minibuffer is in Vi state.") -(vip-deflocalvar vip-insert-minibuffer-minor-mode nil +(viper-deflocalvar viper-insert-minibuffer-minor-mode nil "Minor mode that forces Vi-style when the Minibuffer is in Insert state.") ;; Some common error messages -(defconst vip-SpuriousText "Spurious text after command" "") -(defconst vip-BadExCommand "Not an editor command" "") -(defconst vip-InvalidCommandArgument "Invalid command argument" "") -(defconst vip-NoPrevSearch "No previous search string" "") -(defconst vip-EmptyRegister "`%c': Nothing in this register" "") -(defconst vip-InvalidRegister "`%c': Invalid register" "") -(defconst vip-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "") -(defconst vip-InvalidTextmarker "`%c': Invalid text marker" "") -(defconst vip-InvalidViCommand "Invalid command" "") -(defconst vip-BadAddress "Ill-formed address" "") -(defconst vip-FirstAddrExceedsSecond "First address exceeds second" "") -(defconst vip-NoFileSpecified "No file specified" "") +(defconst viper-SpuriousText "Spurious text after command" "") +(defconst viper-BadExCommand "Not an editor command" "") +(defconst viper-InvalidCommandArgument "Invalid command argument" "") +(defconst viper-NoPrevSearch "No previous search string" "") +(defconst viper-EmptyRegister "`%c': Nothing in this register" "") +(defconst viper-InvalidRegister "`%c': Invalid register" "") +(defconst viper-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "") +(defconst viper-InvalidTextmarker "`%c': Invalid text marker" "") +(defconst viper-InvalidViCommand "Invalid command" "") +(defconst viper-BadAddress "Ill-formed address" "") +(defconst viper-FirstAddrExceedsSecond "First address exceeds second" "") +(defconst viper-NoFileSpecified "No file specified" "") ;; Is t until viper-mode executes for the very first time. ;; Prevents recursive descend into startup messages. -(defvar vip-first-time t) +(defvar viper-first-time t) -(defvar viper-expert-level (if (boundp 'vip-expert-level) vip-expert-level 0) +(defvar viper-expert-level (if (boundp 'viper-expert-level) viper-expert-level 0) "User's expert level. -The minor mode vip-vi-diehard-minor-mode is in effect when -viper-expert-level is 1 or 2 or when vip-want-emacs-keys-in-vi is t. -The minor mode vip-insert-diehard-minor-mode is in effect when -viper-expert-level is 1 or 2 or if vip-want-emacs-keys-in-insert is t. +The minor mode viper-vi-diehard-minor-mode is in effect when +viper-expert-level is 1 or 2 or when viper-want-emacs-keys-in-vi is t. +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. @@ -261,8 +253,8 @@ ;;; ISO characters -(vip-deflocalvar vip-automatic-iso-accents nil "") -(defcustom vip-automatic-iso-accents nil +(viper-deflocalvar viper-automatic-iso-accents nil "") +(defcustom viper-automatic-iso-accents nil "*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." @@ -273,15 +265,15 @@ ;; VI-style Undo ;; Used to 'undo' complex commands, such as replace and insert commands. -(vip-deflocalvar vip-undo-needs-adjustment nil) -(put 'vip-undo-needs-adjustment 'permanent-local t) +(viper-deflocalvar viper-undo-needs-adjustment nil) +(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 -;; erased by vip-change-state-to-vi and vip-repeat. -(defconst vip-buffer-undo-list-mark 'viper) +;; erased by viper-change-state-to-vi and viper-repeat. +(defconst viper-buffer-undo-list-mark 'viper) -(defcustom vip-keep-point-on-undo nil +(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 it better fits your working style." @@ -291,20 +283,26 @@ ;; Replace mode and changing text -;; Viper's own after/before change functions, which get vip-add-hook'ed to +;; Viper's own after/before change functions, which get viper-add-hook'ed to ;; Emacs's -(vip-deflocalvar vip-after-change-functions nil "") -(vip-deflocalvar vip-before-change-functions nil "") -(vip-deflocalvar vip-post-command-hooks nil "") -(vip-deflocalvar vip-pre-command-hooks nil "") +(viper-deflocalvar viper-after-change-functions nil "") +(viper-deflocalvar viper-before-change-functions nil "") +(viper-deflocalvar viper-post-command-hooks nil "") +(viper-deflocalvar viper-pre-command-hooks nil "") ;; Can be used to pass global states around for short period of time -(vip-deflocalvar vip-intermediate-command nil "") +(viper-deflocalvar viper-intermediate-command nil "") + +;; 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/" +(defconst viper-this-command-keys nil) ;; Indicates that the current destructive command has started in replace mode. -(vip-deflocalvar vip-began-as-replace nil "") +(viper-deflocalvar viper-began-as-replace nil "") -(defcustom vip-allow-multiline-replace-regions t +(defcustom viper-allow-multiline-replace-regions t "If non-nil, Viper will allow multi-line replace regions. This is an extension to standard Vi. If nil, commands that attempt to replace text spanning multiple lines first @@ -312,114 +310,114 @@ :type 'boolean :group 'viper) -(defcustom vip-replace-overlay-cursor-color "Red" +(defcustom viper-replace-overlay-cursor-color "Red" "*Cursor color when Viper is in Replace state." :type 'string :group 'viper) -(defcustom vip-insert-state-cursor-color "Green" +(defcustom viper-insert-state-cursor-color "Green" "Cursor color when Viper is in insert state." :type 'string :group 'viper) ;; place to save cursor colow when switching to insert mode -(vip-deflocalvar vip-saved-cursor-color nil "") +(viper-deflocalvar viper-saved-cursor-color nil "") -(vip-deflocalvar vip-replace-overlay nil "") -(put 'vip-replace-overlay 'permanent-local t) +(viper-deflocalvar viper-replace-overlay nil "") +(put 'viper-replace-overlay 'permanent-local t) -(defcustom vip-replace-overlay-pixmap "gray3" +(defcustom viper-replace-overlay-pixmap "gray3" "Pixmap to use for search face on non-color displays." :type 'string :group 'viper) -(defcustom vip-search-face-pixmap "gray3" +(defcustom viper-search-face-pixmap "gray3" "Pixmap to use for search face on non-color displays." :type 'string :group 'viper) -(defcustom vip-replace-region-end-delimiter "$" +(defcustom viper-replace-region-end-delimiter "$" "A string marking the end of replacement regions. -It is used only with TTYs or if `vip-use-replace-region-delimiters' +It is used only with TTYs or if `viper-use-replace-region-delimiters' is non-nil." :type 'string :group 'viper) -(defcustom vip-replace-region-start-delimiter "" +(defcustom viper-replace-region-start-delimiter "" "A string marking the beginning of replacement regions. -It is used only with TTYs or if `vip-use-replace-region-delimiters' +It is used only with TTYs or if `viper-use-replace-region-delimiters' is non-nil." :type 'string :group 'viper) -(defcustom vip-use-replace-region-delimiters (not (vip-has-face-support-p)) - "*If non-nil, Viper will always use `vip-replace-region-end-delimiter' and -`vip-replace-region-start-delimiter' to delimit replacement regions, even on +(defcustom viper-use-replace-region-delimiters (not (viper-has-face-support-p)) + "*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." :type 'boolean :group 'viper) ;; XEmacs requires glyphs -(if vip-xemacs-p +(if viper-xemacs-p (progn - (or (glyphp vip-replace-region-end-delimiter) - (setq vip-replace-region-end-delimiter - (make-glyph vip-replace-region-end-delimiter))) - (or (glyphp vip-replace-region-start-delimiter) - (setq vip-replace-region-start-delimiter - (make-glyph vip-replace-region-start-delimiter))) + (or (glyphp viper-replace-region-end-delimiter) + (setq viper-replace-region-end-delimiter + (make-glyph viper-replace-region-end-delimiter))) + (or (glyphp viper-replace-region-start-delimiter) + (setq viper-replace-region-start-delimiter + (make-glyph viper-replace-region-start-delimiter))) )) ;; These are local marker that must be initialized to nil and moved with -;; `vip-move-marker-locally' +;; `viper-move-marker-locally' ;; ;; Remember the last position inside the replace region. -(vip-deflocalvar vip-last-posn-in-replace-region nil) +(viper-deflocalvar viper-last-posn-in-replace-region nil) ;; Remember the last position while inserting -(vip-deflocalvar vip-last-posn-while-in-insert-state nil) -(put 'vip-last-posn-in-replace-region 'permanent-local t) -(put 'vip-last-posn-while-in-insert-state 'permanent-local t) +(viper-deflocalvar viper-last-posn-while-in-insert-state nil) +(put 'viper-last-posn-in-replace-region 'permanent-local t) +(put 'viper-last-posn-while-in-insert-state 'permanent-local t) -(vip-deflocalvar vip-sitting-in-replace nil "") -(put 'vip-sitting-in-replace 'permanent-local t) +(viper-deflocalvar viper-sitting-in-replace nil "") +(put 'viper-sitting-in-replace 'permanent-local t) ;; Remember the number of characters that have to be deleted in replace ;; mode to compensate for the inserted characters. -(vip-deflocalvar vip-replace-chars-to-delete 0 "") -(vip-deflocalvar vip-replace-chars-deleted 0 "") +(viper-deflocalvar viper-replace-chars-to-delete 0 "") +(viper-deflocalvar viper-replace-chars-deleted 0 "") ;; Insertion ring and command ring -(defcustom vip-insertion-ring-size 14 +(defcustom viper-insertion-ring-size 14 "The size of history of inserted text. This is a list where Viper keeps the history of previously inserted pieces of text." :type 'integer :group 'viper) ;; The insertion ring. -(defvar vip-insertion-ring nil) +(defvar viper-insertion-ring nil) ;; This is temp insertion ring. Used to do rotation for display purposes. -;; When rotation just started, it is initialized to vip-insertion-ring. -(defvar vip-temp-insertion-ring nil) -(defvar vip-last-inserted-string-from-insertion-ring "") +;; 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 "") -(defcustom vip-command-ring-size 14 +(defcustom viper-command-ring-size 14 "The size of history of Vi commands repeatable with dot." :type 'integer :group 'viper) ;; The command ring. -(defvar vip-command-ring nil) +(defvar viper-command-ring nil) ;; This is temp command ring. Used to do rotation for display purposes. -;; When rotation just started, it is initialized to vip-command-ring. -(defvar vip-temp-command-ring nil) +;; When rotation just started, it is initialized to viper-command-ring. +(defvar viper-temp-command-ring nil) ;; Fast keyseq and ESC keyseq timeouts -(defcustom vip-fast-keyseq-timeout 200 +(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 will make it hard to use Vi-stile timeout macros." :type 'integer :group 'viper) -(defcustom vip-ESC-keyseq-timeout (if (vip-window-display-p) - 0 vip-fast-keyseq-timeout) +(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 this value too low will make it impossible to use function keys in insert mode @@ -430,29 +428,29 @@ ;; Modes and related variables ;; Current mode. One of: `emacs-state', `vi-state', `insert-state' -(vip-deflocalvar vip-current-state 'emacs-state) +(viper-deflocalvar viper-current-state 'emacs-state) ;; Autoindent in insert ;; Variable that keeps track of whether C-t has been pressed. -(vip-deflocalvar vip-cted nil "") +(viper-deflocalvar viper-cted nil "") ;; Preserve the indent value, used by C-d in insert mode. -(vip-deflocalvar vip-current-indent 0) +(viper-deflocalvar viper-current-indent 0) ;; Whether to preserve the indent, used by C-d in insert mode. -(vip-deflocalvar vip-preserve-indent nil) +(viper-deflocalvar viper-preserve-indent nil) -(vip-deflocalvar vip-auto-indent nil "") -(defcustom vip-auto-indent nil +(viper-deflocalvar viper-auto-indent nil "") +(defcustom viper-auto-indent nil "*Enable autoindent, if t. This is a buffer-local variable." :type 'boolean :group 'viper) -(vip-deflocalvar vip-electric-mode t "") -(defcustom vip-electric-mode t +(viper-deflocalvar viper-electric-mode t "") +(defcustom viper-electric-mode t "*If t, electrify Viper. Currently, this only electrifies auto-indentation, making it appropriate to the mode of the buffer. @@ -462,14 +460,14 @@ :type 'boolean :group 'viper) -(defcustom vip-shift-width 8 +(defcustom viper-shift-width 8 "*The shiftwidth variable." :type 'integer :group 'viper) ;; Variables for repeating destructive commands -(defcustom vip-keep-point-on-repeat t +(defcustom viper-keep-point-on-repeat t "*If t, don't move point when repeating previous command. This is useful for doing repeated changes with the '.' key. The user can change this to nil, if she likes when the cursor moves @@ -478,40 +476,40 @@ :group 'viper) ;; Remember insert point as a marker. This is a local marker that must be -;; initialized to nil and moved with `vip-move-marker-locally'. -(vip-deflocalvar vip-insert-point nil) -(put 'vip-insert-point 'permanent-local t) +;; initialized to nil and moved with `viper-move-marker-locally'. +(viper-deflocalvar viper-insert-point nil) +(put 'viper-insert-point 'permanent-local t) ;; This remembers the point before dabbrev-expand was called. -;; If vip-insert-point turns out to be bigger than that, it is reset -;; back to vip-pre-command-point. +;; If viper-insert-point turns out to be bigger than that, it is reset +;; 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 -;; If dabbrev-expand is called after `blo' and ^ undicates vip-insert-point, +;; 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 ;; will insert the expansion, and we get: blablo^ ;; Whatever we insert next goes before the ^, i.e., before the -;; vip-insert-point marker. So, Viper will think that nothing was +;; 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 ;; discovered later. ;; -(vip-deflocalvar vip-pre-command-point nil) -(put 'vip-pre-command-point 'permanent-local t) ; this is probably an overkill +(viper-deflocalvar viper-pre-command-point nil) +(put 'viper-pre-command-point 'permanent-local t) ; this is probably an overkill ;; This is used for saving inserted text. -(defvar vip-last-insertion nil) +(defvar viper-last-insertion nil) ;; Remembers the last replaced region. -(defvar vip-last-replace-region "") +(defvar viper-last-replace-region "") ;; Remember com point as a marker. -;; This is a local marker. Should be moved with `vip-move-marker-locally' -(vip-deflocalvar vip-com-point nil) +;; 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) ;; It is used to re-execute last destructive command. @@ -523,53 +521,53 @@ ;; INSERTED-TEXT is text inserted by that command (in case of o, c, C, i, r ;; commands). ;; COMMAND-KEYS are the keys that were typed to invoke the command. -(defvar vip-d-com nil) +(defvar viper-d-com nil) ;; The character remembered by the Vi `r' command. -(defvar vip-d-char nil) +(defvar viper-d-char nil) ;; Name of register to store deleted or yanked strings -(defvar vip-use-register nil) +(defvar viper-use-register nil) ;; Variables for Moves and Searches ;; For use by `;' command. -(defvar vip-f-char nil) +(defvar viper-f-char nil) ;; For use by `.' command. -(defvar vip-F-char nil) +(defvar viper-F-char nil) ;; For use by `;' command. -(defvar vip-f-forward nil) +(defvar viper-f-forward nil) ;; For use by `;' command. -(defvar vip-f-offset nil) +(defvar viper-f-offset nil) ;; Last search string -(defvar vip-s-string "") +(defvar viper-s-string "") -(defcustom vip-quote-string "> " +(defcustom viper-quote-string "> " "String inserted at the beginning of quoted region." :type 'string :group 'viper) ;; If t, search is forward. -(defvar vip-s-forward nil) +(defvar viper-s-forward nil) -(defcustom vip-case-fold-search nil +(defcustom viper-case-fold-search nil "*If not nil, search ignores cases." :type 'boolean :group 'viper) -(defcustom vip-re-search t +(defcustom viper-re-search t "*If not nil, search is regexp search, otherwise vanilla search." :type 'boolean :tag "Regexp Search" :group 'viper) -(defcustom vip-search-scroll-threshold 2 +(defcustom viper-search-scroll-threshold 2 "*If search lands within this threshnold from the window top/bottom, the window will be scrolled up or down appropriately, to reveal context. If you want Viper search to behave as usual in Vi, set this variable to a @@ -577,81 +575,81 @@ :type 'boolean :group 'viper) -(defcustom vip-re-query-replace t +(defcustom viper-re-query-replace t "*If t then do regexp replace, if nil then do string replace." :type 'boolean :tag "Regexp Query Replace" :group 'viper) -(defcustom vip-re-replace t +(defcustom viper-re-replace t "*If t, do regexp replace. nil means do string replace." :type 'boolean :tag "Regexp Replace" :group 'viper) -(defcustom vip-parse-sexp-ignore-comments t +(defcustom viper-parse-sexp-ignore-comments t "*If t, `%' ignores the parentheses that occur inside comments." :type 'boolean :group 'viper) -(vip-deflocalvar vip-ex-style-motion t "") -(defcustom vip-ex-style-motion t +(viper-deflocalvar viper-ex-style-motion t "") +(defcustom viper-ex-style-motion t "*If t, the commands l,h do not cross lines, etc (Ex-style). If nil, these commands cross line boundaries." :type 'boolean :group 'viper) -(vip-deflocalvar vip-ex-style-editing-in-insert t "") -(defcustom vip-ex-style-editing-in-insert t +(viper-deflocalvar viper-ex-style-editing-in-insert t "") +(defcustom viper-ex-style-editing-in-insert t "*If t, `Backspace' and `Delete' don't cross line boundaries in insert, 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." :type 'boolean :group 'viper) -(vip-deflocalvar vip-ESC-moves-cursor-back vip-ex-style-editing-in-insert "") -(defcustom vip-ESC-moves-cursor-back nil +(viper-deflocalvar viper-ESC-moves-cursor-back viper-ex-style-editing-in-insert "") +(defcustom viper-ESC-moves-cursor-back nil "*If t, ESC moves cursor back when changing from insert to vi state. If nil, the cursor stays where it was." :type 'boolean :group 'viper) -(vip-deflocalvar vip-delete-backwards-in-replace nil "") -(defcustom vip-delete-backwards-in-replace nil +(viper-deflocalvar viper-delete-backwards-in-replace nil "") +(defcustom viper-delete-backwards-in-replace nil "*If t, DEL key will delete characters while moving the cursor backwards. If nil, the cursor will move backwards without deleting anything." :type 'boolean :group 'viper) -(defcustom vip-buffer-search-char nil +(defcustom viper-buffer-search-char nil "*Key used for buffer-searching. Must be a character type, e.g., ?g." :type '(choice (const nil) character) :group 'viper) -(defcustom vip-search-wrap-around-t t +(defcustom viper-search-wrap-around-t t "*If t, search wraps around." :type 'boolean :tag "Search Wraps Around" :group 'viper) -(vip-deflocalvar vip-related-files-and-buffers-ring nil "") -(defcustom vip-related-files-and-buffers-ring nil +(viper-deflocalvar viper-related-files-and-buffers-ring nil "") +(defcustom viper-related-files-and-buffers-ring nil "*List of file and buffer names that are considered to be related to the current buffer. Related buffers can be cycled through via :R and :P commands." :type 'boolean :group 'viper) -(put 'vip-related-files-and-buffers-ring 'permanent-local t) +(put 'viper-related-files-and-buffers-ring 'permanent-local t) ;; Used to find out if we are done with searching the current buffer. -(vip-deflocalvar vip-local-search-start-marker nil) +(viper-deflocalvar viper-local-search-start-marker nil) ;; As above, but global -(defvar vip-search-start-marker (make-marker)) +(defvar viper-search-start-marker (make-marker)) ;; the search overlay -(vip-deflocalvar vip-search-overlay nil) +(viper-deflocalvar viper-search-overlay nil) -(defvar vip-heading-start +(defvar viper-heading-start (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++ "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|" @@ -660,7 +658,7 @@ "^.+:-") ; prolog "*Regexps for Headings. Used by \[\[ and \]\].") -(defvar vip-heading-end +(defvar viper-heading-end (concat "^}\\|" ; C/C++ "^\\\\end{\\|" ; latex "^@end \\|" ; texinfo @@ -675,106 +673,102 @@ ;; inside the lines. ;; Remembers position of the last jump done using ``'. -(vip-deflocalvar vip-last-jump nil) +(viper-deflocalvar viper-last-jump nil) ;; Remembers position of the last jump done using `''. -(vip-deflocalvar vip-last-jump-ignore 0) +(viper-deflocalvar viper-last-jump-ignore 0) ;; History variables ;; History of search strings. -(defvar vip-search-history (list "")) +(defvar viper-search-history (list "")) ;; History of query-replace strings used as a source. -(defvar vip-replace1-history nil) +(defvar viper-replace1-history nil) ;; History of query-replace strings used as replacement. -(defvar vip-replace2-history nil) +(defvar viper-replace2-history nil) ;; History of region quoting strings. -(defvar vip-quote-region-history (list vip-quote-string)) +(defvar viper-quote-region-history (list viper-quote-string)) ;; History of Ex-style commands. -(defvar vip-ex-history nil) +(defvar viper-ex-history nil) ;; History of shell commands. -(defvar vip-shell-history nil) +(defvar viper-shell-history nil) ;; Last shell command. There are two of these, one for Ex (in viper-ex) ;; and one for Vi. ;; Last shell command executed with ! command. -(defvar vip-last-shell-com nil) +(defvar viper-last-shell-com nil) ;;; Miscellaneous -(defvar vip-inhibit-startup-message nil +(defvar viper-inhibit-startup-message nil "Whether Viper startup message should be inhibited.") -(defcustom vip-spell-function 'ispell-region +(defcustom viper-spell-function 'ispell-region "Spell function used by #s<move> command to spell." :type 'function :group 'viper) -(defcustom vip-tags-file-name "TAGS" +(defcustom viper-tags-file-name "TAGS" "The tags file used by Viper." :type 'string :group 'viper) -;; Indicates if we are in the middle of executing a command that takes another -;; command as an argument, e.g., cw, dw, etc. -(defvar vip-inside-command-argument-action nil) - ;; Minibuffer -(defcustom vip-vi-style-in-minibuffer t +(defcustom viper-vi-style-in-minibuffer t "If t, use vi-style editing in minibuffer. -Should be set in `~/.vip' file." +Should be set in `~/.viper' file." :type 'boolean :group 'viper) ;; overlay used in the minibuffer to indicate which state it is in -(vip-deflocalvar vip-minibuffer-overlay nil) +(viper-deflocalvar viper-minibuffer-overlay nil) ;; Hook, specific to Viper, which is run just *before* exiting the minibuffer. ;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run ;; *after* exiting the minibuffer -(defvar vip-minibuffer-exit-hook nil) +(defvar viper-minibuffer-exit-hook nil) ;; Mode line -(defconst vip-vi-state-id "<V> " +(defconst viper-vi-state-id "<V> " "Mode line tag identifying the Vi mode of Viper.") -(defconst vip-emacs-state-id "<E> " +(defconst viper-emacs-state-id "<E> " "Mode line tag identifying the Emacs mode of Viper.") -(defconst vip-insert-state-id "<I> " +(defconst viper-insert-state-id "<I> " "Mode line tag identifying the Insert mode of Viper.") -(defconst vip-replace-state-id "<R> " +(defconst viper-replace-state-id "<R> " "Mode line tag identifying the Replace mode of Viper.") -(defcustom vip-vi-state-hook nil +(defcustom viper-vi-state-hook nil "*Hooks run just before the switch to Vi mode is completed." :type 'hook :group 'viper) -(defcustom vip-insert-state-hook nil +(defcustom viper-insert-state-hook nil "*Hooks run just before the switch to Insert mode is completed." :type 'hook :group 'viper) -(defcustom vip-replace-state-hook nil +(defcustom viper-replace-state-hook nil "*Hooks run just before the switch to Replace mode is completed." :type 'hook :group 'viper) -(defcustom vip-emacs-state-hook nil +(defcustom viper-emacs-state-hook nil "*Hooks run just before the switch to Emacs mode is completed." :type 'hook :group 'viper) -(defcustom vip-load-hook nil +(defcustom viper-load-hook nil "Hooks run just after loading Viper." :type 'hook :group 'viper) ;;; Local Variables: -;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun) +;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) ;;; End: ;;; viper-ex.el ends here
--- a/lisp/emulation/viper-keym.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-keym.el Sat Aug 02 07:40:22 1997 +0000 @@ -25,11 +25,11 @@ ;; compiler pacifier (defvar viper-always) -(defvar vip-current-state) -(defvar vip-mode-string) +(defvar viper-current-state) +(defvar viper-mode-string) (defvar viper-expert-level) -(defvar vip-ex-style-editing-in-insert) -(defvar vip-ex-style-motion) +(defvar viper-ex-style-editing-in-insert) +(defvar viper-ex-style-motion) ;; loading happens only in non-interactive compilation ;; in order to spare non-viperized emacs from being viperized @@ -46,43 +46,43 @@ ;;; Variables -(defvar vip-toggle-key "\C-z" +(defvar viper-toggle-key "\C-z" "The key used to change states from emacs to Vi and back. In insert mode, this key also functions as Meta. -Must be set in .vip file or prior to loading Viper. +Must be set in .viper file or prior to loading Viper. This setting cannot be changed interactively.") -(defvar vip-ESC-key "\e" +(defvar viper-ESC-key "\e" "Key used to ESC. -Must be set in .vip file or prior to loading Viper. +Must be set in .viper file or prior to loading Viper. This setting cannot be changed interactively.") ;;; Emacs keys in other states. -(defcustom vip-want-emacs-keys-in-insert t +(defcustom viper-want-emacs-keys-in-insert t "*Set to nil if you want complete Vi compatibility in insert mode. Complete compatibility with Vi is not recommended for power use of Viper." :type 'boolean :group 'viper) -(defcustom vip-want-emacs-keys-in-vi t +(defcustom viper-want-emacs-keys-in-vi t "*Set to nil if you want complete Vi compatibility in Vi mode. Full Vi compatibility is not recommended for power use of Viper." :type 'boolean :group 'viper) -(defcustom vip-no-multiple-ESC t +(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 enables cursor keys and is generally more convenient, as terminals usually don't have a convenient Meta key. -Setting vip-no-multiple-ESC to nil will allow as many multiple ESC, +Setting viper-no-multiple-ESC to nil will allow as many multiple ESC, as is allowed by the major mode in effect." :type 'boolean :group 'viper) -(defcustom vip-want-ctl-h-help nil +(defcustom viper-want-ctl-h-help nil "*If t then C-h is bound to help-command in insert mode, if nil then it is bound to delete-backward-char." :type 'boolean @@ -93,76 +93,76 @@ ;; Keymaps for vital things like \e and C-z. ;; Not for users -(defvar vip-vi-intercept-map (make-sparse-keymap)) -(defvar vip-insert-intercept-map (make-sparse-keymap)) -(defvar vip-emacs-intercept-map (make-sparse-keymap)) +(defvar viper-vi-intercept-map (make-sparse-keymap)) +(defvar viper-insert-intercept-map (make-sparse-keymap)) +(defvar viper-emacs-intercept-map (make-sparse-keymap)) ;; keymap used to zap all keymaps other than function-key-map, ;; device-function-key-map, etc. -(defvar vip-overriding-map (make-sparse-keymap)) +(defvar viper-overriding-map (make-sparse-keymap)) -(vip-deflocalvar vip-vi-local-user-map (make-sparse-keymap) +(viper-deflocalvar viper-vi-local-user-map (make-sparse-keymap) "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 to save-buffers-kill-emacs then post article, etc.") -(put 'vip-vi-local-user-map 'permanent-local t) +(put 'viper-vi-local-user-map 'permanent-local t) -(defvar vip-vi-global-user-map (make-sparse-keymap) +(defvar viper-vi-global-user-map (make-sparse-keymap) "Keymap for user-defined global bindings. These bindings are seen in all Viper buffers.") -(defvar vip-vi-basic-map (make-keymap) +(defvar viper-vi-basic-map (make-keymap) "This is the main keymap in effect in Viper's Vi state. This map is global, shared by all buffers.") -(defvar vip-vi-kbd-map (make-sparse-keymap) +(defvar viper-vi-kbd-map (make-sparse-keymap) "This keymap keeps keyboard macros defined via the :map command.") -(defvar vip-vi-diehard-map (make-sparse-keymap) +(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.") -(vip-deflocalvar vip-insert-local-user-map (make-sparse-keymap) +(viper-deflocalvar viper-insert-local-user-map (make-sparse-keymap) "Auxiliary map for per-buffer user-defined keybindings in Insert state.") -(put 'vip-insert-local-user-map 'permanent-local t) +(put 'viper-insert-local-user-map 'permanent-local t) -(defvar vip-insert-global-user-map (make-sparse-keymap) +(defvar viper-insert-global-user-map (make-sparse-keymap) "Auxiliary map for global user-defined bindings in Insert state.") -(defvar vip-insert-basic-map (make-sparse-keymap) +(defvar viper-insert-basic-map (make-sparse-keymap) "The basic insert-mode keymap.") -(defvar vip-insert-diehard-map (make-keymap) +(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 -vip-insert-basic-map. Not recommended, except for novice users.") +viper-insert-basic-map. Not recommended, except for novice users.") -(defvar vip-insert-kbd-map (make-sparse-keymap) +(defvar viper-insert-kbd-map (make-sparse-keymap) "This keymap keeps VI-style kbd macros for insert mode.") -(defvar vip-replace-map (make-sparse-keymap) +(defvar viper-replace-map (make-sparse-keymap) "Map used in Viper's replace state.") -(defvar vip-emacs-global-user-map (make-sparse-keymap) +(defvar viper-emacs-global-user-map (make-sparse-keymap) "Auxiliary map for global user-defined bindings in Emacs state.") -(defvar vip-emacs-kbd-map (make-sparse-keymap) +(defvar viper-emacs-kbd-map (make-sparse-keymap) "This keymap keeps Vi-style kbd macros for emacs mode.") -(vip-deflocalvar vip-emacs-local-user-map (make-sparse-keymap) +(viper-deflocalvar viper-emacs-local-user-map (make-sparse-keymap) "Auxiliary map for local user-defined bindings in Emacs state.") -(put 'vip-emacs-local-user-map 'permanent-local t) +(put 'viper-emacs-local-user-map 'permanent-local t) ;; This keymap should stay empty -(defvar vip-empty-keymap (make-sparse-keymap)) +(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 -;; and, after .vip is loaded, we add this keymap to vip-vi-basic-map. -(defvar vip-mode-map (make-sparse-keymap)) +;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map. +(defvar viper-mode-map (make-sparse-keymap)) ;;; Variables used by minor modes @@ -171,296 +171,296 @@ ;; ((major-mode . keymap) (major-mode . keymap) ...) ;; Viper uses these keymaps to make user-requested adjustments ;; to its Vi state in various major modes.") -(defvar vip-vi-state-modifier-alist nil) +(defvar viper-vi-state-modifier-alist nil) ;; Association list of the form ;; ((major-mode . keymap) (major-mode . keymap) ...) ;; Viper uses these keymaps to make user-requested adjustments ;; to its Insert state in various major modes.") -(defvar vip-insert-state-modifier-alist nil) +(defvar viper-insert-state-modifier-alist nil) ;; Association list of the form ;; ((major-mode . keymap) (major-mode . keymap) ...) ;; Viper uses these keymaps to make user-requested adjustments ;; to its Emacs state in various major modes. -(defvar vip-emacs-state-modifier-alist nil) +(defvar viper-emacs-state-modifier-alist nil) -;; Tells vip-add-local-keys to create a new vip-vi-local-user-map for new +;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new ;; buffers. Not a user option. -(vip-deflocalvar vip-need-new-vi-local-map t "") -(put 'vip-need-new-vi-local-map 'permanent-local t) +(viper-deflocalvar viper-need-new-vi-local-map t "") +(put 'viper-need-new-vi-local-map 'permanent-local t) -;; Tells vip-add-local-keys to create a new vip-insert-local-user-map for new -;; buffers. Not a user option. -(vip-deflocalvar vip-need-new-insert-local-map t "") -(put 'vip-need-new-insert-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. +(viper-deflocalvar viper-need-new-insert-local-map t "") +(put 'viper-need-new-insert-local-map 'permanent-local t) -;; Tells vip-add-local-keys to create a new vip-emacs-local-user-map for new -;; buffers. Not a user option. -(vip-deflocalvar vip-need-new-emacs-local-map t "") -(put 'vip-need-new-emacs-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. +(viper-deflocalvar viper-need-new-emacs-local-map t "") +(put 'viper-need-new-emacs-local-map 'permanent-local t) ;; Insert mode keymap ;; for novice users, pretend you are the real vi. -(define-key vip-insert-diehard-map "\t" 'vip-insert-tab) -(define-key vip-insert-diehard-map "\C-a" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-b" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-c" 'vip-change-state-to-vi) -(define-key vip-insert-diehard-map "\C-e" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-f" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-g" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-i" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-k" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-l" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-n" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-o" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-p" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-q" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-r" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-s" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-u" 'vip-erase-line) -(define-key vip-insert-diehard-map "\C-x" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-y" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-z" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-]" 'self-insert-command) -(define-key vip-insert-diehard-map "\C-_" 'self-insert-command) +(define-key viper-insert-diehard-map "\t" 'viper-insert-tab) +(define-key viper-insert-diehard-map "\C-a" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-b" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-c" 'viper-change-state-to-vi) +(define-key viper-insert-diehard-map "\C-e" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-f" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-g" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-i" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-k" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-l" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-n" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-o" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-p" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-q" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-r" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-s" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-u" 'viper-erase-line) +(define-key viper-insert-diehard-map "\C-x" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-y" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-z" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-]" 'self-insert-command) +(define-key viper-insert-diehard-map "\C-_" 'self-insert-command) (let ((i ?\ )) (while (<= i ?~) - (define-key vip-insert-diehard-map (make-string 1 i) 'self-insert-command) + (define-key viper-insert-diehard-map (make-string 1 i) 'self-insert-command) (setq i (1+ i)))) ;; Insert mode map when user wants emacs style -(define-key vip-insert-basic-map "\C-d" 'vip-backward-indent) -(define-key vip-insert-basic-map "\C-w" 'vip-delete-backward-word) -(define-key vip-insert-basic-map "\C-t" 'vip-forward-indent) -(define-key vip-insert-basic-map - (if vip-xemacs-p [(shift tab)] [S-tab]) 'vip-insert-tab) -(define-key vip-insert-basic-map "\C-v" 'quoted-insert) -(define-key vip-insert-basic-map "\C-?" 'vip-del-backward-char-in-insert) -(define-key vip-insert-basic-map "\C-\\" 'vip-alternate-Meta-key) -(define-key vip-insert-basic-map vip-toggle-key 'vip-escape-to-vi) -(define-key vip-insert-basic-map "\C-c\M-p" - 'vip-insert-prev-from-insertion-ring) -(define-key vip-insert-basic-map "\C-c\M-n" - 'vip-insert-next-from-insertion-ring) +(define-key viper-insert-basic-map "\C-d" 'viper-backward-indent) +(define-key viper-insert-basic-map "\C-w" 'viper-delete-backward-word) +(define-key viper-insert-basic-map "\C-t" 'viper-forward-indent) +(define-key viper-insert-basic-map + (if viper-xemacs-p [(shift tab)] [S-tab]) 'viper-insert-tab) +(define-key viper-insert-basic-map "\C-v" 'quoted-insert) +(define-key viper-insert-basic-map "\C-?" 'viper-del-backward-char-in-insert) +(define-key viper-insert-basic-map "\C-\\" 'viper-alternate-Meta-key) +(define-key viper-insert-basic-map viper-toggle-key 'viper-escape-to-vi) +(define-key viper-insert-basic-map "\C-c\M-p" + 'viper-insert-prev-from-insertion-ring) +(define-key viper-insert-basic-map "\C-c\M-n" + 'viper-insert-next-from-insertion-ring) ;; Replace keymap -(define-key vip-replace-map "\C-t" 'vip-forward-indent) -(define-key vip-replace-map "\C-j" 'vip-replace-state-carriage-return) -(define-key vip-replace-map "\C-m" 'vip-replace-state-carriage-return) -(define-key vip-replace-map "\C-?" 'vip-del-backward-char-in-replace) +(define-key viper-replace-map "\C-t" 'viper-forward-indent) +(define-key viper-replace-map "\C-j" 'viper-replace-state-carriage-return) +(define-key viper-replace-map "\C-m" 'viper-replace-state-carriage-return) +(define-key viper-replace-map "\C-?" 'viper-del-backward-char-in-replace) ;; Vi keymaps -(define-key vip-vi-basic-map "\C-^" - (function (lambda () (interactive) (vip-ex "e#")))) -(define-key vip-vi-basic-map "\C-b" 'vip-scroll-screen-back) -(define-key vip-vi-basic-map "\C-d" 'vip-scroll-up) -(define-key vip-vi-basic-map "\C-e" 'vip-scroll-up-one) -(define-key vip-vi-basic-map "\C-f" 'vip-scroll-screen) -(define-key vip-vi-basic-map "\C-m" 'vip-next-line-at-bol) -(define-key vip-vi-basic-map "\C-u" 'vip-scroll-down) -(define-key vip-vi-basic-map "\C-y" 'vip-scroll-down-one) -(define-key vip-vi-basic-map "\C-s" 'vip-isearch-forward) -(define-key vip-vi-basic-map "\C-r" 'vip-isearch-backward) -(define-key vip-vi-basic-map "\C-c/" 'vip-toggle-search-style) -(define-key vip-vi-basic-map "\C-cg" 'vip-info-on-file) +(define-key viper-vi-basic-map "\C-^" + (function (lambda () (interactive) (viper-ex "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) +(define-key viper-vi-basic-map "\C-f" 'viper-scroll-screen) +(define-key viper-vi-basic-map "\C-m" 'viper-next-line-at-bol) +(define-key viper-vi-basic-map "\C-u" 'viper-scroll-down) +(define-key viper-vi-basic-map "\C-y" 'viper-scroll-down-one) +(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 vip-vi-basic-map "\C-c\M-p" 'vip-prev-destructive-command) -(define-key vip-vi-basic-map "\C-c\M-n" 'vip-next-destructive-command) +(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) -(define-key vip-vi-basic-map " " 'vip-forward-char) -(define-key vip-vi-basic-map "!" 'vip-command-argument) -(define-key vip-vi-basic-map "\"" 'vip-command-argument) -(define-key vip-vi-basic-map "#" 'vip-command-argument) -(define-key vip-vi-basic-map "$" 'vip-goto-eol) -(define-key vip-vi-basic-map "%" 'vip-paren-match) -(define-key vip-vi-basic-map "&" - (function (lambda () (interactive) (vip-ex "&")))) -(define-key vip-vi-basic-map "'" 'vip-goto-mark-and-skip-white) -(define-key vip-vi-basic-map "(" 'vip-backward-sentence) -(define-key vip-vi-basic-map ")" 'vip-forward-sentence) -(define-key vip-vi-basic-map "*" 'call-last-kbd-macro) -(define-key vip-vi-basic-map "+" 'vip-next-line-at-bol) -(define-key vip-vi-basic-map "," 'vip-repeat-find-opposite) -(define-key vip-vi-basic-map "-" 'vip-previous-line-at-bol) -(define-key vip-vi-basic-map "." 'vip-repeat) -(define-key vip-vi-basic-map "/" 'vip-search-forward) +(define-key viper-vi-basic-map " " 'viper-forward-char) +(define-key viper-vi-basic-map "!" 'viper-command-argument) +(define-key viper-vi-basic-map "\"" 'viper-command-argument) +(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 "'" 'viper-goto-mark-and-skip-white) +(define-key viper-vi-basic-map "(" 'viper-backward-sentence) +(define-key viper-vi-basic-map ")" 'viper-forward-sentence) +(define-key viper-vi-basic-map "*" 'call-last-kbd-macro) +(define-key viper-vi-basic-map "+" 'viper-next-line-at-bol) +(define-key viper-vi-basic-map "," 'viper-repeat-find-opposite) +(define-key viper-vi-basic-map "-" 'viper-previous-line-at-bol) +(define-key viper-vi-basic-map "." 'viper-repeat) +(define-key viper-vi-basic-map "/" 'viper-search-forward) -(define-key vip-vi-basic-map "0" 'vip-beginning-of-line) -(define-key vip-vi-basic-map "1" 'vip-digit-argument) -(define-key vip-vi-basic-map "2" 'vip-digit-argument) -(define-key vip-vi-basic-map "3" 'vip-digit-argument) -(define-key vip-vi-basic-map "4" 'vip-digit-argument) -(define-key vip-vi-basic-map "5" 'vip-digit-argument) -(define-key vip-vi-basic-map "6" 'vip-digit-argument) -(define-key vip-vi-basic-map "7" 'vip-digit-argument) -(define-key vip-vi-basic-map "8" 'vip-digit-argument) -(define-key vip-vi-basic-map "9" 'vip-digit-argument) +(define-key viper-vi-basic-map "0" 'viper-beginning-of-line) +(define-key viper-vi-basic-map "1" 'viper-digit-argument) +(define-key viper-vi-basic-map "2" 'viper-digit-argument) +(define-key viper-vi-basic-map "3" 'viper-digit-argument) +(define-key viper-vi-basic-map "4" 'viper-digit-argument) +(define-key viper-vi-basic-map "5" 'viper-digit-argument) +(define-key viper-vi-basic-map "6" 'viper-digit-argument) +(define-key viper-vi-basic-map "7" 'viper-digit-argument) +(define-key viper-vi-basic-map "8" 'viper-digit-argument) +(define-key viper-vi-basic-map "9" 'viper-digit-argument) -(define-key vip-vi-basic-map ":" 'vip-ex) -(define-key vip-vi-basic-map ";" 'vip-repeat-find) -(define-key vip-vi-basic-map "<" 'vip-command-argument) -(define-key vip-vi-basic-map "=" 'vip-command-argument) -(define-key vip-vi-basic-map ">" 'vip-command-argument) -(define-key vip-vi-basic-map "?" 'vip-search-backward) -(define-key vip-vi-basic-map "@" 'vip-register-macro) +(define-key viper-vi-basic-map ":" 'viper-ex) +(define-key viper-vi-basic-map ";" 'viper-repeat-find) +(define-key viper-vi-basic-map "<" 'viper-command-argument) +(define-key viper-vi-basic-map "=" 'viper-command-argument) +(define-key viper-vi-basic-map ">" 'viper-command-argument) +(define-key viper-vi-basic-map "?" 'viper-search-backward) +(define-key viper-vi-basic-map "@" 'viper-register-macro) -(define-key vip-vi-basic-map "A" 'vip-Append) -(define-key vip-vi-basic-map "B" 'vip-backward-Word) -(define-key vip-vi-basic-map "C" 'vip-change-to-eol) -(define-key vip-vi-basic-map "D" 'vip-kill-line) -(define-key vip-vi-basic-map "E" 'vip-end-of-Word) -(define-key vip-vi-basic-map "F" 'vip-find-char-backward) -(define-key vip-vi-basic-map "G" 'vip-goto-line) -(define-key vip-vi-basic-map "H" 'vip-window-top) -(define-key vip-vi-basic-map "I" 'vip-Insert) -(define-key vip-vi-basic-map "J" 'vip-join-lines) -(define-key vip-vi-basic-map "K" 'vip-nil) -(define-key vip-vi-basic-map "L" 'vip-window-bottom) -(define-key vip-vi-basic-map "M" 'vip-window-middle) -(define-key vip-vi-basic-map "N" 'vip-search-Next) -(define-key vip-vi-basic-map "O" 'vip-Open-line) -(define-key vip-vi-basic-map "P" 'vip-Put-back) -(define-key vip-vi-basic-map "Q" 'vip-query-replace) -(define-key vip-vi-basic-map "R" 'vip-overwrite) -(define-key vip-vi-basic-map "S" 'vip-substitute-line) -(define-key vip-vi-basic-map "T" 'vip-goto-char-backward) -(define-key vip-vi-basic-map "U" 'vip-undo) -(define-key vip-vi-basic-map "V" 'find-file-other-window) -(define-key vip-vi-basic-map "W" 'vip-forward-Word) -(define-key vip-vi-basic-map "X" 'vip-delete-backward-char) -(define-key vip-vi-basic-map "Y" 'vip-yank-line) -(define-key vip-vi-basic-map "ZZ" 'vip-save-kill-buffer) +(define-key viper-vi-basic-map "A" 'viper-Append) +(define-key viper-vi-basic-map "B" 'viper-backward-Word) +(define-key viper-vi-basic-map "C" 'viper-change-to-eol) +(define-key viper-vi-basic-map "D" 'viper-kill-line) +(define-key viper-vi-basic-map "E" 'viper-end-of-Word) +(define-key viper-vi-basic-map "F" 'viper-find-char-backward) +(define-key viper-vi-basic-map "G" 'viper-goto-line) +(define-key viper-vi-basic-map "H" 'viper-window-top) +(define-key viper-vi-basic-map "I" 'viper-Insert) +(define-key viper-vi-basic-map "J" 'viper-join-lines) +(define-key viper-vi-basic-map "K" 'viper-nil) +(define-key viper-vi-basic-map "L" 'viper-window-bottom) +(define-key viper-vi-basic-map "M" 'viper-window-middle) +(define-key viper-vi-basic-map "N" 'viper-search-Next) +(define-key viper-vi-basic-map "O" 'viper-Open-line) +(define-key viper-vi-basic-map "P" 'viper-Put-back) +(define-key viper-vi-basic-map "Q" 'viper-query-replace) +(define-key viper-vi-basic-map "R" 'viper-overwrite) +(define-key viper-vi-basic-map "S" 'viper-substitute-line) +(define-key viper-vi-basic-map "T" 'viper-goto-char-backward) +(define-key viper-vi-basic-map "U" 'viper-undo) +(define-key viper-vi-basic-map "V" 'find-file-other-window) +(define-key viper-vi-basic-map "W" 'viper-forward-Word) +(define-key viper-vi-basic-map "X" 'viper-delete-backward-char) +(define-key viper-vi-basic-map "Y" 'viper-yank-line) +(define-key viper-vi-basic-map "ZZ" 'viper-save-kill-buffer) -(define-key vip-vi-basic-map "\\" 'vip-escape-to-emacs) -(define-key vip-vi-basic-map "[" 'vip-brac-function) -(define-key vip-vi-basic-map "]" 'vip-ket-function) -(define-key vip-vi-basic-map "\C-\\" 'vip-alternate-Meta-key) -(define-key vip-vi-basic-map "^" 'vip-bol-and-skip-white) -(define-key vip-vi-basic-map "`" 'vip-goto-mark) +(define-key viper-vi-basic-map "\\" 'viper-escape-to-emacs) +(define-key viper-vi-basic-map "[" 'viper-brac-function) +(define-key viper-vi-basic-map "]" 'viper-ket-function) +(define-key viper-vi-basic-map "\C-\\" 'viper-alternate-Meta-key) +(define-key viper-vi-basic-map "^" 'viper-bol-and-skip-white) +(define-key viper-vi-basic-map "`" 'viper-goto-mark) -(define-key vip-vi-basic-map "a" 'vip-append) -(define-key vip-vi-basic-map "b" 'vip-backward-word) -(define-key vip-vi-basic-map "c" 'vip-command-argument) -(define-key vip-vi-basic-map "d" 'vip-command-argument) -(define-key vip-vi-basic-map "e" 'vip-end-of-word) -(define-key vip-vi-basic-map "f" 'vip-find-char-forward) -(define-key vip-vi-basic-map "g" 'vip-nil) -(define-key vip-vi-basic-map "h" 'vip-backward-char) -(define-key vip-vi-basic-map "i" 'vip-insert) -(define-key vip-vi-basic-map "j" 'vip-next-line) -(define-key vip-vi-basic-map "k" 'vip-previous-line) -(define-key vip-vi-basic-map "l" 'vip-forward-char) -(define-key vip-vi-basic-map "m" 'vip-mark-point) -(define-key vip-vi-basic-map "n" 'vip-search-next) -(define-key vip-vi-basic-map "o" 'vip-open-line) -(define-key vip-vi-basic-map "p" 'vip-put-back) -(define-key vip-vi-basic-map "q" 'vip-nil) -(define-key vip-vi-basic-map "r" 'vip-replace-char) -(define-key vip-vi-basic-map "s" 'vip-substitute) -(define-key vip-vi-basic-map "t" 'vip-goto-char-forward) -(define-key vip-vi-basic-map "u" 'vip-undo) -(define-key vip-vi-basic-map "v" 'find-file) -(define-key vip-vi-basic-map "\C-v" 'find-file-other-frame) -(define-key vip-vi-basic-map "w" 'vip-forward-word) -(define-key vip-vi-basic-map "x" 'vip-delete-char) -(define-key vip-vi-basic-map "y" 'vip-command-argument) -(define-key vip-vi-basic-map "zH" 'vip-line-to-top) -(define-key vip-vi-basic-map "zM" 'vip-line-to-middle) -(define-key vip-vi-basic-map "zL" 'vip-line-to-bottom) -(define-key vip-vi-basic-map "z\C-m" 'vip-line-to-top) -(define-key vip-vi-basic-map "z." 'vip-line-to-middle) -(define-key vip-vi-basic-map "z-" 'vip-line-to-bottom) +(define-key viper-vi-basic-map "a" 'viper-append) +(define-key viper-vi-basic-map "b" 'viper-backward-word) +(define-key viper-vi-basic-map "c" 'viper-command-argument) +(define-key viper-vi-basic-map "d" 'viper-command-argument) +(define-key viper-vi-basic-map "e" 'viper-end-of-word) +(define-key viper-vi-basic-map "f" 'viper-find-char-forward) +(define-key viper-vi-basic-map "g" 'viper-nil) +(define-key viper-vi-basic-map "h" 'viper-backward-char) +(define-key viper-vi-basic-map "i" 'viper-insert) +(define-key viper-vi-basic-map "j" 'viper-next-line) +(define-key viper-vi-basic-map "k" 'viper-previous-line) +(define-key viper-vi-basic-map "l" 'viper-forward-char) +(define-key viper-vi-basic-map "m" 'viper-mark-point) +(define-key viper-vi-basic-map "n" 'viper-search-next) +(define-key viper-vi-basic-map "o" 'viper-open-line) +(define-key viper-vi-basic-map "p" 'viper-put-back) +(define-key viper-vi-basic-map "q" 'viper-nil) +(define-key viper-vi-basic-map "r" 'viper-replace-char) +(define-key viper-vi-basic-map "s" 'viper-substitute) +(define-key viper-vi-basic-map "t" 'viper-goto-char-forward) +(define-key viper-vi-basic-map "u" 'viper-undo) +(define-key viper-vi-basic-map "v" 'find-file) +(define-key viper-vi-basic-map "\C-v" 'find-file-other-frame) +(define-key viper-vi-basic-map "w" 'viper-forward-word) +(define-key viper-vi-basic-map "x" 'viper-delete-char) +(define-key viper-vi-basic-map "y" 'viper-command-argument) +(define-key viper-vi-basic-map "zH" 'viper-line-to-top) +(define-key viper-vi-basic-map "zM" 'viper-line-to-middle) +(define-key viper-vi-basic-map "zL" 'viper-line-to-bottom) +(define-key viper-vi-basic-map "z\C-m" 'viper-line-to-top) +(define-key viper-vi-basic-map "z." 'viper-line-to-middle) +(define-key viper-vi-basic-map "z-" 'viper-line-to-bottom) -(define-key vip-vi-basic-map "{" 'vip-backward-paragraph) -(define-key vip-vi-basic-map "|" 'vip-goto-col) -(define-key vip-vi-basic-map "}" 'vip-forward-paragraph) -(define-key vip-vi-basic-map "~" 'vip-toggle-case) -(define-key vip-vi-basic-map "\C-?" 'vip-backward-char) -(define-key vip-vi-basic-map "_" 'vip-nil) +(define-key viper-vi-basic-map "{" 'viper-backward-paragraph) +(define-key viper-vi-basic-map "|" 'viper-goto-col) +(define-key viper-vi-basic-map "}" 'viper-forward-paragraph) +(define-key viper-vi-basic-map "~" 'viper-toggle-case) +(define-key viper-vi-basic-map "\C-?" 'viper-backward-char) +(define-key viper-vi-basic-map "_" 'viper-nil) ;;; Escape from Emacs to Vi for one command -(global-set-key "\C-c\\" 'vip-escape-to-vi) ; everywhere +(global-set-key "\C-c\\" 'viper-escape-to-vi) ; everywhere -;;; This is vip-vi-diehard-map. Used when vip-vi-diehard-minor-mode is on. +;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on. -(define-key vip-vi-diehard-map "\C-a" 'vip-nil) -(define-key vip-vi-diehard-map "\C-c" 'vip-nil) -(define-key vip-vi-diehard-map "\C-g" 'vip-info-on-file) -(define-key vip-vi-diehard-map "\C-i" 'vip-nil) -(define-key vip-vi-diehard-map "\C-k" 'vip-nil) -(define-key vip-vi-diehard-map "\C-l" 'redraw-display) -(define-key vip-vi-diehard-map "\C-n" 'vip-next-line) -(define-key vip-vi-diehard-map "\C-o" 'vip-nil) -(define-key vip-vi-diehard-map "\C-p" 'vip-previous-line) -(define-key vip-vi-diehard-map "\C-q" 'vip-nil) -(define-key vip-vi-diehard-map "\C-r" 'redraw-display) -(define-key vip-vi-diehard-map "\C-s" 'vip-nil) -(define-key vip-vi-diehard-map "\C-t" 'vip-nil) -(define-key vip-vi-diehard-map "\C-v" 'vip-nil) -(define-key vip-vi-diehard-map "\C-w" 'vip-nil) -(define-key vip-vi-diehard-map "@" 'vip-nil) -(define-key vip-vi-diehard-map "_" 'vip-nil) -(define-key vip-vi-diehard-map "*" 'vip-nil) -(define-key vip-vi-diehard-map "#" 'vip-nil) -(define-key vip-vi-diehard-map "\C-_" 'vip-nil) -(define-key vip-vi-diehard-map "\C-]" 'vip-nil) ; This is actually tags. +(define-key viper-vi-diehard-map "\C-a" 'viper-nil) +(define-key viper-vi-diehard-map "\C-c" 'viper-nil) +(define-key viper-vi-diehard-map "\C-g" 'viper-info-on-file) +(define-key viper-vi-diehard-map "\C-i" 'viper-nil) +(define-key viper-vi-diehard-map "\C-k" 'viper-nil) +(define-key viper-vi-diehard-map "\C-l" 'redraw-display) +(define-key viper-vi-diehard-map "\C-n" 'viper-next-line) +(define-key viper-vi-diehard-map "\C-o" 'viper-nil) +(define-key viper-vi-diehard-map "\C-p" 'viper-previous-line) +(define-key viper-vi-diehard-map "\C-q" 'viper-nil) +(define-key viper-vi-diehard-map "\C-r" 'redraw-display) +(define-key viper-vi-diehard-map "\C-s" 'viper-nil) +(define-key viper-vi-diehard-map "\C-t" 'viper-nil) +(define-key viper-vi-diehard-map "\C-v" 'viper-nil) +(define-key viper-vi-diehard-map "\C-w" 'viper-nil) +(define-key viper-vi-diehard-map "@" 'viper-nil) +(define-key viper-vi-diehard-map "_" 'viper-nil) +(define-key viper-vi-diehard-map "*" 'viper-nil) +(define-key viper-vi-diehard-map "#" 'viper-nil) +(define-key viper-vi-diehard-map "\C-_" 'viper-nil) +(define-key viper-vi-diehard-map "\C-]" 'viper-nil) ; This is actually tags. ;;; Minibuffer keymap -(defvar vip-minibuffer-map (make-sparse-keymap) +(defvar viper-minibuffer-map (make-sparse-keymap) "Keymap used to modify keys when Minibuffer is in Insert state.") -(define-key vip-minibuffer-map "\C-m" 'vip-exit-minibuffer) -(define-key vip-minibuffer-map "\C-j" 'vip-exit-minibuffer) +(define-key viper-minibuffer-map "\C-m" 'viper-exit-minibuffer) +(define-key viper-minibuffer-map "\C-j" 'viper-exit-minibuffer) ;; Map used to read Ex-style commands. -(defvar vip-ex-cmd-map (make-sparse-keymap)) -(define-key vip-ex-cmd-map " " 'ex-cmd-read-exit) -(define-key vip-ex-cmd-map "\t" 'ex-cmd-complete) +(defvar viper-ex-cmd-map (make-sparse-keymap)) +(define-key viper-ex-cmd-map " " 'ex-cmd-read-exit) +(define-key viper-ex-cmd-map "\t" 'ex-cmd-complete) ;; Keymap for reading file names in Ex-style commands. (defvar ex-read-filename-map (make-sparse-keymap)) -(define-key ex-read-filename-map " " 'vip-complete-filename-or-exit) -(define-key ex-read-filename-map "!" 'vip-handle-!) +(define-key ex-read-filename-map " " 'viper-complete-filename-or-exit) +(define-key ex-read-filename-map "!" 'viper-handle-!) ;; Some other maps -(defvar vip-slash-and-colon-map (make-sparse-keymap) +(defvar viper-slash-and-colon-map (make-sparse-keymap) "This map redefines `/' and `:' to behave as in Vi. Useful in some modes, such as Gnus, MH, etc.") -(define-key vip-slash-and-colon-map ":" 'vip-ex) -(define-key vip-slash-and-colon-map "/" 'vip-search-forward) +(define-key viper-slash-and-colon-map ":" 'viper-ex) +(define-key viper-slash-and-colon-map "/" 'viper-search-forward) -(defvar vip-comint-mode-modifier-map (make-sparse-keymap) +(defvar viper-comint-mode-modifier-map (make-sparse-keymap) "This map modifies comint mode.") -(define-key vip-comint-mode-modifier-map "\C-m" 'comint-send-input) -(define-key vip-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof) +(define-key viper-comint-mode-modifier-map "\C-m" 'comint-send-input) +(define-key viper-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof) -(defvar vip-dired-modifier-map (make-sparse-keymap) +(defvar viper-dired-modifier-map (make-sparse-keymap) "This map modifies Dired behavior.") -(define-key vip-dired-modifier-map ":" 'vip-ex) -(define-key vip-dired-modifier-map "/" 'vip-search-forward) +(define-key viper-dired-modifier-map ":" 'viper-ex) +(define-key viper-dired-modifier-map "/" 'viper-search-forward) -(defvar vip-help-modifier-map (make-sparse-keymap) +(defvar viper-help-modifier-map (make-sparse-keymap) "This map modifies Help mode behavior.") -(define-key vip-help-modifier-map "q" (if vip-xemacs-p 'help-mode-quit)) +(define-key viper-help-modifier-map "q" (if viper-xemacs-p 'help-mode-quit)) ;;; Code -(defun vip-add-local-keys (state alist) +(defun viper-add-local-keys (state alist) "Override some vi-state or insert-state bindings in the current buffer. The effect is seen in the current buffer only. Useful for customizing mailer buffers, gnus, etc. @@ -469,64 +469,64 @@ Normally, this would be called from a hook to a major mode or on a per buffer basis. Usage: - (vip-add-local-keys state '((key-str . func) (key-str . func)...)) " + (viper-add-local-keys state '((key-str . func) (key-str . func)...)) " (let (map) (cond ((eq state 'vi-state) - (if vip-need-new-vi-local-map - (setq vip-vi-local-user-map (make-sparse-keymap))) - (setq vip-need-new-vi-local-map nil - map vip-vi-local-user-map)) + (if viper-need-new-vi-local-map + (setq viper-vi-local-user-map (make-sparse-keymap))) + (setq viper-need-new-vi-local-map nil + map viper-vi-local-user-map)) ((eq state 'insert-state) - (if vip-need-new-insert-local-map - (setq vip-insert-local-user-map (make-sparse-keymap))) - (setq vip-need-new-insert-local-map nil - map vip-insert-local-user-map)) + (if viper-need-new-insert-local-map + (setq viper-insert-local-user-map (make-sparse-keymap))) + (setq viper-need-new-insert-local-map nil + map viper-insert-local-user-map)) ((eq state 'emacs-state) - (if vip-need-new-emacs-local-map - (setq vip-emacs-local-user-map (make-sparse-keymap))) - (setq vip-need-new-emacs-local-map nil - map vip-emacs-local-user-map)) + (if viper-need-new-emacs-local-map + (setq viper-emacs-local-user-map (make-sparse-keymap))) + (setq viper-need-new-emacs-local-map nil + map viper-emacs-local-user-map)) (t (error - "Invalid state in vip-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))) - (vip-modify-keymap map alist) - (vip-normalize-minor-mode-map-alist) - (vip-set-mode-vars-for vip-current-state))) + (viper-modify-keymap map alist) + (viper-normalize-minor-mode-map-alist) + (viper-set-mode-vars-for viper-current-state))) -(defun vip-zap-local-keys () - "Unconditionally reset Viper vip-*-local-user-map's. +(defun viper-zap-local-keys () + "Unconditionally reset Viper viper-*-local-user-map's. Rarely useful, but if u made a mistake by switching to a mode that adds undesirable local keys, e.g., comint-mode, then this function can restore sanity." (interactive) - (setq vip-vi-local-user-map (make-sparse-keymap) - vip-need-new-vi-local-map nil - vip-insert-local-user-map (make-sparse-keymap) - vip-need-new-insert-local-map nil - vip-emacs-local-user-map (make-sparse-keymap) - vip-need-new-emacs-local-map nil) - (vip-normalize-minor-mode-map-alist)) + (setq viper-vi-local-user-map (make-sparse-keymap) + viper-need-new-vi-local-map nil + viper-insert-local-user-map (make-sparse-keymap) + viper-need-new-insert-local-map nil + viper-emacs-local-user-map (make-sparse-keymap) + viper-need-new-emacs-local-map nil) + (viper-normalize-minor-mode-map-alist)) -(defun vip-modify-major-mode (mode state keymap) +(defun viper-modify-major-mode (mode state keymap) "Modify key bindings in a major-mode in a Viper state using a keymap. 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 vip-change-state-to-emacs to this +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 vip-set-hooks for hints. +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. -Arguments: (major-mode vip-state keymap)" +Arguments: (major-mode viper-state keymap)" (let ((alist - (cond ((eq state 'vi-state) 'vip-vi-state-modifier-alist) - ((eq state 'insert-state) 'vip-insert-state-modifier-alist) - ((eq state 'emacs-state) 'vip-emacs-state-modifier-alist))) + (cond ((eq state 'vi-state) 'viper-vi-state-modifier-alist) + ((eq state 'insert-state) 'viper-insert-state-modifier-alist) + ((eq state 'emacs-state) 'viper-emacs-state-modifier-alist))) elt) (if (setq elt (assoc mode (eval alist))) (set alist (delq elt (eval alist)))) @@ -536,74 +536,74 @@ ;; normalize in the actual buffer where changes to the keymap are ;; to take place. However, it doesn't hurt, and it helps whenever this ;; function is actually called from within the right buffer. - (vip-normalize-minor-mode-map-alist) + (viper-normalize-minor-mode-map-alist) - (vip-set-mode-vars-for vip-current-state))) + (viper-set-mode-vars-for viper-current-state))) ;; Displays variables that control Viper's keymaps -(defun vip-debug-keymaps () +(defun viper-debug-keymaps () (interactive) - (with-output-to-temp-buffer " *vip-debug*" + (with-output-to-temp-buffer " *viper-debug*" (princ (format "Buffer name: %s\n\n" (buffer-name))) (princ "Variables: \n") (princ (format "major-mode: %S\n" major-mode)) - (princ (format "vip-current-state: %S\n" vip-current-state)) - (princ (format "vip-mode-string: %S\n\n" vip-mode-string)) - (princ (format "vip-vi-intercept-minor-mode: %S\n" - vip-vi-intercept-minor-mode)) - (princ (format "vip-insert-intercept-minor-mode: %S\n" - vip-insert-intercept-minor-mode)) - (princ (format "vip-emacs-intercept-minor-mode: %S\n" - vip-emacs-intercept-minor-mode)) - (princ (format "vip-vi-minibuffer-minor-mode: %S\n" - vip-vi-minibuffer-minor-mode)) - (princ (format "vip-insert-minibuffer-minor-mode: %S\n\n" - vip-insert-minibuffer-minor-mode)) - (princ (format "vip-vi-local-user-minor-mode: %S\n" - vip-vi-local-user-minor-mode)) - (princ (format "vip-vi-global-user-minor-mode: %S\n" - vip-vi-global-user-minor-mode)) - (princ (format "vip-vi-kbd-minor-mode: %S\n" vip-vi-kbd-minor-mode)) - (princ (format "vip-vi-state-modifier-minor-mode: %S\n" - vip-vi-state-modifier-minor-mode)) - (princ (format "vip-vi-diehard-minor-mode: %S\n" - vip-vi-diehard-minor-mode)) - (princ (format "vip-vi-basic-minor-mode: %S\n" vip-vi-basic-minor-mode)) - (princ (format "vip-replace-minor-mode: %S\n" vip-replace-minor-mode)) - (princ (format "vip-insert-local-user-minor-mode: %S\n" - vip-insert-local-user-minor-mode)) - (princ (format "vip-insert-global-user-minor-mode: %S\n" - vip-insert-global-user-minor-mode)) - (princ (format "vip-insert-kbd-minor-mode: %S\n" - vip-insert-kbd-minor-mode)) - (princ (format "vip-insert-state-modifier-minor-mode: %S\n" - vip-insert-state-modifier-minor-mode)) - (princ (format "vip-insert-diehard-minor-mode: %S\n" - vip-insert-diehard-minor-mode)) - (princ (format "vip-insert-basic-minor-mode: %S\n" - vip-insert-basic-minor-mode)) - (princ (format "vip-emacs-local-user-minor-mode: %S\n" - vip-emacs-local-user-minor-mode)) - (princ (format "vip-emacs-kbd-minor-mode: %S\n" - vip-emacs-kbd-minor-mode)) - (princ (format "vip-emacs-global-user-minor-mode: %S\n" - vip-emacs-global-user-minor-mode)) - (princ (format "vip-emacs-state-modifier-minor-mode: %S\n" - vip-emacs-state-modifier-minor-mode)) + (princ (format "viper-current-state: %S\n" viper-current-state)) + (princ (format "viper-mode-string: %S\n\n" viper-mode-string)) + (princ (format "viper-vi-intercept-minor-mode: %S\n" + viper-vi-intercept-minor-mode)) + (princ (format "viper-insert-intercept-minor-mode: %S\n" + viper-insert-intercept-minor-mode)) + (princ (format "viper-emacs-intercept-minor-mode: %S\n" + viper-emacs-intercept-minor-mode)) + (princ (format "viper-vi-minibuffer-minor-mode: %S\n" + viper-vi-minibuffer-minor-mode)) + (princ (format "viper-insert-minibuffer-minor-mode: %S\n\n" + viper-insert-minibuffer-minor-mode)) + (princ (format "viper-vi-local-user-minor-mode: %S\n" + viper-vi-local-user-minor-mode)) + (princ (format "viper-vi-global-user-minor-mode: %S\n" + viper-vi-global-user-minor-mode)) + (princ (format "viper-vi-kbd-minor-mode: %S\n" viper-vi-kbd-minor-mode)) + (princ (format "viper-vi-state-modifier-minor-mode: %S\n" + viper-vi-state-modifier-minor-mode)) + (princ (format "viper-vi-diehard-minor-mode: %S\n" + viper-vi-diehard-minor-mode)) + (princ (format "viper-vi-basic-minor-mode: %S\n" viper-vi-basic-minor-mode)) + (princ (format "viper-replace-minor-mode: %S\n" viper-replace-minor-mode)) + (princ (format "viper-insert-local-user-minor-mode: %S\n" + viper-insert-local-user-minor-mode)) + (princ (format "viper-insert-global-user-minor-mode: %S\n" + viper-insert-global-user-minor-mode)) + (princ (format "viper-insert-kbd-minor-mode: %S\n" + viper-insert-kbd-minor-mode)) + (princ (format "viper-insert-state-modifier-minor-mode: %S\n" + viper-insert-state-modifier-minor-mode)) + (princ (format "viper-insert-diehard-minor-mode: %S\n" + viper-insert-diehard-minor-mode)) + (princ (format "viper-insert-basic-minor-mode: %S\n" + viper-insert-basic-minor-mode)) + (princ (format "viper-emacs-local-user-minor-mode: %S\n" + viper-emacs-local-user-minor-mode)) + (princ (format "viper-emacs-kbd-minor-mode: %S\n" + viper-emacs-kbd-minor-mode)) + (princ (format "viper-emacs-global-user-minor-mode: %S\n" + viper-emacs-global-user-minor-mode)) + (princ (format "viper-emacs-state-modifier-minor-mode: %S\n" + viper-emacs-state-modifier-minor-mode)) (princ (format "\nviper-expert-level %S\n" viper-expert-level)) - (princ (format "vip-no-multiple-ESC %S\n" vip-no-multiple-ESC)) + (princ (format "viper-no-multiple-ESC %S\n" viper-no-multiple-ESC)) (princ (format "viper-always %S\n" viper-always)) - (princ (format "vip-ex-style-motion %S\n" - vip-ex-style-motion)) - (princ (format "vip-ex-style-editing-in-insert %S\n" - vip-ex-style-editing-in-insert)) - (princ (format "vip-want-emacs-keys-in-vi %S\n" - vip-want-emacs-keys-in-vi)) - (princ (format "vip-want-emacs-keys-in-insert %S\n" - vip-want-emacs-keys-in-insert)) - (princ (format "vip-want-ctl-h-help %S\n" vip-want-ctl-h-help)) + (princ (format "viper-ex-style-motion %S\n" + viper-ex-style-motion)) + (princ (format "viper-ex-style-editing-in-insert %S\n" + viper-ex-style-editing-in-insert)) + (princ (format "viper-want-emacs-keys-in-vi %S\n" + viper-want-emacs-keys-in-vi)) + (princ (format "viper-want-emacs-keys-in-insert %S\n" + viper-want-emacs-keys-in-insert)) + (princ (format "viper-want-ctl-h-help %S\n" viper-want-ctl-h-help)) (princ "\n\n\n") (princ (format "Default value for minor-mode-map-alist: \n%S\n\n" @@ -615,9 +615,9 @@ ;;; Keymap utils -(defun vip-add-keymap (mapsrc mapdst) +(defun viper-add-keymap (mapsrc mapdst) "Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse." - (if vip-xemacs-p + (if viper-xemacs-p (map-keymap (function (lambda (key binding) (define-key mapdst key binding))) mapsrc) @@ -627,7 +627,7 @@ )) (cdr mapsrc)))) -(defun vip-modify-keymap (map alist) +(defun viper-modify-keymap (map alist) "Modifies MAP with bindings specified in the ALIST. The alist has the form ((key . function) (key . function) ... )." (mapcar (function (lambda (p) @@ -636,7 +636,7 @@ ;;; Local Variables: -;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun) +;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) ;;; End:
--- a/lisp/emulation/viper-macs.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-macs.el Sat Aug 02 07:40:22 1997 +0000 @@ -24,10 +24,10 @@ (provide 'viper-macs) ;; compiler pacifier -(defvar vip-ex-work-buf) -(defvar vip-custom-file-name) -(defvar vip-current-state) -(defvar vip-fast-keyseq-timeout) +(defvar viper-ex-work-buf) +(defvar viper-custom-file-name) +(defvar viper-current-state) +(defvar viper-fast-keyseq-timeout) ;; loading happens only in non-interactive compilation ;; in order to spare non-viperized emacs from being viperized @@ -52,27 +52,27 @@ ;;; Variables ;; Register holding last macro. -(defvar vip-last-macro-reg nil) +(defvar viper-last-macro-reg nil) ;; format of the elements of kbd alists: ;; (name ((buf . macr)...(buf . macr)) ((maj-mode . macr)...) (t . macr)) ;; kbd macro alist for Vi state -(defvar vip-vi-kbd-macro-alist nil) +(defvar viper-vi-kbd-macro-alist nil) ;; same for insert/replace state -(defvar vip-insert-kbd-macro-alist nil) +(defvar viper-insert-kbd-macro-alist nil) ;; same for emacs state -(defvar vip-emacs-kbd-macro-alist nil) +(defvar viper-emacs-kbd-macro-alist nil) ;; Internal var that passes info between start-kbd-macro and end-kbd-macro ;; in :map and :map! -(defvar vip-kbd-macro-parameters nil) +(defvar viper-kbd-macro-parameters nil) -(defvar vip-this-kbd-macro nil +(defvar viper-this-kbd-macro nil "Vector of keys representing the name of currently running Viper kbd macro.") -(defvar vip-last-kbd-macro nil +(defvar viper-last-kbd-macro nil "Vector of keys representing the name of last Viper keyboard macro.") -(defcustom vip-repeat-from-history-key 'f12 +(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 @@ -93,7 +93,7 @@ (let ((mod-char "") macro-name macro-body map-args ins) (save-window-excursion - (set-buffer vip-ex-work-buf) + (set-buffer viper-ex-work-buf) (if (looking-at "!") (progn (setq ins t @@ -102,19 +102,19 @@ (setq map-args (ex-map-read-args mod-char) macro-name (car map-args) macro-body (cdr map-args)) - (setq vip-kbd-macro-parameters (list ins mod-char macro-name macro-body)) + (setq viper-kbd-macro-parameters (list ins mod-char macro-name macro-body)) (if macro-body - (vip-end-mapping-kbd-macro 'ignore) + (viper-end-mapping-kbd-macro 'ignore) (ex-fixup-history (format "map%s %S" mod-char - (vip-display-macro macro-name))) + (viper-display-macro macro-name))) ;; if defining macro for insert, switch there for authentic WYSIWYG - (if ins (vip-change-state-to-insert)) + (if ins (viper-change-state-to-insert)) (start-kbd-macro nil) - (define-key vip-vi-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro) - (define-key vip-insert-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro) - (define-key vip-emacs-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro) + (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" - (vip-display-macro macro-name) + (viper-display-macro macro-name) (if ins "Insert" "Vi"))) )) @@ -124,7 +124,7 @@ (let ((mod-char "") temp macro-name ins) (save-window-excursion - (set-buffer vip-ex-work-buf) + (set-buffer viper-ex-work-buf) (if (looking-at "!") (progn (setq ins t @@ -132,10 +132,10 @@ (forward-char 1)))) (setq macro-name (ex-unmap-read-args mod-char)) - (setq temp (vip-fixup-macro (vconcat macro-name))) ;; copy and fixup + (setq temp (viper-fixup-macro (vconcat macro-name))) ;; copy and fixup (ex-fixup-history (format "unmap%s %S" mod-char - (vip-display-macro temp))) - (vip-unrecord-kbd-macro macro-name (if ins 'insert-state 'vi-state)) + (viper-display-macro temp))) + (viper-unrecord-kbd-macro macro-name (if ins 'insert-state 'vi-state)) )) @@ -179,31 +179,31 @@ (format ":map%s %s" variant (if (> (length key-seq) 0) - (prin1-to-string (vip-display-macro key-seq)) + (prin1-to-string (viper-display-macro key-seq)) ""))) (message message) - (setq event (vip-read-key)) - ;;(setq event (vip-read-event)) + (setq event (viper-read-key)) + ;;(setq event (viper-read-event)) (setq key - (if (vip-mouse-event-p event) + (if (viper-mouse-event-p event) (progn (message "%s (No mouse---only keyboard keys, please)" message) (sit-for 2) nil) - (vip-event-key event))) + (viper-event-key event))) ) (setq macro-name key-seq)) (if (= (length macro-name) 0) (error "Can't map an empty macro name")) - (setq macro-name (vip-fixup-macro macro-name)) - (if (vip-char-array-p macro-name) - (setq macro-name (vip-char-array-to-macro macro-name))) + (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))) (if macro-body - (cond ((vip-char-array-p macro-body) - (setq macro-body (vip-char-array-to-macro macro-body))) + (cond ((viper-char-array-p macro-body) + (setq macro-body (viper-char-array-to-macro macro-body))) ((vectorp macro-body) nil) (t (error "map: Invalid syntax in macro definition")))) (setq cursor-in-echo-area nil)(sit-for 0) ; this overcomes xemacs tty bug @@ -215,14 +215,14 @@ (defun ex-unmap-read-args (variant) (let ((cursor-in-echo-area t) (macro-alist (if (string= variant "!") - vip-insert-kbd-macro-alist - vip-vi-kbd-macro-alist)) + viper-insert-kbd-macro-alist + viper-vi-kbd-macro-alist)) ;; these are disabled just in case, to avoid surprises when doing ;; completing-read - vip-vi-kbd-minor-mode vip-insert-kbd-minor-mode - vip-emacs-kbd-minor-mode - vip-vi-intercept-minor-mode vip-insert-intercept-minor-mode - vip-emacs-intercept-minor-mode + viper-vi-kbd-minor-mode viper-insert-kbd-minor-mode + viper-emacs-kbd-minor-mode + viper-vi-intercept-minor-mode viper-insert-intercept-minor-mode + viper-emacs-intercept-minor-mode event message key key-seq macro-name) (setq macro-name (ex-get-inline-cmd-args ".*unma?p?[!]*[ \t]*")) @@ -246,29 +246,29 @@ ":unmap%s %s" variant (if (> (length key-seq) 0) (prin1-to-string - (vip-display-macro key-seq)) + (viper-display-macro key-seq)) ""))) (setq key-seq - (vip-do-sequence-completion key-seq macro-alist message)) + (viper-do-sequence-completion key-seq macro-alist message)) )) (setq message (format ":unmap%s %s" variant (if (> (length key-seq) 0) (prin1-to-string - (vip-display-macro key-seq)) + (viper-display-macro key-seq)) ""))) (message message) - (setq event (vip-read-key)) - ;;(setq event (vip-read-event)) + (setq event (viper-read-key)) + ;;(setq event (viper-read-event)) (setq key - (if (vip-mouse-event-p event) + (if (viper-mouse-event-p event) (progn (message "%s (No mouse---only keyboard keys, please)" message) (sit-for 2) nil) - (vip-event-key event))) + (viper-event-key event))) ) (setq macro-name key-seq)) @@ -286,35 +286,35 @@ ;; optional argument IGNORE, if t, indicates that we are dealing with an ;; existing macro that needs to be registered, but there is no need to ;; terminate a kbd macro. -(defun vip-end-mapping-kbd-macro (&optional ignore) +(defun viper-end-mapping-kbd-macro (&optional ignore) (interactive) - (define-key vip-vi-intercept-map "\C-x)" nil) - (define-key vip-insert-intercept-map "\C-x)" nil) - (define-key vip-emacs-intercept-map "\C-x)" nil) + (define-key viper-vi-intercept-map "\C-x)" nil) + (define-key viper-insert-intercept-map "\C-x)" nil) + (define-key viper-emacs-intercept-map "\C-x)" nil) (if (and (not ignore) - (or (not vip-kbd-macro-parameters) + (or (not viper-kbd-macro-parameters) (not defining-kbd-macro))) (error "Not mapping a kbd-macro")) - (let ((mod-char (nth 1 vip-kbd-macro-parameters)) - (ins (nth 0 vip-kbd-macro-parameters)) - (macro-name (nth 2 vip-kbd-macro-parameters)) - (macro-body (nth 3 vip-kbd-macro-parameters))) - (setq vip-kbd-macro-parameters nil) + (let ((mod-char (nth 1 viper-kbd-macro-parameters)) + (ins (nth 0 viper-kbd-macro-parameters)) + (macro-name (nth 2 viper-kbd-macro-parameters)) + (macro-body (nth 3 viper-kbd-macro-parameters))) + (setq viper-kbd-macro-parameters nil) (or ignore (progn (end-kbd-macro nil) - (setq macro-body (vip-events-to-macro last-kbd-macro)) + (setq macro-body (viper-events-to-macro last-kbd-macro)) ;; always go back to Vi, since this is where we started ;; defining macro - (vip-change-state-to-vi))) + (viper-change-state-to-vi))) - (vip-record-kbd-macro macro-name + (viper-record-kbd-macro macro-name (if ins 'insert-state 'vi-state) - (vip-display-macro macro-body)) + (viper-display-macro macro-body)) (ex-fixup-history (format "map%s %S %S" mod-char - (vip-display-macro macro-name) - (vip-display-macro macro-body))) + (viper-display-macro macro-name) + (viper-display-macro macro-body))) )) @@ -325,8 +325,8 @@ ;; accepts as macro names: strings and vectors. ;; strings must be strings of characters; vectors must be vectors of keys ;; in canonic form. the canonic form is essentially the form used in XEmacs -(defun vip-record-kbd-macro (macro-name state macro-body &optional scope) - "Record a Vi macro. Can be used in `.vip' file to define permanent macros. +(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. @@ -337,16 +337,16 @@ (macro-alist-var (cond ((eq state 'vi-state) (setq state-name "Vi state" - keymap vip-vi-kbd-map) - 'vip-vi-kbd-macro-alist) + keymap viper-vi-kbd-map) + 'viper-vi-kbd-macro-alist) ((memq state '(insert-state replace-state)) (setq state-name "Insert state" - keymap vip-insert-kbd-map) - 'vip-insert-kbd-macro-alist) + keymap viper-insert-kbd-map) + 'viper-insert-kbd-macro-alist) (t (setq state-name "Emacs state" - keymap vip-emacs-kbd-map) - 'vip-emacs-kbd-macro-alist) + keymap viper-emacs-kbd-map) + 'viper-emacs-kbd-macro-alist) )) new-elt old-elt old-sub-elt msg temp lis lis2) @@ -355,13 +355,13 @@ (error "Can't map an empty macro name")) ;; Macro-name is usually a vector. However, command history or macros - ;; recorded in ~/.vip may be recorded as strings. So, convert to vectors. - (setq macro-name (vip-fixup-macro macro-name)) - (if (vip-char-array-p macro-name) - (setq macro-name (vip-char-array-to-macro macro-name))) - (setq macro-body (vip-fixup-macro macro-body)) - (if (vip-char-array-p macro-body) - (setq macro-body (vip-char-array-to-macro macro-body))) + ;; 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))) + (setq macro-body (viper-fixup-macro macro-body)) + (if (viper-char-array-p macro-body) + (setq macro-body (viper-char-array-to-macro macro-body))) ;; don't ask if scope is given and is of the right type (or (eq scope t) @@ -377,11 +377,11 @@ (setq msg (format "%S is mapped to %s for %s in `%s'" - (vip-display-macro macro-name) - (vip-abbreviate-string + (viper-display-macro macro-name) + (viper-abbreviate-string (format "%S" - (setq temp (vip-display-macro macro-body))) + (setq temp (viper-display-macro macro-body))) 14 "" "" (if (stringp temp) " ....\"" " ....]")) state-name (buffer-name))) @@ -393,11 +393,11 @@ (setq msg (format "%S is mapped to %s for %s in `%S'" - (vip-display-macro macro-name) - (vip-abbreviate-string + (viper-display-macro macro-name) + (viper-abbreviate-string (format "%S" - (setq temp (vip-display-macro macro-body))) + (setq temp (viper-display-macro macro-body))) 14 "" "" (if (stringp macro-body) " ....\"" " ....]")) state-name major-mode)) @@ -406,33 +406,33 @@ (setq msg (format "%S is globally mapped to %s in %s" - (vip-display-macro macro-name) - (vip-abbreviate-string + (viper-display-macro macro-name) + (viper-abbreviate-string (format "%S" - (setq temp (vip-display-macro macro-body))) + (setq temp (viper-display-macro macro-body))) 14 "" "" (if (stringp macro-body) " ....\"" " ....]")) state-name)) t))) (if (y-or-n-p (format "Save this macro in %s? " - (vip-abbreviate-file-name vip-custom-file-name))) - (vip-save-string-in-file - (format "\n(vip-record-kbd-macro %S '%S %s '%S)" - (vip-display-macro macro-name) + (viper-abbreviate-file-name viper-custom-file-name))) + (viper-save-string-in-file + (format "\n(viper-record-kbd-macro %S '%S %s '%S)" + (viper-display-macro macro-name) state ;; if we don't let vector macro-body through %S, ;; the symbols `\.' `\[' etc will be converted into ;; characters, causing invalid read error on recorded - ;; macros in .vip. + ;; macros in .viper. ;; I am not sure is macro-body can still be a string at ;; this point, but I am preserving this option anyway. (if (vectorp macro-body) (format "%S" macro-body) macro-body) scope) - vip-custom-file-name)) + viper-custom-file-name)) (message msg) )) @@ -451,11 +451,11 @@ ;; insert new-elt in macro-alist-var and keep the list sorted (define-key keymap - (vector (vip-key-to-emacs-key (aref macro-name 0))) - 'vip-exec-mapped-kbd-macro) + (vector (viper-key-to-emacs-key (aref macro-name 0))) + 'viper-exec-mapped-kbd-macro) (setq lis (eval macro-alist-var)) - (while (and lis (string< (vip-array-to-string (car (car lis))) - (vip-array-to-string macro-name))) + (while (and lis (string< (viper-array-to-string (car (car lis))) + (viper-array-to-string macro-name))) (setq lis2 (cons (car lis) lis2)) (setq lis (cdr lis))) @@ -463,90 +463,90 @@ (set macro-alist-var (append lis2 (cons new-elt lis))) (setq old-elt new-elt))) (setq old-sub-elt - (cond ((eq scope t) (vip-kbd-global-pair old-elt)) - ((symbolp scope) (assoc scope (vip-kbd-mode-alist old-elt))) - ((stringp scope) (assoc scope (vip-kbd-buf-alist old-elt))))) + (cond ((eq scope t) (viper-kbd-global-pair old-elt)) + ((symbolp scope) (assoc scope (viper-kbd-mode-alist old-elt))) + ((stringp scope) (assoc scope (viper-kbd-buf-alist old-elt))))) (if old-sub-elt (setcdr old-sub-elt macro-body) (cond ((symbolp scope) (setcar (cdr (cdr old-elt)) (cons (cons scope macro-body) - (vip-kbd-mode-alist old-elt)))) + (viper-kbd-mode-alist old-elt)))) ((stringp scope) (setcar (cdr old-elt) (cons (cons scope macro-body) - (vip-kbd-buf-alist old-elt)))))) + (viper-kbd-buf-alist old-elt)))))) )) -;; macro name must be a vector of vip-style keys -(defun vip-unrecord-kbd-macro (macro-name state) +;; 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 vip-style keys. This command is used by Viper -internally, but the user can also use it in ~/.vip 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 vip-describe-kbd-macros and copy the name from -there." +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." (let* (state-name keymap (macro-alist-var (cond ((eq state 'vi-state) (setq state-name "Vi state" - keymap vip-vi-kbd-map) - 'vip-vi-kbd-macro-alist) + keymap viper-vi-kbd-map) + 'viper-vi-kbd-macro-alist) ((memq state '(insert-state replace-state)) (setq state-name "Insert state" - keymap vip-insert-kbd-map) - 'vip-insert-kbd-macro-alist) + keymap viper-insert-kbd-map) + 'viper-insert-kbd-macro-alist) (t (setq state-name "Emacs state" - keymap vip-emacs-kbd-map) - 'vip-emacs-kbd-macro-alist) + keymap viper-emacs-kbd-map) + 'viper-emacs-kbd-macro-alist) )) buf-mapping mode-mapping global-mapping macro-pair macro-entry) ;; Macro-name is usually a vector. However, command history or macros - ;; recorded in ~/.vip may appear as strings. So, convert to vectors. - (setq macro-name (vip-fixup-macro macro-name)) - (if (vip-char-array-p macro-name) - (setq macro-name (vip-char-array-to-macro macro-name))) + ;; 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))) (setq macro-entry (assoc macro-name (eval macro-alist-var))) (if (= (length macro-name) 0) (error "Can't unmap an empty macro name")) (if (null macro-entry) (error "%S is not mapped to a macro for %s in `%s'" - (vip-display-macro macro-name) + (viper-display-macro macro-name) state-name (buffer-name))) - (setq buf-mapping (vip-kbd-buf-pair macro-entry) - mode-mapping (vip-kbd-mode-pair macro-entry) - global-mapping (vip-kbd-global-pair macro-entry)) + (setq buf-mapping (viper-kbd-buf-pair macro-entry) + mode-mapping (viper-kbd-mode-pair macro-entry) + global-mapping (viper-kbd-global-pair macro-entry)) (cond ((and (cdr buf-mapping) (or (and (not (cdr mode-mapping)) (not (cdr global-mapping))) (y-or-n-p (format "Unmap %S for `%s' only? " - (vip-display-macro macro-name) + (viper-display-macro macro-name) (buffer-name))))) (setq macro-pair buf-mapping) (message "%S is unmapped for %s in `%s'" - (vip-display-macro macro-name) + (viper-display-macro macro-name) state-name (buffer-name))) ((and (cdr mode-mapping) (or (not (cdr global-mapping)) (y-or-n-p (format "Unmap %S for the major mode `%S' only? " - (vip-display-macro macro-name) + (viper-display-macro macro-name) major-mode)))) (setq macro-pair mode-mapping) (message "%S is unmapped for %s in %S" - (vip-display-macro macro-name) state-name major-mode)) - ((cdr (setq macro-pair (vip-kbd-global-pair macro-entry))) + (viper-display-macro macro-name) state-name major-mode)) + ((cdr (setq macro-pair (viper-kbd-global-pair macro-entry))) (message "Global mapping for %S in %s is removed" - (vip-display-macro macro-name) state-name)) + (viper-display-macro macro-name) state-name)) (t (error "%S is not mapped to a macro for %s in `%s'" - (vip-display-macro macro-name) + (viper-display-macro macro-name) state-name (buffer-name)))) (setcdr macro-pair nil) (or (cdr buf-mapping) @@ -554,19 +554,19 @@ (cdr global-mapping) (progn (set macro-alist-var (delq macro-entry (eval macro-alist-var))) - (if (vip-can-release-key (aref macro-name 0) + (if (viper-can-release-key (aref macro-name 0) (eval macro-alist-var)) (define-key keymap - (vector (vip-key-to-emacs-key (aref macro-name 0))) + (vector (viper-key-to-emacs-key (aref macro-name 0))) nil)) )) )) ;; Check if MACRO-ALIST has an entry for a macro name starting with ;; CHAR. If not, this indicates that the binding for this char -;; in vip-vi/insert-kbd-map can be released. -(defun vip-can-release-key (char macro-alist) +;; in viper-vi/insert-kbd-map can be released. +(defun viper-can-release-key (char macro-alist) (let ((lis macro-alist) (can-release t) macro-name) @@ -579,52 +579,52 @@ can-release)) -(defun vip-exec-mapped-kbd-macro (count) +(defun viper-exec-mapped-kbd-macro (count) "Dispatch kbd macro." (interactive "P") - (let* ((macro-alist (cond ((eq vip-current-state 'vi-state) - vip-vi-kbd-macro-alist) - ((memq vip-current-state + (let* ((macro-alist (cond ((eq viper-current-state 'vi-state) + viper-vi-kbd-macro-alist) + ((memq viper-current-state '(insert-state replace-state)) - vip-insert-kbd-macro-alist) + viper-insert-kbd-macro-alist) (t - vip-emacs-kbd-macro-alist))) + viper-emacs-kbd-macro-alist))) (unmatched-suffix "") ;; Macros and keys are executed with other macros turned off ;; For macros, this is done to avoid macro recursion - vip-vi-kbd-minor-mode vip-insert-kbd-minor-mode - vip-emacs-kbd-minor-mode + viper-vi-kbd-minor-mode viper-insert-kbd-minor-mode + viper-emacs-kbd-minor-mode next-best-match keyseq event-seq macro-first-char macro-alist-elt macro-body command) (setq macro-first-char last-command-event - event-seq (vip-read-fast-keysequence macro-first-char macro-alist) - keyseq (vip-events-to-macro event-seq) + event-seq (viper-read-fast-keysequence macro-first-char macro-alist) + keyseq (viper-events-to-macro event-seq) macro-alist-elt (assoc keyseq macro-alist) - next-best-match (vip-find-best-matching-macro macro-alist keyseq)) + next-best-match (viper-find-best-matching-macro macro-alist keyseq)) (if (null macro-alist-elt) (setq macro-alist-elt (car next-best-match) unmatched-suffix (subseq event-seq (cdr next-best-match)))) (cond ((null macro-alist-elt)) - ((setq macro-body (vip-kbd-buf-definition macro-alist-elt))) - ((setq macro-body (vip-kbd-mode-definition macro-alist-elt))) - ((setq macro-body (vip-kbd-global-definition macro-alist-elt)))) + ((setq macro-body (viper-kbd-buf-definition macro-alist-elt))) + ((setq macro-body (viper-kbd-mode-definition macro-alist-elt))) + ((setq macro-body (viper-kbd-global-definition macro-alist-elt)))) ;; when defining keyboard macro, don't use the macro mappings (if (and macro-body (not defining-kbd-macro)) ;; block cmd executed as part of a macro from entering command history (let ((command-history command-history)) - (setq vip-this-kbd-macro (car macro-alist-elt)) - (execute-kbd-macro (vip-macro-to-events macro-body) count) - (setq vip-this-kbd-macro nil - vip-last-kbd-macro (car macro-alist-elt)) - (vip-set-unread-command-events unmatched-suffix)) + (setq viper-this-kbd-macro (car macro-alist-elt)) + (execute-kbd-macro (viper-macro-to-events macro-body) count) + (setq viper-this-kbd-macro nil + viper-last-kbd-macro (car macro-alist-elt)) + (viper-set-unread-command-events unmatched-suffix)) ;; If not a macro, or the macro is suppressed while defining another ;; macro, put keyseq back on the event queue - (vip-set-unread-command-events event-seq) + (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 @@ -640,36 +640,36 @@ ;;; Displaying and completing macros -(defun vip-describe-kbd-macros () +(defun viper-describe-kbd-macros () "Show currently defined keyboard macros." (interactive) - (with-output-to-temp-buffer " *vip-info*" + (with-output-to-temp-buffer " *viper-info*" (princ "Macros in Vi state:\n===================\n") - (mapcar 'vip-describe-one-macro vip-vi-kbd-macro-alist) + (mapcar 'viper-describe-one-macro viper-vi-kbd-macro-alist) (princ "\n\nMacros in Insert and Replace states:\n====================================\n") - (mapcar 'vip-describe-one-macro vip-insert-kbd-macro-alist) + (mapcar 'viper-describe-one-macro viper-insert-kbd-macro-alist) (princ "\n\nMacros in Emacs state:\n======================\n") - (mapcar 'vip-describe-one-macro vip-emacs-kbd-macro-alist) + (mapcar 'viper-describe-one-macro viper-emacs-kbd-macro-alist) )) -(defun vip-describe-one-macro (macro) +(defun viper-describe-one-macro (macro) (princ (format "\n *** Mappings for %S:\n ------------\n" - (vip-display-macro (car macro)))) + (viper-display-macro (car macro)))) (princ " ** Buffer-specific:") - (if (vip-kbd-buf-alist macro) - (mapcar 'vip-describe-one-macro-elt (vip-kbd-buf-alist macro)) + (if (viper-kbd-buf-alist macro) + (mapcar 'viper-describe-one-macro-elt (viper-kbd-buf-alist macro)) (princ " none\n")) (princ "\n ** Mode-specific:") - (if (vip-kbd-mode-alist macro) - (mapcar 'vip-describe-one-macro-elt (vip-kbd-mode-alist macro)) + (if (viper-kbd-mode-alist macro) + (mapcar 'viper-describe-one-macro-elt (viper-kbd-mode-alist macro)) (princ " none\n")) (princ "\n ** Global:") - (if (vip-kbd-global-definition macro) - (princ (format "\n %S" (cdr (vip-kbd-global-pair macro)))) + (if (viper-kbd-global-definition macro) + (princ (format "\n %S" (cdr (viper-kbd-global-pair macro)))) (princ " none")) (princ "\n")) -(defun vip-describe-one-macro-elt (elt) +(defun viper-describe-one-macro-elt (elt) (let ((name (car elt)) (defn (cdr elt))) (princ (format "\n * %S:\n %S\n" name defn)))) @@ -677,23 +677,23 @@ ;; check if SEQ is a prefix of some car of an element in ALIST -(defun vip-keyseq-is-a-possible-macro (seq alist) - (let ((converted-seq (vip-events-to-macro seq))) +(defun viper-keyseq-is-a-possible-macro (seq alist) + (let ((converted-seq (viper-events-to-macro seq))) (eval (cons 'or (mapcar (function (lambda (elt) - (vip-prefix-subseq-p converted-seq elt))) - (vip-this-buffer-macros alist)))))) + (viper-prefix-subseq-p converted-seq elt))) + (viper-this-buffer-macros alist)))))) ;; whether SEQ1 is a prefix of SEQ2 -(defun vip-prefix-subseq-p (seq1 seq2) +(defun viper-prefix-subseq-p (seq1 seq2) (let ((len1 (length seq1)) (len2 (length seq2))) (if (<= len1 len2) (equal seq1 (subseq seq2 0 len1))))) ;; find the longest common prefix -(defun vip-common-seq-prefix (&rest seqs) +(defun viper-common-seq-prefix (&rest seqs) (let* ((first (car seqs)) (rest (cdr seqs)) (pref []) @@ -713,15 +713,15 @@ pref)) ;; get all sequences that match PREFIX from a given A-LIST -(defun vip-extract-matching-alist-members (pref alist) +(defun viper-extract-matching-alist-members (pref alist) (delq nil (mapcar (function (lambda (elt) - (if (vip-prefix-subseq-p pref elt) + (if (viper-prefix-subseq-p pref elt) elt))) - (vip-this-buffer-macros alist)))) + (viper-this-buffer-macros alist)))) -(defun vip-do-sequence-completion (seq alist compl-message) - (let* ((matches (vip-extract-matching-alist-members seq alist)) - (new-seq (apply 'vip-common-seq-prefix matches)) +(defun viper-do-sequence-completion (seq alist compl-message) + (let* ((matches (viper-extract-matching-alist-members seq alist)) + (new-seq (apply 'viper-common-seq-prefix matches)) ) (cond ((and (equal seq new-seq) (= (length matches) 1)) (message "%s (Sole completion)" compl-message) @@ -733,24 +733,24 @@ ((member seq matches) (message "%s (Complete, but not unique)" compl-message) (sit-for 2) - (vip-display-vector-completions matches)) + (viper-display-vector-completions matches)) ((equal seq new-seq) - (vip-display-vector-completions matches))) + (viper-display-vector-completions matches))) new-seq)) -(defun vip-display-vector-completions (list) +(defun viper-display-vector-completions (list) (with-output-to-temp-buffer "*Completions*" (display-completion-list (mapcar 'prin1-to-string - (mapcar 'vip-display-macro list))))) + (mapcar 'viper-display-macro list))))) ;; alist is the alist of macros ;; str is the fast key sequence entered ;; returns: (matching-macro-def . unmatched-suffix-start-index) -(defun vip-find-best-matching-macro (alist str) +(defun viper-find-best-matching-macro (alist str) (let ((lis alist) (def-len 0) (str-len (length str)) @@ -760,9 +760,9 @@ def-len (length (car macro-def))) (if (and (>= str-len def-len) (equal (car macro-def) (subseq str 0 def-len))) - (if (or (vip-kbd-buf-definition macro-def) - (vip-kbd-mode-definition macro-def) - (vip-kbd-global-definition macro-def)) + (if (or (viper-kbd-buf-definition macro-def) + (viper-kbd-mode-definition macro-def) + (viper-kbd-global-definition macro-def)) (setq found t)) ) (setq lis (cdr lis))) @@ -778,14 +778,14 @@ ;; returns a list of names of macros defined for the current buffer -(defun vip-this-buffer-macros (macro-alist) +(defun viper-this-buffer-macros (macro-alist) (let (candidates) (setq candidates (mapcar (function (lambda (elt) - (if (or (vip-kbd-buf-definition elt) - (vip-kbd-mode-definition elt) - (vip-kbd-global-definition 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)))) @@ -793,10 +793,10 @@ ;; if seq of Viper key symbols (representing a macro) can be converted to a ;; string--do so. Otherwise, do nothing. -(defun vip-display-macro (macro-name-or-body) - (cond ((vip-char-symbol-sequence-p macro-name-or-body) +(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 "")) - ((vip-char-array-p macro-name-or-body) + ((viper-char-array-p macro-name-or-body) (mapconcat 'char-to-string macro-name-or-body "")) (t macro-name-or-body))) @@ -809,27 +809,27 @@ ;; 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 ;; textual form (say, in .emacs) and then read them back. -(defun vip-events-to-macro (event-seq) +(defun viper-events-to-macro (event-seq) (vconcat (delq nil (mapcar (function (lambda (elt) (if (consp elt) nil - (vip-event-key elt)))) + (viper-event-key elt)))) event-seq)))) ;; convert strings or arrays of characters to Viper macro form -(defun vip-char-array-to-macro (array) +(defun viper-char-array-to-macro (array) (let ((vec (vconcat array)) macro) - (if vip-xemacs-p + (if viper-xemacs-p (setq macro (mapcar 'character-to-event vec)) (setq macro vec)) - (vconcat (mapcar 'vip-event-key macro)))) + (vconcat (mapcar 'viper-event-key macro)))) ;; For macros bodies and names, goes over MACRO and checks if all members are ;; names of keys (actually, it only checks if they are symbols or lists ;; if a digit is found, it is converted into a symbol (e.g., 0 -> \0, etc). ;; If MACRO is not a list or vector -- doesn't change MACRO. -(defun vip-fixup-macro (macro) +(defun viper-fixup-macro (macro) (let ((len (length macro)) (idx 0) elt break) @@ -848,7 +848,7 @@ (intern (char-to-string (+ ?0 elt))))) ))) ((listp elt) - (vip-fixup-macro elt)) + (viper-fixup-macro elt)) ((symbolp elt) nil) (t (setq break t))) (setq idx (1+ idx)))) @@ -857,15 +857,15 @@ (error "Wrong type macro component, symbol-or-listp, %S" elt) macro))) -(defun vip-char-array-p (array) - (eval (cons 'and (mapcar 'vip-characterp array)))) +(defun viper-char-array-p (array) + (eval (cons 'and (mapcar 'viper-characterp array)))) -(defun vip-macro-to-events (macro-body) - (vconcat (mapcar 'vip-key-to-emacs-key macro-body))) +(defun viper-macro-to-events (macro-body) + (vconcat (mapcar 'viper-key-to-emacs-key macro-body))) ;; check if vec is a vector of character symbols -(defun vip-char-symbol-sequence-p (vec) +(defun viper-char-symbol-sequence-p (vec) (and (sequencep vec) (eval @@ -878,7 +878,7 @@ ;; Check if vec is a vector of key-press events representing characters ;; XEmacs only -(defun vip-event-vector-p (vec) +(defun viper-event-vector-p (vec) (and (vectorp vec) (eval (cons 'and (mapcar '(lambda (elt) (if (eventp elt) t)) vec))))) @@ -889,15 +889,15 @@ ;; 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 -;; vip-fast-keyseq-timeout. -(defun vip-read-fast-keysequence (event macro-alist) +;; viper-fast-keyseq-timeout. +(defun viper-read-fast-keysequence (event macro-alist) (let ((lis (vector event)) next-event) - (while (and (vip-fast-keysequence-p) - (vip-keyseq-is-a-possible-macro lis macro-alist)) - (setq next-event (vip-read-key)) - ;;(setq next-event (vip-read-event)) - (or (vip-mouse-event-p next-event) + (while (and (viper-fast-keysequence-p) + (viper-keyseq-is-a-possible-macro lis macro-alist)) + (setq next-event (viper-read-key)) + ;;(setq next-event (viper-read-event)) + (or (viper-mouse-event-p next-event) (setq lis (vconcat lis (vector next-event))))) lis)) @@ -905,7 +905,7 @@ ;;; Keyboard macros in registers ;; sets register to last-kbd-macro carefully. -(defun vip-set-register-macro (reg) +(defun viper-set-register-macro (reg) (if (get-register reg) (if (y-or-n-p "Register contains data. Overwrite? ") () @@ -913,35 +913,35 @@ "Macro not saved in register. Can still be invoked via `C-x e'"))) (set-register reg last-kbd-macro)) -(defun vip-register-macro (count) +(defun viper-register-macro (count) "Keyboard macros in registers - a modified \@ command." (interactive "P") (let ((reg (downcase (read-char)))) (cond ((or (and (<= ?a reg) (<= reg ?z))) - (setq vip-last-macro-reg reg) + (setq viper-last-macro-reg reg) (if defining-kbd-macro (progn (end-kbd-macro) - (vip-set-register-macro reg)) + (viper-set-register-macro reg)) (execute-kbd-macro (get-register reg) count))) ((or (= ?@ reg) (= ?\^j reg) (= ?\^m reg)) - (if vip-last-macro-reg + (if viper-last-macro-reg nil (error "No previous kbd macro")) - (execute-kbd-macro (get-register vip-last-macro-reg) count)) + (execute-kbd-macro (get-register viper-last-macro-reg) count)) ((= ?\# reg) (start-kbd-macro count)) ((= ?! reg) (setq reg (downcase (read-char))) (if (or (and (<= ?a reg) (<= reg ?z))) (progn - (setq vip-last-macro-reg reg) - (vip-set-register-macro reg)))) + (setq viper-last-macro-reg reg) + (viper-set-register-macro reg)))) (t (error "`%c': Unknown register" reg))))) -(defun vip-global-execute () +(defun viper-global-execute () "Call last keyboad macro for each line in the region." (if (> (point) (mark t)) (exchange-point-and-mark)) (beginning-of-line)
--- a/lisp/emulation/viper-mous.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-mous.el Sat Aug 02 07:40:22 1997 +0000 @@ -26,11 +26,11 @@ ;; compiler pacifier (defvar double-click-time) (defvar mouse-track-multi-click-time) -(defvar vip-search-start-marker) -(defvar vip-local-search-start-marker) -(defvar vip-search-history) -(defvar vip-s-string) -(defvar vip-re-search) +(defvar viper-search-start-marker) +(defvar viper-local-search-start-marker) +(defvar viper-search-history) +(defvar viper-s-string) +(defvar viper-re-search) ;; loading happens only in non-interactive compilation ;; in order to spare non-viperized emacs from being viperized @@ -49,7 +49,7 @@ (defgroup viper-mouse nil "Support for Viper special mouse-bound commands" - :prefix "vip-" + :prefix "viper-" :group 'viper) @@ -57,13 +57,13 @@ ;; Variable used for catching the switch-frame event. ;; If non-nil, indicates that previous-frame should be the selected -;; one. Used by vip-mouse-click-get-word. Not a user option. -(defvar vip-frame-of-focus nil) +;; 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. -(defconst vip-current-frame-saved (selected-frame)) +(defconst viper-current-frame-saved (selected-frame)) -(defcustom vip-surrounding-word-function 'vip-surrounding-word +(defcustom viper-surrounding-word-function 'viper-surrounding-word "*Function that determines what constitutes a word for clicking events. Takes two parameters: a COUNT, indicating how many words to return, and CLICK-COUNT, telling whether this is the first click, a double-click, @@ -73,8 +73,8 @@ ;; time interval in millisecond within which successive clicks are ;; considered related -(defcustom vip-multiclick-timeout (if (vip-window-display-p) - (if vip-xemacs-p +(defcustom viper-multiclick-timeout (if (viper-window-display-p) + (if viper-xemacs-p mouse-track-multi-click-time double-click-time) 500) @@ -84,55 +84,63 @@ :group 'viper-mouse) ;; current event click count; XEmacs only -(defvar vip-current-click-count 0) +(defvar viper-current-click-count 0) ;; time stamp of the last click event; XEmacs only -(defvar vip-last-click-event-timestamp 0) +(defvar viper-last-click-event-timestamp 0) ;; Local variable used to toggle wraparound search on click. -(vip-deflocalvar vip-mouse-click-search-noerror t) +(viper-deflocalvar viper-mouse-click-search-noerror t) ;; Local variable used to delimit search after wraparound. -(vip-deflocalvar vip-mouse-click-search-limit nil) +(viper-deflocalvar viper-mouse-click-search-limit nil) ;; remembers prefix argument to pass along to commands invoked by second ;; click. ;; This is needed because in Emacs (not XEmacs), assigning to preix-arg ;; causes Emacs to count the second click as if it was a single click -(defvar vip-global-prefix-argument nil) +(defvar viper-global-prefix-argument nil) + + +;; same keys, but parsed +(defvar viper-mouse-up-search-key-parsed nil) +(defvar viper-mouse-down-search-key-parsed nil) +(defvar viper-mouse-up-insert-key-parsed nil) +(defvar viper-mouse-down-insert-key-parsed nil) + ;;; Code -(defsubst vip-multiclick-p () - (not (vip-sit-for-short vip-multiclick-timeout t))) +(defsubst viper-multiclick-p () + (not (viper-sit-for-short viper-multiclick-timeout t))) ;; Returns window where click occurs -(defsubst vip-mouse-click-window (click) - (if vip-xemacs-p +(defsubst viper-mouse-click-window (click) + (if viper-xemacs-p (event-window click) (posn-window (event-start click)))) ;; Returns window where click occurs -(defsubst vip-mouse-click-frame (click) - (window-frame (vip-mouse-click-window click))) +(defsubst viper-mouse-click-frame (click) + (window-frame (viper-mouse-click-window click))) ;; Returns the buffer of the window where click occurs -(defsubst vip-mouse-click-window-buffer (click) - (window-buffer (vip-mouse-click-window click))) +(defsubst viper-mouse-click-window-buffer (click) + (window-buffer (viper-mouse-click-window click))) ;; Returns the name of the buffer in the window where click occurs -(defsubst vip-mouse-click-window-buffer-name (click) - (buffer-name (vip-mouse-click-window-buffer click))) +(defsubst viper-mouse-click-window-buffer-name (click) + (buffer-name (viper-mouse-click-window-buffer click))) ;; Returns position of a click -(defsubst vip-mouse-click-posn (click) - (if vip-xemacs-p +(defsubst viper-mouse-click-posn (click) + (if viper-xemacs-p (event-point click) (posn-point (event-start click)))) -(defun vip-surrounding-word (count click-count) +(defun viper-surrounding-word (count click-count) "Returns word surrounding point according to a heuristic. COUNT indicates how many regions to return. If CLICK-COUNT is 1, `word' is a word in Vi sense. @@ -153,16 +161,16 @@ (if (> click-count 2) (save-excursion (beginning-of-line) - (vip-skip-all-separators-forward 'within-line) + (viper-skip-all-separators-forward 'within-line) (setq beg (point)) (end-of-line) (setq result (buffer-substring beg (point)))) - (if (and (not (vip-looking-at-alphasep)) - (or (save-excursion (vip-backward-char-carefully) - (vip-looking-at-alpha)) - (save-excursion (vip-forward-char-carefully) - (vip-looking-at-alpha)))) + (if (and (not (viper-looking-at-alphasep)) + (or (save-excursion (viper-backward-char-carefully) + (viper-looking-at-alpha)) + (save-excursion (viper-forward-char-carefully) + (viper-looking-at-alpha)))) (setq modifiers (cond ((looking-at "\\\\") "\\\\") ((looking-at "-") "C-C-") @@ -172,7 +180,7 @@ ((looking-at "[<>]") "<>") ((looking-at "[`']") "`'") ((looking-at "\\^") "\\^") - ((vip-looking-at-separator) "") + ((viper-looking-at-separator) "") (t (char-to-string (following-char)))) )) @@ -183,45 +191,45 @@ (save-excursion - (cond ((> click-count 1) (vip-skip-nonseparators 'backward)) - ((vip-looking-at-alpha modifiers) - (vip-skip-alpha-backward modifiers)) - ((not (vip-looking-at-alphasep modifiers)) - (vip-skip-nonalphasep-backward)) + (cond ((> click-count 1) (viper-skip-nonseparators 'backward)) + ((viper-looking-at-alpha modifiers) + (viper-skip-alpha-backward modifiers)) + ((not (viper-looking-at-alphasep modifiers)) + (viper-skip-nonalphasep-backward)) (t (if (> click-count 1) - (vip-skip-nonseparators 'backward) - (vip-skip-alpha-backward modifiers)))) + (viper-skip-nonseparators 'backward) + (viper-skip-alpha-backward modifiers)))) (setq word-beg (point)) (setq skip-flag nil) ; don't move 1 char forw the first time (while (> count 0) - (if skip-flag (vip-forward-char-carefully 1)) + (if skip-flag (viper-forward-char-carefully 1)) (setq skip-flag t) ; now always move 1 char forward (if (> click-count 1) - (vip-skip-nonseparators 'forward) - (vip-skip-alpha-forward modifiers)) + (viper-skip-nonseparators 'forward) + (viper-skip-alpha-forward modifiers)) (setq count (1- count))) (setq result (buffer-substring word-beg (point)))) ) ; if ;; XEmacs doesn't have set-text-properties, but there buffer-substring ;; doesn't return properties together with the string, so it's not needed. - (if vip-emacs-p + (if viper-emacs-p (set-text-properties 0 (length result) nil result)) result )) -(defun vip-mouse-click-get-word (click count click-count) +(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. On single or double click, returns the word as determined by -`vip-surrounding-word-function'." +`viper-surrounding-word-function'." (let ((click-word "") - (click-pos (vip-mouse-click-posn click)) - (click-buf (vip-mouse-click-window-buffer click))) + (click-pos (viper-mouse-click-posn click)) + (click-buf (viper-mouse-click-window-buffer click))) (or (natnump count) (setq count 1)) (or (natnump click-count) (setq click-count 1)) @@ -233,21 +241,21 @@ (goto-char click-pos) (setq click-word - (funcall vip-surrounding-word-function count click-count))) + (funcall viper-surrounding-word-function count click-count))) (error "Click must be over a window.")) click-word)))) -(defun vip-mouse-click-insert-word (click arg) +(defun viper-mouse-click-insert-word (click arg) "Insert word clicked or double-clicked on. With prefix argument, N, insert that many words. This command must be bound to a mouse click. The double-click action of the same mouse button must not be bound \(or it must be bound to the same function\). -See `vip-surrounding-word' for the definition of a word in this case." +See `viper-surrounding-word' for the definition of a word in this case." (interactive "e\nP") - (if vip-frame-of-focus ;; to handle clicks in another frame - (select-frame vip-frame-of-focus)) + (if viper-frame-of-focus ;; to handle clicks in another frame + (select-frame viper-frame-of-focus)) ;; turn arg into a number (cond ((integerp arg) nil) @@ -256,168 +264,175 @@ (setq arg (car arg))) (t (setq arg 1))) - (let (click-count interrupting-event) - (if (and - (vip-multiclick-p) - ;; This trick checks if there is a pending mouse event - ;; if so, we use this latter event and discard the current mouse click - ;; If the next pending event is not a mouse event, we execute - ;; the current mouse event - (progn - (setq interrupting-event (vip-read-event)) - (vip-mouse-event-p last-input-event))) - (progn ;; interrupted wait - (setq vip-global-prefix-argument arg) - ;; count this click for XEmacs - (vip-event-click-count click)) - ;; uninterrupted wait or the interrupting event wasn't a mouse event - (setq click-count (vip-event-click-count click)) - (if (> click-count 1) - (setq arg vip-global-prefix-argument - vip-global-prefix-argument nil)) - (insert (vip-mouse-click-get-word click arg click-count)) - (if (and interrupting-event - (eventp interrupting-event) - (not (vip-mouse-event-p interrupting-event))) - (vip-set-unread-command-events interrupting-event)) - ))) + (if (not (eq (key-binding viper-mouse-down-insert-key-parsed) + 'viper-mouse-catch-frame-switch)) + () ; do nothing + (let (click-count interrupting-event) + (if (and + (viper-multiclick-p) + ;; This trick checks if there is a pending mouse event if so, we use + ;; this latter event and discard the current mouse click If the next + ;; pending event is not a mouse event, we execute the current mouse + ;; event + (progn + (setq interrupting-event (viper-read-event)) + (viper-mouse-event-p last-input-event))) + (progn ; interrupted wait + (setq viper-global-prefix-argument arg) + ;; count this click for XEmacs + (viper-event-click-count click)) + ;; uninterrupted wait or the interrupting event wasn't a mouse event + (setq click-count (viper-event-click-count click)) + (if (> click-count 1) + (setq arg viper-global-prefix-argument + viper-global-prefix-argument nil)) + (insert (viper-mouse-click-get-word click arg click-count)) + (if (and interrupting-event + (eventp interrupting-event) + (not (viper-mouse-event-p interrupting-event))) + (viper-set-unread-command-events interrupting-event)) + )))) ;; arg is an event. accepts symbols and numbers, too -(defun vip-mouse-event-p (event) +(defun viper-mouse-event-p (event) (if (eventp event) (string-match "\\(mouse-\\|frame\\|screen\\|track\\)" - (prin1-to-string (vip-event-key event))))) + (prin1-to-string (viper-event-key event))))) ;; XEmacs has no double-click events. So, we must simulate. ;; So, we have to simulate event-click-count. -(defun vip-event-click-count (click) - (if vip-xemacs-p +(defun viper-event-click-count (click) + (if viper-xemacs-p (progn ;; if more than 1 second - (if (> (- (event-timestamp click) vip-last-click-event-timestamp) - vip-multiclick-timeout) - (setq vip-current-click-count 0)) - (setq vip-last-click-event-timestamp (event-timestamp click) - vip-current-click-count (1+ vip-current-click-count))) + (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))) (event-click-count click))) -(defun vip-mouse-click-search-word (click arg) +(defun viper-mouse-click-search-word (click arg) "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 same button must not be bound \(or it must be bound to the same function\). -See `vip-surrounding-word' for the details on what constitutes a word for +See `viper-surrounding-word' for the details on what constitutes a word for this command." (interactive "e\nP") - (if vip-frame-of-focus ;; to handle clicks in another frame - (select-frame vip-frame-of-focus)) - (let (click-word click-count - (previous-search-string vip-s-string)) - - (if (and - (vip-multiclick-p) - ;; This trick checks if there is a pending mouse event - ;; if so, we use this latter event and discard the current mouse click - ;; If the next pending event is not a mouse event, we execute - ;; the current mouse event - (progn - (vip-read-event) - (vip-mouse-event-p last-input-event))) - (progn ;; interrupted wait - (setq vip-global-prefix-argument - (or vip-global-prefix-argument arg)) - ;; remember command that was before the multiclick - (setq this-command last-command) - ;; make sure we counted this event---needed for XEmacs only - (vip-event-click-count click)) - ;; uninterrupted wait - (setq click-count (vip-event-click-count click)) - (setq click-word (vip-mouse-click-get-word click nil click-count)) - - (if (> click-count 1) - (setq arg vip-global-prefix-argument - vip-global-prefix-argument nil)) - (setq arg (or arg 1)) + (if viper-frame-of-focus ;; to handle clicks in another frame + (select-frame viper-frame-of-focus)) + (if (not (eq (key-binding viper-mouse-down-search-key-parsed) + 'viper-mouse-catch-frame-switch)) + () ; do nothing + (let ((previous-search-string viper-s-string) + click-word click-count) - (vip-deactivate-mark) - (if (or (not (string= click-word vip-s-string)) - (not (markerp vip-search-start-marker)) - (not (equal (marker-buffer vip-search-start-marker) - (current-buffer))) - (not (eq last-command 'vip-mouse-click-search-word))) - (progn - (setq vip-search-start-marker (point-marker) - vip-local-search-start-marker vip-search-start-marker - vip-mouse-click-search-noerror t - vip-mouse-click-search-limit nil) - - ;; make search string known to Viper - (setq vip-s-string (if vip-re-search - (regexp-quote click-word) - click-word)) - (if (not (string= vip-s-string (car vip-search-history))) - (setq vip-search-history - (cons vip-s-string vip-search-history))) - )) - - (push-mark nil t) - (while (> arg 0) - (vip-forward-word 1) - (condition-case nil + (if (and + (viper-multiclick-p) + ;; This trick checks if there is a pending mouse event if so, we use + ;; this latter event and discard the current mouse click If the next + ;; pending event is not a mouse event, we execute the current mouse + ;; event + (progn + (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) + ;; make sure we counted this event---needed for XEmacs only + (viper-event-click-count click)) + ;; uninterrupted wait + (setq click-count (viper-event-click-count click)) + (setq click-word (viper-mouse-click-get-word click nil click-count)) + + (if (> click-count 1) + (setq arg viper-global-prefix-argument + viper-global-prefix-argument nil)) + (setq arg (or arg 1)) + + (viper-deactivate-mark) + (if (or (not (string= click-word viper-s-string)) + (not (markerp viper-search-start-marker)) + (not (equal (marker-buffer viper-search-start-marker) + (current-buffer))) + (not (eq last-command 'viper-mouse-click-search-word))) (progn - (if (not (search-forward click-word vip-mouse-click-search-limit - vip-mouse-click-search-noerror)) - (progn - (setq vip-mouse-click-search-noerror nil) - (setq vip-mouse-click-search-limit - (save-excursion - (if (and - (markerp vip-local-search-start-marker) - (marker-buffer vip-local-search-start-marker)) - (goto-char vip-local-search-start-marker)) - (vip-line-pos 'end))) - - (goto-char (point-min)) - (search-forward click-word - vip-mouse-click-search-limit nil))) - (goto-char (match-beginning 0)) - (message "Searching for: %s" vip-s-string) - (if (<= arg 1) ; found the right occurrence of the pattern - (progn - (vip-adjust-window) - (vip-flash-search-pattern))) - ) - (error (beep 1) - (if (or (not (string= click-word previous-search-string)) - (not (eq last-command 'vip-mouse-click-search-word))) - (message "`%s': String not found in %s" - vip-s-string (buffer-name (current-buffer))) - (message - "`%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)) - (setq vip-mouse-click-search-noerror t) - (setq vip-mouse-click-search-limit nil) - (if (and (markerp vip-local-search-start-marker) - (marker-buffer vip-local-search-start-marker)) - (goto-char vip-local-search-start-marker)))) - (setq arg (1- arg))) - ))) + (setq viper-search-start-marker (point-marker) + viper-local-search-start-marker viper-search-start-marker + viper-mouse-click-search-noerror t + viper-mouse-click-search-limit nil) + + ;; make search string known to Viper + (setq viper-s-string (if viper-re-search + (regexp-quote click-word) + click-word)) + (if (not (string= viper-s-string (car viper-search-history))) + (setq viper-search-history + (cons viper-s-string viper-search-history))) + )) + + (push-mark nil t) + (while (> arg 0) + (viper-forward-word 1) + (condition-case nil + (progn + (if (not (search-forward + click-word viper-mouse-click-search-limit + viper-mouse-click-search-noerror)) + (progn + (setq viper-mouse-click-search-noerror nil) + (setq viper-mouse-click-search-limit + (save-excursion + (if (and + (markerp viper-local-search-start-marker) + (marker-buffer viper-local-search-start-marker)) + (goto-char viper-local-search-start-marker)) + (viper-line-pos 'end))) + + (goto-char (point-min)) + (search-forward click-word + viper-mouse-click-search-limit nil))) + (goto-char (match-beginning 0)) + (message "Searching for: %s" viper-s-string) + (if (<= arg 1) ; found the right occurrence of the pattern + (progn + (viper-adjust-window) + (viper-flash-search-pattern))) + ) + (error (beep 1) + (if (or (not (string= click-word previous-search-string)) + (not (eq last-command 'viper-mouse-click-search-word))) + (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" + click-word (buffer-name (current-buffer))) + (setq arg 1) ;; to terminate the loop + (sit-for 2)) + (setq viper-mouse-click-search-noerror t) + (setq viper-mouse-click-search-limit nil) + (if (and (markerp viper-local-search-start-marker) + (marker-buffer viper-local-search-start-marker)) + (goto-char viper-local-search-start-marker)))) + (setq arg (1- arg))) + )))) -(defun vip-mouse-catch-frame-switch (event arg) +(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 bindings in the Viper manual." (interactive "e\nP") - (setq vip-frame-of-focus nil) - ;; pass prefix arg along to vip-mouse-click-search/insert-word + (setq viper-frame-of-focus nil) + ;; pass prefix arg along to viper-mouse-click-search/insert-word (setq prefix-arg arg) (if (eq last-command 'handle-switch-frame) - (setq vip-frame-of-focus vip-current-frame-saved)) - ;; make Emacs forget that it executed vip-mouse-catch-frame-switch + (setq viper-frame-of-focus viper-current-frame-saved)) + ;; 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. @@ -431,18 +446,185 @@ ;; 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 -;; vip-mouse-click-* commands when you click in a frame other than the one +;; 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 -;; until you do something other than vip-mouse-click-* command. +;; 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. -(defsubst vip-remember-current-frame (frame) +(defsubst viper-remember-current-frame (frame) (setq last-command 'handle-switch-frame - vip-current-frame-saved (selected-frame))) + viper-current-frame-saved (selected-frame))) + + +;; 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 +;; returns button-down key. +(defun viper-parse-mouse-key (key-var event-type) + (let ((key (eval key-var)) + button-spec meta-spec shift-spec control-spec key-spec) + (if (null key) + ;; just return nil + () + (setq button-spec + (cond ((memq 1 key) + (if viper-emacs-p + (if (eq 'up event-type) + "mouse-1" "down-mouse-1") + (if (eq 'up event-type) + 'button1up 'button1))) + ((memq 2 key) + (if viper-emacs-p + (if (eq 'up event-type) + "mouse-2" "down-mouse-2") + (if (eq 'up event-type) + 'button2up 'button2))) + ((memq 3 key) + (if viper-emacs-p + (if (eq 'up event-type) + "mouse-3" "down-mouse-3") + (if (eq 'up event-type) + 'button3up 'button3))) + (t (error + "%S: invalid button number, %S" key-var key))) + meta-spec + (if (memq 'meta key) + (if viper-emacs-p "M-" 'meta) + (if viper-emacs-p "" nil)) + shift-spec + (if (memq 'shift key) + (if viper-emacs-p "S-" 'shift) + (if viper-emacs-p "" nil)) + control-spec + (if (memq 'control key) + (if viper-emacs-p "C-" 'control) + (if viper-emacs-p "" nil))) + + (setq key-spec (if viper-emacs-p + (vector + (intern + (concat + control-spec meta-spec shift-spec button-spec))) + (vector + (delq + nil + (list + control-spec meta-spec shift-spec button-spec))))) + ))) + +(defun viper-unbind-mouse-search-key () + (if viper-mouse-up-search-key-parsed + (global-unset-key viper-mouse-up-search-key-parsed)) + (if viper-mouse-down-search-key-parsed + (global-unset-key viper-mouse-down-search-key-parsed)) + (setq viper-mouse-up-search-key-parsed nil + viper-mouse-down-search-key-parsed nil)) + +(defun viper-unbind-mouse-insert-key () + (if viper-mouse-up-insert-key-parsed + (global-unset-key viper-mouse-up-insert-key-parsed)) + (if viper-mouse-down-insert-key-parsed + (global-unset-key viper-mouse-down-insert-key-parsed)) + (setq viper-mouse-up-insert-key-parsed nil + viper-mouse-down-insert-key-parsed nil)) + +;; If FORCE, bind even if this mouse action is already bound to something else +(defun viper-bind-mouse-search-key (&optional force) + (setq viper-mouse-up-search-key-parsed + (viper-parse-mouse-key 'viper-mouse-search-key 'up) + viper-mouse-down-search-key-parsed + (viper-parse-mouse-key 'viper-mouse-search-key 'down)) + (cond ((or (null viper-mouse-up-search-key-parsed) + (null viper-mouse-down-search-key-parsed)) + nil) ; just quit + ((and (null force) + (key-binding viper-mouse-up-search-key-parsed) + (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" + 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" + viper-mouse-down-search-key-parsed)) + (t + (global-set-key viper-mouse-up-search-key-parsed + 'viper-mouse-click-search-word) + (global-set-key viper-mouse-down-search-key-parsed + 'viper-mouse-catch-frame-switch)))) + +;; If FORCE, bind even if this mouse action is already bound to something else +(defun viper-bind-mouse-insert-key (&optional force) + (setq viper-mouse-up-insert-key-parsed + (viper-parse-mouse-key 'viper-mouse-insert-key 'up) + viper-mouse-down-insert-key-parsed + (viper-parse-mouse-key 'viper-mouse-insert-key 'down)) + (cond ((or (null viper-mouse-up-insert-key-parsed) + (null viper-mouse-down-insert-key-parsed)) + nil) ; just quit + ((and (null force) + (key-binding viper-mouse-up-insert-key-parsed) + (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" + 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" + viper-mouse-down-insert-key-parsed)) + (t + (global-set-key viper-mouse-up-insert-key-parsed + 'viper-mouse-click-insert-word) + (global-set-key viper-mouse-down-insert-key-parsed + 'viper-mouse-catch-frame-switch)))) + +(defun viper-reset-mouse-search-key (symb val) + (viper-unbind-mouse-search-key) + (set symb val) + (viper-bind-mouse-search-key 'force)) + +(defun viper-reset-mouse-insert-key (symb val) + (viper-unbind-mouse-insert-key) + (set symb val) + (viper-bind-mouse-insert-key 'force)) + + +(defcustom viper-mouse-search-key '(meta shift 1) + "*Key used to click-search in Viper. +Must be a list that specifies the mouse button and modifiers. The supported +modifiers are `meta', `shift', and `control'. For instance, `(meta shift 1)' +means that holding the meta and shift keys down and clicking on a word with +mouse button 1 will initiate search for that word in the buffer that was +current just before the click. This buffer may be different from the one where +the click occurred." + :type 'list + :set 'viper-reset-mouse-search-key + :group 'viper-mouse) + +(defcustom viper-mouse-insert-key '(meta shift 2) + "*Key used to click-insert in Viper. +Must be a list that specifies the mouse button and modifiers. The supported +modifiers are `meta', `shift', and `control'. For instance, `(meta shift 2)' +means that holding the meta and shift keys down and clicking on a word with +mouse button 2 will insert that word at the cursor in the buffer that was +current just before the click. This buffer may be different from the one where +the click occurred." + :type 'list + :set 'viper-reset-mouse-insert-key + :group 'viper-mouse) + ;;; Local Variables: -;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun) +;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) ;;; End:
--- a/lisp/emulation/viper-util.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper-util.el Sat Aug 02 07:40:22 1997 +0000 @@ -23,18 +23,18 @@ ;; Code ;; Compiler pacifier -(defvar vip-overriding-map) +(defvar viper-overriding-map) (defvar pm-color-alist) (defvar zmacs-region-stays) -(defvar vip-minibuffer-current-face) -(defvar vip-minibuffer-insert-face) -(defvar vip-minibuffer-vi-face) -(defvar vip-minibuffer-emacs-face) -(defvar vip-replace-overlay-face) -(defvar vip-fast-keyseq-timeout) +(defvar viper-minibuffer-current-face) +(defvar viper-minibuffer-insert-face) +(defvar viper-minibuffer-vi-face) +(defvar viper-minibuffer-emacs-face) +(defvar viper-replace-overlay-face) +(defvar viper-fast-keyseq-timeout) (defvar ex-unix-type-shell) (defvar ex-unix-type-shell-options) -(defvar vip-ex-tmp-buf-name) +(defvar viper-ex-tmp-buf-name) (require 'cl) (require 'ring) @@ -55,62 +55,62 @@ ;; A fix for NeXT Step ;; Should probably be eliminated in later versions. -(if (and (vip-window-display-p) (eq (vip-device-type) 'ns)) +(if (and (viper-window-display-p) (eq (viper-device-type) 'ns)) (progn (fset 'x-display-color-p (symbol-function 'ns-display-color-p)) (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)) )) -(if vip-xemacs-p +(if viper-xemacs-p (progn - (fset 'vip-read-event (symbol-function 'next-command-event)) - (fset 'vip-make-overlay (symbol-function 'make-extent)) - (fset 'vip-overlay-start (symbol-function 'extent-start-position)) - (fset 'vip-overlay-end (symbol-function 'extent-end-position)) - (fset 'vip-overlay-put (symbol-function 'set-extent-property)) - (fset 'vip-overlay-p (symbol-function 'extentp)) - (fset 'vip-overlay-get (symbol-function 'extent-property)) - (fset 'vip-move-overlay (symbol-function 'set-extent-endpoints)) - (if (vip-window-display-p) - (fset 'vip-iconify (symbol-function 'iconify-frame))) - (cond ((vip-has-face-support-p) - (fset 'vip-get-face (symbol-function 'get-face)) - (fset 'vip-color-defined-p + (fset 'viper-read-event (symbol-function 'next-command-event)) + (fset 'viper-make-overlay (symbol-function 'make-extent)) + (fset 'viper-overlay-start (symbol-function 'extent-start-position)) + (fset 'viper-overlay-end (symbol-function 'extent-end-position)) + (fset 'viper-overlay-put (symbol-function 'set-extent-property)) + (fset 'viper-overlay-p (symbol-function 'extentp)) + (fset 'viper-overlay-get (symbol-function 'extent-property)) + (fset 'viper-move-overlay (symbol-function 'set-extent-endpoints)) + (if (viper-window-display-p) + (fset 'viper-iconify (symbol-function 'iconify-frame))) + (cond ((viper-has-face-support-p) + (fset 'viper-get-face (symbol-function 'get-face)) + (fset 'viper-color-defined-p (symbol-function 'valid-color-name-p)) ))) - (fset 'vip-read-event (symbol-function 'read-event)) - (fset 'vip-make-overlay (symbol-function 'make-overlay)) - (fset 'vip-overlay-start (symbol-function 'overlay-start)) - (fset 'vip-overlay-end (symbol-function 'overlay-end)) - (fset 'vip-overlay-put (symbol-function 'overlay-put)) - (fset 'vip-overlay-p (symbol-function 'overlayp)) - (fset 'vip-overlay-get (symbol-function 'overlay-get)) - (fset 'vip-move-overlay (symbol-function 'move-overlay)) - (if (vip-window-display-p) - (fset 'vip-iconify (symbol-function 'iconify-or-deiconify-frame))) - (cond ((vip-has-face-support-p) - (fset 'vip-get-face (symbol-function 'internal-get-face)) - (fset 'vip-color-defined-p (symbol-function 'x-color-defined-p)) + (fset 'viper-read-event (symbol-function 'read-event)) + (fset 'viper-make-overlay (symbol-function 'make-overlay)) + (fset 'viper-overlay-start (symbol-function 'overlay-start)) + (fset 'viper-overlay-end (symbol-function 'overlay-end)) + (fset 'viper-overlay-put (symbol-function 'overlay-put)) + (fset 'viper-overlay-p (symbol-function 'overlayp)) + (fset 'viper-overlay-get (symbol-function 'overlay-get)) + (fset 'viper-move-overlay (symbol-function 'move-overlay)) + (if (viper-window-display-p) + (fset 'viper-iconify (symbol-function 'iconify-or-deiconify-frame))) + (cond ((viper-has-face-support-p) + (fset 'viper-get-face (symbol-function 'internal-get-face)) + (fset 'viper-color-defined-p (symbol-function 'x-color-defined-p)) ))) -(fset 'vip-characterp +(fset 'viper-characterp (symbol-function - (if vip-xemacs-p 'characterp 'integerp))) + (if viper-xemacs-p 'characterp 'integerp))) -(defsubst vip-color-display-p () - (if vip-emacs-p +(defsubst viper-color-display-p () + (if viper-emacs-p (x-display-color-p) (eq (device-class (selected-device)) 'color))) -(defsubst vip-get-cursor-color () - (if vip-emacs-p +(defsubst viper-get-cursor-color () + (if viper-emacs-p (cdr (assoc 'cursor-color (frame-parameters))) (color-instance-name (frame-property (selected-frame) 'cursor-color)))) -(defun vip-set-face-pixmap (face pixmap) +(defun viper-set-face-pixmap (face pixmap) "Set face pixmap on a monochrome display." - (if (and (vip-window-display-p) (not (vip-color-display-p))) + (if (and (viper-window-display-p) (not (viper-color-display-p))) (condition-case nil (set-face-background-pixmap face pixmap) (error @@ -119,156 +119,156 @@ ;; OS/2 -(cond ((eq (vip-device-type) 'pm) - (fset 'vip-color-defined-p +(cond ((eq (viper-device-type) 'pm) + (fset 'viper-color-defined-p (function (lambda (color) (assoc color pm-color-alist)))))) ;; needed to smooth out the difference between Emacs and XEmacs -(defsubst vip-italicize-face (face) - (if vip-xemacs-p +(defsubst viper-italicize-face (face) + (if viper-xemacs-p (make-face-italic face) (make-face-italic face nil 'noerror))) ;; test if display is color and the colors are defined -(defsubst vip-can-use-colors (&rest colors) - (if (vip-color-display-p) - (not (memq nil (mapcar 'vip-color-defined-p colors))) +(defsubst viper-can-use-colors (&rest colors) + (if (viper-color-display-p) + (not (memq nil (mapcar 'viper-color-defined-p colors))) )) -(defun vip-hide-face (face) - (if (and (vip-has-face-support-p) vip-emacs-p) +(defun viper-hide-face (face) + (if (and (viper-has-face-support-p) viper-emacs-p) (add-to-list 'facemenu-unlisted-faces face))) ;; cursor colors -(defun vip-change-cursor-color (new-color) - (if (and (vip-window-display-p) (vip-color-display-p) - (stringp new-color) (vip-color-defined-p new-color) - (not (string= new-color (vip-get-cursor-color)))) +(defun viper-change-cursor-color (new-color) + (if (and (viper-window-display-p) (viper-color-display-p) + (stringp new-color) (viper-color-defined-p new-color) + (not (string= new-color (viper-get-cursor-color)))) (modify-frame-parameters (selected-frame) (list (cons 'cursor-color new-color))))) -(defun vip-save-cursor-color () - (if (and (vip-window-display-p) (vip-color-display-p)) - (let ((color (vip-get-cursor-color))) - (if (and (stringp color) (vip-color-defined-p color) - (not (string= color vip-replace-overlay-cursor-color))) - (vip-overlay-put vip-replace-overlay 'vip-cursor-color color))))) +(defun viper-save-cursor-color () + (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))))) ;; restore cursor color from replace overlay -(defsubst vip-restore-cursor-color-after-replace () - (vip-change-cursor-color - (vip-overlay-get vip-replace-overlay 'vip-cursor-color))) -(defsubst vip-restore-cursor-color-after-insert () - (vip-change-cursor-color vip-saved-cursor-color)) +(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)) ;; Face-saving tricks -(defvar vip-search-face - (if (vip-has-face-support-p) +(defvar viper-search-face + (if (viper-has-face-support-p) (progn - (make-face 'vip-search-face) - (vip-hide-face 'vip-search-face) - (or (face-differs-from-default-p 'vip-search-face) - ;; face wasn't set in .vip or .Xdefaults - (if (vip-can-use-colors "Black" "khaki") + (make-face 'viper-search-face) + (viper-hide-face 'viper-search-face) + (or (face-differs-from-default-p 'viper-search-face) + ;; face wasn't set in .viper or .Xdefaults + (if (viper-can-use-colors "Black" "khaki") (progn - (set-face-background 'vip-search-face "khaki") - (set-face-foreground 'vip-search-face "Black")) - (set-face-underline-p 'vip-search-face t) - (vip-set-face-pixmap 'vip-search-face vip-search-face-pixmap))) - 'vip-search-face)) + (set-face-background 'viper-search-face "khaki") + (set-face-foreground 'viper-search-face "Black")) + (set-face-underline-p 'viper-search-face t) + (viper-set-face-pixmap 'viper-search-face viper-search-face-pixmap))) + 'viper-search-face)) "*Face used to flash out the search pattern.") -(defvar vip-replace-overlay-face - (if (vip-has-face-support-p) +(defvar viper-replace-overlay-face + (if (viper-has-face-support-p) (progn - (make-face 'vip-replace-overlay-face) - (vip-hide-face 'vip-replace-overlay-face) - (or (face-differs-from-default-p 'vip-replace-overlay-face) + (make-face 'viper-replace-overlay-face) + (viper-hide-face 'viper-replace-overlay-face) + (or (face-differs-from-default-p 'viper-replace-overlay-face) (progn - (if (vip-can-use-colors "darkseagreen2" "Black") + (if (viper-can-use-colors "darkseagreen2" "Black") (progn (set-face-background - 'vip-replace-overlay-face "darkseagreen2") - (set-face-foreground 'vip-replace-overlay-face "Black"))) - (set-face-underline-p 'vip-replace-overlay-face t) - (vip-set-face-pixmap - 'vip-replace-overlay-face vip-replace-overlay-pixmap))) - 'vip-replace-overlay-face)) + 'viper-replace-overlay-face "darkseagreen2") + (set-face-foreground 'viper-replace-overlay-face "Black"))) + (set-face-underline-p 'viper-replace-overlay-face t) + (viper-set-face-pixmap + 'viper-replace-overlay-face viper-replace-overlay-pixmap))) + 'viper-replace-overlay-face)) "*Face for highlighting replace regions on a window display.") -(defvar vip-minibuffer-emacs-face - (if (vip-has-face-support-p) +(defvar viper-minibuffer-emacs-face + (if (viper-has-face-support-p) (progn - (make-face 'vip-minibuffer-emacs-face) - (vip-hide-face 'vip-minibuffer-emacs-face) - (or (face-differs-from-default-p 'vip-minibuffer-emacs-face) - ;; face wasn't set in .vip or .Xdefaults - (if vip-vi-style-in-minibuffer + (make-face 'viper-minibuffer-emacs-face) + (viper-hide-face 'viper-minibuffer-emacs-face) + (or (face-differs-from-default-p 'viper-minibuffer-emacs-face) + ;; face wasn't set in .viper or .Xdefaults + (if viper-vi-style-in-minibuffer ;; emacs state is an exception in the minibuffer - (if (vip-can-use-colors "darkseagreen2" "Black") + (if (viper-can-use-colors "darkseagreen2" "Black") (progn (set-face-background - 'vip-minibuffer-emacs-face "darkseagreen2") + 'viper-minibuffer-emacs-face "darkseagreen2") (set-face-foreground - 'vip-minibuffer-emacs-face "Black")) - (copy-face 'modeline 'vip-minibuffer-emacs-face)) + 'viper-minibuffer-emacs-face "Black")) + (copy-face 'modeline 'viper-minibuffer-emacs-face)) ;; emacs state is the main state in the minibuffer - (if (vip-can-use-colors "Black" "pink") + (if (viper-can-use-colors "Black" "pink") (progn - (set-face-background 'vip-minibuffer-emacs-face "pink") + (set-face-background 'viper-minibuffer-emacs-face "pink") (set-face-foreground - 'vip-minibuffer-emacs-face "Black")) - (copy-face 'italic 'vip-minibuffer-emacs-face)) + 'viper-minibuffer-emacs-face "Black")) + (copy-face 'italic 'viper-minibuffer-emacs-face)) )) - 'vip-minibuffer-emacs-face)) + 'viper-minibuffer-emacs-face)) "Face used in the Minibuffer when it is in Emacs state.") -(defvar vip-minibuffer-insert-face - (if (vip-has-face-support-p) +(defvar viper-minibuffer-insert-face + (if (viper-has-face-support-p) (progn - (make-face 'vip-minibuffer-insert-face) - (vip-hide-face 'vip-minibuffer-insert-face) - (or (face-differs-from-default-p 'vip-minibuffer-insert-face) - (if vip-vi-style-in-minibuffer - (if (vip-can-use-colors "Black" "pink") + (make-face 'viper-minibuffer-insert-face) + (viper-hide-face 'viper-minibuffer-insert-face) + (or (face-differs-from-default-p 'viper-minibuffer-insert-face) + (if viper-vi-style-in-minibuffer + (if (viper-can-use-colors "Black" "pink") (progn - (set-face-background 'vip-minibuffer-insert-face "pink") + (set-face-background 'viper-minibuffer-insert-face "pink") (set-face-foreground - 'vip-minibuffer-insert-face "Black")) - (copy-face 'italic 'vip-minibuffer-insert-face)) + 'viper-minibuffer-insert-face "Black")) + (copy-face 'italic 'viper-minibuffer-insert-face)) ;; If Insert state is an exception - (if (vip-can-use-colors "darkseagreen2" "Black") + (if (viper-can-use-colors "darkseagreen2" "Black") (progn (set-face-background - 'vip-minibuffer-insert-face "darkseagreen2") + 'viper-minibuffer-insert-face "darkseagreen2") (set-face-foreground - 'vip-minibuffer-insert-face "Black")) - (copy-face 'modeline 'vip-minibuffer-insert-face)) - (vip-italicize-face 'vip-minibuffer-insert-face))) - 'vip-minibuffer-insert-face)) + 'viper-minibuffer-insert-face "Black")) + (copy-face 'modeline 'viper-minibuffer-insert-face)) + (viper-italicize-face 'viper-minibuffer-insert-face))) + 'viper-minibuffer-insert-face)) "Face used in the Minibuffer when it is in Insert state.") -(defvar vip-minibuffer-vi-face - (if (vip-has-face-support-p) +(defvar viper-minibuffer-vi-face + (if (viper-has-face-support-p) (progn - (make-face 'vip-minibuffer-vi-face) - (vip-hide-face 'vip-minibuffer-vi-face) - (or (face-differs-from-default-p 'vip-minibuffer-vi-face) - (if vip-vi-style-in-minibuffer - (if (vip-can-use-colors "Black" "grey") + (make-face 'viper-minibuffer-vi-face) + (viper-hide-face 'viper-minibuffer-vi-face) + (or (face-differs-from-default-p 'viper-minibuffer-vi-face) + (if viper-vi-style-in-minibuffer + (if (viper-can-use-colors "Black" "grey") (progn - (set-face-background 'vip-minibuffer-vi-face "grey") - (set-face-foreground 'vip-minibuffer-vi-face "Black")) - (copy-face 'bold 'vip-minibuffer-vi-face)) - (copy-face 'bold 'vip-minibuffer-vi-face) - (invert-face 'vip-minibuffer-vi-face))) - 'vip-minibuffer-vi-face)) + (set-face-background 'viper-minibuffer-vi-face "grey") + (set-face-foreground 'viper-minibuffer-vi-face "Black")) + (copy-face 'bold 'viper-minibuffer-vi-face)) + (copy-face 'bold 'viper-minibuffer-vi-face) + (invert-face 'viper-minibuffer-vi-face))) + 'viper-minibuffer-vi-face)) "Face used in the Minibuffer when it is in Vi state.") ;; the current face to be used in the minibuffer -(vip-deflocalvar vip-minibuffer-current-face vip-minibuffer-emacs-face "") +(viper-deflocalvar viper-minibuffer-current-face viper-minibuffer-emacs-face "") ;; Check the current version against the major and minor version numbers @@ -280,10 +280,10 @@ ;; 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 ;; testing for sufficiently high Emacs versions. -(defun vip-check-version (op major minor &optional type-of-emacs) +(defun viper-check-version (op major minor &optional type-of-emacs) (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version)) - (and (cond ((eq type-of-emacs 'xemacs) vip-xemacs-p) - ((eq type-of-emacs 'emacs) vip-emacs-p) + (and (cond ((eq type-of-emacs 'xemacs) viper-xemacs-p) + ((eq type-of-emacs 'emacs) viper-emacs-p) (t t)) (cond ((eq op '=) (and (= emacs-minor-version minor) (= emacs-major-version major))) @@ -294,39 +294,13 @@ (funcall op emacs-minor-version minor) t))) (t - (error "%S: Invalid op in vip-check-version" op)))) + (error "%S: Invalid op in viper-check-version" op)))) (cond ((memq op '(= > >=)) nil) ((memq op '(< <=)) t)))) -;;;; warn if it is a wrong version of emacs -;;(if (or (vip-check-version '< 19 35 'emacs) -;; (vip-check-version '< 19 15 'xemacs)) -;; (progn -;; (with-output-to-temp-buffer " *vip-info*" -;; (switch-to-buffer " *vip-info*") -;; (insert -;; (format " -;; -;;This version of Viper requires -;; -;;\t Emacs 19.35 and higher -;;\t OR -;;\t XEmacs 19.15 and higher -;; -;;It is unlikely to work under Emacs version %s -;;that you are using... " emacs-version)) -;; -;; (if noninteractive -;; () -;; (beep 1) -;; (beep 1) -;; (insert "\n\nType any key to continue... ") -;; (vip-read-event))) -;; (kill-buffer " *vip-info*"))) - -(defun vip-get-visible-buffer-window (wind) - (if vip-xemacs-p +(defun viper-get-visible-buffer-window (wind) + (if viper-xemacs-p (get-buffer-window wind t) (get-buffer-window wind 'visible))) @@ -336,7 +310,7 @@ ;; 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." -(defun vip-line-pos (pos) +(defun viper-line-pos (pos) (let ((cur-pos (point)) (result)) (cond @@ -345,7 +319,7 @@ ((equal pos 'end) (end-of-line)) ((equal pos 'mid) - (goto-char (+ (vip-line-pos 'start) (vip-line-pos 'end) 2))) + (goto-char (+ (viper-line-pos 'start) (viper-line-pos 'end) 2))) ((equal pos 'indent) (back-to-indentation)) (t nil)) @@ -360,9 +334,9 @@ ;; ;; This is useful for moving markers that are supposed to be local. ;; For this, VAR-NAME should be made buffer-local with nil as a default. -;; Then, each time this var is used in `vip-move-marker-locally' in a new +;; Then, each time this var is used in `viper-move-marker-locally' in a new ;; buffer, a new marker will be created. -(defun vip-move-marker-locally (var pos &optional buffer) +(defun viper-move-marker-locally (var pos &optional buffer) (if (markerp (eval var)) () (set var (make-marker))) @@ -370,7 +344,7 @@ ;; Print CONDITIONS as a message. -(defun vip-message-conditions (conditions) +(defun viper-message-conditions (conditions) (let ((case (car conditions)) (msg (cdr conditions))) (if (null msg) (message "%s" case) @@ -382,7 +356,7 @@ ;;; List/alist utilities ;; Convert LIST to an alist -(defun vip-list-to-alist (lst) +(defun viper-list-to-alist (lst) (let ((alist)) (while lst (setq alist (cons (list (car lst)) alist)) @@ -390,7 +364,7 @@ alist)) ;; Convert ALIST to a list. -(defun vip-alist-to-list (alst) +(defun viper-alist-to-list (alst) (let ((lst)) (while alst (setq lst (cons (car (car alst)) lst)) @@ -398,7 +372,7 @@ lst)) ;; Filter ALIST using REGEXP. Return alist whose elements match the regexp. -(defun vip-filter-alist (regexp alst) +(defun viper-filter-alist (regexp alst) (interactive "s x") (let ((outalst) (inalst alst)) (while (car inalst) @@ -408,7 +382,7 @@ outalst)) ;; Filter LIST using REGEXP. Return list whose elements match the regexp. -(defun vip-filter-list (regexp lst) +(defun viper-filter-list (regexp lst) (interactive "s x") (let ((outlst) (inlst lst)) (while (car inlst) @@ -421,7 +395,7 @@ ;; Append LIS2 to LIS1, both alists, by side-effect and returns LIS1 ;; LIS2 is modified by filtering it: deleting its members of the form ;; \(car elt\) such that (car elt') is in LIS1. -(defun vip-append-filter-alist (lis1 lis2) +(defun viper-append-filter-alist (lis1 lis2) (let ((temp lis1) elt) @@ -437,7 +411,7 @@ ;;; Support for :e and file globbing -(defun vip-ex-nontrivial-find-file-unix (filespec) +(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. @@ -452,11 +426,11 @@ ;; using cond in anticipation of further additions (cond (ex-unix-type-shell-options) )) - (command (cond (vip-ms-style-os-p (format "\"ls -1 -d %s\"" filespec)) + (command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec)) (t (format "ls -1 -d %s" filespec)))) file-list status) (save-excursion - (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) + (set-buffer (get-buffer-create viper-ex-tmp-buf-name)) (erase-buffer) (setq status (if gshell-options @@ -473,35 +447,35 @@ (save-excursion (skip-chars-forward " \t\n\j") (if (looking-at "ls:") - (vip-forward-Word 1)) + (viper-forward-Word 1)) (error "%s: %s" (if (stringp gshell) gshell "shell") - (buffer-substring (point) (vip-line-pos 'end))) + (buffer-substring (point) (viper-line-pos 'end))) )) (goto-char (point-min)) - (setq file-list (vip-get-filenames-from-buffer 'one-per-line))) + (setq file-list (viper-get-filenames-from-buffer 'one-per-line))) (mapcar 'find-file file-list) )) -(defun vip-ex-nontrivial-find-file-ms (filespec) +(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 -`vip-ex-nontrivial-find-file-unix', making it into the value of the variable +`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 `vip-ex-nontrivial-find-file-unix'." +to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'." (save-excursion - (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) + (set-buffer (get-buffer-create viper-ex-tmp-buf-name)) (erase-buffer) (insert filespec) (goto-char (point-min)) (mapcar 'find-file - (vip-glob-ms-windows-files (vip-get-filenames-from-buffer))) + (viper-glob-ms-windows-files (viper-get-filenames-from-buffer))) )) @@ -509,7 +483,7 @@ ;; return a list of file names listed in the buffer beginning at point ;; If optional arg is supplied, assume each filename is listed on a separate ;; line -(defun vip-get-filenames-from-buffer (&optional one-per-line) +(defun viper-get-filenames-from-buffer (&optional one-per-line) (let ((skip-chars (if one-per-line "\t\n" " \t\n")) result fname delim) (skip-chars-forward skip-chars) @@ -532,9 +506,9 @@ result)) ;; convert MS-DOS wildcards to regexp -(defun vip-wildcard-to-regexp (wcard) +(defun viper-wildcard-to-regexp (wcard) (save-excursion - (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) + (set-buffer (get-buffer-create viper-ex-tmp-buf-name)) (erase-buffer) (insert wcard) (goto-char (point-min)) @@ -551,7 +525,7 @@ ;; glob windows files ;; LIST is expected to be in reverse order -(defun vip-glob-ms-windows-files (list) +(defun viper-glob-ms-windows-files (list) (let ((tmp list) (case-fold-search t) tmp2) @@ -563,7 +537,7 @@ t ; return full names ;; the regexp part: globs the file names (concat "^" - (vip-wildcard-to-regexp + (viper-wildcard-to-regexp (file-name-nondirectory (car tmp))) "$")) tmp2)) @@ -574,7 +548,7 @@ ;;; Insertion ring ;; Rotate RING's index. DIRection can be positive or negative. -(defun vip-ring-rotate1 (ring dir) +(defun viper-ring-rotate1 (ring dir) (if (and (ring-p ring) (> (ring-length ring) 0)) (progn (setcar ring (cond ((> dir 0) @@ -583,57 +557,58 @@ (ring-minus1 (car ring) (ring-length ring))) ;; don't rotate if dir = 0 (t (car ring)))) - (vip-current-ring-item ring) + (viper-current-ring-item ring) ))) -(defun vip-special-ring-rotate1 (ring dir) - (if (memq vip-intermediate-command +(defun viper-special-ring-rotate1 (ring dir) + (if (memq viper-intermediate-command '(repeating-display-destructive-command repeating-insertion-from-ring)) - (vip-ring-rotate1 ring dir) + (viper-ring-rotate1 ring dir) ;; don't rotate otherwise - (vip-ring-rotate1 ring 0))) + (viper-ring-rotate1 ring 0))) ;; current ring item; if N is given, then so many items back from the ;; current -(defun vip-current-ring-item (ring &optional n) +(defun viper-current-ring-item (ring &optional n) (setq n (or n 0)) (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. -(defun vip-push-onto-ring (item ring-var) +(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)))))) (or (null item) ; don't push nil (and (stringp item) (string= item "")) ; or empty strings - (equal item (vip-current-ring-item (eval ring-var))) ; or old stuff - ;; Since vip-set-destructive-command checks if we are inside vip-repeat, - ;; we don't check whether this-command-keys is a `.'. - ;; The cmd vip-repeat makes a call to the current function only if - ;; `.' is 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 anything - ;; meaningful (in that case we don't know what to show to the user). - (and (eq ring-var 'vip-command-ring) + (equal item (viper-current-ring-item (eval ring-var))) ; or old stuff + ;; 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 + ;; 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 + ;; anything meaningful (in that case we don't know what to show to the + ;; user). + (and (eq ring-var 'viper-command-ring) (string-match "\\([0-9]*\e\\|^[ \t]*$\\|escape\\)" - (vip-array-to-string (this-command-keys)))) - (vip-ring-insert (eval ring-var) item)) + (viper-array-to-string (this-command-keys)))) + (viper-ring-insert (eval ring-var) item)) ) ;; removing elts from ring seems to break it -(defun vip-cleanup-ring (ring) +(defun viper-cleanup-ring (ring) (or (< (ring-length ring) 2) - (null (vip-current-ring-item ring)) + (null (viper-current-ring-item ring)) ;; last and previous equal - (if (equal (vip-current-ring-item ring) (vip-current-ring-item ring 1)) - (vip-ring-pop ring)))) + (if (equal (viper-current-ring-item ring) + (viper-current-ring-item ring 1)) + (viper-ring-pop ring)))) ;; ring-remove seems to be buggy, so we concocted this for our purposes. -(defun vip-ring-pop (ring) +(defun viper-ring-pop (ring) (let* ((ln (ring-length ring)) (vec (cdr (cdr ring))) (veclen (length vec)) @@ -654,7 +629,7 @@ top-elt )) -(defun vip-ring-insert (ring item) +(defun viper-ring-insert (ring item) (let* ((ln (ring-length ring)) (vec (cdr (cdr ring))) (veclen (length vec)) @@ -682,7 +657,7 @@ ;; POST-STRING is a string to append to the abbrev string. ;; ABBREV_SIGN is a string to be inserted before POST-STRING ;; if the orig string was truncated. -(defun vip-abbreviate-string (string max-len +(defun viper-abbreviate-string (string max-len pre-string post-string abbrev-sign) (let (truncated-str) (setq truncated-str @@ -695,7 +670,7 @@ (t (format "%s%s%s" pre-string truncated-str post-string))))) ;; tells if we are over a whitespace-only line -(defsubst vip-over-whitespace-line () +(defsubst viper-over-whitespace-line () (save-excursion (beginning-of-line) (looking-at "^[ \t]*$"))) @@ -707,7 +682,7 @@ ;; If given, MESSAGE is a message to be displayed after that. ;; This message is erased after 2 secs, if erase-msg is non-nil. ;; Arguments: var message custom-file &optional erase-message -(defun vip-save-setting (var message custom-file &optional erase-msg) +(defun viper-save-setting (var message custom-file &optional erase-msg) (let* ((var-name (symbol-name var)) (var-val (if (boundp var) (eval var))) (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name)) @@ -736,7 +711,7 @@ ;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that ;; match this pattern. -(defun vip-save-string-in-file (string custom-file &optional pattern) +(defun viper-save-string-in-file (string custom-file &optional pattern) (let ((buf (find-file-noselect (substitute-in-file-name custom-file)))) (save-excursion (set-buffer buf) @@ -753,132 +728,137 @@ ;; Search -(defun vip-flash-search-pattern () - (if (vip-overlay-p vip-search-overlay) - (vip-move-overlay vip-search-overlay (match-beginning 0) (match-end 0)) - (setq vip-search-overlay - (vip-make-overlay +(defun viper-flash-search-pattern () + (if (viper-overlay-p viper-search-overlay) + (viper-move-overlay + viper-search-overlay (match-beginning 0) (match-end 0)) + (setq viper-search-overlay + (viper-make-overlay (match-beginning 0) (match-end 0) (current-buffer)))) - (vip-overlay-put vip-search-overlay 'priority vip-search-overlay-priority) - (if (vip-has-face-support-p) + (viper-overlay-put + viper-search-overlay 'priority viper-search-overlay-priority) + (if (viper-has-face-support-p) (progn - (vip-overlay-put vip-search-overlay 'face vip-search-face) + (viper-overlay-put viper-search-overlay 'face viper-search-face) (sit-for 2) - (vip-overlay-put vip-search-overlay 'face nil)))) + (viper-overlay-put viper-search-overlay 'face nil)))) ;; Replace state -(defsubst vip-move-replace-overlay (beg end) - (vip-move-overlay vip-replace-overlay beg end)) +(defsubst viper-move-replace-overlay (beg end) + (viper-move-overlay viper-replace-overlay beg end)) -(defun vip-set-replace-overlay (beg end) - (if (vip-overlay-p vip-replace-overlay) - (vip-move-replace-overlay beg end) - (setq vip-replace-overlay (vip-make-overlay beg end (current-buffer))) +(defun viper-set-replace-overlay (beg end) + (if (viper-overlay-p viper-replace-overlay) + (viper-move-replace-overlay beg end) + (setq viper-replace-overlay (viper-make-overlay beg end (current-buffer))) ;; never detach - (vip-overlay-put - vip-replace-overlay (if vip-emacs-p 'evaporate 'detachable) nil) - (vip-overlay-put - vip-replace-overlay 'priority vip-replace-overlay-priority) + (viper-overlay-put + viper-replace-overlay (if viper-emacs-p 'evaporate 'detachable) nil) + (viper-overlay-put + viper-replace-overlay 'priority viper-replace-overlay-priority) ;; If Emacs will start supporting overlay maps, as it currently supports - ;; text-property maps, we could do away with vip-replace-minor-mode and + ;; text-property maps, we could do away with viper-replace-minor-mode and ;; just have keymap attached to replace overlay. - ;;(vip-overlay-put - ;; vip-replace-overlay - ;; (if vip-xemacs-p 'keymap 'local-map) - ;; vip-replace-map) + ;;(viper-overlay-put + ;; viper-replace-overlay + ;; (if viper-xemacs-p 'keymap 'local-map) + ;; viper-replace-map) ) - (if (vip-has-face-support-p) - (vip-overlay-put vip-replace-overlay 'face vip-replace-overlay-face)) - (vip-save-cursor-color) - (vip-change-cursor-color vip-replace-overlay-cursor-color) + (if (viper-has-face-support-p) + (viper-overlay-put + viper-replace-overlay 'face viper-replace-overlay-face)) + (viper-save-cursor-color) + (viper-change-cursor-color viper-replace-overlay-cursor-color) ) -(defun vip-set-replace-overlay-glyphs (before-glyph after-glyph) - (if (or (not (vip-has-face-support-p)) - vip-use-replace-region-delimiters) - (let ((before-name (if vip-xemacs-p 'begin-glyph 'before-string)) - (after-name (if vip-xemacs-p 'end-glyph 'after-string))) - (vip-overlay-put vip-replace-overlay before-name before-glyph) - (vip-overlay-put vip-replace-overlay after-name after-glyph)))) +(defun viper-set-replace-overlay-glyphs (before-glyph after-glyph) + (if (or (not (viper-has-face-support-p)) + viper-use-replace-region-delimiters) + (let ((before-name (if viper-xemacs-p 'begin-glyph 'before-string)) + (after-name (if viper-xemacs-p 'end-glyph 'after-string))) + (viper-overlay-put viper-replace-overlay before-name before-glyph) + (viper-overlay-put viper-replace-overlay after-name after-glyph)))) -(defun vip-hide-replace-overlay () - (vip-set-replace-overlay-glyphs nil nil) - (vip-restore-cursor-color-after-replace) - (vip-restore-cursor-color-after-insert) - (if (vip-has-face-support-p) - (vip-overlay-put vip-replace-overlay 'face nil))) +(defun viper-hide-replace-overlay () + (viper-set-replace-overlay-glyphs nil nil) + (viper-restore-cursor-color-after-replace) + (viper-restore-cursor-color-after-insert) + (if (viper-has-face-support-p) + (viper-overlay-put viper-replace-overlay 'face nil))) -(defsubst vip-replace-start () - (vip-overlay-start vip-replace-overlay)) -(defsubst vip-replace-end () - (vip-overlay-end vip-replace-overlay)) +(defsubst viper-replace-start () + (viper-overlay-start viper-replace-overlay)) +(defsubst viper-replace-end () + (viper-overlay-end viper-replace-overlay)) ;; Minibuffer -(defun vip-set-minibuffer-overlay () - (vip-check-minibuffer-overlay) - (if (vip-has-face-support-p) +(defun viper-set-minibuffer-overlay () + (viper-check-minibuffer-overlay) + (if (viper-has-face-support-p) (progn - (vip-overlay-put - vip-minibuffer-overlay 'face vip-minibuffer-current-face) - (vip-overlay-put - vip-minibuffer-overlay 'priority vip-minibuffer-overlay-priority) + (viper-overlay-put + viper-minibuffer-overlay 'face viper-minibuffer-current-face) + (viper-overlay-put + viper-minibuffer-overlay 'priority viper-minibuffer-overlay-priority) ;; never detach - (vip-overlay-put - vip-minibuffer-overlay (if vip-emacs-p 'evaporate 'detachable) nil) - ;; make vip-minibuffer-overlay open-ended + (viper-overlay-put + viper-minibuffer-overlay + (if viper-emacs-p 'evaporate 'detachable) + nil) + ;; make viper-minibuffer-overlay open-ended ;; In emacs, it is made open ended at creation time - (if vip-xemacs-p + (if viper-xemacs-p (progn - (vip-overlay-put vip-minibuffer-overlay 'start-open nil) - (vip-overlay-put vip-minibuffer-overlay 'end-open nil))) + (viper-overlay-put viper-minibuffer-overlay 'start-open nil) + (viper-overlay-put viper-minibuffer-overlay 'end-open nil))) ))) -(defun vip-check-minibuffer-overlay () - (or (vip-overlay-p vip-minibuffer-overlay) - (setq vip-minibuffer-overlay - (if vip-xemacs-p - (vip-make-overlay 1 (1+ (buffer-size)) (current-buffer)) +(defun viper-check-minibuffer-overlay () + (or (viper-overlay-p viper-minibuffer-overlay) + (setq viper-minibuffer-overlay + (if viper-xemacs-p + (viper-make-overlay 1 (1+ (buffer-size)) (current-buffer)) ;; make overlay open-ended - (vip-make-overlay + (viper-make-overlay 1 (1+ (buffer-size)) (current-buffer) nil 'rear-advance))) )) -(defsubst vip-is-in-minibuffer () +(defsubst viper-is-in-minibuffer () (string-match "\*Minibuf-" (buffer-name))) ;;; XEmacs compatibility -(defun vip-abbreviate-file-name (file) - (if vip-emacs-p +(defun viper-abbreviate-file-name (file) + (if viper-emacs-p (abbreviate-file-name file) ;; XEmacs requires addl argument (abbreviate-file-name file t))) ;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg ;; in sit-for, so this function smoothes out the differences. -(defsubst vip-sit-for-short (val &optional nodisp) - (if vip-xemacs-p +(defsubst viper-sit-for-short (val &optional nodisp) + (if viper-xemacs-p (sit-for (/ val 1000.0) nodisp) (sit-for 0 val nodisp))) ;; EVENT may be a single event of a sequence of events -(defsubst vip-ESC-event-p (event) +(defsubst viper-ESC-event-p (event) (let ((ESC-keys '(?\e (control \[) escape)) - (key (vip-event-key event))) + (key (viper-event-key event))) (member key ESC-keys))) ;; checks if object is a marker, has a buffer, and points to within that buffer -(defun vip-valid-marker (marker) +(defun viper-valid-marker (marker) (if (and (markerp marker) (marker-buffer marker)) (let ((buf (marker-buffer marker)) (pos (marker-position marker))) @@ -886,27 +866,27 @@ (set-buffer buf) (and (<= pos (point-max)) (<= (point-min) pos)))))) -(defsubst vip-mark-marker () - (if vip-xemacs-p +(defsubst viper-mark-marker () + (if viper-xemacs-p (mark-marker t) (mark-marker))) ;; like (set-mark-command nil) but doesn't push twice, if (car mark-ring) ;; is the same as (mark t). -(defsubst vip-set-mark-if-necessary () - (setq mark-ring (delete (vip-mark-marker) mark-ring)) +(defsubst viper-set-mark-if-necessary () + (setq mark-ring (delete (viper-mark-marker) mark-ring)) (set-mark-command nil)) ;; In transient mark mode (zmacs mode), it is annoying when regions become ;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless ;; the user explicitly wants highlighting, e.g., by hitting '' or `` -(defun vip-deactivate-mark () - (if vip-xemacs-p +(defun viper-deactivate-mark () + (if viper-xemacs-p (zmacs-deactivate-region) (deactivate-mark))) -(defsubst vip-leave-region-active () - (if vip-xemacs-p +(defsubst viper-leave-region-active () + (if viper-xemacs-p (setq zmacs-region-stays t))) ;; Check if arg is a valid character for register @@ -914,7 +894,7 @@ ;; Letter means lowercase letters, Letter means uppercase letters, and ;; digit means digits from 1 to 9. ;; If TYPE is nil, then down/uppercase letters and digits are allowed. -(defun vip-valid-register (reg &optional type) +(defun viper-valid-register (reg &optional type) (or type (setq type '(letter Letter digit))) (or (if (memq 'letter type) (and (<= ?a reg) (<= reg ?z))) @@ -925,22 +905,11 @@ )) -(defsubst vip-events-to-keys (events) - (cond (vip-xemacs-p (events-to-keys events)) +(defsubst viper-events-to-keys (events) + (cond (viper-xemacs-p (events-to-keys events)) (t events))) -(defun vip-eval-after-load (file form) - (if vip-emacs-p - (eval-after-load file form) - (or (assoc file after-load-alist) - (setq after-load-alist (cons (list file) after-load-alist))) - (let ((elt (assoc file after-load-alist))) - (or (member form (cdr elt)) - (setq elt (nconc elt (list form))))) - form - )) - ;; This is here because Emacs changed the way local hooks work. ;; ;;Add to the value of HOOK the function FUNCTION. @@ -952,7 +921,7 @@ ;;HOOK should be a symbol, and FUNCTION may be any valid function. If ;;HOOK is void, it is first set to nil. If HOOK's value is a single ;;function, it is changed to a list of functions." -(defun vip-add-hook (hook function &optional append) +(defun viper-add-hook (hook function &optional append) (if (not (boundp hook)) (set hook nil)) ;; If the hook value is a single function, turn it into a list. (let ((old (symbol-value hook))) @@ -970,8 +939,8 @@ ;; Remove from the value of HOOK the function FUNCTION. ;; HOOK should be a symbol, and FUNCTION may be any valid function. If ;; FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the -;; list of hooks to run in HOOK, then nothing is done. See `vip-add-hook'." -(defun vip-remove-hook (hook function) +;; list of hooks to run in HOOK, then nothing is done. See `viper-add-hook'." +(defun viper-remove-hook (hook function) (if (or (not (boundp hook)) ;unbound symbol, or (null (symbol-value hook)) ;value is nil, or (null function)) ;function is nil, then @@ -987,15 +956,15 @@ ;; it is suggested that an event must be copied before it is assigned to ;; last-command-event in XEmacs -(defun vip-copy-event (event) - (if vip-xemacs-p +(defun viper-copy-event (event) + (if viper-xemacs-p (copy-event event) event)) ;; like read-event, but in XEmacs also try to convert to char, if possible -(defun vip-read-event-convert-to-char () +(defun viper-read-event-convert-to-char () (let (event) - (if vip-emacs-p + (if viper-emacs-p (read-event) (setq event (next-command-event)) (or (event-to-character event) @@ -1003,15 +972,15 @@ )) ;; This function lets function-key-map convert key sequences into logical -;; keys. This does a better job than vip-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. -(defun vip-read-key () - (let ((overriding-local-map vip-overriding-map) +(defun viper-read-key () + (let ((overriding-local-map viper-overriding-map) (inhibit-quit t) key) - (use-global-map vip-overriding-map) + (use-global-map viper-overriding-map) (setq key (elt (read-key-sequence nil) 0)) (use-global-map global-map) key)) @@ -1020,40 +989,48 @@ ;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil) ;; instead of nil, if '(nil) was previously inadvertently assigned to ;; unread-command-events -(defun vip-event-key (event) +(defun viper-event-key (event) (or (and event (eventp event)) - (error "vip-event-key: Wrong type argument, eventp, %S" event)) - (when (cond (vip-xemacs-p (or (key-press-event-p event) - (mouse-event-p event))) + (error "viper-event-key: Wrong type argument, eventp, %S" event)) + (when (cond (viper-xemacs-p (or (key-press-event-p event) + (mouse-event-p event))) (t t)) (let ((mod (event-modifiers event)) basis) (setq basis (cond - (vip-xemacs-p + (viper-xemacs-p (cond ((key-press-event-p event) (event-key event)) ((button-event-p event) (concat "mouse-" (prin1-to-string (event-button event)))) (t - (error "vip-event-key: Unknown event, %S" event)))) + (error "viper-event-key: Unknown event, %S" event)))) (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 - (cond ((and (vip-characterp event) (<= ?A event) (<= event ?Z)) + (cond ((and (viper-characterp event) (<= ?A event) (<= event ?Z)) (setq mod nil event event)) ;; Emacs has the oddity whereby characters 128+char ;; represent M-char *if* this appears inside a string. ;; So, we convert them manually to (meta char). - ((and (vip-characterp event) + ((and (viper-characterp event) (< ?\C-? event) (<= event 255)) (setq mod '(meta) event (- event ?\C-? 1))) + ((and (null mod) (eq event 'return)) + (setq event ?\C-m)) + ((and (null mod) (eq event 'space)) + (setq event ?\ )) + ((and (null mod) (eq event 'delete)) + (setq event ?\C-?)) + ((and (null mod) (eq event 'backspace)) + (setq event ?\C-h)) (t (event-basic-type event))) ))) - (if (vip-characterp basis) + (if (viper-characterp basis) (setq basis (if (= basis ?\C-?) (list 'control '\?) ; taking care of an emacs bug @@ -1062,9 +1039,9 @@ (append mod (list basis)) basis)))) -(defun vip-key-to-emacs-key (key) +(defun viper-key-to-emacs-key (key) (let (key-name char-p modifiers mod-char-list base-key base-key-name) - (cond (vip-xemacs-p key) + (cond (viper-xemacs-p key) ((symbolp key) (setq key-name (symbol-name key)) @@ -1072,10 +1049,10 @@ (string-to-char key-name)) ;; Emacs doesn't recognize `return' and `escape' as events on ;; dumb terminals, so we translate them into characters - ((and vip-emacs-p (not (vip-window-display-p)) + ((and viper-emacs-p (not (viper-window-display-p)) (string= key-name "return")) ?\C-m) - ((and vip-emacs-p (not (vip-window-display-p)) + ((and viper-emacs-p (not (viper-window-display-p)) (string= key-name "escape")) ?\e) ;; pass symbol-event as is @@ -1083,7 +1060,7 @@ ((listp key) (setq modifiers (subseq key 0 (1- (length key))) - base-key (vip-seq-last-elt key) + base-key (viper-seq-last-elt key) base-key-name (symbol-name base-key) char-p (= (length base-key-name) 1)) (setq mod-char-list @@ -1112,27 +1089,27 @@ ;; 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 vip-array-to-string (event-seq) +(defun viper-array-to-string (event-seq) (let (temp temp2) (cond ((stringp event-seq) event-seq) - ((vip-event-vector-p event-seq) - (setq temp (mapcar 'vip-event-key event-seq)) - (cond ((vip-char-symbol-sequence-p temp) + ((viper-event-vector-p event-seq) + (setq temp (mapcar 'viper-event-key event-seq)) + (cond ((viper-char-symbol-sequence-p temp) (mapconcat 'symbol-name temp "")) - ((and (vip-char-array-p - (setq temp2 (mapcar 'vip-key-to-character temp)))) + ((and (viper-char-array-p + (setq temp2 (mapcar 'viper-key-to-character temp)))) (mapconcat 'char-to-string temp2 "")) (t (prin1-to-string (vconcat temp))))) - ((vip-char-symbol-sequence-p event-seq) + ((viper-char-symbol-sequence-p event-seq) (mapconcat 'symbol-name event-seq "")) ((and (vectorp event-seq) - (vip-char-array-p - (setq temp (mapcar 'vip-key-to-character event-seq)))) + (viper-char-array-p + (setq temp (mapcar 'viper-key-to-character event-seq)))) (mapconcat 'char-to-string temp "")) (t (prin1-to-string event-seq))))) -(defun vip-key-press-events-to-chars (events) - (mapconcat (if vip-emacs-p +(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))))) @@ -1141,14 +1118,14 @@ ;; Uses different timeouts for ESC-sequences and others -(defsubst vip-fast-keysequence-p () - (not (vip-sit-for-short - (if (vip-ESC-event-p last-input-event) - vip-ESC-keyseq-timeout - vip-fast-keyseq-timeout) +(defsubst viper-fast-keysequence-p () + (not (viper-sit-for-short + (if (viper-ESC-event-p last-input-event) + viper-ESC-keyseq-timeout + viper-fast-keyseq-timeout) t))) -(defun vip-read-char-exclusive () +(defun viper-read-char-exclusive () (let (char (echo-keystrokes 1)) (while (null char) @@ -1156,14 +1133,15 @@ (setq char (read-char)) (error ;; skip event if not char - (vip-read-event)))) + (viper-read-event)))) char)) ;; key is supposed to be in viper's representation, e.g., (control l), a ;; character, etc. -(defun vip-key-to-character (key) +(defun viper-key-to-character (key) (cond ((eq key 'space) ?\ ) ((eq key 'delete) ?\C-?) + ((eq key 'return) ?\C-m) ((eq key 'backspace) ?\C-h) ((and (symbolp key) (= 1 (length (symbol-name key)))) @@ -1176,21 +1154,21 @@ (t key))) -(defun vip-setup-master-buffer (&rest other-files-or-buffers) +(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 the `Local variables' section of a file." - (setq vip-related-files-and-buffers-ring + (setq viper-related-files-and-buffers-ring (make-ring (1+ (length other-files-or-buffers)))) (mapcar '(lambda (elt) - (vip-ring-insert vip-related-files-and-buffers-ring elt)) + (viper-ring-insert viper-related-files-and-buffers-ring elt)) other-files-or-buffers) - (vip-ring-insert vip-related-files-and-buffers-ring (buffer-name)) + (viper-ring-insert viper-related-files-and-buffers-ring (buffer-name)) ) ;;; Movement utilities -(defcustom vip-syntax-preference 'strict-vi +(defcustom viper-syntax-preference 'strict-vi "*Syntax type characterizing Viper's alphanumeric symbols. `emacs' means only word constituents are considered to be alphanumeric. Word constituents are symbols specified as word constituents by the current @@ -1204,116 +1182,118 @@ (const extended) (const emacs)) :group 'viper) -(vip-deflocalvar vip-ALPHA-char-class "w" +(viper-deflocalvar viper-ALPHA-char-class "w" "String of syntax classes characterizing Viper's alphanumeric symbols. In addition, the symbol `_' may be considered alphanumeric if -`vip-syntax-preference'is `reformed-vi'.") +`viper-syntax-preference'is `reformed-vi'.") -(vip-deflocalvar vip-strict-ALPHA-chars "a-zA-Z0-9_" +(viper-deflocalvar viper-strict-ALPHA-chars "a-zA-Z0-9_" "Regexp matching the set of alphanumeric characters acceptable to strict Vi.") -(vip-deflocalvar vip-strict-SEP-chars " \t\n" +(viper-deflocalvar viper-strict-SEP-chars " \t\n" "Regexp matching the set of alphanumeric characters acceptable to strict Vi.") -(vip-deflocalvar vip-SEP-char-class " -" +(viper-deflocalvar viper-SEP-char-class " -" "String of syntax classes for Vi separators. Usually contains ` ', linefeed, TAB or formfeed.") -(defun vip-update-alphanumeric-class () - "Set the syntax class of Viper alphanumerals according to `vip-syntax-preference'. -Must be called in order for changes to `vip-syntax-preference' to take effect." +(defun viper-update-alphanumeric-class () + "Set the syntax class of Viper alphanumerals according to `viper-syntax-preference'. +Must be called in order for changes to `viper-syntax-preference' to take effect." (interactive) (setq-default - vip-ALPHA-char-class - (cond ((eq vip-syntax-preference 'emacs) "w") ; only word constituents - ((eq vip-syntax-preference 'extended) "w_") ; word & symbol chars + viper-ALPHA-char-class + (cond ((eq viper-syntax-preference 'emacs) "w") ; only word constituents + ((eq viper-syntax-preference 'extended) "w_") ; word & symbol chars (t "w")))) ; vi syntax: word constituents and the symbol `_' ;; addl-chars are characters to be temporarily considered as alphanumerical -(defun vip-looking-at-alpha (&optional addl-chars) +(defun viper-looking-at-alpha (&optional addl-chars) (or (stringp addl-chars) (setq addl-chars "")) - (if (eq vip-syntax-preference 'reformed-vi) + (if (eq viper-syntax-preference 'reformed-vi) (setq addl-chars (concat addl-chars "_"))) (let ((char (char-after (point)))) (if char - (if (eq vip-syntax-preference 'strict-vi) - (looking-at (concat "[" vip-strict-ALPHA-chars addl-chars "]")) + (if (eq viper-syntax-preference 'strict-vi) + (looking-at (concat "[" viper-strict-ALPHA-chars addl-chars "]")) (or (memq char ;; convert string to list (append (vconcat addl-chars) nil)) (memq (char-syntax char) - (append (vconcat vip-ALPHA-char-class) nil))))) + (append (vconcat viper-ALPHA-char-class) nil))))) )) -(defun vip-looking-at-separator () +(defun viper-looking-at-separator () (let ((char (char-after (point)))) (if char (or (eq char ?\n) ; RET is always a separator in Vi (memq (char-syntax char) - (append (vconcat vip-SEP-char-class) nil)))))) + (append (vconcat viper-SEP-char-class) nil)))))) -(defsubst vip-looking-at-alphasep (&optional addl-chars) - (or (vip-looking-at-separator) (vip-looking-at-alpha addl-chars))) +(defsubst viper-looking-at-alphasep (&optional addl-chars) + (or (viper-looking-at-separator) (viper-looking-at-alpha addl-chars))) -(defun vip-skip-alpha-forward (&optional addl-chars) +(defun viper-skip-alpha-forward (&optional addl-chars) (or (stringp addl-chars) (setq addl-chars "")) - (vip-skip-syntax + (viper-skip-syntax 'forward - (cond ((eq vip-syntax-preference 'strict-vi) + (cond ((eq viper-syntax-preference 'strict-vi) "") - (t vip-ALPHA-char-class )) - (cond ((eq vip-syntax-preference 'strict-vi) - (concat vip-strict-ALPHA-chars addl-chars)) + (t viper-ALPHA-char-class )) + (cond ((eq viper-syntax-preference 'strict-vi) + (concat viper-strict-ALPHA-chars addl-chars)) (t addl-chars)))) -(defun vip-skip-alpha-backward (&optional addl-chars) +(defun viper-skip-alpha-backward (&optional addl-chars) (or (stringp addl-chars) (setq addl-chars "")) - (vip-skip-syntax + (viper-skip-syntax 'backward - (cond ((eq vip-syntax-preference 'strict-vi) + (cond ((eq viper-syntax-preference 'strict-vi) "") - (t vip-ALPHA-char-class )) - (cond ((eq vip-syntax-preference 'strict-vi) - (concat vip-strict-ALPHA-chars addl-chars)) + (t viper-ALPHA-char-class )) + (cond ((eq viper-syntax-preference 'strict-vi) + (concat viper-strict-ALPHA-chars addl-chars)) (t addl-chars)))) ;; weird syntax tables may confuse strict-vi style -(defsubst vip-skip-all-separators-forward (&optional within-line) - (vip-skip-syntax 'forward - vip-SEP-char-class - (or within-line "\n") - (if within-line (vip-line-pos 'end)))) -(defsubst vip-skip-all-separators-backward (&optional within-line) - (vip-skip-syntax 'backward - vip-SEP-char-class - (or within-line "\n") - (if within-line (vip-line-pos 'start)))) -(defun vip-skip-nonseparators (direction) +(defsubst viper-skip-all-separators-forward (&optional within-line) + (viper-skip-syntax 'forward + viper-SEP-char-class + (or within-line "\n") + (if within-line (viper-line-pos 'end)))) +(defsubst viper-skip-all-separators-backward (&optional within-line) + (viper-skip-syntax 'backward + viper-SEP-char-class + (or within-line "\n") + (if within-line (viper-line-pos 'start)))) +(defun viper-skip-nonseparators (direction) (let ((func (intern (format "skip-syntax-%S" direction)))) - (funcall func (concat "^" vip-SEP-char-class) - (vip-line-pos (if (eq direction 'forward) 'end 'start))))) + (funcall func (concat "^" viper-SEP-char-class) + (viper-line-pos (if (eq direction 'forward) 'end 'start))))) -(defun vip-skip-nonalphasep-forward () - (if (eq vip-syntax-preference 'strict-vi) +(defun viper-skip-nonalphasep-forward () + (if (eq viper-syntax-preference 'strict-vi) (skip-chars-forward - (concat "^" vip-strict-SEP-chars vip-strict-ALPHA-chars)) + (concat "^" viper-strict-SEP-chars viper-strict-ALPHA-chars)) (skip-syntax-forward (concat - "^" vip-ALPHA-char-class vip-SEP-char-class) (vip-line-pos 'end)))) -(defun vip-skip-nonalphasep-backward () - (if (eq vip-syntax-preference 'strict-vi) + "^" viper-ALPHA-char-class viper-SEP-char-class) (viper-line-pos 'end)))) +(defun viper-skip-nonalphasep-backward () + (if (eq viper-syntax-preference 'strict-vi) (skip-chars-backward - (concat "^" vip-strict-SEP-chars vip-strict-ALPHA-chars)) + (concat "^" viper-strict-SEP-chars viper-strict-ALPHA-chars)) (skip-syntax-backward (concat - "^" vip-ALPHA-char-class vip-SEP-char-class) (vip-line-pos 'start)))) + "^" + viper-ALPHA-char-class viper-SEP-char-class) + (viper-line-pos 'start)))) ;; Skip SYNTAX like skip-syntax-* and ADDL-CHARS like skip-chars-* ;; Return the number of chars traveled. ;; Either SYNTAX or ADDL-CHARS can be nil, in which case they are interpreted ;; as an empty string. -(defun vip-skip-syntax (direction syntax addl-chars &optional limit) +(defun viper-skip-syntax (direction syntax addl-chars &optional limit) (let ((total 0) (local 1) (skip-chars-func (intern (format "skip-chars-%S" direction))) @@ -1334,7 +1314,7 @@ ;;; Local Variables: -;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun) +;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) ;;; End: ;;; viper-util.el ends here
--- a/lisp/emulation/viper.el Sat Aug 02 06:56:24 1997 +0000 +++ b/lisp/emulation/viper.el Sat Aug 02 07:40:22 1997 +0000 @@ -1,4 +1,4 @@ -;;; viper.el --- A full-featured Vi emulator for GNU Emacs 19 and XEmacs 19, +;;; 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. @@ -8,7 +8,7 @@ ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. -(defconst viper-version "2.95 of July 23, 1997" +(defconst viper-version "2.96 of August 1, 1997" "The current version of Viper") ;; This file is part of GNU Emacs. @@ -30,7 +30,7 @@ ;;; Commentary: -;; Viper is a full-featured Vi emulator for Emacs 19. 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 @@ -124,41 +124,40 @@ ;; ;; (add-hook 'your-favorite-mode 'viper-mode) ;; or -;; (add-hook 'your-favorite-mode 'vip-change-state-to-emacs) +;; (add-hook 'your-favorite-mode 'viper-change-state-to-emacs) ;; ;; 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.) ;; ;; 2. Keymap handling -;; Because Emacs 19 has an elegant mechanism for turning minor mode keymaps -;; on and off, implementation of Viper has been greatly simplified. Viper -;; has several minor modes. +;; Each Viper state (insert, vi, replace) is implemented as a collection of +;; several minor modes, each with its own keymap. ;; ;; Viper's Vi state consists of seven minor modes: ;; -;; vip-vi-intercept-minor-mode -;; vip-vi-local-user-minor-mode -;; vip-vi-global-user-minor-mode -;; vip-vi-kbd-minor-mode -;; vip-vi-state-modifier-minor-mode -;; vip-vi-diehard-minor-mode -;; vip-vi-basic-minor-mode +;; viper-vi-intercept-minor-mode +;; viper-vi-local-user-minor-mode +;; viper-vi-global-user-minor-mode +;; viper-vi-kbd-minor-mode +;; viper-vi-state-modifier-minor-mode +;; viper-vi-diehard-minor-mode +;; viper-vi-basic-minor-mode ;; ;; Bindings done to the keymap of the first mode overshadow those done to ;; the second, which, in turn, overshadows those done to the third, etc. ;; -;; The last vip-vi-basic-minor-mode contains most of the usual Vi bindings +;; 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. ;; Novice users, however, may want to set their viper-expert-level to 1 -;; in their .vip file. This will enable vip-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 ;; enable `C-c' and many Emacs facilities will become available. -;; In this case, vip-vi-diehard-minor-mode is inactive. +;; In this case, viper-vi-diehard-minor-mode is inactive. ;; ;; Viper gurus should have at least ;; (setq viper-expert-level 4) @@ -167,13 +166,13 @@ ;; 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 -;; vip-want-* See viper-set-expert-level for details. +;; viper-want-* See viper-set-expert-level for details. ;; -;; The very first minor mode, vip-vi-intercept-minor-mode, is of no +;; 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 ;; ESC and C-z. ;; -;; The second mode, vip-vi-local-user-minor-mode, usually has an +;; The second mode, viper-vi-local-user-minor-mode, usually has an ;; 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, @@ -181,109 +180,110 @@ ;; 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 -;; vip-add-local-keys function (see its doc). +;; viper-add-local-keys function (see its doc). ;; -;; The third minor mode, vip-vi-global-user-minor-mode, is also intended -;; for the users but, unlike vip-vi-local-user-minor-mode, its key +;; 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 ;; with define-key command. ;; -;; The fourth minor mode, vip-vi-kbd-minor-mode, is used by keyboard +;; The fourth minor mode, viper-vi-kbd-minor-mode, is used by keyboard ;; macros. Users are NOT supposed to modify this keymap directly. ;; -;; The fifth mode, vip-vi-state-modifier-minor-mode, can be used to set +;; 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. ;; ;; Users are allowed to modify keymaps that belong to -;; vip-vi-local-user-minor-mode, vip-vi-global-user-minor-mode, -;; and vip-vi-state-modifier-minor-mode only. +;; viper-vi-local-user-minor-mode, viper-vi-global-user-minor-mode, +;; and viper-vi-state-modifier-minor-mode only. ;; ;; Viper's Insert state also has seven minor modes: ;; -;; vip-insert-intercept-minor-mode -;; vip-insert-local-user-minor-mode -;; vip-insert-global-user-minor-mode -;; vip-insert-kbd-minor-mode -;; vip-insert-state-modifier-minor-mode -;; vip-insert-diehard-minor-mode -;; vip-insert-basic-minor-mode +;; viper-insert-intercept-minor-mode +;; viper-insert-local-user-minor-mode +;; viper-insert-global-user-minor-mode +;; viper-insert-kbd-minor-mode +;; viper-insert-state-modifier-minor-mode +;; viper-insert-diehard-minor-mode +;; viper-insert-basic-minor-mode ;; -;; As with VI's editing modes, the first mode, vip-insert-intercept-minor-mode -;; is used to bind vital keys that are not to be changed by the user. +;; As with VI's editing modes, the first mode, +;; viper-insert-intercept-minor-mode is used to bind vital keys that are not +;; to be changed by the user. ;; -;; The next mode, vip-insert-local-user-minor-mode, is used to customize +;; The next mode, viper-insert-local-user-minor-mode, is used to customize ;; bindings in the insert state of Viper. The third mode, -;; vip-insert-global-user-minor-mode is like -;; vip-insert-local-user-minor-mode, except that its bindings are seen in -;; all Viper buffers. As with vip-vi-local-user-minor-mode, its bindings -;; should be done via the function vip-add-local-keys. Bindings for -;; vip-insert-global-user-minor-mode can be set with the define-key command. +;; 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 +;; viper-insert-global-user-minor-mode can be set with the define-key command. ;; -;; The next minor mode, vip-insert-kbd-minor-mode, +;; The next minor mode, viper-insert-kbd-minor-mode, ;; is used for keyboard VI-style macros defined with :map!. ;; -;; The fifth minor mode, vip-insert-state-modifier-minor-mode, is like -;; vip-vi-state-modifier-minor-mode, except that it is used in the Insert +;; The fifth minor mode, viper-insert-state-modifier-minor-mode, is like +;; viper-vi-state-modifier-minor-mode, except that it is used in the Insert ;; state; it can be used to modify keys in a mode-specific fashion. ;; -;; The minor mode vip-insert-diehard-minor-mode is in effect when +;; 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, vip-insert-basic-minor-mode, is always in effect +;; 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 ;; Viper's operation. ;; ;; Finally, Viper provides minor modes for overriding bindings set by Emacs ;; modes when Viper is in Emacs state: ;; -;; vip-emacs-local-user-minor-mode -;; vip-emacs-global-user-minor-mode -;; vip-emacs-kbd-minor-mode -;; vip-emacs-state-modifier-minor-mode +;; viper-emacs-local-user-minor-mode +;; viper-emacs-global-user-minor-mode +;; 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 -;; associated with vip-emacs-global-user-minor-mode, -;; vip-emacs-global-user-map, overrides the global and local keymaps as +;; 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 -;; vip-emacs-local-user-minor-mode, vip-emacs-local-user-map, overrides +;; 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 vip-emacs-state-modifier-minor-mode +;; The keymap associated with viper-emacs-state-modifier-minor-mode ;; overrides keys on a per-major-mode basis. The mode -;; vip-emacs-kbd-minor-mode is used to define Vi-style macros in Emacs +;; 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 ;; called ;; -;; vip-replace-minor-mode +;; viper-replace-minor-mode ;; -;; and its keymap is vip-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. ;; ;; 4. Defining buffer-local bindings in Vi and Insert modes. ;; 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, vip-add-local-keys, to do precisely +;; 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 ;; to Insert mode, you can put ;; -;; (vip-add-local-keys 'insert-state '((key1 . func1) (key2 .func2))) +;; (viper-add-local-keys 'insert-state '((key1 . func1) (key2 .func2))) ;; ;; 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 vip-add-local-keys. +;; 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 vip-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 vip-command-argument, keymaps should bind the +;; convoluted. Instead of viper-command-argument, keymaps should bind the ;; actual commands. E.g., "dw" should be bound to a generic command -;; vip-delete that will delete things based on the value of +;; viper-delete that will delete things based on the value of ;; last-command-char. This would greatly simplify the logic and the code. ;; ;; 2. Somebody should venture to write a customization package a la @@ -303,7 +303,7 @@ ;; compiler pacifier (defvar mark-even-if-inactive) (defvar viper-expert-level) -(defvar vip-expert-level) +(defvar viper-expert-level) ;; loading happens only in non-interactive compilation ;; in order to spare non-viperized emacs from being viperized @@ -320,22 +320,20 @@ (require 'viper-init) ;; better be defined before Viper custom group. -(defvar vip-custom-file-name (vip-convert-standard-file-name "~/.viper") +(defvar viper-custom-file-name (convert-standard-filename "~/.viper") "Viper customisation file. If set by the user, this must be done _before_ Viper is loaded in `~/.emacs'.") (defgroup viper nil "Vi emulation within Emacs. -NOTE: Viper customization should be saved in `vip-custom-file-name', which +NOTE: Viper customization should be saved in `viper-custom-file-name', which defaults to `~/.viper'." - :prefix "vip-" + :prefix "viper-" :group 'emulations) (require 'viper-cmd) -(defvar vip-always t - "See `viper-always'. This variable is for compatibility with older Vipers.") -(defcustom viper-always vip-always +(defcustom viper-always t "Non-nil means, arrange for vi-state to be a default when appropriate. This is different from `viper-mode' variable in that `viper-mode' determines whether to use Viper in the first place, while `viper-always', if nil, lets @@ -373,17 +371,14 @@ -;; The following are provided for compatibility with older VIP's ;;;###autoload -(defalias 'vip-mode 'viper-mode) - -(defalias 'vip-change-mode-to-vi 'vip-change-state-to-vi) -(defalias 'vip-change-mode-to-insert 'vip-change-state-to-insert) -(defalias 'vip-change-mode-to-emacs 'vip-change-state-to-emacs) - - - +(defun toggle-viper-mode () + (interactive) + (if (eq viper-mode t) + (viper-go-away) + (setq viper-mode nil) + (viper-mode))) ;;;###autoload (defun viper-mode () @@ -394,15 +389,15 @@ ;; if the user requested viper-mode explicitly (if viper-mode () - (setq viper-mode 1) + (setq viper-mode t) (load-library "viper")) - (if vip-first-time ; This check is important. Without it, startup and - (progn ; expert-level msgs mix up when viper-mode recurses - (setq vip-first-time nil) - (if (not vip-inhibit-startup-message) + (if viper-first-time ; Important check. Prevents mix-up of startup and + (progn ; expert-level msgs when viper-mode recurses + (setq viper-first-time nil) + (if (not viper-inhibit-startup-message) (save-window-excursion - (setq vip-inhibit-startup-message t) + (setq viper-inhibit-startup-message t) (delete-other-windows) (switch-to-buffer "Viper Startup Message") (erase-buffer) @@ -453,10 +448,10 @@ )) (goto-char (point-min)) (if (y-or-n-p "Inhibit Viper startup message? ") - (vip-save-setting - 'vip-inhibit-startup-message + (viper-save-setting + 'viper-inhibit-startup-message "Viper startup message inhibited" - vip-custom-file-name t)) + viper-custom-file-name t)) ;;(kill-buffer (current-buffer)) (message "The last message is in buffer `Viper Startup Message'") @@ -465,15 +460,15 @@ (viper-set-expert-level 'dont-change-unless))) (or (memq major-mode viper-non-vi-major-modes) ; don't switch to Vi - (vip-change-state-to-vi))))) + (viper-change-state-to-vi))))) ;; This hook designed to enable Vi-style editing in comint-based modes." -(defun vip-comint-mode-hook () +(defun viper-comint-mode-hook () (setq require-final-newline nil - vip-ex-style-editing-in-insert nil - vip-ex-style-motion nil) - (vip-change-state-to-insert)) + viper-ex-style-editing-in-insert nil + viper-ex-style-motion nil) + (viper-change-state-to-insert)) ;; remove viper hooks from SYMBOL @@ -482,9 +477,9 @@ ((not (listp (eval symbol))) nil) ((string-match "-hook" (symbol-name symbol)) (remove-hook symbol 'viper-mode) - (remove-hook symbol 'vip-change-state-to-emacs) - (remove-hook symbol 'vip-change-state-to-insert) - (remove-hook symbol 'vip-change-state-to-vi) + (remove-hook symbol 'viper-change-state-to-emacs) + (remove-hook symbol 'viper-change-state-to-insert) + (remove-hook symbol 'viper-change-state-to-vi) ))) ;; Remove local value in all existing buffers @@ -525,7 +520,7 @@ global-mode-string (viper-standard-value 'global-mode-string viper-saved-non-viper-variables)) - (if vip-emacs-p + (if viper-emacs-p (setq-default mark-even-if-inactive (viper-standard-value @@ -537,76 +532,80 @@ ;; deactivate all advices done by Viper. - (ad-deactivate-regexp "vip-") + (ad-deactivate-regexp "viper-") (setq viper-mode nil) - (viper-delocalize-var 'vip-vi-minibuffer-minor-mode) - (viper-delocalize-var 'vip-insert-minibuffer-minor-mode) - (viper-delocalize-var 'vip-vi-intercept-minor-mode) - (viper-delocalize-var 'vip-insert-intercept-minor-mode) + (viper-delocalize-var 'viper-vi-minibuffer-minor-mode) + (viper-delocalize-var 'viper-insert-minibuffer-minor-mode) + (viper-delocalize-var 'viper-vi-intercept-minor-mode) + (viper-delocalize-var 'viper-insert-intercept-minor-mode) - (viper-delocalize-var 'vip-vi-local-user-minor-mode) - (viper-delocalize-var 'vip-vi-kbd-minor-mode) - (viper-delocalize-var 'vip-vi-global-user-minor-mode) - (viper-delocalize-var 'vip-vi-state-modifier-minor-mode) - (viper-delocalize-var 'vip-vi-diehard-minor-mode) - (viper-delocalize-var 'vip-vi-basic-minor-mode) + (viper-delocalize-var 'viper-vi-local-user-minor-mode) + (viper-delocalize-var 'viper-vi-kbd-minor-mode) + (viper-delocalize-var 'viper-vi-global-user-minor-mode) + (viper-delocalize-var 'viper-vi-state-modifier-minor-mode) + (viper-delocalize-var 'viper-vi-diehard-minor-mode) + (viper-delocalize-var 'viper-vi-basic-minor-mode) - (viper-delocalize-var 'vip-replace-minor-mode) + (viper-delocalize-var 'viper-replace-minor-mode) - (viper-delocalize-var 'vip-insert-local-user-minor-mode) - (viper-delocalize-var 'vip-insert-kbd-minor-mode) - (viper-delocalize-var 'vip-insert-global-user-minor-mode) - (viper-delocalize-var 'vip-insert-state-modifier-minor-mode) - (viper-delocalize-var 'vip-insert-diehard-minor-mode) - (viper-delocalize-var 'vip-insert-basic-minor-mode) + (viper-delocalize-var 'viper-insert-local-user-minor-mode) + (viper-delocalize-var 'viper-insert-kbd-minor-mode) + (viper-delocalize-var 'viper-insert-global-user-minor-mode) + (viper-delocalize-var 'viper-insert-state-modifier-minor-mode) + (viper-delocalize-var 'viper-insert-diehard-minor-mode) + (viper-delocalize-var 'viper-insert-basic-minor-mode) - (viper-delocalize-var 'vip-emacs-intercept-minor-mode) - (viper-delocalize-var 'vip-emacs-local-user-minor-mode) - (viper-delocalize-var 'vip-emacs-kbd-minor-mode) - (viper-delocalize-var 'vip-emacs-global-user-minor-mode) - (viper-delocalize-var 'vip-emacs-state-modifier-minor-mode) + (viper-delocalize-var 'viper-emacs-intercept-minor-mode) + (viper-delocalize-var 'viper-emacs-local-user-minor-mode) + (viper-delocalize-var 'viper-emacs-kbd-minor-mode) + (viper-delocalize-var 'viper-emacs-global-user-minor-mode) + (viper-delocalize-var 'viper-emacs-state-modifier-minor-mode) - (setq-default vip-vi-minibuffer-minor-mode nil - vip-insert-minibuffer-minor-mode nil - vip-vi-intercept-minor-mode nil - vip-insert-intercept-minor-mode nil + (setq-default viper-vi-minibuffer-minor-mode nil + viper-insert-minibuffer-minor-mode nil + viper-vi-intercept-minor-mode nil + viper-insert-intercept-minor-mode nil - vip-vi-local-user-minor-mode nil - vip-vi-kbd-minor-mode nil - vip-vi-global-user-minor-mode nil - vip-vi-state-modifier-minor-mode nil - vip-vi-diehard-minor-mode nil - vip-vi-basic-minor-mode nil + viper-vi-local-user-minor-mode nil + viper-vi-kbd-minor-mode nil + viper-vi-global-user-minor-mode nil + viper-vi-state-modifier-minor-mode nil + viper-vi-diehard-minor-mode nil + viper-vi-basic-minor-mode nil - vip-replace-minor-mode nil + viper-replace-minor-mode nil - vip-insert-local-user-minor-mode nil - vip-insert-kbd-minor-mode nil - vip-insert-global-user-minor-mode nil - vip-insert-state-modifier-minor-mode nil - vip-insert-diehard-minor-mode nil - vip-insert-basic-minor-mode nil + viper-insert-local-user-minor-mode nil + viper-insert-kbd-minor-mode nil + viper-insert-global-user-minor-mode nil + viper-insert-state-modifier-minor-mode nil + viper-insert-diehard-minor-mode nil + viper-insert-basic-minor-mode nil - vip-emacs-intercept-minor-mode nil - vip-emacs-local-user-minor-mode nil - vip-emacs-kbd-minor-mode nil - vip-emacs-global-user-minor-mode nil - vip-emacs-state-modifier-minor-mode nil + viper-emacs-intercept-minor-mode nil + viper-emacs-local-user-minor-mode nil + viper-emacs-kbd-minor-mode nil + viper-emacs-global-user-minor-mode nil + viper-emacs-state-modifier-minor-mode nil ) ;; remove all hooks set by viper (mapatoms 'viper-remove-hooks) - (remove-hook 'comint-mode-hook 'vip-comint-mode-hook) - (remove-hook 'minibuffer-setup-hook 'vip-minibuffer-setup-sentinel) + (remove-hook 'comint-mode-hook 'viper-comint-mode-hook) + (remove-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel) + + ;; unbind Viper mouse bindings + (viper-unbind-mouse-search-key) + (viper-unbind-mouse-insert-key) ) ;; This sets major mode hooks to make them come up in vi-state. -(defun vip-set-hooks () +(defun viper-set-hooks () ;; It is of course a misnomer to call viper-mode a `major mode'. ;; However, this has the effect that if the user didn't specify the @@ -615,16 +614,16 @@ (setq default-major-mode 'viper-mode) ;; The following major modes should come up in vi-state - (defadvice fundamental-mode (after vip-fundamental-mode-ad activate) - "Run `vip-change-state-to-vi' on entry." - (vip-change-state-to-vi)) + (defadvice fundamental-mode (after viper-fundamental-mode-ad activate) + "Run `viper-change-state-to-vi' on entry." + (viper-change-state-to-vi)) (defvar makefile-mode-hook) (add-hook 'makefile-mode-hook 'viper-mode) (defvar help-mode-hook) (add-hook 'help-mode-hook 'viper-mode) - (vip-modify-major-mode 'help-mode 'vi-state vip-help-modifier-map) + (viper-modify-major-mode 'help-mode 'vi-state viper-help-modifier-map) (defvar awk-mode-hook) (add-hook 'awk-mode-hook 'viper-mode) @@ -691,59 +690,59 @@ (add-hook 'python-mode-hook 'viper-mode) (defvar emerge-startup-hook) - (add-hook 'emerge-startup-hook 'vip-change-state-to-emacs) + (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs) ;; Tell vc-diff to put *vc* in Vi mode (if (featurep 'vc) - (defadvice vc-diff (after vip-vc-ad activate) + (defadvice vc-diff (after viper-vc-ad activate) "Force Vi state in VC diff buffer." - (vip-change-state-to-vi)) - (vip-eval-after-load + (viper-change-state-to-vi)) + (eval-after-load "vc" - '(defadvice vc-diff (after vip-vc-ad activate) + '(defadvice vc-diff (after viper-vc-ad activate) "Force Vi state in VC diff buffer." - (vip-change-state-to-vi)))) + (viper-change-state-to-vi)))) - (vip-eval-after-load + (eval-after-load "emerge" - '(defadvice emerge-quit (after vip-emerge-advice activate) - "Run `vip-change-state-to-vi' after quitting emerge." - (vip-change-state-to-vi))) + '(defadvice emerge-quit (after viper-emerge-advice activate) + "Run `viper-change-state-to-vi' after quitting emerge." + (viper-change-state-to-vi))) ;; In case Emerge was loaded before Viper. - (defadvice emerge-quit (after vip-emerge-advice activate) - "Run `vip-change-state-to-vi' after quitting emerge." - (vip-change-state-to-vi)) + (defadvice emerge-quit (after viper-emerge-advice activate) + "Run `viper-change-state-to-vi' after quitting emerge." + (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. - (vip-eval-after-load + (eval-after-load "passwd" - '(defadvice read-passwd-1 (before vip-passwd-ad activate) + '(defadvice read-passwd-1 (before viper-passwd-ad activate) "Switch to emacs state while reading password." - (vip-change-state-to-emacs))) + (viper-change-state-to-emacs))) ;; Emacs shell, ange-ftp, and comint-based modes (defvar comint-mode-hook) - (vip-modify-major-mode - 'comint-mode 'insert-state vip-comint-mode-modifier-map) - (vip-modify-major-mode - 'comint-mode 'vi-state vip-comint-mode-modifier-map) - (vip-modify-major-mode - 'shell-mode 'insert-state vip-comint-mode-modifier-map) - (vip-modify-major-mode - 'shell-mode 'vi-state vip-comint-mode-modifier-map) + (viper-modify-major-mode + 'comint-mode 'insert-state viper-comint-mode-modifier-map) + (viper-modify-major-mode + 'comint-mode 'vi-state viper-comint-mode-modifier-map) + (viper-modify-major-mode + 'shell-mode 'insert-state viper-comint-mode-modifier-map) + (viper-modify-major-mode + 'shell-mode 'vi-state viper-comint-mode-modifier-map) ;; ange-ftp in XEmacs - (vip-modify-major-mode - 'ange-ftp-shell-mode 'insert-state vip-comint-mode-modifier-map) - (vip-modify-major-mode - 'ange-ftp-shell-mode 'vi-state vip-comint-mode-modifier-map) + (viper-modify-major-mode + 'ange-ftp-shell-mode 'insert-state viper-comint-mode-modifier-map) + (viper-modify-major-mode + 'ange-ftp-shell-mode 'vi-state viper-comint-mode-modifier-map) ;; ange-ftp in Emacs - (vip-modify-major-mode - 'internal-ange-ftp-mode 'insert-state vip-comint-mode-modifier-map) - (vip-modify-major-mode - 'internal-ange-ftp-mode 'vi-state vip-comint-mode-modifier-map) + (viper-modify-major-mode + 'internal-ange-ftp-mode 'insert-state viper-comint-mode-modifier-map) + (viper-modify-major-mode + 'internal-ange-ftp-mode 'vi-state viper-comint-mode-modifier-map) ;; set hook - (add-hook 'comint-mode-hook 'vip-comint-mode-hook) + (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ;; Shell scripts (defvar sh-mode-hook) @@ -752,101 +751,102 @@ (add-hook 'ksh-mode-hook 'viper-mode) ;; Dired - (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map) - (vip-set-emacs-state-searchstyle-macros nil 'dired-mode) - (add-hook 'dired-mode-hook 'vip-change-state-to-emacs) + (viper-modify-major-mode 'dired-mode 'emacs-state viper-dired-modifier-map) + (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) + (add-hook 'dired-mode-hook 'viper-change-state-to-emacs) (setq viper-non-vi-major-modes (append '(dired-mode efs-mode internal-ange-ftp-mode) viper-non-vi-major-modes)) ;; Tar - (vip-modify-major-mode 'tar-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'tar-mode) + (viper-modify-major-mode 'tar-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) (setq viper-non-vi-major-modes (cons 'tar-mode viper-non-vi-major-modes)) ;; MH-E - (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) + (viper-modify-major-mode + 'mh-folder-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) ;; changing state to emacs is needed so the preceding will take hold - (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs) + (add-hook 'mh-folder-mode-hook 'viper-change-state-to-emacs) (add-hook 'mh-show-mode-hook 'viper-mode) (setq viper-non-vi-major-modes (cons 'mh-folder-mode viper-non-vi-major-modes)) ;; Gnus - (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'gnus-group-mode) - (vip-modify-major-mode - 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'gnus-summary-mode) + (viper-modify-major-mode + 'gnus-group-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'gnus-group-mode) + (viper-modify-major-mode + 'gnus-summary-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'gnus-summary-mode) ;; changing state to emacs is needed so the preceding will take hold - (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs) - (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs) + (add-hook 'gnus-group-mode-hook 'viper-change-state-to-emacs) + (add-hook 'gnus-summary-mode-hook 'viper-change-state-to-emacs) (add-hook 'gnus-article-mode-hook 'viper-mode) (setq viper-non-vi-major-modes (append '(gnus-group-mode gnus-summary-mode) viper-non-vi-major-modes)) ;; Info - (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'Info-mode) + (viper-modify-major-mode 'Info-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'Info-mode) ;; Switching to emacs is needed so the above will take hold - (defadvice Info-mode (after vip-Info-ad activate) + (defadvice Info-mode (after viper-Info-ad activate) "Switch to emacs mode." - (vip-change-state-to-emacs)) + (viper-change-state-to-emacs)) (setq viper-non-vi-major-modes (cons 'Info-mode viper-non-vi-major-modes)) ;; Buffer menu - (vip-modify-major-mode - 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map) - (vip-set-emacs-state-searchstyle-macros nil 'Buffer-menu-mode) + (viper-modify-major-mode + 'Buffer-menu-mode 'emacs-state viper-slash-and-colon-map) + (viper-set-emacs-state-searchstyle-macros nil 'Buffer-menu-mode) ;; Switching to emacs is needed so the above will take hold - (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate) + (defadvice Buffer-menu-mode (after viper-Buffer-menu-ad activate) "Switch to emacs mode." - (vip-change-state-to-emacs)) + (viper-change-state-to-emacs)) (setq viper-non-vi-major-modes (cons 'Buffer-menu-mode viper-non-vi-major-modes)) ;; View mode (defvar view-mode-hook) (defvar view-hook) - (add-hook 'view-hook 'vip-change-state-to-emacs) - (add-hook 'view-mode-hook 'vip-change-state-to-emacs) + (add-hook 'view-hook 'viper-change-state-to-emacs) + (add-hook 'view-mode-hook 'viper-change-state-to-emacs) (setq viper-non-vi-major-modes (cons 'view-mode viper-non-vi-major-modes)) ;; For VM users. ;; Put summary and other VM buffers in Emacs state. (defvar vm-mode-hooks) (defvar vm-summary-mode-hooks) - (add-hook 'vm-mode-hooks 'vip-change-state-to-emacs) - (add-hook 'vm-summary-mode-hooks 'vip-change-state-to-emacs) + (add-hook 'vm-mode-hooks 'viper-change-state-to-emacs) + (add-hook 'vm-summary-mode-hooks 'viper-change-state-to-emacs) (setq viper-non-vi-major-modes (append '(vm-mode vm-summary-mode) viper-non-vi-major-modes)) ;; For RMAIL users. ;; Put buf in Emacs state after edit. - (vip-eval-after-load + (eval-after-load "rmailedit" - '(defadvice rmail-cease-edit (after vip-rmail-advice activate) + '(defadvice rmail-cease-edit (after viper-rmail-advice activate) "Switch to emacs state when done editing message." - (vip-change-state-to-emacs))) + (viper-change-state-to-emacs))) ;; In case RMAIL was loaded before Viper. - (defadvice rmail-cease-edit (after vip-rmail-advice activate) + (defadvice rmail-cease-edit (after viper-rmail-advice activate) "Switch to emacs state when done editing message." - (vip-change-state-to-emacs)) - ) ; vip-set-hooks + (viper-change-state-to-emacs)) + ) ; viper-set-hooks ;; these are primarily advices and Vi-ish variable settings -(defun vip-non-hook-settings () +(defun viper-non-hook-settings () - ;; 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, - ;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have - ;; different keymaps for different buffers. - ;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode - ;; can be different. + ;; 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, + ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have + ;; different keymaps for different buffers. Also, the keymaps associated + ;; with viper-vi/insert-state-modifier-minor-mode can be different. (make-variable-buffer-local 'minor-mode-map-alist) ;; Viper changes the default mode-line-buffer-identification @@ -859,61 +859,62 @@ (make-variable-buffer-local 'require-final-newline) ;; don't bark when mark is inactive - (if vip-emacs-p + (if viper-emacs-p (setq mark-even-if-inactive t)) (setq scroll-step 1) ;; Variable displaying the current Viper state in the mode line. - (vip-deflocalvar vip-mode-string vip-emacs-state-id) - (or (memq 'vip-mode-string global-mode-string) + (viper-deflocalvar viper-mode-string viper-emacs-state-id) + (or (memq 'viper-mode-string global-mode-string) (setq global-mode-string - (append '("" vip-mode-string) (cdr global-mode-string)))) + (append '("" viper-mode-string) (cdr global-mode-string)))) - (defadvice read-key-sequence (around vip-read-keyseq-ad activate) + (defadvice read-key-sequence (around viper-read-keyseq-ad activate) "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 vip-xemacs-p + (setq event (if viper-xemacs-p (elt keyseq 0) ; XEmacs returns vector of events (elt (listify-key-sequence keyseq) 0))) - (if (vip-ESC-event-p event) + (if (viper-ESC-event-p event) (let (unread-command-events) - (vip-set-unread-command-events keyseq) - (if (vip-fast-keysequence-p) - (let ((vip-vi-global-user-minor-mode nil) - (vip-vi-local-user-minor-mode nil) - (vip-replace-minor-mode nil) ; actually unnecessary - (vip-insert-global-user-minor-mode nil) - (vip-insert-local-user-minor-mode nil)) + (viper-set-unread-command-events keyseq) + (if (viper-fast-keysequence-p) + (let ((viper-vi-global-user-minor-mode nil) + (viper-vi-local-user-minor-mode nil) + (viper-replace-minor-mode nil) ; actually unnecessary + (viper-insert-global-user-minor-mode nil) + (viper-insert-local-user-minor-mode nil)) (setq keyseq ad-do-it)) (setq keyseq ad-do-it)))) keyseq)) - (defadvice describe-key (before vip-read-keyseq-ad protect activate) + (defadvice describe-key (before viper-read-keyseq-ad protect activate) "Force to read key via `read-key-sequence'." - (interactive (list (vip-events-to-keys + (interactive (list (viper-events-to-keys (read-key-sequence "Describe key: "))))) - (defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate) + (defadvice describe-key-briefly + (before viper-read-keyseq-ad protect activate) "Force to read key via `read-key-sequence'." - (interactive (list (vip-events-to-keys + (interactive (list (viper-events-to-keys (read-key-sequence "Describe key briefly: "))))) ;; Advice for use in find-file and read-file-name commands. - (defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate) - "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer." - (run-hooks 'vip-minibuffer-exit-hook)) + (defadvice exit-minibuffer (before viper-exit-minibuffer-advice activate) + "Run `viper-minibuffer-exit-hook' just before exiting the minibuffer." + (run-hooks 'viper-minibuffer-exit-hook)) - (defadvice find-file (before vip-add-suffix-advice activate) + (defadvice find-file (before viper-add-suffix-advice activate) "Use `read-file-name' for reading arguments." (interactive (cons (read-file-name "Find file: " nil default-directory) ;; if Mule and prefix argument, ask for coding system - (cond ((and vip-emacs-p + (cond ((and viper-emacs-p (boundp 'MULE)) ; Emacs 20 with MULE nil) - ((and vip-xemacs-p + ((and viper-xemacs-p (featurep 'mule)) ; XEmacs 20 with MULE (list (and current-prefix-arg @@ -922,15 +923,15 @@ ) ))) - (defadvice find-file-other-window (before vip-add-suffix-advice activate) + (defadvice find-file-other-window (before viper-add-suffix-advice activate) "Use `read-file-name' for reading arguments." (interactive (cons (read-file-name "Find file in other window: " nil default-directory) ;; if Mule and prefix argument, ask for coding system - (cond ((and vip-emacs-p + (cond ((and viper-emacs-p (boundp 'MULE)) ; Emacs 20 with MULE nil) - ((and vip-xemacs-p + ((and viper-xemacs-p (featurep 'mule)) ; XEmacs 20 with MULE (list (and current-prefix-arg @@ -940,15 +941,15 @@ ))) - (defadvice find-file-other-frame (before vip-add-suffix-advice activate) + (defadvice find-file-other-frame (before viper-add-suffix-advice activate) "Use `read-file-name' for reading arguments." (interactive (cons (read-file-name "Find file in other frame: " nil default-directory) ;; if Mule and prefix argument, ask for coding system - (cond ((and vip-emacs-p + (cond ((and viper-emacs-p (boundp 'MULE)) ; Emacs 20 with MULE nil) - ((and vip-xemacs-p + ((and viper-xemacs-p (featurep 'mule)) ; XEmacs 20 with MULE (list (and current-prefix-arg @@ -958,70 +959,28 @@ ))) - (defadvice read-file-name (around vip-suffix-advice activate) - "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook." - (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix)) + (defadvice read-file-name (around viper-suffix-advice activate) + "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook." + (let ((viper-minibuffer-exit-hook 'viper-file-add-suffix)) ad-do-it)) - (defadvice start-kbd-macro (after vip-kbd-advice activate) + (defadvice start-kbd-macro (after viper-kbd-advice activate) "Remove Viper's intercepting bindings for C-x ). This may be needed if the previous `:map' command terminated abnormally." - (define-key vip-vi-intercept-map "\C-x)" nil) - (define-key vip-insert-intercept-map "\C-x)" nil) - (define-key vip-emacs-intercept-map "\C-x)" nil)) - - (cond ((vip-window-display-p) - (let* ((search-key (if vip-xemacs-p - [(meta shift button1up)] [M-S-mouse-1])) - (search-key-catch - (if vip-xemacs-p [(meta shift button1)] [M-S-down-mouse-1])) - (insert-key (if vip-xemacs-p - [(meta shift button2up)] [M-S-mouse-2])) - (insert-key-catch - (if vip-xemacs-p [(meta shift button2)] [M-S-down-mouse-2])) - (search-key-unbound (and (not (key-binding search-key)) - (not (key-binding search-key-catch)))) - (insert-key-unbound (and (not (key-binding insert-key)) - (not (key-binding insert-key-catch)))) - ) - - (if search-key-unbound - (global-set-key search-key 'vip-mouse-click-search-word)) - (if insert-key-unbound - (global-set-key insert-key 'vip-mouse-click-insert-word)) - - ;; The following would be needed if you want to use the above two - ;; while clicking in another frame. If you only want to use them - ;; by clicking in another window, not frame, the bindings below - ;; aren't necessary. - - ;; These must be bound to mouse-down event for the same mouse - ;; buttons as 'vip-mouse-click-search-word and - ;; 'vip-mouse-click-insert-word - (if search-key-unbound - (global-set-key search-key-catch 'vip-mouse-catch-frame-switch)) - (if insert-key-unbound - (global-set-key insert-key-catch 'vip-mouse-catch-frame-switch)) - - (if vip-xemacs-p - (add-hook 'mouse-leave-frame-hook - 'vip-remember-current-frame) - (defadvice handle-switch-frame (before vip-frame-advice activate) - "Remember the selected frame before the switch-frame event." - (vip-remember-current-frame (selected-frame)))) - ))) - ) ; end vip-non-hook-settings + (define-key viper-vi-intercept-map "\C-x)" nil) + (define-key viper-insert-intercept-map "\C-x)" nil) + (define-key viper-emacs-intercept-map "\C-x)" nil)) + ) ; end viper-non-hook-settings (if (eq viper-mode 'ask) (progn (save-window-excursion - (with-output-to-temp-buffer " *vip-info*" + (with-output-to-temp-buffer " *viper-info*" (princ " You have loaded Viper, and are about to Viperize your emacs! -Viper is a Package for Emacs Rebels -and a venomous VI PERil, +Viper is a Package for Emacs Rebels and a venomous VI PERil, It's time to decide: to Viperize or not to Viperize... @@ -1033,12 +992,19 @@ in your .emacs file (preferably, close to the top). These two lines must come in the order given. -Also, the startup file name has been changed from .vip to .viper")) +** Viper users: + **** The startup file name has been changed from .vip to .viper + **** All vip-* style names have been converted to viper-* style.")) (if (y-or-n-p "Viperize? ") (setq viper-mode t) (setq viper-mode nil)) (message "") - (kill-buffer " *vip-info*")))) + (kill-buffer " *viper-info*")))) + +(defun viper-load-custom-file () + (if (and (file-exists-p viper-custom-file-name) + (not noninteractive)) + (load viper-custom-file-name))) @@ -1064,7 +1030,7 @@ (cons 'mode-line-buffer-identification (list (default-value 'mode-line-buffer-identification))) (cons 'global-mode-string (list global-mode-string)) - (if vip-emacs-p + (if viper-emacs-p (cons 'mark-even-if-inactive (list mark-even-if-inactive))) ))) @@ -1075,127 +1041,121 @@ (if viper-mode (progn ;; set advices and some variables that give emacs Vi look. - (vip-non-hook-settings) + (viper-non-hook-settings) ;; repeat the 2nd previous command without rotating the command history - (vip-record-kbd-macro - (vector vip-repeat-from-history-key '\1) 'vi-state - [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) + (viper-record-kbd-macro + (vector viper-repeat-from-history-key '\1) 'vi-state + [(meta x) v i p e r - r e p e a t - f r o m - h i s t o r y return] 't) ;; repeat the 3d previous command without rotating the command history - (vip-record-kbd-macro - (vector vip-repeat-from-history-key '\2) 'vi-state - [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) + (viper-record-kbd-macro + (vector viper-repeat-from-history-key '\2) 'vi-state + [(meta x) v i p e r - r e p e a t - f r o m - h i s t o r y return] 't) ;; set macros for toggling case sensitivity and regexp search - (vip-set-searchstyle-toggling-macros nil) + (viper-set-searchstyle-toggling-macros nil) ;; Make %%% toggle parsing comments for matching parentheses - (vip-set-parsing-style-toggling-macro nil) + (viper-set-parsing-style-toggling-macro nil) + + ;; ~/.viper is loaded if exists + (viper-load-custom-file) + + ;; should be after loading custom file to avoid the pesky msg that + ;; mouse-search/insert keys are already bound + (viper-bind-mouse-search-key) + (viper-bind-mouse-insert-key) )) -;; ~/.viper is loaded if it exists -(if (and (file-exists-p vip-custom-file-name) - viper-mode - (not noninteractive)) - (load vip-custom-file-name)) - -;; VIP compatibility: merge whatever the user has in vip-mode-map into -;; Viper's basic map. -(vip-add-keymap vip-mode-map vip-vi-global-user-map) - -(if (boundp 'vip-expert-level) - (setq viper-expert-level vip-expert-level)) - - -;; Applying Viper customization -- runs after (load .vip) +;; Applying Viper customization -- runs after (load .viper) ;; Save user settings or Viper defaults for vars controled by ;; viper-expert-level (if (null viper-saved-user-settings) (setq viper-saved-user-settings - (list (cons 'vip-want-ctl-h-help (list vip-want-ctl-h-help)) + (list (cons 'viper-want-ctl-h-help (list viper-want-ctl-h-help)) (cons 'viper-always (list viper-always)) - (cons 'vip-no-multiple-ESC (list vip-no-multiple-ESC)) - (cons 'vip-ex-style-motion (list vip-ex-style-motion)) - (cons 'vip-ex-style-editing-in-insert - (list vip-ex-style-editing-in-insert)) - (cons 'vip-want-emacs-keys-in-vi - (list vip-want-emacs-keys-in-vi)) - (cons 'vip-electric-mode (list vip-electric-mode)) - (cons 'vip-want-emacs-keys-in-insert - (list vip-want-emacs-keys-in-insert)) - (cons 'vip-re-search (list vip-re-search))))) + (cons 'viper-no-multiple-ESC (list viper-no-multiple-ESC)) + (cons 'viper-ex-style-motion (list viper-ex-style-motion)) + (cons 'viper-ex-style-editing-in-insert + (list viper-ex-style-editing-in-insert)) + (cons 'viper-want-emacs-keys-in-vi + (list viper-want-emacs-keys-in-vi)) + (cons 'viper-electric-mode (list viper-electric-mode)) + (cons 'viper-want-emacs-keys-in-insert + (list viper-want-emacs-keys-in-insert)) + (cons 'viper-re-search (list viper-re-search))))) (if viper-mode (progn - (vip-set-minibuffer-style) - (if vip-buffer-search-char - (vip-buffer-search-enable)) - (vip-update-alphanumeric-class) + (viper-set-minibuffer-style) + (if viper-buffer-search-char + (viper-buffer-search-enable)) + (viper-update-alphanumeric-class) )) ;;; Familiarize Viper with some minor modes that have their own keymaps (if viper-mode (progn - (vip-harness-minor-mode "compile") - (vip-harness-minor-mode "outline") - (vip-harness-minor-mode "allout") - (vip-harness-minor-mode "xref") - (vip-harness-minor-mode "lmenu") - (vip-harness-minor-mode "vc") - (vip-harness-minor-mode "ltx-math") ; LaTeX-math-mode in AUC-TeX - (vip-harness-minor-mode "latex") ; which is in one of these two files - (vip-harness-minor-mode "cyrillic") - (vip-harness-minor-mode "russian") - (vip-harness-minor-mode "view-less") - (vip-harness-minor-mode "view") + (viper-harness-minor-mode "compile") + (viper-harness-minor-mode "outline") + (viper-harness-minor-mode "allout") + (viper-harness-minor-mode "xref") + (viper-harness-minor-mode "lmenu") + (viper-harness-minor-mode "vc") + (viper-harness-minor-mode "ltx-math") ; LaTeX-math-mode in AUC-TeX, which + (viper-harness-minor-mode "latex") ; sits in one of these two files + (viper-harness-minor-mode "cyrillic") + (viper-harness-minor-mode "russian") + (viper-harness-minor-mode "view-less") + (viper-harness-minor-mode "view") )) ;; Intercept maps could go in viper-keym.el ;; We keep them here in case someone redefines them in ~/.viper -(define-key vip-vi-intercept-map vip-ESC-key 'vip-intercept-ESC-key) -(define-key vip-insert-intercept-map vip-ESC-key 'vip-intercept-ESC-key) +(define-key viper-vi-intercept-map viper-ESC-key 'viper-intercept-ESC-key) +(define-key viper-insert-intercept-map viper-ESC-key 'viper-intercept-ESC-key) -;; This is taken care of by vip-insert-global-user-map. -;;(define-key vip-replace-map vip-ESC-key 'vip-intercept-ESC-key) +;; This is taken care of by viper-insert-global-user-map. +;;(define-key viper-replace-map viper-ESC-key 'viper-intercept-ESC-key) -;; The default vip-toggle-key is \C-z; for the novice, it suspends or +;; The default viper-toggle-key is \C-z; for the novice, it suspends or ;; iconifies Emacs -(define-key vip-vi-intercept-map vip-toggle-key 'vip-toggle-key-action) -(define-key vip-emacs-intercept-map vip-toggle-key 'vip-change-state-to-vi) +(define-key viper-vi-intercept-map viper-toggle-key 'viper-toggle-key-action) +(define-key + viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi) (if (and viper-mode (or viper-always (and (< viper-expert-level 5) (> viper-expert-level 0)))) - (vip-set-hooks)) + (viper-set-hooks)) ;; Let all minor modes take effect after loading ;; this may not be enough, so we also set default minor-mode-alist. ;; Without setting the default, new buffers that come up in emacs mode have -;; minor-mode-map-alist = nil, unless we call vip-change-state-* -(if (eq vip-current-state 'emacs-state) +;; minor-mode-map-alist = nil, unless we call viper-change-state-* +(if (eq viper-current-state 'emacs-state) (progn - (vip-change-state-to-emacs) + (viper-change-state-to-emacs) (setq-default minor-mode-map-alist minor-mode-map-alist) )) -(run-hooks 'vip-load-hook) ; the last chance to change something +(run-hooks 'viper-load-hook) ; the last chance to change something -(provide 'vip) (provide 'viper) ;;; Local Variables: -;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun) +;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) ;;; End: ;;; viper.el ends here