Mercurial > emacs
changeset 16136:de1340e6ddb4
*** empty log message ***
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Fri, 06 Sep 1996 02:13:39 +0000 |
parents | 102e7d27c135 |
children | dc1387f877d4 |
files | lisp/emulation/viper-ex.el lisp/emulation/viper-keym.el lisp/emulation/viper-util.el lisp/emulation/viper.el |
diffstat | 4 files changed, 86 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emulation/viper-ex.el Fri Sep 06 01:17:30 1996 +0000 +++ b/lisp/emulation/viper-ex.el Fri Sep 06 02:13:39 1996 +0000 @@ -285,6 +285,7 @@ ;; A token has a type, \(command, address, end-mark\), and a value (defun vip-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) (skip-chars-forward " \t|") (cond ((looking-at "#") @@ -420,6 +421,7 @@ "!*"))) (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) (goto-char (point-max))) (cond ((vip-looking-back quit-regex1) (exit-minibuffer)) @@ -497,8 +499,7 @@ map))) (save-window-excursion ;; just a precaution - (or (vip-buffer-live-p vip-ex-work-buf) - (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))) + (setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)) (set-buffer vip-ex-work-buf) (delete-region (point-min) (point-max)) (insert com-str "\n") @@ -518,6 +519,8 @@ (t (vip-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) (skip-chars-forward " \t") (cond ((looking-at "|") @@ -554,6 +557,7 @@ ;; Get a regular expression and set `ex-variant', if found (defun vip-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) (skip-chars-forward " \t") (if (looking-at "!") @@ -590,6 +594,7 @@ ;; get an ex command (defun vip-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) (if (looking-at "/") (forward-char 1)) (skip-chars-forward " \t") @@ -605,6 +610,7 @@ ;; Get an Ex option g or c (defun vip-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) (if (looking-at (format "%c" c)) (forward-char 1)) (skip-chars-forward " \t") @@ -716,6 +722,7 @@ (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) (skip-chars-forward " \t") (if (looking-at "[a-zA-Z]") @@ -741,6 +748,7 @@ 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) (skip-chars-forward " \t") (if (looking-at "!") @@ -802,6 +810,7 @@ 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) (skip-chars-forward " \t") (if (looking-at "!") @@ -1167,12 +1176,14 @@ (if (null (setq file (get-file-buffer ex-file))) (progn (ex-find-file ex-file) - (vip-change-state-to-vi) + (or (eq major-mode 'dired-mode) + (vip-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) (delete-region (point-min) (point-max)) (insert ex-offset "\n") @@ -1181,13 +1192,16 @@ (beginning-of-line))) (ex-fixup-history vip-last-ex-prompt ex-file)) -;; Splits the string FILESPEC into substrings separated by newlines. +;; Find-file FILESPEC if it appears to specify a single file. +;; Otherwise, assume that FILES{EC is a wildcard. +;; In this case, split it into substrings separated by newlines. ;; Each line is assumed to be a file name. find-file's each file thus obtained. (defun ex-find-file (filespec) - (let ((nonstandard-filename-chars "[^a-zA-Z0-9_.-/,\\]")) - (if (string-match nonstandard-filename-chars filespec) - (funcall ex-nontrivial-find-file-function filespec) - (find-file filespec)) + (let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]")) + (cond ((file-exists-p filespec) (find-file filespec)) + ((string-match nonstandard-filename-chars filespec) + (funcall ex-nontrivial-find-file-function filespec)) + (t (find-file filespec))) )) @@ -1241,6 +1255,7 @@ (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 com-str (buffer-substring (1+ (point)) (1- (point-max))))) (while marks @@ -1312,6 +1327,7 @@ (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) (skip-chars-forward " \t") (if (looking-at "[a-z]") @@ -1446,6 +1462,7 @@ (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) (if (looking-at "!") (forward-char 1))) (if (< vip-expert-level 3) @@ -1679,6 +1696,7 @@ ;; 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) (goto-char (point-min)) (re-search-forward regex-forw nil t) @@ -1812,6 +1830,7 @@ (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) (skip-chars-forward " \t") (set-mark (point)) @@ -1945,6 +1964,7 @@ (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) (skip-chars-forward " \t") (setq command (buffer-substring (point) (point-max)))
--- a/lisp/emulation/viper-keym.el Fri Sep 06 01:17:30 1996 +0000 +++ b/lisp/emulation/viper-keym.el Fri Sep 06 02:13:39 1996 +0000 @@ -25,6 +25,18 @@ ;;; Variables +(defvar vip-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. +This setting cannot be changed interactively.") + +(defvar vip-ESC-key "\e" + "Key used to ESC. +Must be set in .vip file or prior to loading Viper. +This setting cannot be changed interactively.") + + ;;; Keymaps ;; Keymaps for vital things like \e and C-z. @@ -177,6 +189,8 @@ (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" @@ -195,16 +209,15 @@ (define-key vip-vi-basic-map "\C-^" (function (lambda () (interactive) (vip-ex "e#")))) -(define-key vip-vi-basic-map "\C-b" 'vip-scroll-back) +(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) +(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-\\" 'universal-argument) (define-key vip-vi-basic-map "\C-c/" 'vip-toggle-search-style) (define-key vip-vi-basic-map "\C-cg" 'vip-info-on-file) @@ -279,7 +292,7 @@ (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 "_" 'vip-alternate-ESC) +(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) @@ -321,9 +334,10 @@ (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) ;;; Escape from Emacs to Vi for one command -(global-set-key "\M-\C-z" 'vip-escape-to-vi) ;; in emacs-state +(global-set-key "\C-c\\" 'vip-escape-to-vi) ; everywhere ;;; This is vip-vi-diehard-map. Used when vip-vi-diehard-minor-mode is on. @@ -343,10 +357,11 @@ (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 vip-vi-diehard-map "\C-]" 'vip-nil) ; This is actually tags. ;;; Minibuffer keymap @@ -368,8 +383,23 @@ (define-key ex-read-filename-map " " 'vip-complete-filename-or-exit) (define-key ex-read-filename-map "!" 'vip-handle-!) +;; Some other maps +(defvar vip-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) - +(defvar vip-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) + +(defvar vip-dired-modifier-map (make-sparse-keymap) + "This map modifies Dired behavior.") +(define-key vip-dired-modifier-map ":" 'vip-ex) + + ;;; Code @@ -411,8 +441,8 @@ (defun vip-zap-local-keys () "Unconditionally reset Viper vip-*-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 return -you to sanity." +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
--- a/lisp/emulation/viper-util.el Fri Sep 06 01:17:30 1996 +0000 +++ b/lisp/emulation/viper-util.el Fri Sep 06 02:13:39 1996 +0000 @@ -203,6 +203,15 @@ (cdr (assoc 'cursor-color (frame-parameters))) (color-instance-name (frame-property (selected-frame) 'cursor-color)))) +(defun vip-set-face-pixmap (face pixmap) + "Set face pixmap on a monochrome display." + (if (and (vip-window-display-p) (not (vip-color-display-p))) + (condition-case nil + (set-face-background-pixmap face pixmap) + (error + (message "Pixmap not found for %S: %s" (face-name face) pixmap) + (sit-for 1))))) + ;; OS/2 (cond ((eq (vip-device-type) 'pm) @@ -426,11 +435,11 @@ ;; using cond in anticipation of further additions (cond (ex-unix-type-shell-options) )) - (command (cond (vip-ms-style-os-p (format "\"ls -1 %s\"" filespec)) - (t (format "ls -1 %s" filespec)))) - file-list) + (command (cond (vip-ms-style-os-p (format "\"ls -1 -d %s\"" filespec)) + (t (format "ls -1 -d %s" filespec)))) + file-list status) (save-excursion - (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) + (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) (erase-buffer) (setq status (if gshell-options @@ -470,7 +479,7 @@ `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'." (save-excursion - (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) + (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) (erase-buffer) (insert filespec) (goto-char (point-min)) @@ -508,7 +517,7 @@ ;; convert MS-DOS wildcards to regexp (defun vip-wildcard-to-regexp (wcard) (save-excursion - (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) + (set-buffer (get-buffer-create vip-ex-tmp-buf-name)) (erase-buffer) (insert wcard) (goto-char (point-min)) @@ -744,6 +753,7 @@ (sit-for 2) (vip-overlay-put vip-search-overlay 'face nil)))) + ;; Replace state (defsubst vip-move-replace-overlay (beg end) @@ -1136,9 +1146,8 @@ Usually contains ` ', linefeed, TAB or formfeed.") (defun vip-update-alphanumeric-class () - "Set the syntactic class of Viper alphanumeric symbols according to -the variable `vip-ALPHA-char-class'. Should be called in order for changes to -`vip-ALPHA-char-class' to take effect." + "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." (interactive) (setq-default vip-ALPHA-char-class
--- a/lisp/emulation/viper.el Fri Sep 06 01:17:30 1996 +0000 +++ b/lisp/emulation/viper.el Fri Sep 06 02:13:39 1996 +0000 @@ -821,13 +821,7 @@ (defvar vip-always t "t means, arrange that vi-state will be a default.") -(defvar vip-custom-file-name (cond (vip-vms-os-p "sys$login:.vip") - ((memq system-type '(emx ms-dos)) - "/_vip") - ((memq system-type '(windows-nt windows-95)) - "~/_vip") - (t ; Unix - "~/.vip")) +(defvar vip-custom-file-name (convert-standard-filename "~/.vip") "Viper customisation file. This variable must be set _before_ loading Viper.")