593 |
(if prefix-arg |
(if prefix-arg |
594 |
(reset-this-command-lengths) |
(reset-this-command-lengths) |
595 |
(setq overriding-terminal-local-map nil)) |
(setq overriding-terminal-local-map nil)) |
596 |
(cua--fix-keymaps nil))) |
(cua--select-keymaps))) |
597 |
|
|
598 |
|
|
599 |
;;; Aux. functions |
;;; Aux. functions |
940 |
(if cua-enable-cursor-indications |
(if cua-enable-cursor-indications |
941 |
(cua--update-indications)) |
(cua--update-indications)) |
942 |
|
|
943 |
(cua--fix-keymaps nil) |
(cua--select-keymaps) |
944 |
) |
) |
945 |
|
|
946 |
(error nil))) |
(error nil))) |
954 |
(unless (listp key) (setq key (list key))) |
(unless (listp key) (setq key (list key))) |
955 |
(define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) |
(define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) |
956 |
|
|
957 |
(defvar cua-global-keymap (make-sparse-keymap)) |
(defvar cua-global-keymap (make-sparse-keymap) |
958 |
|
"Global keymap for cua-mode; users may add to this keymap.") |
959 |
|
|
960 |
(defvar cua--cua-keys-keymap (make-sparse-keymap)) |
(defvar cua--cua-keys-keymap (make-sparse-keymap)) |
961 |
(defvar cua--prefix-override-keymap (make-sparse-keymap)) |
(defvar cua--prefix-override-keymap (make-sparse-keymap)) |
962 |
(defvar cua--prefix-repeat-keymap (make-sparse-keymap)) |
(defvar cua--prefix-repeat-keymap (make-sparse-keymap)) |
970 |
(defvar cua--ena-region-keymap nil) |
(defvar cua--ena-region-keymap nil) |
971 |
(defvar cua--ena-global-mark-keymap nil) |
(defvar cua--ena-global-mark-keymap nil) |
972 |
|
|
973 |
(defvar cua--mmap-prefix-override-keymap (cons 'cua--ena-prefix-override-keymap cua--prefix-override-keymap)) |
(defvar cua--keymap-alist |
974 |
(defvar cua--mmap-prefix-repeat-keymap (cons 'cua--ena-prefix-repeat-keymap cua--prefix-repeat-keymap)) |
`((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap) |
975 |
(defvar cua--mmap-cua-keys-keymap (cons 'cua--ena-cua-keys-keymap cua--cua-keys-keymap)) |
(cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap) |
976 |
(defvar cua--mmap-global-mark-keymap (cons 'cua--ena-global-mark-keymap cua--global-mark-keymap)) |
(cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap) |
977 |
(defvar cua--mmap-rectangle-keymap (cons 'cua--rectangle cua--rectangle-keymap)) |
(cua--ena-global-mark-keymap . ,cua--global-mark-keymap) |
978 |
(defvar cua--mmap-region-keymap (cons 'cua--ena-region-keymap cua--region-keymap)) |
(cua--rectangle . ,cua--rectangle-keymap) |
979 |
(defvar cua--mmap-global-keymap (cons 'cua-mode cua-global-keymap)) |
(cua--ena-region-keymap . ,cua--region-keymap) |
980 |
|
(cua-mode . ,cua-global-keymap))) |
981 |
(defvar cua--mmap-list |
|
982 |
(list cua--mmap-prefix-override-keymap |
(defun cua--select-keymaps () |
983 |
cua--mmap-prefix-repeat-keymap |
;; Setup conditions for selecting the proper keymaps in cua--keymap-alist. |
|
cua--mmap-cua-keys-keymap |
|
|
cua--mmap-global-mark-keymap |
|
|
cua--mmap-rectangle-keymap |
|
|
cua--mmap-region-keymap |
|
|
cua--mmap-global-keymap)) |
|
|
|
|
|
(defun cua--fix-keymaps (disable) |
|
|
;; Ensure that cua's keymaps are in minor-mode-map-alist and |
|
|
;; in the correct order. |
|
|
(let (fix |
|
|
(mmap minor-mode-map-alist) |
|
|
(ml cua--mmap-list)) |
|
|
(while (and (not fix) mmap ml) |
|
|
(if (not (eq (car mmap) (car ml))) |
|
|
(setq fix t) |
|
|
(setq mmap (cdr mmap) |
|
|
ml (cdr ml)))) |
|
|
(if ml |
|
|
(setq fix t)) |
|
|
(when (or fix disable) |
|
|
(setq ml cua--mmap-list) |
|
|
(while ml |
|
|
(setq minor-mode-map-alist (delq (car ml) minor-mode-map-alist)) |
|
|
(setq ml (cdr ml)))) |
|
|
(when (and fix (not disable)) |
|
|
(setq minor-mode-map-alist |
|
|
(append (copy-sequence cua--mmap-list) minor-mode-map-alist)))) |
|
984 |
(setq cua--ena-region-keymap |
(setq cua--ena-region-keymap |
985 |
(and mark-active (not deactivate-mark))) |
(and mark-active (not deactivate-mark))) |
986 |
(setq cua--ena-prefix-override-keymap |
(setq cua--ena-prefix-override-keymap |
1102 |
) |
) |
1103 |
(remove-hook 'pre-command-hook 'cua--pre-command-handler) |
(remove-hook 'pre-command-hook 'cua--pre-command-handler) |
1104 |
(remove-hook 'post-command-hook 'cua--post-command-handler)) |
(remove-hook 'post-command-hook 'cua--post-command-handler)) |
1105 |
(cua--fix-keymaps (not cua-mode)) |
|
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 |
|
|
1111 |
(if (fboundp 'cua--rectangle-on-off) |
(if (fboundp 'cua--rectangle-on-off) |
1112 |
(cua--rectangle-on-off cua-mode)) |
(cua--rectangle-on-off cua-mode)) |
1113 |
(setq transient-mark-mode (and cua-mode |
(setq transient-mark-mode (and cua-mode |