Mercurial > emacs
changeset 18424:395e1d352d3b
(vip-mode-map): Add defvar; move earlier.
(vip-c-string): Variable renamed and defvar added.
(vip-save-minibuffer-local-map): Likewise.
(vip-end-with-a-newline-p): Use STRING (the arg) instead of `text'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 23 Jun 1997 19:18:36 +0000 |
parents | 3934c0e29d14 |
children | 847ee3e08152 |
files | lisp/emulation/vip.el |
diffstat | 1 files changed, 147 insertions(+), 143 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emulation/vip.el Mon Jun 23 19:12:42 1997 +0000 +++ b/lisp/emulation/vip.el Mon Jun 23 19:18:36 1997 +0000 @@ -141,6 +141,143 @@ (defvar vip-startup-file (convert-standard-filename "~/.vip") "Filename used as startup file for vip.") +;; key bindings + +(defvar vip-mode-map (make-keymap)) + +(define-key vip-mode-map "\C-a" 'beginning-of-line) +(define-key vip-mode-map "\C-b" 'vip-scroll-back) +(define-key vip-mode-map "\C-c" 'vip-ctl-c) +(define-key vip-mode-map "\C-d" 'vip-scroll-up) +(define-key vip-mode-map "\C-e" 'vip-scroll-up-one) +(define-key vip-mode-map "\C-f" 'vip-scroll) +(define-key vip-mode-map "\C-g" 'vip-keyboard-quit) +(define-key vip-mode-map "\C-h" 'help-command) +(define-key vip-mode-map "\C-m" 'vip-scroll-back) +(define-key vip-mode-map "\C-n" 'vip-other-window) +(define-key vip-mode-map "\C-o" 'vip-open-line-at-point) +(define-key vip-mode-map "\C-u" 'vip-scroll-down) +(define-key vip-mode-map "\C-x" 'vip-ctl-x) +(define-key vip-mode-map "\C-y" 'vip-scroll-down-one) +(define-key vip-mode-map "\C-z" 'vip-change-mode-to-emacs) +(define-key vip-mode-map "\e" 'vip-ESC) + +(define-key vip-mode-map " " 'vip-scroll) +(define-key vip-mode-map "!" 'vip-command-argument) +(define-key vip-mode-map "\"" 'vip-command-argument) +(define-key vip-mode-map "#" 'vip-command-argument) +(define-key vip-mode-map "$" 'vip-goto-eol) +(define-key vip-mode-map "%" 'vip-paren-match) +(define-key vip-mode-map "&" 'vip-nil) +(define-key vip-mode-map "'" 'vip-goto-mark-and-skip-white) +(define-key vip-mode-map "(" 'vip-backward-sentence) +(define-key vip-mode-map ")" 'vip-forward-sentence) +(define-key vip-mode-map "*" 'call-last-kbd-macro) +(define-key vip-mode-map "+" 'vip-next-line-at-bol) +(define-key vip-mode-map "," 'vip-repeat-find-opposite) +(define-key vip-mode-map "-" 'vip-previous-line-at-bol) +(define-key vip-mode-map "." 'vip-repeat) +(define-key vip-mode-map "/" 'vip-search-forward) + +(define-key vip-mode-map "0" 'vip-beginning-of-line) +(define-key vip-mode-map "1" 'vip-digit-argument) +(define-key vip-mode-map "2" 'vip-digit-argument) +(define-key vip-mode-map "3" 'vip-digit-argument) +(define-key vip-mode-map "4" 'vip-digit-argument) +(define-key vip-mode-map "5" 'vip-digit-argument) +(define-key vip-mode-map "6" 'vip-digit-argument) +(define-key vip-mode-map "7" 'vip-digit-argument) +(define-key vip-mode-map "8" 'vip-digit-argument) +(define-key vip-mode-map "9" 'vip-digit-argument) + +(define-key vip-mode-map ":" 'vip-ex) +(define-key vip-mode-map ";" 'vip-repeat-find) +(define-key vip-mode-map "<" 'vip-command-argument) +(define-key vip-mode-map "=" 'vip-command-argument) +(define-key vip-mode-map ">" 'vip-command-argument) +(define-key vip-mode-map "?" 'vip-search-backward) +(define-key vip-mode-map "@" 'vip-nil) + +(define-key vip-mode-map "A" 'vip-Append) +(define-key vip-mode-map "B" 'vip-backward-Word) +(define-key vip-mode-map "C" 'vip-ctl-c-equivalent) +(define-key vip-mode-map "D" 'vip-kill-line) +(define-key vip-mode-map "E" 'vip-end-of-Word) +(define-key vip-mode-map "F" 'vip-find-char-backward) +(define-key vip-mode-map "G" 'vip-goto-line) +(define-key vip-mode-map "H" 'vip-window-top) +(define-key vip-mode-map "I" 'vip-Insert) +(define-key vip-mode-map "J" 'vip-join-lines) +(define-key vip-mode-map "K" 'vip-kill-buffer) +(define-key vip-mode-map "L" 'vip-window-bottom) +(define-key vip-mode-map "M" 'vip-window-middle) +(define-key vip-mode-map "N" 'vip-search-Next) +(define-key vip-mode-map "O" 'vip-Open-line) +(define-key vip-mode-map "P" 'vip-Put-back) +(define-key vip-mode-map "Q" 'vip-query-replace) +(define-key vip-mode-map "R" 'vip-replace-string) +(define-key vip-mode-map "S" 'vip-switch-to-buffer-other-window) +(define-key vip-mode-map "T" 'vip-goto-char-backward) +(define-key vip-mode-map "U" 'vip-nil) +(define-key vip-mode-map "V" 'vip-find-file-other-window) +(define-key vip-mode-map "W" 'vip-forward-Word) +(define-key vip-mode-map "X" 'vip-ctl-x-equivalent) +(define-key vip-mode-map "Y" 'vip-yank-line) +(define-key vip-mode-map "ZZ" 'save-buffers-kill-emacs) + +(define-key vip-mode-map "[" 'vip-nil) +(define-key vip-mode-map "\\" 'vip-escape-to-emacs) +(define-key vip-mode-map "]" 'vip-nil) +(define-key vip-mode-map "^" 'vip-bol-and-skip-white) +(define-key vip-mode-map "_" 'vip-nil) +(define-key vip-mode-map "`" 'vip-goto-mark) + +(define-key vip-mode-map "a" 'vip-append) +(define-key vip-mode-map "b" 'vip-backward-word) +(define-key vip-mode-map "c" 'vip-command-argument) +(define-key vip-mode-map "d" 'vip-command-argument) +(define-key vip-mode-map "e" 'vip-end-of-word) +(define-key vip-mode-map "f" 'vip-find-char-forward) +(define-key vip-mode-map "g" 'vip-info-on-file) +(define-key vip-mode-map "h" 'vip-backward-char) +(define-key vip-mode-map "i" 'vip-insert) +(define-key vip-mode-map "j" 'vip-next-line) +(define-key vip-mode-map "k" 'vip-previous-line) +(define-key vip-mode-map "l" 'vip-forward-char) +(define-key vip-mode-map "m" 'vip-mark-point) +(define-key vip-mode-map "n" 'vip-search-next) +(define-key vip-mode-map "o" 'vip-open-line) +(define-key vip-mode-map "p" 'vip-put-back) +(define-key vip-mode-map "q" 'vip-nil) +(define-key vip-mode-map "r" 'vip-replace-char) +(define-key vip-mode-map "s" 'vip-switch-to-buffer) +(define-key vip-mode-map "t" 'vip-goto-char-forward) +(define-key vip-mode-map "u" 'vip-undo) +(define-key vip-mode-map "v" 'vip-find-file) +(define-key vip-mode-map "w" 'vip-forward-word) +(define-key vip-mode-map "x" 'vip-delete-char) +(define-key vip-mode-map "y" 'vip-command-argument) +(define-key vip-mode-map "zH" 'vip-line-to-top) +(define-key vip-mode-map "zM" 'vip-line-to-middle) +(define-key vip-mode-map "zL" 'vip-line-to-bottom) +(define-key vip-mode-map "z\C-m" 'vip-line-to-top) +(define-key vip-mode-map "z." 'vip-line-to-middle) +(define-key vip-mode-map "z-" 'vip-line-to-bottom) + +(define-key vip-mode-map "{" 'vip-backward-paragraph) +(define-key vip-mode-map "|" 'vip-goto-col) +(define-key vip-mode-map "}" 'vip-forward-paragraph) +(define-key vip-mode-map "~" 'vip-nil) +(define-key vip-mode-map "\177" 'vip-delete-backward-char) + +(define-key ctl-x-map "3" 'vip-buffer-in-two-windows) +(define-key ctl-x-map "\C-i" 'insert-file) + +(defun vip-version () + (interactive) + (message "VIP version 3.5 of September 15, 1987")) + + ;; basic set up (global-set-key "\C-z" 'vip-change-mode-to-vi) @@ -747,11 +884,13 @@ (defun vip-end-with-a-newline-p (string) "Check if the string ends with a newline." - (or (string= text "") + (or (string= string "") (= (aref string (1- (length string))) ?\n))) +(defvar vip-save-minibuffer-local-map) + (defun vip-read-string (prompt &optional init) - (setq save-minibuffer-local-map (copy-keymap minibuffer-local-map)) + (setq vip-save-minibuffer-local-map (copy-keymap minibuffer-local-map)) (define-key minibuffer-local-map "\C-h" 'backward-char) (define-key minibuffer-local-map "\C-w" 'backward-word) (define-key minibuffer-local-map "\e" 'exit-minibuffer) @@ -759,9 +898,9 @@ (condition-case conditions (setq str (read-string prompt init)) (quit - (setq minibuffer-local-map save-minibuffer-local-map) + (setq minibuffer-local-map vip-save-minibuffer-local-map) (signal 'quit nil))) - (setq minibuffer-local-map save-minibuffer-local-map) + (setq minibuffer-local-map vip-save-minibuffer-local-map) str)) @@ -1713,8 +1852,10 @@ ;; making small changes +(defvar vip-c-string) + (defun vip-change (beg end) - (setq c-string + (setq vip-c-string (vip-read-string (format "%s => " (buffer-substring beg end)))) (vip-change-subr beg end)) @@ -1725,7 +1866,7 @@ (setq vip-use-register nil))) (kill-region beg end) (setq this-command 'vip-change) - (insert c-string)) + (insert vip-c-string)) ;; query replace @@ -1858,143 +1999,6 @@ (delete-region (point) (mark)))) -;; key bindings - -(set 'vip-mode-map (make-keymap)) - -(define-key vip-mode-map "\C-a" 'beginning-of-line) -(define-key vip-mode-map "\C-b" 'vip-scroll-back) -(define-key vip-mode-map "\C-c" 'vip-ctl-c) -(define-key vip-mode-map "\C-d" 'vip-scroll-up) -(define-key vip-mode-map "\C-e" 'vip-scroll-up-one) -(define-key vip-mode-map "\C-f" 'vip-scroll) -(define-key vip-mode-map "\C-g" 'vip-keyboard-quit) -(define-key vip-mode-map "\C-h" 'help-command) -(define-key vip-mode-map "\C-m" 'vip-scroll-back) -(define-key vip-mode-map "\C-n" 'vip-other-window) -(define-key vip-mode-map "\C-o" 'vip-open-line-at-point) -(define-key vip-mode-map "\C-u" 'vip-scroll-down) -(define-key vip-mode-map "\C-x" 'vip-ctl-x) -(define-key vip-mode-map "\C-y" 'vip-scroll-down-one) -(define-key vip-mode-map "\C-z" 'vip-change-mode-to-emacs) -(define-key vip-mode-map "\e" 'vip-ESC) - -(define-key vip-mode-map " " 'vip-scroll) -(define-key vip-mode-map "!" 'vip-command-argument) -(define-key vip-mode-map "\"" 'vip-command-argument) -(define-key vip-mode-map "#" 'vip-command-argument) -(define-key vip-mode-map "$" 'vip-goto-eol) -(define-key vip-mode-map "%" 'vip-paren-match) -(define-key vip-mode-map "&" 'vip-nil) -(define-key vip-mode-map "'" 'vip-goto-mark-and-skip-white) -(define-key vip-mode-map "(" 'vip-backward-sentence) -(define-key vip-mode-map ")" 'vip-forward-sentence) -(define-key vip-mode-map "*" 'call-last-kbd-macro) -(define-key vip-mode-map "+" 'vip-next-line-at-bol) -(define-key vip-mode-map "," 'vip-repeat-find-opposite) -(define-key vip-mode-map "-" 'vip-previous-line-at-bol) -(define-key vip-mode-map "." 'vip-repeat) -(define-key vip-mode-map "/" 'vip-search-forward) - -(define-key vip-mode-map "0" 'vip-beginning-of-line) -(define-key vip-mode-map "1" 'vip-digit-argument) -(define-key vip-mode-map "2" 'vip-digit-argument) -(define-key vip-mode-map "3" 'vip-digit-argument) -(define-key vip-mode-map "4" 'vip-digit-argument) -(define-key vip-mode-map "5" 'vip-digit-argument) -(define-key vip-mode-map "6" 'vip-digit-argument) -(define-key vip-mode-map "7" 'vip-digit-argument) -(define-key vip-mode-map "8" 'vip-digit-argument) -(define-key vip-mode-map "9" 'vip-digit-argument) - -(define-key vip-mode-map ":" 'vip-ex) -(define-key vip-mode-map ";" 'vip-repeat-find) -(define-key vip-mode-map "<" 'vip-command-argument) -(define-key vip-mode-map "=" 'vip-command-argument) -(define-key vip-mode-map ">" 'vip-command-argument) -(define-key vip-mode-map "?" 'vip-search-backward) -(define-key vip-mode-map "@" 'vip-nil) - -(define-key vip-mode-map "A" 'vip-Append) -(define-key vip-mode-map "B" 'vip-backward-Word) -(define-key vip-mode-map "C" 'vip-ctl-c-equivalent) -(define-key vip-mode-map "D" 'vip-kill-line) -(define-key vip-mode-map "E" 'vip-end-of-Word) -(define-key vip-mode-map "F" 'vip-find-char-backward) -(define-key vip-mode-map "G" 'vip-goto-line) -(define-key vip-mode-map "H" 'vip-window-top) -(define-key vip-mode-map "I" 'vip-Insert) -(define-key vip-mode-map "J" 'vip-join-lines) -(define-key vip-mode-map "K" 'vip-kill-buffer) -(define-key vip-mode-map "L" 'vip-window-bottom) -(define-key vip-mode-map "M" 'vip-window-middle) -(define-key vip-mode-map "N" 'vip-search-Next) -(define-key vip-mode-map "O" 'vip-Open-line) -(define-key vip-mode-map "P" 'vip-Put-back) -(define-key vip-mode-map "Q" 'vip-query-replace) -(define-key vip-mode-map "R" 'vip-replace-string) -(define-key vip-mode-map "S" 'vip-switch-to-buffer-other-window) -(define-key vip-mode-map "T" 'vip-goto-char-backward) -(define-key vip-mode-map "U" 'vip-nil) -(define-key vip-mode-map "V" 'vip-find-file-other-window) -(define-key vip-mode-map "W" 'vip-forward-Word) -(define-key vip-mode-map "X" 'vip-ctl-x-equivalent) -(define-key vip-mode-map "Y" 'vip-yank-line) -(define-key vip-mode-map "ZZ" 'save-buffers-kill-emacs) - -(define-key vip-mode-map "[" 'vip-nil) -(define-key vip-mode-map "\\" 'vip-escape-to-emacs) -(define-key vip-mode-map "]" 'vip-nil) -(define-key vip-mode-map "^" 'vip-bol-and-skip-white) -(define-key vip-mode-map "_" 'vip-nil) -(define-key vip-mode-map "`" 'vip-goto-mark) - -(define-key vip-mode-map "a" 'vip-append) -(define-key vip-mode-map "b" 'vip-backward-word) -(define-key vip-mode-map "c" 'vip-command-argument) -(define-key vip-mode-map "d" 'vip-command-argument) -(define-key vip-mode-map "e" 'vip-end-of-word) -(define-key vip-mode-map "f" 'vip-find-char-forward) -(define-key vip-mode-map "g" 'vip-info-on-file) -(define-key vip-mode-map "h" 'vip-backward-char) -(define-key vip-mode-map "i" 'vip-insert) -(define-key vip-mode-map "j" 'vip-next-line) -(define-key vip-mode-map "k" 'vip-previous-line) -(define-key vip-mode-map "l" 'vip-forward-char) -(define-key vip-mode-map "m" 'vip-mark-point) -(define-key vip-mode-map "n" 'vip-search-next) -(define-key vip-mode-map "o" 'vip-open-line) -(define-key vip-mode-map "p" 'vip-put-back) -(define-key vip-mode-map "q" 'vip-nil) -(define-key vip-mode-map "r" 'vip-replace-char) -(define-key vip-mode-map "s" 'vip-switch-to-buffer) -(define-key vip-mode-map "t" 'vip-goto-char-forward) -(define-key vip-mode-map "u" 'vip-undo) -(define-key vip-mode-map "v" 'vip-find-file) -(define-key vip-mode-map "w" 'vip-forward-word) -(define-key vip-mode-map "x" 'vip-delete-char) -(define-key vip-mode-map "y" 'vip-command-argument) -(define-key vip-mode-map "zH" 'vip-line-to-top) -(define-key vip-mode-map "zM" 'vip-line-to-middle) -(define-key vip-mode-map "zL" 'vip-line-to-bottom) -(define-key vip-mode-map "z\C-m" 'vip-line-to-top) -(define-key vip-mode-map "z." 'vip-line-to-middle) -(define-key vip-mode-map "z-" 'vip-line-to-bottom) - -(define-key vip-mode-map "{" 'vip-backward-paragraph) -(define-key vip-mode-map "|" 'vip-goto-col) -(define-key vip-mode-map "}" 'vip-forward-paragraph) -(define-key vip-mode-map "~" 'vip-nil) -(define-key vip-mode-map "\177" 'vip-delete-backward-char) - -(define-key ctl-x-map "3" 'vip-buffer-in-two-windows) -(define-key ctl-x-map "\C-i" 'insert-file) - -(defun vip-version () - (interactive) - (message "VIP version 3.5 of September 15, 1987")) - - ;; implement ex commands (defvar ex-token-type nil