diff options
| author | Michael Kifer <kifer@cs.stonybrook.edu> | 2005-02-19 19:32:47 +0000 |
|---|---|---|
| committer | Michael Kifer <kifer@cs.stonybrook.edu> | 2005-02-19 19:32:47 +0000 |
| commit | 3f9526a371904148524ccea298a84a5aa2078644 (patch) | |
| tree | 6c1748c2882fdd03e08817b200d6327a8aa2f14f /lisp | |
| parent | c3a0cca735c0c4114844be886e6e9c66ee960734 (diff) | |
| download | emacs-3f9526a371904148524ccea298a84a5aa2078644.tar.gz | |
* viper-cmd.el (viper-prefix-commands): make into a defconst.
(viper-exec-buffer-search): use regexp-quote to quote the buffer
string.
(viper-minibuffer-setup-sentinel): make some variables buffer-local.
(viper-skip-separators): bug fix.
(viper-set-searchstyle-toggling-macros): allow to unset macros in a
particular major mode.
(viper-del-backward-char-in-replace): don't put deleted char on the
kill ring.
* viper-ex.el (viper-color-display-p): new function.
(viper-has-face-support-p): use viper-color-display-p.
* viper-keym.el (viper-gnus-modifier-map): new keymap.
* viper-macs.el (viper-unrecord-kbd-macro): bug fix.
* viper-util.el (viper-glob-unix-files): fix shell status check.
(viper-file-remote-p): make equivalent to file-remote-p.
* viper.el (viper-major-mode-modifier-list): use
viper-gnus-modifier-map.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 25 | ||||
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 78 | ||||
| -rw-r--r-- | lisp/emulation/viper-ex.el | 2 | ||||
| -rw-r--r-- | lisp/emulation/viper-init.el | 11 | ||||
| -rw-r--r-- | lisp/emulation/viper-keym.el | 4 | ||||
| -rw-r--r-- | lisp/emulation/viper-macs.el | 43 | ||||
| -rw-r--r-- | lisp/emulation/viper-util.el | 10 | ||||
| -rw-r--r-- | lisp/emulation/viper.el | 10 |
8 files changed, 122 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fe1947e1247..cddef68d455 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,28 @@ +2005-02-19 Michael Kifer <kifer@cs.stonybrook.edu> + + * viper-cmd.el (viper-prefix-commands): make into a defconst. + (viper-exec-buffer-search): use regexp-quote to quote the buffer + string. + (viper-minibuffer-setup-sentinel): make some variables buffer-local. + (viper-skip-separators): bug fix. + (viper-set-searchstyle-toggling-macros): allow to unset macros in a + particular major mode. + (viper-del-backward-char-in-replace): don't put deleted char on the + kill ring. + + * viper-ex.el (viper-color-display-p): new function. + (viper-has-face-support-p): use viper-color-display-p. + + * viper-keym.el (viper-gnus-modifier-map): new keymap. + + * viper-macs.el (viper-unrecord-kbd-macro): bug fix. + + * viper-util.el (viper-glob-unix-files): fix shell status check. + (viper-file-remote-p): make equivalent to file-remote-p. + + * viper.el (viper-major-mode-modifier-list): use + viper-gnus-modifier-map. + 2005-02-19 David Kastrup <dak@gnu.org> * subr.el (subregexp-context-p): Fix garbled doc string by adding diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index eb5e5ede4c7..8023336b18b 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -1063,7 +1063,7 @@ as a Meta key and any number of multiple escapes is allowed." ;; call the actual function to execute ESC (if no other symbols followed) ;; or the key bound to the ESC sequence (if the sequence was issued - ;; with very short delay between characters. + ;; with very short delay between characters). (if (eq cmd 'viper-intercept-ESC-key) (setq cmd (cond ((eq viper-current-state 'vi-state) @@ -1529,7 +1529,8 @@ as a Meta key and any number of multiple escapes is allowed." nil) (defun viper-exec-buffer-search (m-com com) - (setq viper-s-string (buffer-substring (point) viper-com-point)) + (setq viper-s-string + (regexp-quote (buffer-substring (point) viper-com-point))) (setq viper-s-forward t) (setq viper-search-history (cons viper-s-string viper-search-history)) (setq viper-intermediate-command 'viper-exec-buffer-search) @@ -1982,6 +1983,16 @@ Undo previous insertion and inserts new." (let ((hook (if viper-vi-style-in-minibuffer 'viper-change-state-to-insert 'viper-change-state-to-emacs))) + ;; making buffer-local variables so that normal buffers won't affect the + ;; minibuffer and vice versa. Otherwise, command arguments will affect + ;; minibuffer ops and insertions from the minibuffer will change those in + ;; the normal buffers + (make-local-variable 'viper-d-com) + (make-local-variable 'viper-last-insertion) + (make-local-variable 'viper-command-ring) + (setq viper-d-com nil + viper-last-insertion nil + viper-command-ring nil) (funcall hook) )) @@ -2707,7 +2718,7 @@ On reaching beginning of line, stop and signal error." (viper-backward-char-carefully) (if (looking-at "\n") (viper-skip-all-separators-backward 'within-line) - (or (bobp) (forward-char))))) + (or (viper-looking-at-separator) (forward-char))))) (defun viper-forward-word-kernel (val) @@ -3630,33 +3641,39 @@ the Emacs binding of `/'." (setq msg "Search style remains unchanged"))) (princ msg t))) -(defun viper-set-searchstyle-toggling-macros (unset) +(defun viper-set-searchstyle-toggling-macros (unset &optional major-mode) "Set the macros for toggling the search style in Viper's vi-state. The macro that toggles case sensitivity is bound to `//', and the one that toggles regexp search is bound to `///'. -With a prefix argument, this function unsets the macros. " +With a prefix argument, this function unsets the macros. +If MAJOR-MODE is set, set the macros only in that major mode." (interactive "P") - (or noninteractive - (if (not unset) - (progn - ;; toggle case sensitivity in search - (viper-record-kbd-macro - "//" 'vi-state - [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] - 't) - ;; toggle regexp/vanila search - (viper-record-kbd-macro - "///" 'vi-state - [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] - 't) - (if (interactive-p) - (message - "// and /// now toggle case-sensitivity and regexp search"))) - (viper-unrecord-kbd-macro "//" 'vi-state) - (sit-for 2) - (viper-unrecord-kbd-macro "///" 'vi-state)))) - - + (let (scope) + (if (and major-mode (symbolp major-mode)) + (setq scope major-mode) + (setq scope 't)) + (or noninteractive + (if (not unset) + (progn + ;; toggle case sensitivity in search + (viper-record-kbd-macro + "//" 'vi-state + [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] + scope) + ;; toggle regexp/vanila search + (viper-record-kbd-macro + "///" 'vi-state + [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] + scope) + (if (interactive-p) + (message + "// and /// now toggle case-sensitivity and regexp search"))) + (viper-unrecord-kbd-macro "//" 'vi-state) + (sit-for 2) + (viper-unrecord-kbd-macro "///" 'vi-state))) + )) + + (defun viper-set-parsing-style-toggling-macro (unset) "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses. This is used in conjunction with the `%' command. @@ -4112,7 +4129,8 @@ Null string will repeat previous search." (interactive) (if (and viper-ex-style-editing (bolp)) (beep 1) - (delete-backward-char 1 t))) + ;; don't put on kill ring + (delete-backward-char 1 nil))) (defun viper-del-backward-char-in-replace () @@ -4124,13 +4142,15 @@ cursor move past the beginning of line." (interactive) (cond (viper-delete-backwards-in-replace (cond ((not (bolp)) - (delete-backward-char 1 t)) + ;; don't put on kill ring + (delete-backward-char 1 nil)) (viper-ex-style-editing (beep 1)) ((bobp) (beep 1)) (t - (delete-backward-char 1 t)))) + ;; don't put on kill ring + (delete-backward-char 1 nil)))) (viper-ex-style-editing (if (bolp) (beep 1) diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index c94edf54bc2..90b006ffb65 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -1,6 +1,6 @@ ;;; viper-ex.el --- functions implementing the Ex commands for Viper -;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 04 Free Software Foundation, Inc. +;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 04, 05 Free Software Foundation, Inc. ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index 2a13f00535e..4f08f1b6cc1 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el @@ -70,6 +70,16 @@ window-system )) +(defun viper-color-display-p () + (condition-case nil + (viper-cond-compile-for-xemacs-or-emacs + (eq (device-class (selected-device)) 'color) ; xemacs form + (if (fboundp 'display-color-p) ; emacs form + (display-color-p) + (x-display-color-p)) + ) + (error nil))) + ;; in XEmacs: device-type is tty on tty and stream in batch. (defun viper-window-display-p () (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc))))) @@ -97,6 +107,7 @@ In all likelihood, you don't need to bother with this setting." (defun viper-has-face-support-p () (cond ((viper-window-display-p)) (viper-force-faces) + ((viper-color-display-p)) (viper-emacs-p (memq (viper-device-type) '(pc))) (viper-xemacs-p (memq (viper-device-type) '(tty pc))))) diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el index 146b54b7034..e5074b95838 100644 --- a/lisp/emulation/viper-keym.el +++ b/lisp/emulation/viper-keym.el @@ -455,6 +455,10 @@ Useful in some modes, such as Gnus, MH, etc.") (define-key viper-dired-modifier-map ":" 'viper-ex) (define-key viper-dired-modifier-map "/" 'viper-search-forward) +(defvar viper-gnus-modifier-map (make-sparse-keymap) + "This map modifies Gnus behavior.") +(define-key viper-gnus-modifier-map ":" 'viper-ex) + ;;; Code diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el index c6a3fdfe1fe..df0e37e7c25 100644 --- a/lisp/emulation/viper-macs.el +++ b/lisp/emulation/viper-macs.el @@ -329,6 +329,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g., ;; 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 +;; More general definitions are inherited by more specific scopes: +;; global->major mode->buffer. More specific definitions override more general (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 @@ -451,22 +453,22 @@ If SCOPE is nil, the user is asked to specify the scope." (list (list (cons scope nil)) nil (cons t nil)))))) (setq old-elt (assoc macro-name (eval macro-alist-var))) - (if (null old-elt) - (progn - ;; insert new-elt in macro-alist-var and keep the list sorted - (define-key - keymap - (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< (viper-array-to-string (car (car lis))) - (viper-array-to-string macro-name))) - (setq lis2 (cons (car lis) lis2)) - (setq lis (cdr lis))) - - (setq lis2 (reverse lis2)) - (set macro-alist-var (append lis2 (cons new-elt lis))) - (setq old-elt new-elt))) + (if (null old-elt) + (progn + ;; insert new-elt in macro-alist-var and keep the list sorted + (define-key + keymap + (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< (viper-array-to-string (car (car lis))) + (viper-array-to-string macro-name))) + (setq lis2 (cons (car lis) lis2)) + (setq lis (cdr lis))) + + (setq lis2 (reverse lis2)) + (set macro-alist-var (append lis2 (cons new-elt lis))) + (setq old-elt new-elt))) (setq old-sub-elt (cond ((eq scope t) (viper-kbd-global-pair old-elt)) ((symbolp scope) (assoc scope (viper-kbd-mode-alist old-elt))) @@ -484,6 +486,11 @@ If SCOPE is nil, the user is asked to specify the scope." ;; macro name must be a vector of viper-style keys +;; viper-unrecord-kbd-macro doesn't have scope. Macro definitions are inherited +;; from global -> major mode -> buffer +;; More specific definition overrides more general +;; Can't unrecord definition for more specific, if a more general definition is +;; in effect (defun viper-unrecord-kbd-macro (macro-name state) "Delete macro MACRO-NAME from Viper STATE. MACRO-NAME must be a vector of viper-style keys. This command is used by Viper @@ -546,7 +553,7 @@ name from there." (setq macro-pair mode-mapping) (message "%S is unmapped for %s in %S" (viper-display-macro macro-name) state-name major-mode)) - ((cdr (setq macro-pair (viper-kbd-global-pair macro-entry))) + ((cdr (setq macro-pair global-mapping)) (message "Global mapping for %S in %s is removed" (viper-display-macro macro-name) state-name)) @@ -560,7 +567,7 @@ name from there." (progn (set macro-alist-var (delq macro-entry (eval macro-alist-var))) (if (viper-can-release-key (aref macro-name 0) - (eval macro-alist-var)) + (eval macro-alist-var)) (define-key keymap (vector (viper-key-to-emacs-key (aref macro-name 0))) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 5e533e5f545..527a04084e2 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -662,14 +662,8 @@ ;; define remote file test -(or (fboundp 'viper-file-remote-p) ; user supplied his own function: use it - (defun viper-file-remote-p (file-name) - (car (cond ((featurep 'efs-auto) (efs-ftp-path file-name)) - ((fboundp 'file-remote-p) (file-remote-p file-name)) - (t (require 'ange-ftp) - ;; Can happen only in Emacs, since XEmacs has file-remote-p - (ange-ftp-ftp-name file-name)))))) - +(defun viper-file-remote-p (file-name) + (file-remote-p file-name)) ;; This is a simple-minded check for whether a file is under version control. diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 15ec74b41f1..be5a8e3467a 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -3,12 +3,12 @@ ;; and a venomous VI PERil. ;; Viper Is also a Package for Emacs Rebels. -;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. +;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 05 Free Software Foundation, Inc. ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> ;; Keywords: emulations -(defconst viper-version "3.11.2 of January 4, 2002" +(defconst viper-version "3.11.4 of February 19, 2005" "The current version of Viper") ;; This file is part of GNU Emacs. @@ -466,7 +466,7 @@ unless it is coming up in a wrong Viper state." (nth 0 triple) (nth 1 triple) (eval (nth 2 triple)))) viper-major-mode-modifier-list)) -;; We change standard bindings in some major mode, making them slightly +;; We change standard bindings in some major modes, making them slightly ;; different than in "normal" vi/insert/emacs states (defcustom viper-major-mode-modifier-list '((help-mode emacs-state viper-slash-and-colon-map) @@ -482,8 +482,8 @@ unless it is coming up in a wrong Viper state." (dired-mode emacs-state viper-dired-modifier-map) (tar-mode emacs-state viper-slash-and-colon-map) (mh-folder-mode emacs-state viper-slash-and-colon-map) - (gnus-group-mode emacs-state viper-slash-and-colon-map) - (gnus-summary-mode emacs-state viper-slash-and-colon-map) + (gnus-group-mode emacs-state viper-gnus-modifier-map) + (gnus-summary-mode emacs-state viper-gnus-modifier-map) (Info-mode emacs-state viper-slash-and-colon-map) (Buffer-menu-mode emacs-state viper-slash-and-colon-map) ) |
