Mercurial > emacs
comparison lisp/emulation/cua-base.el @ 91204:53108e6cea98
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 06 Dec 2007 09:51:45 +0000 |
parents | bdb3fe0ba9fa f4056febc5ff |
children | 606f2d163a64 |
comparison
equal
deleted
inserted
replaced
91203:db40129142b2 | 91204:53108e6cea98 |
---|---|
284 | 284 |
285 (defcustom cua-highlight-region-shift-only nil | 285 (defcustom cua-highlight-region-shift-only nil |
286 "*If non-nil, only highlight region if marked with S-<move>. | 286 "*If non-nil, only highlight region if marked with S-<move>. |
287 When this is non-nil, CUA toggles `transient-mark-mode' on when the region | 287 When this is non-nil, CUA toggles `transient-mark-mode' on when the region |
288 is marked using shifted movement keys, and off when the mark is cleared. | 288 is marked using shifted movement keys, and off when the mark is cleared. |
289 But when the mark was set using \\[cua-set-mark], transient-mark-mode | 289 But when the mark was set using \\[cua-set-mark], Transient Mark mode |
290 is not turned on." | 290 is not turned on." |
291 :type 'boolean | 291 :type 'boolean |
292 :group 'cua) | 292 :group 'cua) |
293 | 293 |
294 (defcustom cua-prefix-override-inhibit-delay | 294 (defcustom cua-prefix-override-inhibit-delay |
404 | 404 |
405 (defcustom cua-rectangle-mark-key [(control return)] | 405 (defcustom cua-rectangle-mark-key [(control return)] |
406 "Global key used to toggle the cua rectangle mark." | 406 "Global key used to toggle the cua rectangle mark." |
407 :set #'(lambda (symbol value) | 407 :set #'(lambda (symbol value) |
408 (set symbol value) | 408 (set symbol value) |
409 (when (and (boundp 'cua--keymaps-initalized) | 409 (when (and (boundp 'cua--keymaps-initialized) |
410 cua--keymaps-initalized) | 410 cua--keymaps-initialized) |
411 (define-key cua-global-keymap value | 411 (define-key cua-global-keymap value |
412 'cua-set-rectangle-mark) | 412 'cua-set-rectangle-mark) |
413 (when (boundp 'cua--rectangle-keymap) | 413 (when (boundp 'cua--rectangle-keymap) |
414 (define-key cua--rectangle-keymap value | 414 (define-key cua--rectangle-keymap value |
415 'cua-clear-rectangle-mark) | 415 'cua-clear-rectangle-mark) |
581 :group 'cua) | 581 :group 'cua) |
582 | 582 |
583 | 583 |
584 ;;; Rectangle support is in cua-rect.el | 584 ;;; Rectangle support is in cua-rect.el |
585 | 585 |
586 (autoload 'cua-set-rectangle-mark "cua-rect" nil t nil) | 586 (autoload 'cua-set-rectangle-mark "cua-rect" |
587 "Start rectangle at mouse click position." t nil) | |
587 | 588 |
588 ;; Stub definitions until it is loaded | 589 ;; Stub definitions until it is loaded |
589 | 590 (defvar cua--rectangle) |
590 (when (not (featurep 'cua-rect)) | 591 (defvar cua--last-killed-rectangle) |
591 (defvar cua--rectangle) | 592 (unless (featurep 'cua-rect) |
592 (setq cua--rectangle nil) | 593 (setq cua--rectangle nil |
593 (defvar cua--last-killed-rectangle) | 594 cua--last-killed-rectangle nil)) |
594 (setq cua--last-killed-rectangle nil)) | 595 |
595 | 596 ;; All behind cua--rectangle tests. |
596 | 597 (declare-function cua-copy-rectangle "cua-rect" (arg)) |
598 (declare-function cua-cut-rectangle "cua-rect" (arg)) | |
599 (declare-function cua--rectangle-left "cua-rect" (&optional val)) | |
600 (declare-function cua--delete-rectangle "cua-rect" ()) | |
601 (declare-function cua--insert-rectangle "cua-rect" | |
602 (rect &optional below paste-column line-count)) | |
603 (declare-function cua--rectangle-corner "cua-rect" (&optional advance)) | |
604 (declare-function cua--rectangle-assert "cua-rect" ()) | |
597 | 605 |
598 ;;; Global Mark support is in cua-gmrk.el | 606 ;;; Global Mark support is in cua-gmrk.el |
599 | 607 |
600 (autoload 'cua-toggle-global-mark "cua-gmrk" nil t nil) | 608 (autoload 'cua-toggle-global-mark "cua-gmrk" nil t nil) |
601 | 609 |
602 ;; Stub definitions until cua-gmrk.el is loaded | 610 ;; Stub definitions until cua-gmrk.el is loaded |
603 | 611 (defvar cua--global-mark-active) |
604 (when (not (featurep 'cua-gmrk)) | 612 (unless (featurep 'cua-gmrk) |
605 (defvar cua--global-mark-active) | |
606 (setq cua--global-mark-active nil)) | 613 (setq cua--global-mark-active nil)) |
607 | 614 |
608 | 615 (declare-function cua--insert-at-global-mark "cua-gmrk" (str &optional msg)) |
609 (provide 'cua-base) | 616 (declare-function cua--global-mark-post-command "cua-gmrk" ()) |
610 | |
611 (eval-when-compile | |
612 (require 'cua-rect) | |
613 (require 'cua-gmrk) | |
614 ) | |
615 | 617 |
616 | 618 |
617 ;;; Low-level Interface | 619 ;;; Low-level Interface |
618 | 620 |
619 (defvar cua-inhibit-cua-keys nil | 621 (defvar cua-inhibit-cua-keys nil |
871 (interactive) | 873 (interactive) |
872 (setq mark-active nil) | 874 (setq mark-active nil) |
873 (setq cua--explicit-region-start nil) | 875 (setq cua--explicit-region-start nil) |
874 (if (fboundp 'cua--cancel-rectangle) | 876 (if (fboundp 'cua--cancel-rectangle) |
875 (cua--cancel-rectangle))) | 877 (cua--cancel-rectangle))) |
878 | |
879 (declare-function x-clipboard-yank "../term/x-win" ()) | |
876 | 880 |
877 (defun cua-paste (arg) | 881 (defun cua-paste (arg) |
878 "Paste last cut or copied region or rectangle. | 882 "Paste last cut or copied region or rectangle. |
879 An active region is deleted before executing the command. | 883 An active region is deleted before executing the command. |
880 With numeric prefix arg, paste from register 0-9 instead. | 884 With numeric prefix arg, paste from register 0-9 instead. |
916 (current-kill 1)) | 920 (current-kill 1)) |
917 (cua-delete-region))) | 921 (cua-delete-region))) |
918 (cond | 922 (cond |
919 (regtxt | 923 (regtxt |
920 (cond | 924 (cond |
925 ;; This being a cons implies cua-rect is loaded? | |
921 ((consp regtxt) (cua--insert-rectangle regtxt)) | 926 ((consp regtxt) (cua--insert-rectangle regtxt)) |
922 ((stringp regtxt) (insert-for-yank regtxt)) | 927 ((stringp regtxt) (insert-for-yank regtxt)) |
923 (t (message "Unknown data in register %c" cua--register)))) | 928 (t (message "Unknown data in register %c" cua--register)))) |
924 ((and cua--last-killed-rectangle | 929 ((and cua--last-killed-rectangle |
925 (eq (and kill-ring (car kill-ring)) (car cua--last-killed-rectangle))) | 930 (eq (and kill-ring (car kill-ring)) (car cua--last-killed-rectangle))) |
952 | 957 |
953 (defvar cua-paste-pop-count nil) | 958 (defvar cua-paste-pop-count nil) |
954 | 959 |
955 (defun cua-paste-pop (arg) | 960 (defun cua-paste-pop (arg) |
956 "Replace a just-pasted text or rectangle with a different text. | 961 "Replace a just-pasted text or rectangle with a different text. |
957 See `yank-pop' for details about the default behaviour. For an alternative | 962 See `yank-pop' for details about the default behavior. For an alternative |
958 behaviour, see `cua-paste-pop-rotate-temporarily'." | 963 behavior, see `cua-paste-pop-rotate-temporarily'." |
959 (interactive "P") | 964 (interactive "P") |
960 (cond | 965 (cond |
961 ((eq last-command 'cua--paste-rectangle) | 966 ((eq last-command 'cua--paste-rectangle) |
962 (undo) | 967 (undo) |
963 (yank arg)) | 968 (yank arg)) |
1223 (setq this-original-command this-command | 1228 (setq this-original-command this-command |
1224 this-command nc))))) | 1229 this-command nc))))) |
1225 | 1230 |
1226 ;; Handle shifted cursor keys and other movement commands. | 1231 ;; Handle shifted cursor keys and other movement commands. |
1227 ;; If region is not active, region is activated if key is shifted. | 1232 ;; If region is not active, region is activated if key is shifted. |
1228 ;; If region is active, region is cancelled if key is unshifted (and region not started with C-SPC). | 1233 ;; If region is active, region is cancelled if key is unshifted |
1229 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement. | 1234 ;; (and region not started with C-SPC). |
1235 ;; If rectangle is active, expand rectangle in specified direction and | |
1236 ;; ignore the movement. | |
1230 ((if window-system | 1237 ((if window-system |
1238 ;; Shortcut for window-system, assuming that input-decode-map is empty. | |
1231 (memq 'shift (event-modifiers | 1239 (memq 'shift (event-modifiers |
1232 (aref (this-single-command-raw-keys) 0))) | 1240 (aref (this-single-command-raw-keys) 0))) |
1233 (or | 1241 (or |
1242 ;; Check if the final key-sequence was shifted. | |
1234 (memq 'shift (event-modifiers | 1243 (memq 'shift (event-modifiers |
1235 (aref (this-single-command-keys) 0))) | 1244 (aref (this-single-command-keys) 0))) |
1236 ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home. | 1245 ;; If not, maybe the raw key-sequence was mapped by input-decode-map |
1237 (and (boundp 'local-function-key-map) | 1246 ;; to a shifted key (and then mapped down to its unshifted form). |
1238 local-function-key-map | 1247 (let* ((keys (this-single-command-raw-keys)) |
1239 (let ((ev (lookup-key local-function-key-map | 1248 (ev (lookup-key input-decode-map keys))) |
1240 (this-single-command-raw-keys)))) | 1249 (or (and (vector ev) (memq 'shift (event-modifiers (aref ev 0)))) |
1241 (and (vector ev) | 1250 ;; Or maybe, the raw key-sequence was not an escape sequence |
1242 (symbolp (setq ev (aref ev 0))) | 1251 ;; and was shifted (and then mapped down to its unshifted form). |
1243 (string-match "S-" (symbol-name ev))))))) | 1252 (memq 'shift (event-modifiers (aref keys 0))))))) |
1244 (unless mark-active | 1253 (unless mark-active |
1245 (push-mark-command nil t)) | 1254 (push-mark-command nil t)) |
1246 (setq cua--last-region-shifted t) | 1255 (setq cua--last-region-shifted t) |
1247 (setq cua--explicit-region-start nil)) | 1256 (setq cua--explicit-region-start nil)) |
1248 | 1257 |
1324 "Global keymap for cua-mode; users may add to this keymap.") | 1333 "Global keymap for cua-mode; users may add to this keymap.") |
1325 | 1334 |
1326 (defvar cua--cua-keys-keymap (make-sparse-keymap)) | 1335 (defvar cua--cua-keys-keymap (make-sparse-keymap)) |
1327 (defvar cua--prefix-override-keymap (make-sparse-keymap)) | 1336 (defvar cua--prefix-override-keymap (make-sparse-keymap)) |
1328 (defvar cua--prefix-repeat-keymap (make-sparse-keymap)) | 1337 (defvar cua--prefix-repeat-keymap (make-sparse-keymap)) |
1329 (defvar cua--global-mark-keymap (make-sparse-keymap)) ; Initalized when cua-gmrk.el is loaded | 1338 (defvar cua--global-mark-keymap (make-sparse-keymap)) ; Initialized when cua-gmrk.el is loaded |
1330 (defvar cua--rectangle-keymap (make-sparse-keymap)) ; Initalized when cua-rect.el is loaded | 1339 (defvar cua--rectangle-keymap (make-sparse-keymap)) ; Initialized when cua-rect.el is loaded |
1331 (defvar cua--region-keymap (make-sparse-keymap)) | 1340 (defvar cua--region-keymap (make-sparse-keymap)) |
1332 | 1341 |
1333 (defvar cua--ena-cua-keys-keymap nil) | 1342 (defvar cua--ena-cua-keys-keymap nil) |
1334 (defvar cua--ena-prefix-override-keymap nil) | 1343 (defvar cua--ena-prefix-override-keymap nil) |
1335 (defvar cua--ena-prefix-repeat-keymap nil) | 1344 (defvar cua--ena-prefix-repeat-keymap nil) |
1368 cua--last-region-shifted))) | 1377 cua--last-region-shifted))) |
1369 (setq cua--ena-global-mark-keymap | 1378 (setq cua--ena-global-mark-keymap |
1370 (and cua--global-mark-active | 1379 (and cua--global-mark-active |
1371 (not (window-minibuffer-p))))) | 1380 (not (window-minibuffer-p))))) |
1372 | 1381 |
1373 (defvar cua--keymaps-initalized nil) | 1382 (defvar cua--keymaps-initialized nil) |
1374 | 1383 |
1375 (defun cua--shift-control-prefix (prefix arg) | 1384 (defun cua--shift-control-prefix (prefix arg) |
1376 ;; handle S-C-x and S-C-c by emulating the fast double prefix function. | 1385 ;; handle S-C-x and S-C-c by emulating the fast double prefix function. |
1377 ;; Don't record this command | 1386 ;; Don't record this command |
1378 (setq this-command last-command) | 1387 (setq this-command last-command) |
1532 :require 'cua-base | 1541 :require 'cua-base |
1533 :link '(emacs-commentary-link "cua-base.el") | 1542 :link '(emacs-commentary-link "cua-base.el") |
1534 (setq mark-even-if-inactive t) | 1543 (setq mark-even-if-inactive t) |
1535 (setq highlight-nonselected-windows nil) | 1544 (setq highlight-nonselected-windows nil) |
1536 | 1545 |
1537 (unless cua--keymaps-initalized | 1546 (unless cua--keymaps-initialized |
1538 (cua--init-keymaps) | 1547 (cua--init-keymaps) |
1539 (setq cua--keymaps-initalized t)) | 1548 (setq cua--keymaps-initialized t)) |
1540 | 1549 |
1541 (if cua-mode | 1550 (if cua-mode |
1542 (progn | 1551 (progn |
1543 (add-hook 'pre-command-hook 'cua--pre-command-handler) | 1552 (add-hook 'pre-command-hook 'cua--pre-command-handler) |
1544 (add-hook 'post-command-hook 'cua--post-command-handler) | 1553 (add-hook 'post-command-hook 'cua--post-command-handler) |
1598 "Toggle CUA debugging." | 1607 "Toggle CUA debugging." |
1599 (interactive) | 1608 (interactive) |
1600 (setq cua--debug (not cua--debug))) | 1609 (setq cua--debug (not cua--debug))) |
1601 | 1610 |
1602 | 1611 |
1603 (provide 'cua) | 1612 (provide 'cua-base) |
1604 | 1613 |
1605 ;;; arch-tag: 21fb6289-ba25-4fee-bfdc-f9fb351acf05 | 1614 ;;; arch-tag: 21fb6289-ba25-4fee-bfdc-f9fb351acf05 |
1606 ;;; cua-base.el ends here | 1615 ;;; cua-base.el ends here |