Mercurial > emacs
comparison lisp/emulation/viper.el @ 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 | da8218af4a5d |
children | d7554c14325c |
comparison
equal
deleted
inserted
replaced
93614:ee3b56d7c857 | 93615:34417c118a39 |
---|---|
595 "The last message is in buffer `Viper Startup Message'") | 595 "The last message is in buffer `Viper Startup Message'") |
596 (sit-for 4) | 596 (sit-for 4) |
597 )) | 597 )) |
598 (viper-set-expert-level 'dont-change-unless))) | 598 (viper-set-expert-level 'dont-change-unless))) |
599 | 599 |
600 (if (eq major-mode 'viper-mode) | |
601 (setq major-mode 'fundamental-mode)) | |
602 | |
603 (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi | 600 (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi |
604 (memq major-mode viper-insert-state-mode-list) ; don't switch | 601 (memq major-mode viper-insert-state-mode-list) ; don't switch |
605 (viper-change-state-to-vi)) | 602 (viper-change-state-to-vi)) |
606 ))) | 603 )) |
604 | |
605 (if (eq major-mode 'viper-mode) | |
606 (setq major-mode 'fundamental-mode)) | |
607 ) | |
607 | 608 |
608 | 609 |
609 ;; Apply a little heuristic to invoke vi state on major-modes | 610 ;; Apply a little heuristic to invoke vi state on major-modes |
610 ;; that are not listed in viper-vi-state-mode-list | 611 ;; that are not listed in viper-vi-state-mode-list |
611 (defun this-major-mode-requires-vi-state (mode) | 612 (defun this-major-mode-requires-vi-state (mode) |
1021 (or (memq 'viper-mode-string global-mode-string) | 1022 (or (memq 'viper-mode-string global-mode-string) |
1022 (setq global-mode-string | 1023 (setq global-mode-string |
1023 (append '("" viper-mode-string) (cdr global-mode-string)))) | 1024 (append '("" viper-mode-string) (cdr global-mode-string)))) |
1024 | 1025 |
1025 (if (featurep 'xemacs) | 1026 (if (featurep 'xemacs) |
1026 ;; XEmacs | 1027 ;; XEmacs |
1027 (defadvice describe-key (before viper-describe-key-ad protect activate) | 1028 (defadvice describe-key (before viper-describe-key-ad protect activate) |
1028 "Force to read key via `viper-read-key-sequence'." | 1029 "Force to read key via `viper-read-key-sequence'." |
1029 (interactive (list (viper-read-key-sequence "Describe key: ")))) | 1030 (interactive (list (viper-read-key-sequence "Describe key: ")))) |
1030 ;; Emacs | 1031 ;; Emacs |
1031 (defadvice describe-key (before viper-describe-key-ad protect activate) | 1032 (defadvice describe-key (before viper-describe-key-ad protect activate) |
1032 "Force to read key via `viper-read-key-sequence'." | 1033 "Force to read key via `viper-read-key-sequence'." |
1033 (interactive (let (key) | 1034 (interactive (let (key) |
1034 (setq key (viper-read-key-sequence | 1035 (setq key (viper-read-key-sequence |
1035 "Describe key (or click or menu item): ")) | 1036 "Describe key (or click or menu item): ")) |
1036 (list key | 1037 (list key |
1037 (prefix-numeric-value current-prefix-arg) | 1038 (prefix-numeric-value current-prefix-arg) |
1038 ;; If KEY is a down-event, read also the | 1039 ;; If KEY is a down-event, read also the |
1039 ;; corresponding up-event. | 1040 ;; corresponding up-event. |
1040 (and (vectorp key) | 1041 (and (vectorp key) |
1041 (let ((last-idx (1- (length key)))) | 1042 (let ((last-idx (1- (length key)))) |
1042 (and (eventp (aref key last-idx)) | 1043 (and (eventp (aref key last-idx)) |
1043 (memq 'down (event-modifiers | 1044 (memq 'down (event-modifiers |
1044 (aref key last-idx))))) | 1045 (aref key last-idx))))) |
1045 (or (and (eventp (aref key 0)) | 1046 (or (and (eventp (aref key 0)) |
1046 (memq 'down (event-modifiers | 1047 (memq 'down (event-modifiers |
1047 (aref key 0))) | 1048 (aref key 0))) |
1048 ;; For the C-down-mouse-2 popup menu, | 1049 ;; For the C-down-mouse-2 popup menu, |
1049 ;; there is no subsequent up-event | 1050 ;; there is no subsequent up-event |
1050 (= (length key) 1)) | 1051 (= (length key) 1)) |
1051 (and (> (length key) 1) | 1052 (and (> (length key) 1) |
1052 (eventp (aref key 1)) | 1053 (eventp (aref key 1)) |
1053 (memq 'down (event-modifiers (aref key 1))))) | 1054 (memq 'down (event-modifiers (aref key 1))))) |
1054 (read-event)))))) | 1055 (read-event)))))) |
1055 ) ; (if (featurep 'xemacs) | 1056 ) ; (if (featurep 'xemacs) |
1056 | 1057 |
1057 (if (featurep 'xemacs) | 1058 (if (featurep 'xemacs) |
1058 ;; XEmacs | 1059 ;; XEmacs |
1059 (defadvice describe-key-briefly | 1060 (defadvice describe-key-briefly |
1060 (before viper-describe-key-briefly-ad protect activate) | 1061 (before viper-describe-key-briefly-ad protect activate) |
1061 "Force to read key via `viper-read-key-sequence'." | 1062 "Force to read key via `viper-read-key-sequence'." |
1062 (interactive (list (viper-read-key-sequence "Describe key briefly: ")))) | 1063 (interactive (list (viper-read-key-sequence "Describe key briefly: ")))) |
1063 ;; Emacs | 1064 ;; Emacs |
1064 (defadvice describe-key-briefly | 1065 (defadvice describe-key-briefly |
1065 (before viper-describe-key-briefly-ad protect activate) | 1066 (before viper-describe-key-briefly-ad protect activate) |
1066 "Force to read key via `viper-read-key-sequence'." | 1067 "Force to read key via `viper-read-key-sequence'." |
1067 (interactive (let (key) | 1068 (interactive (let (key) |
1068 (setq key (viper-read-key-sequence | 1069 (setq key (viper-read-key-sequence |
1069 "Describe key (or click or menu item): ")) | 1070 "Describe key (or click or menu item): ")) |
1070 ;; If KEY is a down-event, read and discard the | 1071 ;; If KEY is a down-event, read and discard the |
1071 ;; corresponding up-event. | 1072 ;; corresponding up-event. |
1072 (and (vectorp key) | 1073 (and (vectorp key) |
1073 (let ((last-idx (1- (length key)))) | 1074 (let ((last-idx (1- (length key)))) |
1074 (and (eventp (aref key last-idx)) | 1075 (and (eventp (aref key last-idx)) |
1075 (memq 'down (event-modifiers (aref key last-idx))))) | 1076 (memq 'down (event-modifiers (aref key last-idx))))) |
1076 (read-event)) | 1077 (read-event)) |
1077 (list key | 1078 (list key |
1078 (if current-prefix-arg | 1079 (if current-prefix-arg |
1079 (prefix-numeric-value current-prefix-arg)) | 1080 (prefix-numeric-value current-prefix-arg)) |
1080 1)))) | 1081 1)))) |
1081 ) ; (if (featurep 'xemacs) | 1082 ) ; (if (featurep 'xemacs) |
1082 | 1083 |
1083 (defadvice find-file (before viper-add-suffix-advice activate) | 1084 (defadvice find-file (before viper-add-suffix-advice activate) |
1084 "Use `read-file-name' for reading arguments." | 1085 "Use `read-file-name' for reading arguments." |
1085 (interactive (cons (read-file-name "Find file: " nil default-directory) | 1086 (interactive (cons (read-file-name "Find file: " nil default-directory) |
1086 ;; XEmacs: if Mule & prefix arg, ask for coding system | 1087 ;; XEmacs: if Mule & prefix arg, ask for coding system |
1087 (cond ((and (featurep 'xemacs) (featurep 'mule)) | 1088 (cond ((and (featurep 'xemacs) (featurep 'mule)) |