diff options
| author | Kim F. Storm | 2002-05-10 08:28:51 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2002-05-10 08:28:51 +0000 |
| commit | a23a8440c7dc0954eb832d5f040f4536c921f8a8 (patch) | |
| tree | 5d4a54380be87a9a7a82ea9bad4e9c178c0d66ad | |
| parent | 963b3fe336cb22510d7df27dc507331087f5c637 (diff) | |
| download | emacs-a23a8440c7dc0954eb832d5f040f4536c921f8a8.tar.gz emacs-a23a8440c7dc0954eb832d5f040f4536c921f8a8.zip | |
(cua-mode): Misc. changes to use
emulation-mode-map-alists instead of minor-mode-map-alist.
| -rw-r--r-- | lisp/emulation/cua-base.el | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 9e8fdb98ebb..354bc6fff60 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -593,7 +593,7 @@ Repeating prefix key when region is active works as a single prefix key." | |||
| 593 | (if prefix-arg | 593 | (if prefix-arg |
| 594 | (reset-this-command-lengths) | 594 | (reset-this-command-lengths) |
| 595 | (setq overriding-terminal-local-map nil)) | 595 | (setq overriding-terminal-local-map nil)) |
| 596 | (cua--fix-keymaps nil))) | 596 | (cua--select-keymaps))) |
| 597 | 597 | ||
| 598 | 598 | ||
| 599 | ;;; Aux. functions | 599 | ;;; Aux. functions |
| @@ -940,7 +940,7 @@ Extra commands should be added to `cua-user-movement-commands'") | |||
| 940 | (if cua-enable-cursor-indications | 940 | (if cua-enable-cursor-indications |
| 941 | (cua--update-indications)) | 941 | (cua--update-indications)) |
| 942 | 942 | ||
| 943 | (cua--fix-keymaps nil) | 943 | (cua--select-keymaps) |
| 944 | ) | 944 | ) |
| 945 | 945 | ||
| 946 | (error nil))) | 946 | (error nil))) |
| @@ -954,7 +954,9 @@ Extra commands should be added to `cua-user-movement-commands'") | |||
| 954 | (unless (listp key) (setq key (list key))) | 954 | (unless (listp key) (setq key (list key))) |
| 955 | (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) | 955 | (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) |
| 956 | 956 | ||
| 957 | (defvar cua-global-keymap (make-sparse-keymap)) | 957 | (defvar cua-global-keymap (make-sparse-keymap) |
| 958 | "Global keymap for cua-mode; users may add to this keymap.") | ||
| 959 | |||
| 958 | (defvar cua--cua-keys-keymap (make-sparse-keymap)) | 960 | (defvar cua--cua-keys-keymap (make-sparse-keymap)) |
| 959 | (defvar cua--prefix-override-keymap (make-sparse-keymap)) | 961 | (defvar cua--prefix-override-keymap (make-sparse-keymap)) |
| 960 | (defvar cua--prefix-repeat-keymap (make-sparse-keymap)) | 962 | (defvar cua--prefix-repeat-keymap (make-sparse-keymap)) |
| @@ -968,44 +970,17 @@ Extra commands should be added to `cua-user-movement-commands'") | |||
| 968 | (defvar cua--ena-region-keymap nil) | 970 | (defvar cua--ena-region-keymap nil) |
| 969 | (defvar cua--ena-global-mark-keymap nil) | 971 | (defvar cua--ena-global-mark-keymap nil) |
| 970 | 972 | ||
| 971 | (defvar cua--mmap-prefix-override-keymap (cons 'cua--ena-prefix-override-keymap cua--prefix-override-keymap)) | 973 | (defvar cua--keymap-alist |
| 972 | (defvar cua--mmap-prefix-repeat-keymap (cons 'cua--ena-prefix-repeat-keymap cua--prefix-repeat-keymap)) | 974 | `((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap) |
| 973 | (defvar cua--mmap-cua-keys-keymap (cons 'cua--ena-cua-keys-keymap cua--cua-keys-keymap)) | 975 | (cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap) |
| 974 | (defvar cua--mmap-global-mark-keymap (cons 'cua--ena-global-mark-keymap cua--global-mark-keymap)) | 976 | (cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap) |
| 975 | (defvar cua--mmap-rectangle-keymap (cons 'cua--rectangle cua--rectangle-keymap)) | 977 | (cua--ena-global-mark-keymap . ,cua--global-mark-keymap) |
| 976 | (defvar cua--mmap-region-keymap (cons 'cua--ena-region-keymap cua--region-keymap)) | 978 | (cua--rectangle . ,cua--rectangle-keymap) |
| 977 | (defvar cua--mmap-global-keymap (cons 'cua-mode cua-global-keymap)) | 979 | (cua--ena-region-keymap . ,cua--region-keymap) |
| 978 | 980 | (cua-mode . ,cua-global-keymap))) | |
| 979 | (defvar cua--mmap-list | 981 | |
| 980 | (list cua--mmap-prefix-override-keymap | 982 | (defun cua--select-keymaps () |
| 981 | cua--mmap-prefix-repeat-keymap | 983 | ;; Setup conditions for selecting the proper keymaps in cua--keymap-alist. |
| 982 | cua--mmap-cua-keys-keymap | ||
| 983 | cua--mmap-global-mark-keymap | ||
| 984 | cua--mmap-rectangle-keymap | ||
| 985 | cua--mmap-region-keymap | ||
| 986 | cua--mmap-global-keymap)) | ||
| 987 | |||
| 988 | (defun cua--fix-keymaps (disable) | ||
| 989 | ;; Ensure that cua's keymaps are in minor-mode-map-alist and | ||
| 990 | ;; in the correct order. | ||
| 991 | (let (fix | ||
| 992 | (mmap minor-mode-map-alist) | ||
| 993 | (ml cua--mmap-list)) | ||
| 994 | (while (and (not fix) mmap ml) | ||
| 995 | (if (not (eq (car mmap) (car ml))) | ||
| 996 | (setq fix t) | ||
| 997 | (setq mmap (cdr mmap) | ||
| 998 | ml (cdr ml)))) | ||
| 999 | (if ml | ||
| 1000 | (setq fix t)) | ||
| 1001 | (when (or fix disable) | ||
| 1002 | (setq ml cua--mmap-list) | ||
| 1003 | (while ml | ||
| 1004 | (setq minor-mode-map-alist (delq (car ml) minor-mode-map-alist)) | ||
| 1005 | (setq ml (cdr ml)))) | ||
| 1006 | (when (and fix (not disable)) | ||
| 1007 | (setq minor-mode-map-alist | ||
| 1008 | (append (copy-sequence cua--mmap-list) minor-mode-map-alist)))) | ||
| 1009 | (setq cua--ena-region-keymap | 984 | (setq cua--ena-region-keymap |
| 1010 | (and mark-active (not deactivate-mark))) | 985 | (and mark-active (not deactivate-mark))) |
| 1011 | (setq cua--ena-prefix-override-keymap | 986 | (setq cua--ena-prefix-override-keymap |
| @@ -1127,7 +1102,12 @@ paste (in addition to the normal emacs bindings)." | |||
| 1127 | ) | 1102 | ) |
| 1128 | (remove-hook 'pre-command-hook 'cua--pre-command-handler) | 1103 | (remove-hook 'pre-command-hook 'cua--pre-command-handler) |
| 1129 | (remove-hook 'post-command-hook 'cua--post-command-handler)) | 1104 | (remove-hook 'post-command-hook 'cua--post-command-handler)) |
| 1130 | (cua--fix-keymaps (not cua-mode)) | 1105 | |
| 1106 | (if (not cua-mode) | ||
| 1107 | (setq emulation-mode-map-alists (delq 'cua--keymap-alist emulation-mode-map-alists)) | ||
| 1108 | (add-to-list 'emulation-mode-map-alists 'cua--keymap-alist) | ||
| 1109 | (cua--select-keymaps)) | ||
| 1110 | |||
| 1131 | (if (fboundp 'cua--rectangle-on-off) | 1111 | (if (fboundp 'cua--rectangle-on-off) |
| 1132 | (cua--rectangle-on-off cua-mode)) | 1112 | (cua--rectangle-on-off cua-mode)) |
| 1133 | (setq transient-mark-mode (and cua-mode | 1113 | (setq transient-mark-mode (and cua-mode |