diff options
| author | Michael Kifer | 2005-07-10 18:46:24 +0000 |
|---|---|---|
| committer | Michael Kifer | 2005-07-10 18:46:24 +0000 |
| commit | 8ea74b0e4570fe6e3ee583b0655bf6137d82dc28 (patch) | |
| tree | d1d6a6c3acdc71b8843ee590b05c4e4150567803 /lisp/emulation | |
| parent | 9a4183e9ea0b4b2d09629652ce3d2d02bff1e647 (diff) | |
| download | emacs-8ea74b0e4570fe6e3ee583b0655bf6137d82dc28.tar.gz emacs-8ea74b0e4570fe6e3ee583b0655bf6137d82dc28.zip | |
* viper-cmd.el (viper--key-maps): new variable.
(viper-normalize-minor-mode-map-alist): use viper--key-maps and
emulation-mode-map-alists.
(viper-envelop-ESC-key): use viper-subseq.
(viper-search-forward/backward/next): disable debug-on-error.
* viper-keym.el (viper-toggle-key,viper-quoted-insert-key,
viper-ESC-key): new defcustoms.
* viper-macs.el (ex-map-read-args): use viper-subseq.
* viper-util.el (viper-key-to-emacs-key): use viper-subseq.
(viper-subseq): copy of subseq from cl.el.
* viper.el (viper-go-away,viper-set-hooks): use
emulation-mode-map-alists, advise self-insert-command, add-minor-mode.
* viper-mous.el (viper-current-frame-saved): use defvar.
* viper-init.el: got rid of -face in face names.
* ediff-diff.el (ediff-extract-diffs,ediff-extract-diffs3):
Make it work with longlines mode
* ediff-mult.el (ediff-meta-mode-hook): new variable.
* ediff-ptch.el (ediff-file-name-sans-prefix): quote regexp.
* ediff-init: got rid of -face in face names.
Diffstat (limited to 'lisp/emulation')
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 72 | ||||
| -rw-r--r-- | lisp/emulation/viper-init.el | 30 | ||||
| -rw-r--r-- | lisp/emulation/viper-keym.el | 97 | ||||
| -rw-r--r-- | lisp/emulation/viper-macs.el | 12 | ||||
| -rw-r--r-- | lisp/emulation/viper-mous.el | 2 | ||||
| -rw-r--r-- | lisp/emulation/viper-util.el | 30 | ||||
| -rw-r--r-- | lisp/emulation/viper.el | 35 |
7 files changed, 199 insertions, 79 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 4f247f2cd38..ecd5251891c 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el | |||
| @@ -36,6 +36,8 @@ | |||
| 36 | (defvar viper-always) | 36 | (defvar viper-always) |
| 37 | (defvar viper-mode-string) | 37 | (defvar viper-mode-string) |
| 38 | (defvar viper-custom-file-name) | 38 | (defvar viper-custom-file-name) |
| 39 | (defvar viper--key-maps) | ||
| 40 | (defvar viper--intercept-key-maps) | ||
| 39 | (defvar iso-accents-mode) | 41 | (defvar iso-accents-mode) |
| 40 | (defvar quail-mode) | 42 | (defvar quail-mode) |
| 41 | (defvar quail-current-str) | 43 | (defvar quail-current-str) |
| @@ -92,7 +94,7 @@ | |||
| 92 | ;; Variables for defining VI commands | 94 | ;; Variables for defining VI commands |
| 93 | 95 | ||
| 94 | ;; Modifying commands that can be prefixes to movement commands | 96 | ;; Modifying commands that can be prefixes to movement commands |
| 95 | (defconst viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\")) | 97 | (defvar viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\")) |
| 96 | ;; define viper-prefix-command-p | 98 | ;; define viper-prefix-command-p |
| 97 | (viper-test-com-defun viper-prefix-command) | 99 | (viper-test-com-defun viper-prefix-command) |
| 98 | 100 | ||
| @@ -440,23 +442,24 @@ | |||
| 440 | ;; This ensures that Viper bindings are in effect, regardless of which minor | 442 | ;; This ensures that Viper bindings are in effect, regardless of which minor |
| 441 | ;; modes were turned on by the user or by other packages. | 443 | ;; modes were turned on by the user or by other packages. |
| 442 | (defun viper-normalize-minor-mode-map-alist () | 444 | (defun viper-normalize-minor-mode-map-alist () |
| 443 | (setq minor-mode-map-alist | 445 | (setq viper--intercept-key-maps |
| 444 | (viper-append-filter-alist | 446 | (list |
| 445 | (list (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map) | 447 | (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map) |
| 446 | (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map) | 448 | (cons 'viper-insert-intercept-minor-mode viper-insert-intercept-map) |
| 447 | (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map) | 449 | (cons 'viper-emacs-intercept-minor-mode viper-emacs-intercept-map) |
| 448 | (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map) | 450 | )) |
| 449 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) | 451 | (setq viper--key-maps |
| 450 | (cons 'viper-vi-state-modifier-minor-mode | 452 | (list (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map) |
| 451 | (if (keymapp | 453 | (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map) |
| 452 | (cdr (assoc major-mode | 454 | (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map) |
| 453 | viper-vi-state-modifier-alist))) | 455 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) |
| 454 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) | 456 | (cons 'viper-vi-state-modifier-minor-mode |
| 455 | viper-empty-keymap)) | 457 | (if (keymapp |
| 456 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) | 458 | (cdr (assoc major-mode viper-vi-state-modifier-alist))) |
| 457 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) | 459 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) |
| 458 | (cons 'viper-insert-intercept-minor-mode | 460 | viper-empty-keymap)) |
| 459 | viper-insert-intercept-map) | 461 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) |
| 462 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) | ||
| 460 | (cons 'viper-replace-minor-mode viper-replace-map) | 463 | (cons 'viper-replace-minor-mode viper-replace-map) |
| 461 | ;; viper-insert-minibuffer-minor-mode must come after | 464 | ;; viper-insert-minibuffer-minor-mode must come after |
| 462 | ;; viper-replace-minor-mode | 465 | ;; viper-replace-minor-mode |
| @@ -476,8 +479,6 @@ | |||
| 476 | viper-empty-keymap)) | 479 | viper-empty-keymap)) |
| 477 | (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map) | 480 | (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map) |
| 478 | (cons 'viper-insert-basic-minor-mode viper-insert-basic-map) | 481 | (cons 'viper-insert-basic-minor-mode viper-insert-basic-map) |
| 479 | (cons 'viper-emacs-intercept-minor-mode | ||
| 480 | viper-emacs-intercept-map) | ||
| 481 | (cons 'viper-emacs-local-user-minor-mode | 482 | (cons 'viper-emacs-local-user-minor-mode |
| 482 | viper-emacs-local-user-map) | 483 | viper-emacs-local-user-map) |
| 483 | (cons 'viper-emacs-kbd-minor-mode viper-emacs-kbd-map) | 484 | (cons 'viper-emacs-kbd-minor-mode viper-emacs-kbd-map) |
| @@ -490,8 +491,16 @@ | |||
| 490 | (cdr | 491 | (cdr |
| 491 | (assoc major-mode viper-emacs-state-modifier-alist)) | 492 | (assoc major-mode viper-emacs-state-modifier-alist)) |
| 492 | viper-empty-keymap)) | 493 | viper-empty-keymap)) |
| 493 | ) | 494 | )) |
| 494 | minor-mode-map-alist))) | 495 | |
| 496 | ;; in emacs with emulation-mode-map-alists, nothing needs to be done | ||
| 497 | (unless | ||
| 498 | (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists)) | ||
| 499 | (setq minor-mode-map-alist | ||
| 500 | (viper-append-filter-alist | ||
| 501 | (append viper--intercept-key-maps viper--key-maps) | ||
| 502 | minor-mode-map-alist))) | ||
| 503 | ) | ||
| 495 | 504 | ||
| 496 | 505 | ||
| 497 | 506 | ||
| @@ -1021,7 +1030,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1021 | (not viper-translate-all-ESC-keysequences)) | 1030 | (not viper-translate-all-ESC-keysequences)) |
| 1022 | ;; put keys following ESC on the unread list | 1031 | ;; put keys following ESC on the unread list |
| 1023 | ;; and return ESC as the key-sequence | 1032 | ;; and return ESC as the key-sequence |
| 1024 | (viper-set-unread-command-events (subseq keyseq 1)) | 1033 | (viper-set-unread-command-events (viper-subseq keyseq 1)) |
| 1025 | (setq last-input-event event | 1034 | (setq last-input-event event |
| 1026 | keyseq (if viper-emacs-p | 1035 | keyseq (if viper-emacs-p |
| 1027 | "\e" | 1036 | "\e" |
| @@ -1032,7 +1041,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1032 | (viper-set-unread-command-events | 1041 | (viper-set-unread-command-events |
| 1033 | (vconcat (vector | 1042 | (vconcat (vector |
| 1034 | (character-to-event (event-key first-key))) | 1043 | (character-to-event (event-key first-key))) |
| 1035 | (subseq keyseq 1))) | 1044 | (viper-subseq keyseq 1))) |
| 1036 | (setq last-input-event event | 1045 | (setq last-input-event event |
| 1037 | keyseq (vector (character-to-event ?\e)))) | 1046 | keyseq (vector (character-to-event ?\e)))) |
| 1038 | ((eventp first-key) | 1047 | ((eventp first-key) |
| @@ -3732,7 +3741,8 @@ Null string will repeat previous search." | |||
| 3732 | (interactive "P") | 3741 | (interactive "P") |
| 3733 | (let ((val (viper-P-val arg)) | 3742 | (let ((val (viper-P-val arg)) |
| 3734 | (com (viper-getcom arg)) | 3743 | (com (viper-getcom arg)) |
| 3735 | (old-str viper-s-string)) | 3744 | (old-str viper-s-string) |
| 3745 | debug-on-error) | ||
| 3736 | (setq viper-s-forward t) | 3746 | (setq viper-s-forward t) |
| 3737 | (viper-if-string "/") | 3747 | (viper-if-string "/") |
| 3738 | ;; this is not used at present, but may be used later | 3748 | ;; this is not used at present, but may be used later |
| @@ -3744,7 +3754,8 @@ Null string will repeat previous search." | |||
| 3744 | (if com | 3754 | (if com |
| 3745 | (progn | 3755 | (progn |
| 3746 | (viper-move-marker-locally 'viper-com-point (mark t)) | 3756 | (viper-move-marker-locally 'viper-com-point (mark t)) |
| 3747 | (viper-execute-com 'viper-search-next val com))))) | 3757 | (viper-execute-com 'viper-search-next val com))) |
| 3758 | )) | ||
| 3748 | 3759 | ||
| 3749 | (defun viper-search-backward (arg) | 3760 | (defun viper-search-backward (arg) |
| 3750 | "Search a string backward. | 3761 | "Search a string backward. |
| @@ -3753,7 +3764,8 @@ Null string will repeat previous search." | |||
| 3753 | (interactive "P") | 3764 | (interactive "P") |
| 3754 | (let ((val (viper-P-val arg)) | 3765 | (let ((val (viper-P-val arg)) |
| 3755 | (com (viper-getcom arg)) | 3766 | (com (viper-getcom arg)) |
| 3756 | (old-str viper-s-string)) | 3767 | (old-str viper-s-string) |
| 3768 | debug-on-error) | ||
| 3757 | (setq viper-s-forward nil) | 3769 | (setq viper-s-forward nil) |
| 3758 | (viper-if-string "?") | 3770 | (viper-if-string "?") |
| 3759 | ;; this is not used at present, but may be used later | 3771 | ;; this is not used at present, but may be used later |
| @@ -3858,7 +3870,8 @@ Null string will repeat previous search." | |||
| 3858 | "Repeat previous search." | 3870 | "Repeat previous search." |
| 3859 | (interactive "P") | 3871 | (interactive "P") |
| 3860 | (let ((val (viper-p-val arg)) | 3872 | (let ((val (viper-p-val arg)) |
| 3861 | (com (viper-getcom arg))) | 3873 | (com (viper-getcom arg)) |
| 3874 | debug-on-error) | ||
| 3862 | (if (null viper-s-string) (error viper-NoPrevSearch)) | 3875 | (if (null viper-s-string) (error viper-NoPrevSearch)) |
| 3863 | (viper-search viper-s-string viper-s-forward arg) | 3876 | (viper-search viper-s-string viper-s-forward arg) |
| 3864 | (if com | 3877 | (if com |
| @@ -3870,7 +3883,8 @@ Null string will repeat previous search." | |||
| 3870 | "Repeat previous search in the reverse direction." | 3883 | "Repeat previous search in the reverse direction." |
| 3871 | (interactive "P") | 3884 | (interactive "P") |
| 3872 | (let ((val (viper-p-val arg)) | 3885 | (let ((val (viper-p-val arg)) |
| 3873 | (com (viper-getcom arg))) | 3886 | (com (viper-getcom arg)) |
| 3887 | debug-on-error) | ||
| 3874 | (if (null viper-s-string) (error viper-NoPrevSearch)) | 3888 | (if (null viper-s-string) (error viper-NoPrevSearch)) |
| 3875 | (viper-search viper-s-string (not viper-s-forward) arg) | 3889 | (viper-search viper-s-string (not viper-s-forward) arg) |
| 3876 | (if com | 3890 | (if com |
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index 6e188f21a9d..8d9aed94770 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el | |||
| @@ -855,15 +855,13 @@ Related buffers can be cycled through via :R and :P commands." | |||
| 855 | (t (:underline t :stipple "gray3"))) | 855 | (t (:underline t :stipple "gray3"))) |
| 856 | "*Face used to flash out the search pattern." | 856 | "*Face used to flash out the search pattern." |
| 857 | :group 'viper-highlighting) | 857 | :group 'viper-highlighting) |
| 858 | ;; backward-compatibility alias | ||
| 859 | (put 'viper-search-face 'face-alias 'viper-search) | ||
| 860 | ;; An internal variable. Viper takes the face from here. | 858 | ;; An internal variable. Viper takes the face from here. |
| 861 | (defvar viper-search-face 'viper-search | 859 | (defvar viper-search-face 'viper-search |
| 862 | "Face used to flash out the search pattern. | 860 | "Face used to flash out the search pattern. |
| 863 | DO NOT CHANGE this variable. Instead, use the customization widget | 861 | DO NOT CHANGE this variable. Instead, use the customization widget |
| 864 | to customize the actual face object `viper-search-face' | 862 | to customize the actual face object `viper-search' |
| 865 | this variable represents.") | 863 | this variable represents.") |
| 866 | (viper-hide-face 'viper-search) | 864 | (viper-hide-face viper-search-face) |
| 867 | 865 | ||
| 868 | 866 | ||
| 869 | (defface viper-replace-overlay | 867 | (defface viper-replace-overlay |
| @@ -871,15 +869,13 @@ this variable represents.") | |||
| 871 | (t (:underline t :stipple "gray3"))) | 869 | (t (:underline t :stipple "gray3"))) |
| 872 | "*Face for highlighting replace regions on a window display." | 870 | "*Face for highlighting replace regions on a window display." |
| 873 | :group 'viper-highlighting) | 871 | :group 'viper-highlighting) |
| 874 | ;; backward-compatibility alias | ||
| 875 | (put 'viper-replace-overlay-face 'face-alias 'viper-replace-overlay) | ||
| 876 | ;; An internal variable. Viper takes the face from here. | 872 | ;; An internal variable. Viper takes the face from here. |
| 877 | (defvar viper-replace-overlay-face 'viper-replace-overlay | 873 | (defvar viper-replace-overlay-face 'viper-replace-overlay |
| 878 | "Face for highlighting replace regions on a window display. | 874 | "Face for highlighting replace regions on a window display. |
| 879 | DO NOT CHANGE this variable. Instead, use the customization widget | 875 | DO NOT CHANGE this variable. Instead, use the customization widget |
| 880 | to customize the actual face object `viper-replace-overlay-face' | 876 | to customize the actual face object `viper-replace-overlay' |
| 881 | this variable represents.") | 877 | this variable represents.") |
| 882 | (viper-hide-face 'viper-replace-overlay) | 878 | (viper-hide-face viper-replace-overlay-face) |
| 883 | 879 | ||
| 884 | 880 | ||
| 885 | (defface viper-minibuffer-emacs | 881 | (defface viper-minibuffer-emacs |
| @@ -887,15 +883,13 @@ this variable represents.") | |||
| 887 | (t (:weight bold))) | 883 | (t (:weight bold))) |
| 888 | "Face used in the Minibuffer when it is in Emacs state." | 884 | "Face used in the Minibuffer when it is in Emacs state." |
| 889 | :group 'viper-highlighting) | 885 | :group 'viper-highlighting) |
| 890 | ;; backward-compatibility alias | ||
| 891 | (put 'viper-minibuffer-emacs-face 'face-alias 'viper-minibuffer-emacs) | ||
| 892 | ;; An internal variable. Viper takes the face from here. | 886 | ;; An internal variable. Viper takes the face from here. |
| 893 | (defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs | 887 | (defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs |
| 894 | "Face used in the Minibuffer when it is in Emacs state. | 888 | "Face used in the Minibuffer when it is in Emacs state. |
| 895 | DO NOT CHANGE this variable. Instead, use the customization widget | 889 | DO NOT CHANGE this variable. Instead, use the customization widget |
| 896 | to customize the actual face object `viper-minibuffer-emacs-face' | 890 | to customize the actual face object `viper-minibuffer-emacs' |
| 897 | this variable represents.") | 891 | this variable represents.") |
| 898 | (viper-hide-face 'viper-minibuffer-emacs) | 892 | (viper-hide-face viper-minibuffer-emacs-face) |
| 899 | 893 | ||
| 900 | 894 | ||
| 901 | (defface viper-minibuffer-insert | 895 | (defface viper-minibuffer-insert |
| @@ -903,15 +897,13 @@ this variable represents.") | |||
| 903 | (t (:slant italic))) | 897 | (t (:slant italic))) |
| 904 | "Face used in the Minibuffer when it is in Insert state." | 898 | "Face used in the Minibuffer when it is in Insert state." |
| 905 | :group 'viper-highlighting) | 899 | :group 'viper-highlighting) |
| 906 | ;; backward-compatibility alias | ||
| 907 | (put 'viper-minibuffer-insert-face 'face-alias 'viper-minibuffer-insert) | ||
| 908 | ;; An internal variable. Viper takes the face from here. | 900 | ;; An internal variable. Viper takes the face from here. |
| 909 | (defvar viper-minibuffer-insert-face 'viper-minibuffer-insert | 901 | (defvar viper-minibuffer-insert-face 'viper-minibuffer-insert |
| 910 | "Face used in the Minibuffer when it is in Insert state. | 902 | "Face used in the Minibuffer when it is in Insert state. |
| 911 | DO NOT CHANGE this variable. Instead, use the customization widget | 903 | DO NOT CHANGE this variable. Instead, use the customization widget |
| 912 | to customize the actual face object `viper-minibuffer-insert-face' | 904 | to customize the actual face object `viper-minibuffer-insert' |
| 913 | this variable represents.") | 905 | this variable represents.") |
| 914 | (viper-hide-face 'viper-minibuffer-insert) | 906 | (viper-hide-face viper-minibuffer-insert-face) |
| 915 | 907 | ||
| 916 | 908 | ||
| 917 | (defface viper-minibuffer-vi | 909 | (defface viper-minibuffer-vi |
| @@ -919,15 +911,13 @@ this variable represents.") | |||
| 919 | (t (:inverse-video t))) | 911 | (t (:inverse-video t))) |
| 920 | "Face used in the Minibuffer when it is in Vi state." | 912 | "Face used in the Minibuffer when it is in Vi state." |
| 921 | :group 'viper-highlighting) | 913 | :group 'viper-highlighting) |
| 922 | ;; backward-compatibility alias | ||
| 923 | (put 'viper-minibuffer-vi-face 'face-alias 'viper-minibuffer-vi) | ||
| 924 | ;; An internal variable. Viper takes the face from here. | 914 | ;; An internal variable. Viper takes the face from here. |
| 925 | (defvar viper-minibuffer-vi-face 'viper-minibuffer-vi | 915 | (defvar viper-minibuffer-vi-face 'viper-minibuffer-vi |
| 926 | "Face used in the Minibuffer when it is in Vi state. | 916 | "Face used in the Minibuffer when it is in Vi state. |
| 927 | DO NOT CHANGE this variable. Instead, use the customization widget | 917 | DO NOT CHANGE this variable. Instead, use the customization widget |
| 928 | to customize the actual face object `viper-minibuffer-vi-face' | 918 | to customize the actual face object `viper-minibuffer-vi' |
| 929 | this variable represents.") | 919 | this variable represents.") |
| 930 | (viper-hide-face 'viper-minibuffer-vi) | 920 | (viper-hide-face viper-minibuffer-vi-face) |
| 931 | 921 | ||
| 932 | ;; the current face to be used in the minibuffer | 922 | ;; the current face to be used in the minibuffer |
| 933 | (viper-deflocalvar | 923 | (viper-deflocalvar |
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el index e83cf14776f..1bbf3dce2c2 100644 --- a/lisp/emulation/viper-keym.el +++ b/lisp/emulation/viper-keym.el | |||
| @@ -50,25 +50,6 @@ | |||
| 50 | 50 | ||
| 51 | ;;; Variables | 51 | ;;; Variables |
| 52 | 52 | ||
| 53 | (defcustom viper-toggle-key "\C-z" | ||
| 54 | "The key used to change states from emacs to Vi and back. | ||
| 55 | In insert mode, this key also functions as Meta. | ||
| 56 | Must be set in .viper file or prior to loading Viper. | ||
| 57 | This setting cannot be changed interactively." | ||
| 58 | :type 'string | ||
| 59 | :group 'viper) | ||
| 60 | |||
| 61 | (defcustom viper-quoted-insert-key "\C-v" | ||
| 62 | "The key used to quote special characters when inserting them in Insert state." | ||
| 63 | :type 'string | ||
| 64 | :group 'viper) | ||
| 65 | |||
| 66 | (defcustom viper-ESC-key "\e" | ||
| 67 | "Key used to ESC. | ||
| 68 | Must be set in .viper file or prior to loading Viper. | ||
| 69 | This setting cannot be changed interactively." | ||
| 70 | :type 'string | ||
| 71 | :group 'viper) | ||
| 72 | 53 | ||
| 73 | ;;; Emacs keys in other states. | 54 | ;;; Emacs keys in other states. |
| 74 | 55 | ||
| @@ -176,6 +157,78 @@ viper-insert-basic-map. Not recommended, except for novice users.") | |||
| 176 | ;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map. | 157 | ;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map. |
| 177 | (defvar viper-mode-map (make-sparse-keymap)) | 158 | (defvar viper-mode-map (make-sparse-keymap)) |
| 178 | 159 | ||
| 160 | ;; Some important keys used in viper | ||
| 161 | (defcustom viper-toggle-key [(control ?z)] ; "\C-z" | ||
| 162 | "The key used to change states from emacs to Vi and back. | ||
| 163 | In insert mode, this key also functions as Meta. | ||
| 164 | |||
| 165 | Enter as a sexp. Examples: \"\\C-z\", [(control ?z)]." | ||
| 166 | :type 'sexp | ||
| 167 | :group 'viper | ||
| 168 | :set (lambda (symbol value) | ||
| 169 | (let ((old-value (if (boundp 'viper-toggle-key) | ||
| 170 | viper-toggle-key | ||
| 171 | [(control ?z)]))) | ||
| 172 | (mapcar | ||
| 173 | (lambda (buf) | ||
| 174 | (save-excursion | ||
| 175 | (set-buffer buf) | ||
| 176 | (when (and (boundp 'viper-insert-basic-map) | ||
| 177 | (keymapp viper-insert-basic-map)) | ||
| 178 | (when old-value | ||
| 179 | (define-key viper-insert-basic-map old-value nil)) | ||
| 180 | (define-key viper-insert-basic-map value 'viper-escape-to-vi)) | ||
| 181 | (when (and (boundp 'viper-vi-intercept-map) | ||
| 182 | (keymapp viper-vi-intercept-map)) | ||
| 183 | (when old-value | ||
| 184 | (define-key viper-vi-intercept-map old-value nil)) | ||
| 185 | (define-key | ||
| 186 | viper-vi-intercept-map value 'viper-toggle-key-action)) | ||
| 187 | (when (and (boundp 'viper-emacs-intercept-map) | ||
| 188 | (keymapp viper-emacs-intercept-map)) | ||
| 189 | (define-key viper-emacs-intercept-map old-value nil) | ||
| 190 | (define-key | ||
| 191 | viper-emacs-intercept-map value 'viper-change-state-to-vi)) | ||
| 192 | )) | ||
| 193 | (buffer-list)) | ||
| 194 | (set-default symbol value) | ||
| 195 | ))) | ||
| 196 | |||
| 197 | (defcustom viper-quoted-insert-key "\C-v" | ||
| 198 | "The key used to quote special characters when inserting them in Insert state." | ||
| 199 | :type 'string | ||
| 200 | :group 'viper) | ||
| 201 | |||
| 202 | (defcustom viper-ESC-key [(escape)] ; "\e" | ||
| 203 | "Key used to ESC. | ||
| 204 | Enter as a sexp. Examples: \"\\e\", [(escape)]." | ||
| 205 | :type 'sexp | ||
| 206 | :group 'viper | ||
| 207 | :set (lambda (symbol value) | ||
| 208 | (let ((old-value (if (boundp 'viper-ESC-key) | ||
| 209 | viper-ESC-key | ||
| 210 | [(escape)]))) | ||
| 211 | (mapcar | ||
| 212 | (lambda (buf) | ||
| 213 | (save-excursion | ||
| 214 | (set-buffer buf) | ||
| 215 | (when (and (boundp 'viper-insert-intercept-map) | ||
| 216 | (keymapp viper-insert-intercept-map)) | ||
| 217 | (when old-value | ||
| 218 | (define-key viper-insert-intercept-map old-value nil)) | ||
| 219 | (define-key | ||
| 220 | viper-insert-intercept-map value 'viper-intercept-ESC-key)) | ||
| 221 | (when (and (boundp 'viper-vi-intercept-map) | ||
| 222 | (keymapp viper-vi-intercept-map)) | ||
| 223 | (when old-value | ||
| 224 | (define-key viper-vi-intercept-map old-value nil)) | ||
| 225 | (define-key | ||
| 226 | viper-vi-intercept-map value 'viper-intercept-ESC-key)) | ||
| 227 | )) | ||
| 228 | (buffer-list)) | ||
| 229 | (set-default symbol value) | ||
| 230 | ))) | ||
| 231 | |||
| 179 | 232 | ||
| 180 | ;;; Variables used by minor modes | 233 | ;;; Variables used by minor modes |
| 181 | 234 | ||
| @@ -197,6 +250,10 @@ viper-insert-basic-map. Not recommended, except for novice users.") | |||
| 197 | ;; to its Emacs state in various major modes. | 250 | ;; to its Emacs state in various major modes. |
| 198 | (defvar viper-emacs-state-modifier-alist nil) | 251 | (defvar viper-emacs-state-modifier-alist nil) |
| 199 | 252 | ||
| 253 | ;; The list of viper keymaps. Set by viper-normalize-minor-mode-map-alist | ||
| 254 | (viper-deflocalvar viper--key-maps nil) | ||
| 255 | (viper-deflocalvar viper--intercept-key-maps nil) | ||
| 256 | |||
| 200 | ;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new | 257 | ;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new |
| 201 | ;; buffers. Not a user option. | 258 | ;; buffers. Not a user option. |
| 202 | (viper-deflocalvar viper-need-new-vi-local-map t "") | 259 | (viper-deflocalvar viper-need-new-vi-local-map t "") |
| @@ -509,7 +566,7 @@ Usage: | |||
| 509 | 566 | ||
| 510 | (defun viper-zap-local-keys () | 567 | (defun viper-zap-local-keys () |
| 511 | "Unconditionally reset Viper viper-*-local-user-map's. | 568 | "Unconditionally reset Viper viper-*-local-user-map's. |
| 512 | Rarely useful, but if u made a mistake by switching to a mode that adds | 569 | Rarely useful, but if you made a mistake by switching to a mode that adds |
| 513 | undesirable local keys, e.g., comint-mode, then this function can restore | 570 | undesirable local keys, e.g., comint-mode, then this function can restore |
| 514 | sanity." | 571 | sanity." |
| 515 | (interactive) | 572 | (interactive) |
diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el index 8a3ce5db9eb..6d79ddec043 100644 --- a/lisp/emulation/viper-macs.el +++ b/lisp/emulation/viper-macs.el | |||
| @@ -178,7 +178,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g., | |||
| 178 | (if (member | 178 | (if (member |
| 179 | key | 179 | key |
| 180 | '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) | 180 | '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) |
| 181 | (setq key-seq (subseq key-seq 0 (- (length key-seq) 2)))) | 181 | (setq key-seq (viper-subseq key-seq 0 (- (length key-seq) 2)))) |
| 182 | (setq message | 182 | (setq message |
| 183 | (format | 183 | (format |
| 184 | ":map%s %s" | 184 | ":map%s %s" |
| @@ -242,9 +242,9 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g., | |||
| 242 | (cond ((member | 242 | (cond ((member |
| 243 | key | 243 | key |
| 244 | '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) | 244 | '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) |
| 245 | (setq key-seq (subseq key-seq 0 (- (length key-seq) 2)))) | 245 | (setq key-seq (viper-subseq key-seq 0 (- (length key-seq) 2)))) |
| 246 | ((member key '(tab (control i) ?\t)) | 246 | ((member key '(tab (control i) ?\t)) |
| 247 | (setq key-seq (subseq key-seq 0 (1- (length key-seq)))) | 247 | (setq key-seq (viper-subseq key-seq 0 (1- (length key-seq)))) |
| 248 | (setq message | 248 | (setq message |
| 249 | (format | 249 | (format |
| 250 | ":unmap%s %s" | 250 | ":unmap%s %s" |
| @@ -618,7 +618,7 @@ name from there." | |||
| 618 | 618 | ||
| 619 | (if (null macro-alist-elt) | 619 | (if (null macro-alist-elt) |
| 620 | (setq macro-alist-elt (car next-best-match) | 620 | (setq macro-alist-elt (car next-best-match) |
| 621 | unmatched-suffix (subseq event-seq (cdr next-best-match)))) | 621 | unmatched-suffix (viper-subseq event-seq (cdr next-best-match)))) |
| 622 | 622 | ||
| 623 | (cond ((null macro-alist-elt)) | 623 | (cond ((null macro-alist-elt)) |
| 624 | ((setq macro-body (viper-kbd-buf-definition macro-alist-elt))) | 624 | ((setq macro-body (viper-kbd-buf-definition macro-alist-elt))) |
| @@ -701,7 +701,7 @@ name from there." | |||
| 701 | (let ((len1 (length seq1)) | 701 | (let ((len1 (length seq1)) |
| 702 | (len2 (length seq2))) | 702 | (len2 (length seq2))) |
| 703 | (if (<= len1 len2) | 703 | (if (<= len1 len2) |
| 704 | (equal seq1 (subseq seq2 0 len1))))) | 704 | (equal seq1 (viper-subseq seq2 0 len1))))) |
| 705 | 705 | ||
| 706 | ;; find the longest common prefix | 706 | ;; find the longest common prefix |
| 707 | (defun viper-common-seq-prefix (&rest seqs) | 707 | (defun viper-common-seq-prefix (&rest seqs) |
| @@ -766,7 +766,7 @@ name from there." | |||
| 766 | (setq macro-def (car lis) | 766 | (setq macro-def (car lis) |
| 767 | def-len (length (car macro-def))) | 767 | def-len (length (car macro-def))) |
| 768 | (if (and (>= str-len def-len) | 768 | (if (and (>= str-len def-len) |
| 769 | (equal (car macro-def) (subseq str 0 def-len))) | 769 | (equal (car macro-def) (viper-subseq str 0 def-len))) |
| 770 | (if (or (viper-kbd-buf-definition macro-def) | 770 | (if (or (viper-kbd-buf-definition macro-def) |
| 771 | (viper-kbd-mode-definition macro-def) | 771 | (viper-kbd-mode-definition macro-def) |
| 772 | (viper-kbd-global-definition macro-def)) | 772 | (viper-kbd-global-definition macro-def)) |
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 503cd145796..77c5f844567 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el | |||
| @@ -65,7 +65,7 @@ | |||
| 65 | (defvar viper-frame-of-focus nil) | 65 | (defvar viper-frame-of-focus nil) |
| 66 | 66 | ||
| 67 | ;; Frame that was selected before the switch-frame event. | 67 | ;; Frame that was selected before the switch-frame event. |
| 68 | (defconst viper-current-frame-saved (selected-frame)) | 68 | (defvar viper-current-frame-saved (selected-frame)) |
| 69 | 69 | ||
| 70 | (defcustom viper-surrounding-word-function 'viper-surrounding-word | 70 | (defcustom viper-surrounding-word-function 'viper-surrounding-word |
| 71 | "*Function that determines what constitutes a word for clicking events. | 71 | "*Function that determines what constitutes a word for clicking events. |
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 2d713df6ef6..d6fe9b43a64 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el | |||
| @@ -41,7 +41,6 @@ | |||
| 41 | (defvar viper-syntax-preference) | 41 | (defvar viper-syntax-preference) |
| 42 | (defvar viper-saved-mark) | 42 | (defvar viper-saved-mark) |
| 43 | 43 | ||
| 44 | (require 'cl) | ||
| 45 | (require 'ring) | 44 | (require 'ring) |
| 46 | 45 | ||
| 47 | (if noninteractive | 46 | (if noninteractive |
| @@ -1068,7 +1067,7 @@ | |||
| 1068 | (t key))) | 1067 | (t key))) |
| 1069 | 1068 | ||
| 1070 | ((listp key) | 1069 | ((listp key) |
| 1071 | (setq modifiers (subseq key 0 (1- (length key))) | 1070 | (setq modifiers (viper-subseq key 0 (1- (length key))) |
| 1072 | base-key (viper-seq-last-elt key) | 1071 | base-key (viper-seq-last-elt key) |
| 1073 | base-key-name (symbol-name base-key) | 1072 | base-key-name (symbol-name base-key) |
| 1074 | char-p (= (length base-key-name) 1)) | 1073 | char-p (= (length base-key-name) 1)) |
| @@ -1503,6 +1502,33 @@ This option is appropriate if you like Emacs-style words." | |||
| 1503 | )) | 1502 | )) |
| 1504 | 1503 | ||
| 1505 | 1504 | ||
| 1505 | ;; this is copied from cl-extra.el | ||
| 1506 | ;; Return the subsequence of SEQ from START to END. | ||
| 1507 | ;; If END is omitted, it defaults to the length of the sequence. | ||
| 1508 | ;; If START or END is negative, it counts from the end. | ||
| 1509 | (defun viper-subseq (seq start &optional end) | ||
| 1510 | (if (stringp seq) (substring seq start end) | ||
| 1511 | (let (len) | ||
| 1512 | (and end (< end 0) (setq end (+ end (setq len (length seq))))) | ||
| 1513 | (if (< start 0) (setq start (+ start (or len (setq len (length seq)))))) | ||
| 1514 | (cond ((listp seq) | ||
| 1515 | (if (> start 0) (setq seq (nthcdr start seq))) | ||
| 1516 | (if end | ||
| 1517 | (let ((res nil)) | ||
| 1518 | (while (>= (setq end (1- end)) start) | ||
| 1519 | (push (pop seq) res)) | ||
| 1520 | (nreverse res)) | ||
| 1521 | (copy-sequence seq))) | ||
| 1522 | (t | ||
| 1523 | (or end (setq end (or len (length seq)))) | ||
| 1524 | (let ((res (make-vector (max (- end start) 0) nil)) | ||
| 1525 | (i 0)) | ||
| 1526 | (while (< start end) | ||
| 1527 | (aset res i (aref seq start)) | ||
| 1528 | (setq i (1+ i) start (1+ start))) | ||
| 1529 | res)))))) | ||
| 1530 | |||
| 1531 | |||
| 1506 | 1532 | ||
| 1507 | (provide 'viper-util) | 1533 | (provide 'viper-util) |
| 1508 | 1534 | ||
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index fe65cb69cbb..3a95fa26835 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> | 8 | ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> |
| 9 | ;; Keywords: emulations | 9 | ;; Keywords: emulations |
| 10 | 10 | ||
| 11 | (defconst viper-version "3.11.4 of February 19, 2005" | 11 | (defconst viper-version "3.11.5 of July 8, 2005" |
| 12 | "The current version of Viper") | 12 | "The current version of Viper") |
| 13 | 13 | ||
| 14 | ;; This file is part of GNU Emacs. | 14 | ;; This file is part of GNU Emacs. |
| @@ -320,6 +320,7 @@ | |||
| 320 | ;; end pacifier | 320 | ;; end pacifier |
| 321 | 321 | ||
| 322 | (require 'viper-init) | 322 | (require 'viper-init) |
| 323 | (require 'viper-keym) | ||
| 323 | 324 | ||
| 324 | ;; better be defined before Viper custom group. | 325 | ;; better be defined before Viper custom group. |
| 325 | (defvar viper-custom-file-name (convert-standard-filename "~/.viper") | 326 | (defvar viper-custom-file-name (convert-standard-filename "~/.viper") |
| @@ -691,6 +692,12 @@ remains buffer-local." | |||
| 691 | 692 | ||
| 692 | (setq viper-mode nil) | 693 | (setq viper-mode nil) |
| 693 | 694 | ||
| 695 | (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists)) | ||
| 696 | (setq emulation-mode-map-alists | ||
| 697 | (delq 'viper--intercept-key-maps | ||
| 698 | (delq 'viper--key-maps emulation-mode-map-alists)) | ||
| 699 | )) | ||
| 700 | |||
| 694 | (viper-delocalize-var 'viper-vi-minibuffer-minor-mode) | 701 | (viper-delocalize-var 'viper-vi-minibuffer-minor-mode) |
| 695 | (viper-delocalize-var 'viper-insert-minibuffer-minor-mode) | 702 | (viper-delocalize-var 'viper-insert-minibuffer-minor-mode) |
| 696 | (viper-delocalize-var 'viper-vi-intercept-minor-mode) | 703 | (viper-delocalize-var 'viper-vi-intercept-minor-mode) |
| @@ -874,9 +881,27 @@ remains buffer-local." | |||
| 874 | "Switch to emacs state while reading password." | 881 | "Switch to emacs state while reading password." |
| 875 | (viper-change-state-to-emacs))) | 882 | (viper-change-state-to-emacs))) |
| 876 | 883 | ||
| 884 | (defadvice self-insert-command (around viper-self-insert-ad activate) | ||
| 885 | "Ignore all self-inserting keys in the vi-state." | ||
| 886 | (if (and (eq viper-current-state 'vi-state) (interactive-p)) | ||
| 887 | (beep 1) | ||
| 888 | ad-do-it | ||
| 889 | )) | ||
| 890 | |||
| 891 | (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists)) | ||
| 892 | ;; needs to be as early as possible | ||
| 893 | (add-to-ordered-list | ||
| 894 | 'emulation-mode-map-alists 'viper--intercept-key-maps 100) | ||
| 895 | ;; needs to be after cua-mode | ||
| 896 | (add-to-ordered-list 'emulation-mode-map-alists 'viper--key-maps 500) | ||
| 897 | ) | ||
| 898 | |||
| 877 | ;; Emacs shell, ange-ftp, and comint-based modes | 899 | ;; Emacs shell, ange-ftp, and comint-based modes |
| 878 | (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint | 900 | (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint |
| 879 | 901 | ||
| 902 | (add-hook 'eshell-mode-hook | ||
| 903 | (lambda () (setq viper-auto-indent nil))) | ||
| 904 | |||
| 880 | (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) ; dired | 905 | (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) ; dired |
| 881 | (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) ; tar | 906 | (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) ; tar |
| 882 | (viper-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) ; mhe | 907 | (viper-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) ; mhe |
| @@ -1058,6 +1083,14 @@ remains buffer-local." | |||
| 1058 | (define-key viper-insert-intercept-map "\C-x)" nil) | 1083 | (define-key viper-insert-intercept-map "\C-x)" nil) |
| 1059 | (define-key viper-emacs-intercept-map "\C-x)" nil)) | 1084 | (define-key viper-emacs-intercept-map "\C-x)" nil)) |
| 1060 | 1085 | ||
| 1086 | (defadvice add-minor-mode (after | ||
| 1087 | viper-advice-add-minor-mode | ||
| 1088 | (toggle name &optional keymap after toggle-fun) | ||
| 1089 | activate) | ||
| 1090 | "Run viper-normalize-minor-mode-map-alist after adding a minor mode." | ||
| 1091 | (viper-normalize-minor-mode-map-alist) | ||
| 1092 | (setq-default minor-mode-map-alist minor-mode-map-alist)) | ||
| 1093 | |||
| 1061 | ;; catch frame switching event | 1094 | ;; catch frame switching event |
| 1062 | (if (viper-window-display-p) | 1095 | (if (viper-window-display-p) |
| 1063 | (if viper-xemacs-p | 1096 | (if viper-xemacs-p |