• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/emulation/

Lines Matching +defs:cua +defs:rectangle +defs:keymap

0 ;;; cua-base.el --- emulate CUA key bindings
6 ;; Author: Kim F. Storm <storm@cua.dk>
7 ;; Keywords: keyboard emulation convenience cua
69 ;; cua-prefix-override-inhibit-delay variable.
76 ;; bindings, customize cua-enable-cua-keys to nil.
115 ;; (setq cua-normal-cursor-color "red")
116 ;; (setq cua-overwrite-cursor-color "yellow")
117 ;; (setq cua-read-only-cursor-color "green")
138 ;; CUA rectangle support
140 ;; Emacs' normal rectangle support is based on interpreting the region
141 ;; between the mark and point as a "virtual rectangle", and using a
142 ;; completely separate set of "rectangle commands" [C-x r ...] on the
143 ;; region to copy, kill, fill a.s.o. the virtual rectangle.
145 ;; cua-mode's superior rectangle support uses a true visual
146 ;; representation of the selected rectangle, i.e. it highlights the
148 ;; rectangle. Unlike emacs' traditional rectangle commands, the
149 ;; selected rectangle always as straight left and right edges, even
153 ;; virtual dimensions of the rectangle).
155 ;; This means that cua-mode's rectangles are not limited to the actual
157 ;; short line, you can still extend the rectangle to include more columns
158 ;; of longer lines in the same rectangle. And you can also have the
159 ;; left edge of a rectangle start in the middle of a TAB character.
162 ;; To start a rectangle, use [C-return] and extend it using the normal
164 ;; C-end). Once the rectangle has the desired size, you can cut or
166 ;; subsequently insert it - as a rectangle - using C-v (or C-y). So
167 ;; the only new command you need to know to work with cua-mode
170 ;; Normally, when you paste a rectangle using C-v (C-y), each line of
171 ;; the rectangle is inserted into the existing lines in the buffer.
172 ;; If overwrite-mode is active when you paste a rectangle, it is
175 ;; If you prefer the traditional rectangle marking (i.e. don't want
176 ;; straight edges), [M-p] toggles this for the current rectangle,
177 ;; or you can customize cua-virtual-rectangle-edges.
180 ;; rectangle in one of the other corners of the rectangle, just use
183 ;; entire rectangle overlay (but not the contents) in the given
186 ;; [C-return] cancels the rectangle
187 ;; [C-space] activates the region bounded by the rectangle
189 ;; If you type a normal (self-inserting) character when the rectangle is
191 ;; of the rectangle. The "current side" is the side on which the cursor
192 ;; is currently located. If the rectangle is only 1 column wide,
194 ;; bottom of the rectangle. So, for example, to comment out an entire
199 ;; cua-mode's rectangle support also includes all the normal rectangle
202 ;; [M-a] aligns all words at the left edge of the rectangle
203 ;; [M-b] fills the rectangle with blanks (tabs and spaces)
204 ;; [M-c] closes the rectangle by removing all blanks at the left edge
205 ;; of the rectangle
206 ;; [M-f] fills the rectangle with a single character (prompt)
207 ;; [M-i] increases the first number found on each line of the rectangle
210 ;; [M-k] kills the rectangle as normal multi-line text (for paste)
211 ;; [M-l] downcases the rectangle
212 ;; [M-m] copies the rectangle as normal multi-line text (for paste)
213 ;; [M-n] fills each line of the rectangle with increasing numbers using
215 ;; [M-o] opens the rectangle by moving the highlighted text to the
216 ;; right of the rectangle and filling the rectangle with blanks.
217 ;; [M-p] toggles virtual straight rectangle edges
219 ;; [M-q] performs text filling on the rectangle
220 ;; [M-r] replaces REGEXP (prompt) by STRING (prompt) in rectangle
221 ;; [M-R] reverse the lines in the rectangle
222 ;; [M-s] fills each line of the rectangle with the same STRING (prompt)
223 ;; [M-t] performs text fill of the rectangle with TEXT (prompt)
224 ;; [M-u] upcases the rectangle
225 ;; [M-|] runs shell command on rectangle
226 ;; [M-'] restricts rectangle to lines with CHAR (prompt) at left column
227 ;; [M-/] restricts rectangle to lines matching REGEXP (prompt)
230 ;; [M-C-up] and [M-C-down] scrolls the lines INSIDE the rectangle up
231 ;; and down; lines scrolled outside the top or bottom of the rectangle
244 ;; [C-x] If you cut a region or rectangle, it is automatically inserted
246 ;; [C-c] If you copy a region or rectangle, it is immediately inserted
257 ;; [TAB] Indents the current line or rectangle to the column of the
264 (defgroup cua nil
266 :prefix "cua"
271 :link '(emacs-commentary-link :tag "Commentary" "cua-base.el")
272 :link '(emacs-library-link :tag "Lisp File" "cua-base.el"))
274 (defcustom cua-enable-cua-keys t
283 :group 'cua)
285 (defcustom cua-highlight-region-shift-only nil
289 But when the mark was set using \\[cua-set-mark], transient-mark-mode
292 :group 'cua)
294 (defcustom cua-prefix-override-inhibit-delay
306 :group 'cua)
308 (defcustom cua-delete-selection t
312 :group 'cua)
314 (defcustom cua-keep-region-after-copy nil
317 :group 'cua)
319 (defcustom cua-toggle-set-mark t
320 "*If non-nil, the `cua-set-mark' command toggles the mark."
323 :group 'cua)
325 (defcustom cua-auto-mark-last-change nil
327 This means that \\[universal-argument] \\[cua-set-mark] will jump to the position
329 See `cua-set-mark' for details."
331 :group 'cua)
333 (defcustom cua-enable-register-prefix 'not-ctrl-u
345 :group 'cua)
347 (defcustom cua-delete-copy-to-register-0 t
348 "*If non-nil, save last deleted region or rectangle to register 0."
350 :group 'cua)
352 (defcustom cua-enable-region-auto-help nil
355 :group 'cua)
357 (defcustom cua-enable-modeline-indications nil
360 :group 'cua)
362 (defcustom cua-check-pending-input t
367 :group 'cua)
369 (defcustom cua-paste-pop-rotate-temporarily nil
370 "*If non-nil, \\[cua-paste-pop] only rotates the kill-ring temporarily.
372 the most recently killed text. Each immediately following \\[cua-paste-pop] replaces
377 :group 'cua)
381 (defcustom cua-virtual-rectangle-edges t
385 M-p toggles this feature when a rectangle is active."
387 :group 'cua)
389 (defcustom cua-auto-tabify-rectangles 1000
390 "*If non-nil, automatically tabify after rectangle commands.
392 are modified by inserting or deleting a rectangle. If value is
394 the rectangle, and only do the conversion if any tabs are already
396 and after the region marked by the rectangle to search."
400 :group 'cua)
402 (defvar cua-global-keymap) ; forward
403 (defvar cua--region-keymap) ; forward
405 (defcustom cua-rectangle-mark-key [(control return)]
406 "Global key used to toggle the cua rectangle mark."
409 (when (and (boundp 'cua--keymaps-initalized)
410 cua--keymaps-initalized)
411 (define-key cua-global-keymap value
412 'cua-set-rectangle-mark)
413 (when (boundp 'cua--rectangle-keymap)
414 (define-key cua--rectangle-keymap value
415 'cua-clear-rectangle-mark)
416 (define-key cua--region-keymap value
417 'cua-toggle-rectangle-mark))))
419 :group 'cua)
421 (defcustom cua-rectangle-modifier-key 'meta
422 "*Modifier key used for rectangle commands bindings.
429 :group 'cua)
431 (defcustom cua-enable-rectangle-auto-help t
432 "*If non-nil, automatically show help for region, rectangle and global mark."
434 :group 'cua)
436 (defface cua-rectangle
439 "*Font used by CUA for highlighting the rectangle."
440 :group 'cua)
442 (defface cua-rectangle-noselect
445 "*Font used by CUA for highlighting the non-selected rectangle lines."
446 :group 'cua)
451 (defcustom cua-global-mark-keep-visible t
454 :group 'cua)
456 (defface cua-global-mark
461 :group 'cua)
463 (defcustom cua-global-mark-blink-cursor-interval 0.20
467 :group 'cua)
472 (defcustom cua-enable-cursor-indications nil
475 :group 'cua)
477 (defcustom cua-normal-cursor-color (or (and (boundp 'initial-cursor-color) initial-cursor-color)
508 :group 'cua)
510 (defcustom cua-read-only-cursor-color "darkgreen"
512 Only used when `cua-enable-cursor-indications' is non-nil.
532 :group 'cua)
534 (defcustom cua-overwrite-cursor-color "yellow"
536 Only used when `cua-enable-cursor-indications' is non-nil.
556 :group 'cua)
558 (defcustom cua-global-mark-cursor-color "cyan"
561 Only used when `cua-enable-cursor-indications' is non-nil.
581 :group 'cua)
584 ;;; Rectangle support is in cua-rect.el
586 (autoload 'cua-set-rectangle-mark "cua-rect" nil t nil)
590 (when (not (featurep 'cua-rect))
591 (defvar cua--rectangle)
592 (setq cua--rectangle nil)
593 (defvar cua--last-killed-rectangle)
594 (setq cua--last-killed-rectangle nil))
598 ;;; Global Mark support is in cua-gmrk.el
600 (autoload 'cua-toggle-global-mark "cua-gmrk" nil t nil)
602 ;; Stub definitions until cua-gmrk.el is loaded
604 (when (not (featurep 'cua-gmrk))
605 (defvar cua--global-mark-active)
606 (setq cua--global-mark-active nil))
609 (provide 'cua-base)
612 (require 'cua-rect)
613 (require 'cua-gmrk)
619 (defvar cua-inhibit-cua-keys nil
621 (make-variable-buffer-local 'cua-inhibit-cua-keys)
625 ;; Current region was started using cua-set-mark.
626 (defvar cua--explicit-region-start nil)
627 (make-variable-buffer-local 'cua--explicit-region-start)
630 (defvar cua--last-region-shifted nil)
632 ;; buffer + point prior to current command when rectangle is active
634 (defvar cua--buffer-and-point-before-command nil)
637 (defvar cua--status-string nil)
638 (make-variable-buffer-local 'cua--status-string)
640 (defvar cua--debug nil)
650 ;; In state [1], the cua--prefix-override-keymap is active.
651 ;; This keymap binds the C-x and C-c prefix keys to the
652 ;; cua--prefix-override-handler function.
654 ;; When a prefix key is typed in state [1], cua--prefix-override-handler
659 ;; In state [2], the cua--prefix-override-keymap is inactive. Instead the
660 ;; cua--prefix-repeat-keymap is active. This keymap binds C-c C-c and C-x
661 ;; C-x to the cua--prefix-repeat-handler function.
663 ;; If the prefix key is repeated in state [2], cua--prefix-repeat-handler
667 ;; The basic cua--cua-keys-keymap binds [C-x timeout] to kill-region and
669 ;; the cua--prefix-override-timeout function will push a `timeout' event on
672 ;; In state [3] both cua--prefix-override-keymap and cua--prefix-repeat-keymap
673 ;; are inactive, so the timeout in cua-global-keymap binding is used, or the
678 ;; state [1]. So cua--prefix-override-handler and cua--prefix-repeat-handler
681 ;; State [1] is recognized by cua--prefix-override-timer is nil,
682 ;; state [2] is recognized by cua--prefix-override-timer is a timer, and
683 ;; state [3] is recognized by cua--prefix-override-timer is t.
685 (defvar cua--prefix-override-timer nil)
686 (defvar cua--prefix-override-length nil)
688 (defun cua--prefix-override-replay (arg repeat)
692 (setq cua--prefix-override-length (- i repeat))
693 (setq cua--prefix-override-timer
698 (and cua-check-pending-input (input-pending-p))
700 (not (numberp cua-prefix-override-inhibit-delay))
701 (<= cua-prefix-override-inhibit-delay 0)
703 (run-with-timer cua-prefix-override-inhibit-delay nil
704 'cua--prefix-override-timeout)))
713 (defun cua--prefix-override-handler (arg)
717 (cua--prefix-override-replay arg 0))
719 (defun cua--prefix-repeat-handler (arg)
722 (cua--prefix-override-replay arg 1))
724 (defun cua--prefix-copy-handler (arg)
725 "Copy region/rectangle, then replay last key."
727 (if cua--rectangle
728 (cua-copy-rectangle arg)
729 (cua-copy-region arg))
734 (defun cua--prefix-cut-handler (arg)
735 "Cut region/rectangle, then replay last key."
737 (if cua--rectangle
738 (cua-cut-rectangle arg)
739 (cua-cut-region arg))
744 (defun cua--prefix-override-timeout ()
745 (setq cua--prefix-override-timer t)
746 (when (= (length (this-command-keys)) cua--prefix-override-length)
751 (cua--select-keymaps)))
756 (defun cua--fallback ()
761 (defun cua--keep-active ()
765 (defun cua--deactivate (&optional now)
766 (setq cua--explicit-region-start nil)
774 (defvar cua--register nil)
776 (defun cua--prefix-arg (arg)
777 (setq cua--register
778 (and cua-enable-register-prefix
784 ((eq cua-enable-register-prefix 'not-ctrl-u)
786 ((eq cua-enable-register-prefix 'ctrl-u-only)
790 (if cua--register nil arg))
795 (defvar cua--last-deleted-region-pos nil)
796 (defvar cua--last-deleted-region-text nil)
798 (defun cua-delete-region ()
800 Save a copy in register 0 if `cua-delete-copy-to-register-0' is non-nil."
805 (setq cua--last-deleted-region-text (filter-buffer-substring start end))
806 (if cua-delete-copy-to-register-0
807 (set-register ?0 cua--last-deleted-region-text))
809 (setq cua--last-deleted-region-pos
813 (cua--deactivate)
816 (defun cua-replace-region ()
819 (let ((not-empty (and cua-delete-selection (cua-delete-region))))
825 (cua--fallback)))))
827 (defun cua-copy-region (arg)
831 (setq arg (cua--prefix-arg arg))
832 (setq cua--last-killed-rectangle nil)
837 (cua--register
838 (copy-to-register cua--register start end nil))
843 (if cua-keep-region-after-copy
844 (cua--keep-active)
845 (cua--deactivate))))
847 (defun cua-cut-region (arg)
851 (setq cua--last-killed-rectangle nil)
853 (cua-copy-region arg)
854 (setq arg (cua--prefix-arg arg))
859 (cua--register
860 (copy-to-register cua--register start end t))
865 (cua--deactivate)))
869 (defun cua-cancel ()
870 "Cancel the active region, rectangle, or global mark."
873 (setq cua--explicit-region-start nil)
874 (if (fboundp 'cua--cancel-rectangle)
875 (cua--cancel-rectangle)))
877 (defun cua-paste (arg)
878 "Paste last cut or copied region or rectangle.
883 (setq arg (cua--prefix-arg arg))
884 (let ((regtxt (and cua--register (get-register cua--register)))
888 ((and cua--register (not regtxt))
889 (message "Nothing in register %c" cua--register))
890 (cua--global-mark-active
892 (cua--insert-at-global-mark regtxt)
894 (cua--insert-at-global-mark (filter-buffer-substring (point) (+ (point) count)))
904 (if cua--rectangle
907 (setq paste-column (cua--rectangle-left))
908 (setq paste-lines (cua--delete-rectangle))
914 (cua-delete-region)))
918 ((consp regtxt) (cua--insert-rectangle regtxt))
920 (t (message "Unknown data in register %c" cua--register))))
921 ((and cua--last-killed-rectangle
922 (eq (and kill-ring (car kill-ring)) (car cua--last-killed-rectangle)))
925 (setq this-command 'cua--paste-rectangle)
928 (cua--insert-rectangle (cdr cua--last-killed-rectangle)
938 ;; cua-paste-pop-rotate-temporarily == t mechanism:
950 (defvar cua-paste-pop-count nil)
952 (defun cua-paste-pop (arg)
953 "Replace a just-pasted text or rectangle with a different text.
955 behaviour, see `cua-paste-pop-rotate-temporarily'."
958 ((eq last-command 'cua--paste-rectangle)
961 ((not cua-paste-pop-rotate-temporarily)
966 ((or (null cua-paste-pop-count)
968 (eq last-command 'cua-paste))
969 (setq cua-paste-pop-count rotate)
971 (yank-pop cua-paste-pop-count))
972 ((and (eq last-command 'cua-paste-pop) (not (consp arg)))
973 (setq cua-paste-pop-count (+ cua-paste-pop-count rotate))
975 (yank-pop cua-paste-pop-count))
977 (setq cua-paste-pop-count
978 (if (consp arg) (+ cua-paste-pop-count rotate -1) 1))
979 (yank (1+ cua-paste-pop-count)))))
983 (setq this-command 'cua-paste-pop))))
985 (defun cua-exchange-point-and-mark (arg)
993 (if cua--rectangle
994 (cua--rectangle-corner 0)))))
997 (defvar cua--repeat-replace-text nil)
999 (defun cua-repeat-replace-region (arg)
1005 (when cua--last-deleted-region-pos
1008 (set-buffer (car cua--last-deleted-region-pos))
1012 (elt (cdr cua--last-deleted-region-pos))
1025 (setq cua--repeat-replace-text
1028 (setq cua--repeat-replace-text
1032 (setq cua--last-deleted-region-pos nil))
1033 (if (and cua--last-deleted-region-text
1034 cua--repeat-replace-text
1035 (search-forward cua--last-deleted-region-text nil t nil))
1036 (replace-match cua--repeat-replace-text arg t)))
1038 (defun cua-help-for-region (&optional help)
1048 (defun cua-pop-to-last-change ()
1070 (defun cua-set-mark (&optional arg)
1082 If `cua-auto-mark-last-change' is non-nil, this command behaves as if there
1101 (or (and cua-auto-mark-last-change
1102 (cua-pop-to-last-change))
1104 ((and cua-toggle-set-mark mark-active)
1105 (cua--deactivate)
1109 (setq cua--explicit-region-start t)
1110 (setq cua--last-region-shifted nil)
1111 (if cua-enable-region-auto-help
1112 (cua-help-for-region t)))))
1118 (defun cua-scroll-up (&optional arg)
1126 ((eq arg '-) (cua-scroll-down nil))
1128 (cua-scroll-down (- (prefix-numeric-value arg))))
1136 (put 'cua-scroll-up 'CUA 'move)
1138 (defun cua-scroll-down (&optional arg)
1146 ((eq arg '-) (cua-scroll-up nil))
1148 (cua-scroll-up (- (prefix-numeric-value arg))))
1156 (put 'cua-scroll-down 'CUA 'move)
1160 (defun cua--update-indications ()
1163 ((and cua--global-mark-active
1164 cua-global-mark-cursor-color)
1165 cua-global-mark-cursor-color)
1167 cua-read-only-cursor-color)
1168 cua-read-only-cursor-color)
1169 ((and cua-overwrite-cursor-color overwrite-mode)
1170 cua-overwrite-cursor-color)
1171 (t cua-normal-cursor-color)))
1186 (defun cua--pre-command-handler-1 ()
1188 (when cua--prefix-override-timer
1189 (if (timerp cua--prefix-override-timer)
1190 (cancel-timer cua--prefix-override-timer))
1191 (setq cua--prefix-override-timer nil))
1206 'cua-paste)
1208 (if cua--rectangle
1209 'cua-copy-rectangle
1210 'cua-copy-region))
1212 (if cua--rectangle
1213 'cua-delete-rectangle
1214 'cua-delete-region))
1216 (if cua--rectangle
1217 'cua-delete-rectangle ;; replace?
1218 'cua-replace-region)))))
1226 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
1243 (setq cua--last-region-shifted t)
1244 (setq cua--explicit-region-start nil))
1247 ((or cua--explicit-region-start cua--rectangle)
1258 (setq cua--buffer-and-point-before-command
1259 (if cua--rectangle (cons (current-buffer) (point)))))
1261 (defun cua--pre-command-handler ()
1262 (when cua-mode
1264 (cua--pre-command-handler-1)
1269 (defun cua--post-command-handler-1 ()
1270 (when cua--global-mark-active
1271 (cua--global-mark-post-command))
1272 (when (fboundp 'cua--rectangle-post-command)
1273 (cua--rectangle-post-command))
1274 (setq cua--buffer-and-point-before-command nil)
1276 (setq cua--explicit-region-start nil))
1279 (if cua--debug
1281 (cua--rectangle (cua--rectangle-assert))
1283 (mark t) (point) cua--explicit-region-start))))
1285 ;; Disable transient-mark-mode if rectangle active in current buffer.
1287 (setq transient-mark-mode (and (not cua--rectangle)
1288 (if cua-highlight-region-shift-only
1289 (not cua--explicit-region-start)
1291 (if cua-enable-cursor-indications
1292 (cua--update-indications))
1294 (cua--select-keymaps))
1296 (defun cua--post-command-handler ()
1297 (when cua-mode
1299 (cua--post-command-handler-1)
1305 ;; Cached value of actual cua-rectangle-modifier-key
1306 (defvar cua--rectangle-modifier-key 'meta)
1308 (defun cua--M/H-key (map key fct)
1311 (define-key map (vector (cons cua--rectangle-modifier-key key)) fct))
1313 (defun cua--self-insert-char-p (def)
1320 (defvar cua-global-keymap (make-sparse-keymap)
1321 "Global keymap for cua-mode; users may add to this keymap.")
1323 (defvar cua--cua-keys-keymap (make-sparse-keymap))
1324 (defvar cua--prefix-override-keymap (make-sparse-keymap))
1325 (defvar cua--prefix-repeat-keymap (make-sparse-keymap))
1326 (defvar cua--global-mark-keymap (make-sparse-keymap)) ; Initalized when cua-gmrk.el is loaded
1327 (defvar cua--rectangle-keymap (make-sparse-keymap)) ; Initalized when cua-rect.el is loaded
1328 (defvar cua--region-keymap (make-sparse-keymap))
1330 (defvar cua--ena-cua-keys-keymap nil)
1331 (defvar cua--ena-prefix-override-keymap nil)
1332 (defvar cua--ena-prefix-repeat-keymap nil)
1333 (defvar cua--ena-region-keymap nil)
1334 (defvar cua--ena-global-mark-keymap nil)
1336 (defvar cua--keymap-alist
1337 `((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap)
1338 (cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap)
1339 (cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap)
1340 (cua--ena-global-mark-keymap . ,cua--global-mark-keymap)
1341 (cua--rectangle . ,cua--rectangle-keymap)
1342 (cua--ena-region-keymap . ,cua--region-keymap)
1343 (cua-mode . ,cua-global-keymap)))
1345 (defun cua--select-keymaps ()
1346 ;; Setup conditions for selecting the proper keymaps in cua--keymap-alist.
1347 (setq cua--ena-region-keymap
1349 (setq cua--ena-prefix-override-keymap
1350 (and cua--ena-region-keymap
1351 cua-enable-cua-keys
1352 (not cua-inhibit-cua-keys)
1353 (or (eq cua-enable-cua-keys t)
1354 (not cua--explicit-region-start))
1356 (not cua--prefix-override-timer)))
1357 (setq cua--ena-prefix-repeat-keymap
1358 (and cua--ena-region-keymap
1359 (or (timerp cua--prefix-override-timer)
1360 (eq cua--prefix-override-timer 'shift))))
1361 (setq cua--ena-cua-keys-keymap
1362 (and cua-enable-cua-keys
1363 (not cua-inhibit-cua-keys)
1364 (or (eq cua-enable-cua-keys t)
1365 cua--last-region-shifted)))
1366 (setq cua--ena-global-mark-keymap
1367 (and cua--global-mark-active
1370 (defvar cua--keymaps-initalized nil)
1372 (defun cua--shift-control-prefix (prefix arg)
1379 ;; Activate the cua--prefix-repeat-keymap
1380 (setq cua--prefix-override-timer 'shift)
1384 (defun cua--shift-control-c-prefix (arg)
1386 (cua--shift-control-prefix ?\C-c arg))
1388 (defun cua--shift-control-x-prefix (arg)
1390 (cua--shift-control-prefix ?\C-x arg))
1392 (defun cua--init-keymaps ()
1393 ;; Cache actual rectangle modifier key.
1394 (setq cua--rectangle-modifier-key
1395 (if (and cua-rectangle-modifier-key
1397 cua-rectangle-modifier-key
1399 ;; C-return always toggles rectangle mark
1400 (define-key cua-global-keymap cua-rectangle-mark-key 'cua-set-rectangle-mark)
1401 (unless (eq cua--rectangle-modifier-key 'meta)
1402 (cua--M/H-key cua-global-keymap ?\s 'cua-set-rectangle-mark)
1403 (define-key cua-global-keymap
1404 (vector (list cua--rectangle-modifier-key 'mouse-1)) 'cua-mouse-set-rectangle-mark))
1406 (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
1408 ;; replace region with rectangle or element on kill ring
1409 (define-key cua-global-keymap [remap yank] 'cua-paste)
1410 (define-key cua-global-keymap [remap clipboard-yank] 'cua-paste)
1411 (define-key cua-global-keymap [remap x-clipboard-yank] 'cua-paste)
1413 (define-key cua-global-keymap [remap yank-pop] 'cua-paste-pop)
1415 (define-key cua-global-keymap [remap set-mark-command] 'cua-set-mark)
1418 (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up)
1419 (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down)
1421 (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region)
1422 (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill)
1423 (define-key cua--cua-keys-keymap [(control z)] 'undo)
1424 (define-key cua--cua-keys-keymap [(control v)] 'yank)
1425 (define-key cua--cua-keys-keymap [(meta v)] 'cua-repeat-replace-region)
1426 (define-key cua--cua-keys-keymap [remap exchange-point-and-mark] 'cua-exchange-point-and-mark)
1428 (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler)
1429 (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler)
1431 (define-key cua--prefix-repeat-keymap [(control x) (control x)] 'cua--prefix-repeat-handler)
1432 (define-key cua--prefix-repeat-keymap [(control x) up] 'cua--prefix-cut-handler)
1433 (define-key cua--prefix-repeat-keymap [(control x) down] 'cua--prefix-cut-handler)
1434 (define-key cua--prefix-repeat-keymap [(control x) left] 'cua--prefix-cut-handler)
1435 (define-key cua--prefix-repeat-keymap [(control x) right] 'cua--prefix-cut-handler)
1436 (define-key cua--prefix-repeat-keymap [(control c) (control c)] 'cua--prefix-repeat-handler)
1437 (define-key cua--prefix-repeat-keymap [(control c) up] 'cua--prefix-copy-handler)
1438 (define-key cua--prefix-repeat-keymap [(control c) down] 'cua--prefix-copy-handler)
1439 (define-key cua--prefix-repeat-keymap [(control c) left] 'cua--prefix-copy-handler)
1440 (define-key cua--prefix-repeat-keymap [(control c) right] 'cua--prefix-copy-handler)
1443 (define-key cua--region-keymap [(shift control x)] 'cua--shift-control-x-prefix)
1444 (define-key cua--region-keymap [(shift control c)] 'cua--shift-control-c-prefix)
1447 (define-key cua--region-keymap [remap self-insert-command] 'cua-replace-region)
1448 (define-key cua--region-keymap [remap self-insert-iso] 'cua-replace-region)
1449 (define-key cua--region-keymap [remap insert-register] 'cua-replace-region)
1450 (define-key cua--region-keymap [remap newline-and-indent] 'cua-replace-region)
1451 (define-key cua--region-keymap [remap newline] 'cua-replace-region)
1452 (define-key cua--region-keymap [remap open-line] 'cua-replace-region)
1454 (define-key cua--region-keymap [remap delete-backward-char] 'cua-delete-region)
1455 (define-key cua--region-keymap [remap backward-delete-char] 'cua-delete-region)
1456 (define-key cua--region-keymap [remap backward-delete-char-untabify] 'cua-delete-region)
1457 (define-key cua--region-keymap [remap delete-char] 'cua-delete-region)
1459 (define-key cua--region-keymap [remap kill-region] 'cua-cut-region)
1460 (define-key cua--region-keymap [remap clipboard-kill-region] 'cua-cut-region)
1462 (define-key cua--region-keymap [remap copy-region-as-kill] 'cua-copy-region)
1463 (define-key cua--region-keymap [remap kill-ring-save] 'cua-copy-region)
1464 (define-key cua--region-keymap [remap clipboard-kill-ring-save] 'cua-copy-region)
1465 ;; cancel current region/rectangle
1466 (define-key cua--region-keymap [remap keyboard-escape-quit] 'cua-cancel)
1467 (define-key cua--region-keymap [remap keyboard-quit] 'cua-cancel)
1489 ;; State prior to enabling cua-mode
1495 (defvar cua--saved-state nil)
1498 (define-minor-mode cua-mode
1517 You can customize `cua-enable-cua-keys' to completely disable the
1518 CUA bindings, or `cua-prefix-override-inhibit-delay' to change
1524 shifted movement key, set `cua-highlight-region-shift-only'."
1526 :group 'cua
1527 :set-after '(cua-enable-modeline-indications
1528 cua-rectangle-mark-key cua-rectangle-modifier-key)
1529 :require 'cua-base
1530 :link '(emacs-commentary-link "cua-base.el")
1534 (unless cua--keymaps-initalized
1535 (cua--init-keymaps)
1536 (setq cua--keymaps-initalized t))
1538 (if cua-mode
1540 (add-hook 'pre-command-hook 'cua--pre-command-handler)
1541 (add-hook 'post-command-hook 'cua--post-command-handler)
1542 (if (and cua-enable-modeline-indications (not (assoc 'cua-mode minor-mode-alist)))
1543 (setq minor-mode-alist (cons '(cua-mode cua--status-string) minor-mode-alist)))
1544 (if cua-enable-cursor-indications
1545 (cua--update-indications)))
1547 (remove-hook 'pre-command-hook 'cua--pre-command-handler)
1548 (remove-hook 'post-command-hook 'cua--post-command-handler))
1550 (if (not cua-mode)
1551 (setq emulation-mode-map-alists (delq 'cua--keymap-alist emulation-mode-map-alists))
1552 (add-to-ordered-list 'emulation-mode-map-alists 'cua--keymap-alist 400)
1553 (cua--select-keymaps))
1556 (cua-mode
1557 (setq cua--saved-state
1566 (cua--deactivate)
1567 (setq transient-mark-mode (and cua-mode
1568 (if cua-highlight-region-shift-only
1569 (not cua--explicit-region-start)
1571 (cua--saved-state
1572 (setq transient-mark-mode (car cua--saved-state))
1573 (if (nth 1 cua--saved-state)
1575 (if (nth 2 cua--saved-state)
1579 (if (nth 1 cua--saved-state) " Delete-Selection" "")
1580 (if (and (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " and" "")
1581 (if (nth 2 cua--saved-state) " PC-Selection" "")
1582 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
1583 (setq cua--saved-state nil))))
1587 (defun cua-selection-mode (arg)
1590 (setq-default cua-enable-cua-keys nil)
1591 (cua-mode arg))
1594 (defun cua-debug ()
1597 (setq cua--debug (not cua--debug)))
1602 ;; Except for version 1.2, all of the 1.x and 2.x version of cua-mode
1609 ;;;###autoload "now enable CUA via the Options menu or by customizing option `cua-mode'.\n\n"
1616 (provide 'cua)
1619 ;;; cua-base.el ends here