Mercurial > emacs
changeset 93615:34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
* 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.
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Thu, 03 Apr 2008 21:04:18 +0000 |
parents | ee3b56d7c857 |
children | 71f10341b865 |
files | lisp/ChangeLog lisp/emulation/viper-cmd.el lisp/emulation/viper-ex.el lisp/emulation/viper-macs.el lisp/emulation/viper-mous.el lisp/emulation/viper-util.el lisp/emulation/viper.el |
diffstat | 7 files changed, 111 insertions(+), 99 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/ChangeLog Thu Apr 03 21:04:18 2008 +0000 @@ -1,3 +1,16 @@ +2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu> + + * 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 <monnier@iro.umontreal.ca> * files.el (auto-mode-alist): Use archive-mode for Debian packages.
--- a/lisp/emulation/viper-cmd.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper-cmd.el Thu Apr 03 21:04:18 2008 +0000 @@ -1839,13 +1839,13 @@ (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 @@ (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 @@ ;; (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
--- a/lisp/emulation/viper-ex.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper-ex.el Thu Apr 03 21:04:18 2008 +0000 @@ -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 @@ ;; 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)
--- a/lisp/emulation/viper-macs.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper-macs.el Thu Apr 03 21:04:18 2008 +0000 @@ -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 @@ (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))
--- a/lisp/emulation/viper-mous.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper-mous.el Thu Apr 03 21:04:18 2008 +0000 @@ -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)
--- a/lisp/emulation/viper-util.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper-util.el Thu Apr 03 21:04:18 2008 +0000 @@ -209,10 +209,9 @@ (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 @@ (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 @@ ;; 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 @@ (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 ""))
--- a/lisp/emulation/viper.el Thu Apr 03 20:06:46 2008 +0000 +++ b/lisp/emulation/viper.el Thu Apr 03 21:04:18 2008 +0000 @@ -597,13 +597,14 @@ )) (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 @@ (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)