From 2ee00512e35d3bb872f6c7be39e0c3bb286ca2fe Mon Sep 17 00:00:00 2001 From: Michael Kifer Date: Thu, 3 Apr 2008 21:04:18 +0000 Subject: [PATCH] 2008-04-03 Michael Kifer * viper-macs.el (viper-read-fast-keysequence): use viper-read-event instead of viper-read-key. * viper.el (viper-mode): move the check for fundamental mode. * viper-utils.el (viper-get-saved-cursor-color-in-replace-mode) viper-get-saved-cursor-color-in-insert-mode): get rid of redundant let-statements. * viper*.el: replaced load with require in eval-when-compile. --- lisp/ChangeLog | 13 +++++ lisp/emulation/viper-cmd.el | 23 ++++---- lisp/emulation/viper-ex.el | 9 ++-- lisp/emulation/viper-macs.el | 16 +++--- lisp/emulation/viper-mous.el | 6 +-- lisp/emulation/viper-util.el | 22 ++++---- lisp/emulation/viper.el | 121 ++++++++++++++++++++++--------------------- 7 files changed, 111 insertions(+), 99 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fa273b8af6c..a8edd6cb63e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2008-04-03 Michael Kifer + + * viper-macs.el (viper-read-fast-keysequence): use viper-read-event + instead of viper-read-key. + + * viper.el (viper-mode): move the check for fundamental mode. + + * viper-utils.el (viper-get-saved-cursor-color-in-replace-mode) + viper-get-saved-cursor-color-in-insert-mode): get rid of redundant + let-statements. + + * viper*.el: replaced load with require in eval-when-compile. + 2008-04-03 Stefan Monnier * files.el (auto-mode-alist): Use archive-mode for Debian packages. diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index a56c69e095b..26ae05c24fd 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -1839,13 +1839,13 @@ invokes the command before that, etc." (concat "`" (viper-array-to-string keys) "'") (viper-abbreviate-string (if (featurep 'xemacs) - (replace-in-string ; xemacs - (cond ((characterp text) (char-to-string text)) - ((stringp text) text) - (t "")) - "\n" "^J") - text ; emacs - ) + (replace-in-string ; xemacs + (cond ((characterp text) (char-to-string text)) + ((stringp text) text) + (t "")) + "\n" "^J") + text ; emacs + ) max-text-len " inserting `" "'" " .......")) )) @@ -2159,9 +2159,9 @@ To turn this feature off, set this variable to nil." (key-binding (setq key (read-key-sequence nil)))) (cond ((eq cmd 'self-insert-command) (if (featurep 'xemacs) - (insert (events-to-keys key)) ; xemacs - (insert key) ; emacs - )) + (insert (events-to-keys key)) ; xemacs + (insert key) ; emacs + )) ((memq cmd '(exit-minibuffer viper-exit-minibuffer)) nil) (t (command-execute cmd))) @@ -3450,7 +3450,8 @@ controlled by the sign of prefix numeric value." ;; (which is called from viper-search-forward/backward/next). If the value of ;; viper-search-scroll-threshold is negative - don't scroll. (defun viper-adjust-window () - (let ((win-height (if (featurep 'xemacs) (window-displayed-height) + (let ((win-height (if (featurep 'xemacs) + (window-displayed-height) (1- (window-height)))) ; adjust for modeline (pt (point)) at-top-p at-bottom-p diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index cd153bdaf91..af5780f0d72 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -46,10 +46,8 @@ ;; in order to spare non-viperized emacs from being viperized (if noninteractive (eval-when-compile - (let ((load-path (cons (expand-file-name ".") load-path))) - (or (featurep 'viper-cmd) - (load "viper-cmd.el" nil t 'nosuffix)) - ))) + (require 'viper-cmd) + )) ;; end pacifier (require 'viper-util) @@ -2077,7 +2075,8 @@ Please contact your system administrator. " ;; create temp buffer for the region (setq temp-buf (get-buffer-create " *ex-write*")) (set-buffer temp-buf) - (if (featurep 'xemacs) (set-visited-file-name ex-file) + (if (featurep 'xemacs) + (set-visited-file-name ex-file) (set-visited-file-name ex-file 'noquery)) (erase-buffer) (if (and file-exists ex-append) diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el index a9e24f28e7b..448903da5c9 100644 --- a/lisp/emulation/viper-macs.el +++ b/lisp/emulation/viper-macs.el @@ -38,10 +38,8 @@ ;; in order to spare non-viperized emacs from being viperized (if noninteractive (eval-when-compile - (let ((load-path (cons (expand-file-name ".") load-path))) - (or (featurep 'viper-cmd) - (load "viper-cmd.el" nil t 'nosuffix)) - ))) + (require 'viper-cmd) + )) ;; end pacifier (require 'viper-util) @@ -873,9 +871,13 @@ name from there." (let ((lis (vector event)) 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)) + (viper-keyseq-is-a-possible-macro lis macro-alist)) + ;; Seems that viper-read-event is more robust here. We need to be able to + ;; place these events on unread-command-events list. If we use + ;; viper-read-key then events will be converted to keys, and sometimes + ;; (e.g., (control \[)) those keys differ from the corresponding events. + ;; So, do not use (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)) diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 1d60d1eb5ee..e7d2315b52b 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el @@ -41,10 +41,8 @@ ;; in order to spare non-viperized emacs from being viperized (if noninteractive (eval-when-compile - (let ((load-path (cons (expand-file-name ".") load-path))) - (or (featurep 'viper-cmd) - (load "viper-cmd.el" nil t 'nosuffix)) - ))) + (require 'viper-cmd) + )) ;; end pacifier (require 'viper-util) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index c89823754fa..7410e05f7b4 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -209,10 +209,9 @@ Otherwise return the normal value." (if (featurep 'emacs) 'frame-parameter 'frame-property) (selected-frame) 'viper-saved-cursor-color-in-replace-mode) - (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color))) - (or (and (eq viper-current-state 'emacs-mode) - ecolor) - (viper-frame-value viper-vi-state-cursor-color))))) + (or (and (eq viper-current-state 'emacs-mode) + (viper-frame-value viper-emacs-state-cursor-color)) + (viper-frame-value viper-vi-state-cursor-color)))) (defsubst viper-get-saved-cursor-color-in-insert-mode () (or @@ -220,10 +219,9 @@ Otherwise return the normal value." (if (featurep 'emacs) 'frame-parameter 'frame-property) (selected-frame) 'viper-saved-cursor-color-in-insert-mode) - (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color))) - (or (and (eq viper-current-state 'emacs-mode) - ecolor) - (viper-frame-value viper-vi-state-cursor-color))))) + (or (and (eq viper-current-state 'emacs-mode) + (viper-frame-value viper-emacs-state-cursor-color)) + (viper-frame-value viper-vi-state-cursor-color)))) (defsubst viper-get-saved-cursor-color-in-emacs-mode () (or @@ -996,7 +994,7 @@ Otherwise return the normal value." ;; This function lets function-key-map convert key sequences into logical ;; keys. This does a better job than viper-read-event when it comes to kbd ;; 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 +;; by correctly mapping key sequences for Left/Right/... (on an ascii ;; terminal) into logical keys left, right, etc. (defun viper-read-key () (let ((overriding-local-map viper-overriding-map) @@ -1206,9 +1204,9 @@ Otherwise return the normal value." (defun viper-key-press-events-to-chars (events) (mapconcat (if (featurep 'xemacs) - (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs - 'char-to-string ; emacs - ) + (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs + 'char-to-string ; emacs + ) events "")) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 0ca83ae6ec0..a3667aa5993 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -597,13 +597,14 @@ This startup message appears whenever you load Viper, unless you type `y' now." )) (viper-set-expert-level 'dont-change-unless))) - (if (eq major-mode 'viper-mode) - (setq major-mode 'fundamental-mode)) - (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi (memq major-mode viper-insert-state-mode-list) ; don't switch (viper-change-state-to-vi)) - ))) + )) + + (if (eq major-mode 'viper-mode) + (setq major-mode 'fundamental-mode)) + ) ;; Apply a little heuristic to invoke vi state on major-modes @@ -1023,63 +1024,63 @@ It also can't undo some Viper settings." (append '("" viper-mode-string) (cdr global-mode-string)))) (if (featurep 'xemacs) - ;; XEmacs - (defadvice describe-key (before viper-describe-key-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (list (viper-read-key-sequence "Describe key: ")))) - ;; Emacs - (defadvice describe-key (before viper-describe-key-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (let (key) - (setq key (viper-read-key-sequence - "Describe key (or click or menu item): ")) - (list key - (prefix-numeric-value current-prefix-arg) - ;; If KEY is a down-event, read also the - ;; corresponding up-event. - (and (vectorp key) - (let ((last-idx (1- (length key)))) - (and (eventp (aref key last-idx)) - (memq 'down (event-modifiers - (aref key last-idx))))) - (or (and (eventp (aref key 0)) - (memq 'down (event-modifiers - (aref key 0))) - ;; For the C-down-mouse-2 popup menu, - ;; there is no subsequent up-event - (= (length key) 1)) - (and (> (length key) 1) - (eventp (aref key 1)) - (memq 'down (event-modifiers (aref key 1))))) - (read-event)))))) - ) ; (if (featurep 'xemacs) - + ;; XEmacs + (defadvice describe-key (before viper-describe-key-ad protect activate) + "Force to read key via `viper-read-key-sequence'." + (interactive (list (viper-read-key-sequence "Describe key: ")))) + ;; Emacs + (defadvice describe-key (before viper-describe-key-ad protect activate) + "Force to read key via `viper-read-key-sequence'." + (interactive (let (key) + (setq key (viper-read-key-sequence + "Describe key (or click or menu item): ")) + (list key + (prefix-numeric-value current-prefix-arg) + ;; If KEY is a down-event, read also the + ;; corresponding up-event. + (and (vectorp key) + (let ((last-idx (1- (length key)))) + (and (eventp (aref key last-idx)) + (memq 'down (event-modifiers + (aref key last-idx))))) + (or (and (eventp (aref key 0)) + (memq 'down (event-modifiers + (aref key 0))) + ;; For the C-down-mouse-2 popup menu, + ;; there is no subsequent up-event + (= (length key) 1)) + (and (> (length key) 1) + (eventp (aref key 1)) + (memq 'down (event-modifiers (aref key 1))))) + (read-event)))))) + ) ; (if (featurep 'xemacs) + (if (featurep 'xemacs) - ;; XEmacs - (defadvice describe-key-briefly - (before viper-describe-key-briefly-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (list (viper-read-key-sequence "Describe key briefly: ")))) - ;; Emacs - (defadvice describe-key-briefly - (before viper-describe-key-briefly-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (let (key) - (setq key (viper-read-key-sequence - "Describe key (or click or menu item): ")) - ;; If KEY is a down-event, read and discard the - ;; corresponding up-event. - (and (vectorp key) - (let ((last-idx (1- (length key)))) - (and (eventp (aref key last-idx)) - (memq 'down (event-modifiers (aref key last-idx))))) - (read-event)) - (list key - (if current-prefix-arg - (prefix-numeric-value current-prefix-arg)) - 1)))) - ) ; (if (featurep 'xemacs) - + ;; XEmacs + (defadvice describe-key-briefly + (before viper-describe-key-briefly-ad protect activate) + "Force to read key via `viper-read-key-sequence'." + (interactive (list (viper-read-key-sequence "Describe key briefly: ")))) + ;; Emacs + (defadvice describe-key-briefly + (before viper-describe-key-briefly-ad protect activate) + "Force to read key via `viper-read-key-sequence'." + (interactive (let (key) + (setq key (viper-read-key-sequence + "Describe key (or click or menu item): ")) + ;; If KEY is a down-event, read and discard the + ;; corresponding up-event. + (and (vectorp key) + (let ((last-idx (1- (length key)))) + (and (eventp (aref key last-idx)) + (memq 'down (event-modifiers (aref key last-idx))))) + (read-event)) + (list key + (if current-prefix-arg + (prefix-numeric-value current-prefix-arg)) + 1)))) + ) ; (if (featurep 'xemacs) + (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) -- 2.11.4.GIT