annotate lisp/emulation/cua-base.el @ 56839:8425c441196c

(cua-auto-expand-rectangles): Remove automatic rectangle padding feature; replace by non-destructive virtual rectangle edges feature. (cua-virtual-rectangle-edges): New defcustom. (cua-auto-tabify-rectangles): New defcustom. (cua-paste): If paste into a marked rectangle, insert rectangle at current column, even if virtual; also paste exactly as many lines as has been marked (ignore additional lines or add empty lines), but paste whole source if only one line is marked. (cua--update-indications): No longer use overwrite-cursor to indicate rectangle padding
author Kim F. Storm <storm@cua.dk>
date Sun, 29 Aug 2004 20:57:42 +0000
parents a7600d0e7fdc
children c4ba14ad9689 3219f94257bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1 ;;; cua-base.el --- emulate CUA key bindings
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
2
55263
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
3 ;; Copyright (C) 1997,98,99,200,01,02,03,04 Free Software Foundation, Inc.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
4
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
5 ;; Author: Kim F. Storm <storm@cua.dk>
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
6 ;; Keywords: keyboard emulation convenience cua
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
7
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
9
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
13 ;; any later version.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
14
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
18 ;; GNU General Public License for more details.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
19
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
24
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
25
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
26 ;;; Commentary:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
27
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
28 ;; This is the CUA package which provides a complete emulation of the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
29 ;; standard CUA key bindings (Motif/Windows/Mac GUI) for selecting and
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
30 ;; manipulating the region where S-<movement> is used to highlight &
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
31 ;; extend the region.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
32
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
33 ;; CUA style key bindings for cut and paste
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
34 ;; ----------------------------------------
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
35
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
36 ;; This package allows the C-z, C-x, C-c, and C-v keys to be
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
37 ;; bound appropriately according to the Motif/Windows GUI, i.e.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
38 ;; C-z -> undo
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
39 ;; C-x -> cut
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
40 ;; C-c -> copy
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
41 ;; C-v -> paste
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
42 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
43 ;; The tricky part is the handling of the C-x and C-c keys which
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
44 ;; are normally used as prefix keys for most of emacs' built-in
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
45 ;; commands. With CUA they still do!!!
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
46 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
47 ;; Only when the region is currently active (and highlighted since
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
48 ;; transient-mark-mode is used), the C-x and C-c keys will work as CUA
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
49 ;; keys
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
50 ;; C-x -> cut
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
51 ;; C-c -> copy
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
52 ;; When the region is not active, C-x and C-c works as prefix keys!
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
53 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
54 ;; This probably sounds strange and difficult to get used to - but
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
55 ;; based on my own experience and the feedback from many users of
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
56 ;; this package, it actually works very well and users adapt to it
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
57 ;; instantly - or at least very quickly. So give it a try!
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
58 ;; ... and in the few cases where you make a mistake and accidentally
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
59 ;; delete the region - you just undo the mistake (with C-z).
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
60 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
61 ;; If you really need to perform a command which starts with one of
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
62 ;; the prefix keys even when the region is active, you have three options:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
63 ;; - press the prefix key twice very quickly (within 0.2 seconds),
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
64 ;; - press the prefix key and the following key within 0.2 seconds), or
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
65 ;; - use the SHIFT key with the prefix key, i.e. C-X or C-C
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
66 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
67 ;; This behaviour can be customized via the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
68 ;; cua-prefix-override-inhibit-delay variable.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
69
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
70 ;; In addition to using the shifted movement keys, you can also use
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
71 ;; [C-space] to start the region and use unshifted movement keys to extend
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
72 ;; it. To cancel the region, use [C-space] or [C-g].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
73
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
74 ;; If you prefer to use the standard emacs cut, copy, paste, and undo
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
75 ;; bindings, customize cua-enable-cua-keys to nil.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
76
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
77
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
78 ;; Typing text replaces the region
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
79 ;; -------------------------------
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
80
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
81 ;; When the region is active, i.e. highlighted, the text in region is
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
82 ;; replaced by the text you type.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
83
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
84 ;; The replaced text is saved in register 0 which can be inserted using
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
85 ;; the key sequence M-0 C-v (see the section on register support below).
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
86
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
87 ;; If you have just replaced a highlighted region with typed text,
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
88 ;; you can repeat the replace with M-v. This will search forward
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
89 ;; for a streach of text identical to the previous contents of the
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
90 ;; region (i.e. the contents of register 0) and replace it with the
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
91 ;; text you typed to replace the original region. Repeating M-v will
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
92 ;; replace the next matching region and so on.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
93 ;;
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
94 ;; Example: Suppose you have a line like this
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
95 ;; The redo operation will redo the last redoable command
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
96 ;; which you want to change into
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
97 ;; The repeat operation will repeat the last repeatable command
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
98 ;; This is done by highlighting the first occurrence of "redo"
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
99 ;; and type "repeat" M-v M-v.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
100
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
101 ;; Note: Since CUA-mode duplicates the functionality of the
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
102 ;; delete-selection-mode, that mode is automatically disabled when
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
103 ;; CUA-mode is enabled.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
104
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
105
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
106 ;; CUA mode indications
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
107 ;; --------------------
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
108 ;; You can choose to let CUA use different cursor colors to indicate
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
109 ;; overwrite mode and read-only buffers. For example, the following
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
110 ;; setting will use a RED cursor in normal (insertion) mode in
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
111 ;; read-write buffers, a YELLOW cursor in overwrite mode in read-write
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
112 ;; buffers, and a GREEN cursor read-only buffers:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
113 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
114 ;; (setq cua-normal-cursor-color "red")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
115 ;; (setq cua-overwrite-cursor-color "yellow")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
116 ;; (setq cua-read-only-cursor-color "green")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
117 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
118
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
119 ;; CUA register support
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
120 ;; --------------------
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
121 ;; Emacs' standard register support is also based on a separate set of
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
122 ;; "register commands".
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
123 ;;
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
124 ;; CUA's register support is activated by providing a numeric
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
125 ;; prefix argument to the C-x, C-c, and C-v commands. For example,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
126 ;; to copy the selected region to register 2, enter [M-2 C-c].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
127 ;; Or if you have activated the keypad prefix mode, enter [kp-2 C-c].
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
128 ;;
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
129 ;; And CUA will copy and paste normal region as well as rectangles
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
130 ;; into the registers, i.e. you use exactly the same command for both.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
131 ;;
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
132 ;; In addition, the last highlighted text that is deleted (not
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
133 ;; copied), e.g. by [delete] or by typing text over a highlighted
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
134 ;; region, is automatically saved in register 0, so you can insert it
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
135 ;; using [M-0 C-v].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
136
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
137 ;; CUA rectangle support
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
138 ;; ---------------------
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
139 ;; Emacs' normal rectangle support is based on interpreting the region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
140 ;; between the mark and point as a "virtual rectangle", and using a
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
141 ;; completely separate set of "rectangle commands" [C-x r ...] on the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
142 ;; region to copy, kill, fill a.s.o. the virtual rectangle.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
143 ;;
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
144 ;; cua-mode's superior rectangle support uses a true visual
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
145 ;; representation of the selected rectangle, i.e. it highlights the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
146 ;; actual part of the buffer that is currently selected as part of the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
147 ;; rectangle. Unlike emacs' traditional rectangle commands, the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
148 ;; selected rectangle always as straight left and right edges, even
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
149 ;; when those are in the middle of a TAB character or beyond the end
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
150 ;; of the current line. And it does this without actually modifying
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
151 ;; the buffer contents (it uses display overlays to visualize the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
152 ;; virtual dimensions of the rectangle).
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
153 ;;
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
154 ;; This means that cua-mode's rectangles are not limited to the actual
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
155 ;; contents of the buffer, so if the cursor is currently at the end of a
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
156 ;; short line, you can still extend the rectangle to include more columns
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
157 ;; of longer lines in the same rectangle. And you can also have the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
158 ;; left edge of a rectangle start in the middle of a TAB character.
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
159 ;; Sounds strange? Try it!
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
160 ;;
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
161 ;; To start a rectangle, use [S-return] and extend it using the normal
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
162 ;; movement keys (up, down, left, right, home, end, C-home,
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
163 ;; C-end). Once the rectangle has the desired size, you can cut or
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
164 ;; copy it using C-x and C-c (or C-w and M-w), and you can
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
165 ;; subsequently insert it - as a rectangle - using C-v (or C-y). So
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
166 ;; the only new command you need to know to work with cua-mode
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
167 ;; rectangles is S-return!
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
168 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
169 ;; Normally, when you paste a rectangle using C-v (C-y), each line of
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
170 ;; the rectangle is inserted into the existing lines in the buffer.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
171 ;; If overwrite-mode is active when you paste a rectangle, it is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
172 ;; inserted as normal (multi-line) text.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
173 ;;
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
174 ;; If you prefer the traditional rectangle marking (i.e. don't want
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
175 ;; straight edges), [M-p] toggles this for the current rectangle,
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
176 ;; or you can customize cua-virtual-rectangle-edges.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
177
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
178 ;; And there's more: If you want to extend or reduce the size of the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
179 ;; rectangle in one of the other corners of the rectangle, just use
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
180 ;; [return] to move the cursor to the "next" corner. Or you can use
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
181 ;; the [M-up], [M-down], [M-left], and [M-right] keys to move the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
182 ;; entire rectangle overlay (but not the contents) in the given
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
183 ;; direction.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
184 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
185 ;; [S-return] cancels the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
186 ;; [C-space] activates the region bounded by the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
187
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
188 ;; If you type a normal (self-inserting) character when the rectangle is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
189 ;; active, the character is inserted on the "current side" of every line
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
190 ;; of the rectangle. The "current side" is the side on which the cursor
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
191 ;; is currently located. If the rectangle is only 1 column wide,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
192 ;; insertion will be performed to the left when the cursor is at the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
193 ;; bottom of the rectangle. So, for example, to comment out an entire
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
194 ;; paragraph like this one, just place the cursor on the first character
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
195 ;; of the first line, and enter the following:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
196 ;; S-return M-} ; ; <space> S-return
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
197
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
198 ;; cua-mode's rectangle support also includes all the normal rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
199 ;; functions with easy access:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
200 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
201 ;; [M-a] aligns all words at the left edge of the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
202 ;; [M-b] fills the rectangle with blanks (tabs and spaces)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
203 ;; [M-c] closes the rectangle by removing all blanks at the left edge
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
204 ;; of the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
205 ;; [M-f] fills the rectangle with a single character (prompt)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
206 ;; [M-i] increases the first number found on each line of the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
207 ;; by the amount given by the numeric prefix argument (default 1)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
208 ;; It recognizes 0x... as hexadecimal numbers
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
209 ;; [M-k] kills the rectangle as normal multi-line text (for paste)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
210 ;; [M-l] downcases the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
211 ;; [M-m] copies the rectangle as normal multi-line text (for paste)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
212 ;; [M-n] fills each line of the rectangle with increasing numbers using
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
213 ;; a supplied format string (prompt)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
214 ;; [M-o] opens the rectangle by moving the highlighted text to the
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
215 ;; right of the rectangle and filling the rectangle with blanks.
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
216 ;; [M-p] toggles virtual straight rectangle edges
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
217 ;; [M-P] inserts tabs and spaces (padding) to make real straight edges
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
218 ;; [M-q] performs text filling on the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
219 ;; [M-r] replaces REGEXP (prompt) by STRING (prompt) in rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
220 ;; [M-R] reverse the lines in the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
221 ;; [M-s] fills each line of the rectangle with the same STRING (prompt)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
222 ;; [M-t] performs text fill of the rectangle with TEXT (prompt)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
223 ;; [M-u] upcases the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
224 ;; [M-|] runs shell command on rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
225 ;; [M-'] restricts rectangle to lines with CHAR (prompt) at left column
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
226 ;; [M-/] restricts rectangle to lines matching REGEXP (prompt)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
227 ;; [C-?] Shows a brief list of the above commands.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
228
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
229 ;; [M-C-up] and [M-C-down] scrolls the lines INSIDE the rectangle up
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
230 ;; and down; lines scrolled outside the top or bottom of the rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
231 ;; are lost, but can be recovered using [C-z].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
232
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
233 ;; CUA Global Mark
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
234 ;; ---------------
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
235 ;; The final feature provided by CUA is the "global mark", which
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
236 ;; makes it very easy to copy bits and pieces from the same and other
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
237 ;; files into the current text. To enable and cancel the global mark,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
238 ;; use [S-C-space]. The cursor will blink when the global mark
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
239 ;; is active. The following commands behave differently when the global
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
240 ;; mark is set:
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
241 ;; <ch> All characters (including newlines) you type are inserted
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
242 ;; at the global mark!
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
243 ;; [C-x] If you cut a region or rectangle, it is automatically inserted
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
244 ;; at the global mark, and the global mark is advanced.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
245 ;; [C-c] If you copy a region or rectangle, it is immediately inserted
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
246 ;; at the global mark, and the global mark is advanced.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
247 ;; [C-v] Copies a single character to the global mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
248 ;; [C-d] Moves (i.e. deletes and inserts) a single character to the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
249 ;; global mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
250 ;; [backspace] deletes the character before the global mark, while
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
251 ;; [delete] deltes the character after the global mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
252
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
253 ;; [S-C-space] Jumps to and cancels the global mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
254 ;; [C-u S-C-space] Cancels the global mark (stays in current buffer).
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
255
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
256 ;; [TAB] Indents the current line or rectangle to the column of the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
257 ;; global mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
258
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
259 ;;; Code:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
260
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
261 ;;; Customization
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
262
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
263 (defgroup cua nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
264 "Emulate CUA key bindings including C-x and C-c."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
265 :prefix "cua"
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
266 :group 'editing-basics
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
267 :group 'convenience
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
268 :group 'emulations
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
269 :link '(emacs-commentary-link :tag "Commentary" "cua-base.el")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
270 :link '(emacs-library-link :tag "Lisp File" "cua-base.el"))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
271
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
272 (defcustom cua-enable-cua-keys t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
273 "*Enable using C-z, C-x, C-c, and C-v for undo, cut, copy, and paste.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
274 If the value is t, these mappings are always enabled. If the value is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
275 'shift, these keys are only enabled if the last region was marked with
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
276 a shifted movement key. If the value is nil, these keys are never
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
277 enabled."
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
278 :type '(choice (const :tag "Disabled" nil)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
279 (const :tag "Shift region only" shift)
45231
d68e3a5fce0c (cua-enable-cua-keys)
Kim F. Storm <storm@cua.dk>
parents: 45225
diff changeset
280 (other :tag "Enabled" t))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
281 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
282
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
283 (defcustom cua-highlight-region-shift-only nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
284 "*If non-nil, only highlight region if marked with S-<move>.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
285 When this is non-nil, CUA toggles `transient-mark-mode' on when the region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
286 is marked using shifted movement keys, and off when the mark is cleared.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
287 But when the mark was set using \\[cua-set-mark], transient-mark-mode
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
288 is not turned on."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
289 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
290 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
291
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
292 (defcustom cua-prefix-override-inhibit-delay
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
293 (if (featurep 'lisp-float-type) (/ (float 1) (float 5)) nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
294 "*If non-nil, time in seconds to delay before overriding prefix key.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
295 If there is additional input within this time, the prefix key is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
296 used as a normal prefix key. So typing a key sequence quickly will
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
297 inhibit overriding the prefix key.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
298 As a special case, if the prefix keys repeated within this time, the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
299 first prefix key is discarded, so typing a prefix key twice in quick
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
300 succession will also inhibit overriding the prefix key.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
301 If the value is nil, use a shifted prefix key to inhibit the override."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
302 :type '(choice (number :tag "Inhibit delay")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
303 (const :tag "No delay" nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
304 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
305
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
306 (defcustom cua-keep-region-after-copy nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
307 "If non-nil, don't deselect the region after copying."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
308 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
309 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
310
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
311 (defcustom cua-enable-register-prefix 'not-ctrl-u
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
312 "*If non-nil, registers are supported via numeric prefix arg.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
313 If the value is t, any numeric prefix arg in the range 0 to 9 will be
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
314 interpreted as a register number.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
315 If the value is not-ctrl-u, using C-u to enter a numeric prefix is not
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
316 interpreted as a register number.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
317 If the value is ctrl-u-only, only numeric prefix entered with C-u is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
318 interpreted as a register number."
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
319 :type '(choice (const :tag "Disabled" nil)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
320 (const :tag "Enabled, but C-u arg is not a register" not-ctrl-u)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
321 (const :tag "Enabled, but only for C-u arg" ctrl-u-only)
45231
d68e3a5fce0c (cua-enable-cua-keys)
Kim F. Storm <storm@cua.dk>
parents: 45225
diff changeset
322 (other :tag "Enabled" t))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
323 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
324
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
325 (defcustom cua-delete-copy-to-register-0 t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
326 "*If non-nil, save last deleted region or rectangle to register 0."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
327 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
328 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
329
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
330 (defcustom cua-use-hyper-key nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
331 "*If non-nil, bind rectangle commands to H-? instead of M-?.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
332 If set to 'also, toggle region command is also on S-return.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
333 Must be set prior to enabling CUA."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
334 :type '(choice (const :tag "Meta key and S-return" nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
335 (const :tag "Hyper key only" only)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
336 (const :tag "Hyper key and S-return" also))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
337 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
338
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
339 (defcustom cua-enable-region-auto-help nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
340 "*If non-nil, automatically show help for active region."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
341 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
342 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
343
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
344 (defcustom cua-enable-modeline-indications nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
345 "*If non-nil, use minor-mode hook to show status in mode line."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
346 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
347 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
348
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
349 (defcustom cua-check-pending-input t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
350 "*If non-nil, don't override prefix key if input pending.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
351 It is rumoured that input-pending-p is unreliable under some window
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
352 managers, so try setting this to nil, if prefix override doesn't work."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
353 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
354 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
355
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
356
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
357 ;;; Rectangle Customization
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
358
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
359 (defcustom cua-virtual-rectangle-edges t
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
360 "*If non-nil, rectangles have virtual straight edges.
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
361 Note that although rectangles are always DISPLAYED with straight edges, the
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
362 buffer is NOT modified, until you execute a command that actually modifies it.
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
363 \[M-p] toggles this feature when a rectangle is active."
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
364 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
365 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
366
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
367 (defcustom cua-auto-tabify-rectangles 1000
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
368 "*If non-nil, automatically tabify after rectangle commands.
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
369 This basically means that `tabify' is applied to all lines that
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
370 are modified by inserting or deleting a rectangle. If value is
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
371 an integer, cua will look for existing tabs in a region around
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
372 the rectangle, and only do the conversion if any tabs are already
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
373 present. The number specifies then number of characters before
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
374 and after the region marked by the rectangle to search."
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
375 :type '(choice (number :tag "Auto detect (limit)")
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
376 (const :tag "Disabled" nil)
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
377 (other :tag "Enabled" t))
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
378 :group 'cua)
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
379
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
380 (defcustom cua-enable-rectangle-auto-help t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
381 "*If non-nil, automatically show help for region, rectangle and global mark."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
382 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
383 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
384
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
385 (defface cua-rectangle-face 'nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
386 "*Font used by CUA for highlighting the rectangle."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
387 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
388
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
389 (defface cua-rectangle-noselect-face 'nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
390 "*Font used by CUA for highlighting the non-selected rectangle lines."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
391 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
392
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
393 (defcustom cua-undo-max 64
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
394 "*Max no of undoable CUA rectangle changes (including undo)."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
395 :type 'integer
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
396 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
397
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
398
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
399 ;;; Global Mark Customization
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
400
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
401 (defcustom cua-global-mark-keep-visible t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
402 "*If non-nil, always keep global mark visible in other window."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
403 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
404 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
405
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
406 (defface cua-global-mark-face '((((class color))
50636
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
407 :foreground "black"
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
408 :background "yellow")
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
409 (t :bold t))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
410 "*Font used by CUA for highlighting the global mark."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
411 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
412
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
413 (defcustom cua-global-mark-blink-cursor-interval 0.20
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
414 "*Blink cursor at this interval when global mark is active."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
415 :type '(choice (number :tag "Blink interval")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
416 (const :tag "No blink" nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
417 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
418
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
419
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
420 ;;; Cursor Indication Customization
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
421
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
422 (defcustom cua-enable-cursor-indications nil
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
423 "*If non-nil, use different cursor colors for indications."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
424 :type 'boolean
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
425 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
426
47777
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
427 (defcustom cua-normal-cursor-color (or (and (boundp 'initial-cursor-color) initial-cursor-color)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
428 (and (boundp 'initial-frame-alist)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
429 (assoc 'cursor-color initial-frame-alist)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
430 (cdr (assoc 'cursor-color initial-frame-alist)))
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
431 (and (boundp 'default-frame-alist)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
432 (assoc 'cursor-color default-frame-alist)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
433 (cdr (assoc 'cursor-color default-frame-alist)))
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
434 (frame-parameter nil 'cursor-color)
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
435 "red")
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
436 "Normal (non-overwrite) cursor color.
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
437 Default is to load cursor color from initial or default frame parameters.
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
438
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
439 If the value is a COLOR name, then only the `cursor-color' attribute will be
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
440 affected. If the value is a cursor TYPE (one of: box, hollow, bar, or hbar),
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
441 then only the `cursor-type' property will be affected. If the value is
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
442 a cons (TYPE . COLOR), then both properties are affected."
47777
6a7ae10d9c96 (cua-normal-cursor-color): Fixed
Kim F. Storm <storm@cua.dk>
parents: 45954
diff changeset
443 :initialize 'custom-initialize-default
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
444 :type '(choice
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
445 (color :tag "Color")
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
446 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
447 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
448 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
449 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
450 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
451 (cons :tag "Color and Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
452 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
453 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
454 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
455 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
456 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
457 (color :tag "Color")))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
458 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
459
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
460 (defcustom cua-read-only-cursor-color "darkgreen"
54851
99eea8becc4f (cua-read-only-cursor-color)
Kim F. Storm <storm@cua.dk>
parents: 53167
diff changeset
461 "*Cursor color used in read-only buffers, if non-nil.
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
462 Only used when `cua-enable-cursor-indications' is non-nil.
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
463
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
464 If the value is a COLOR name, then only the `cursor-color' attribute will be
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
465 affected. If the value is a cursor TYPE (one of: box, hollow, bar, or hbar),
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
466 then only the `cursor-type' property will be affected. If the value is
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
467 a cons (TYPE . COLOR), then both properties are affected."
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
468 :type '(choice
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
469 (color :tag "Color")
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
470 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
471 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
472 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
473 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
474 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
475 (cons :tag "Color and Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
476 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
477 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
478 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
479 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
480 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
481 (color :tag "Color")))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
482 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
483
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
484 (defcustom cua-overwrite-cursor-color "yellow"
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
485 "*Cursor color used when overwrite mode is set, if non-nil.
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
486 Only used when `cua-enable-cursor-indications' is non-nil.
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
487
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
488 If the value is a COLOR name, then only the `cursor-color' attribute will be
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
489 affected. If the value is a cursor TYPE (one of: box, hollow, bar, or hbar),
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
490 then only the `cursor-type' property will be affected. If the value is
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
491 a cons (TYPE . COLOR), then both properties are affected."
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
492 :type '(choice
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
493 (color :tag "Color")
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
494 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
495 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
496 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
497 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
498 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
499 (cons :tag "Color and Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
500 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
501 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
502 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
503 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
504 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
505 (color :tag "Color")))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
506 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
507
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
508 (defcustom cua-global-mark-cursor-color "cyan"
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
509 "*Indication for active global mark.
54851
99eea8becc4f (cua-read-only-cursor-color)
Kim F. Storm <storm@cua.dk>
parents: 53167
diff changeset
510 Will change cursor color to specified color if string.
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
511 Only used when `cua-enable-cursor-indications' is non-nil.
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
512
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
513 If the value is a COLOR name, then only the `cursor-color' attribute will be
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
514 affected. If the value is a cursor TYPE (one of: box, hollow, bar, or hbar),
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
515 then only the `cursor-type' property will be affected. If the value is
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
516 a cons (TYPE . COLOR), then both properties are affected."
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
517 :type '(choice
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
518 (color :tag "Color")
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
519 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
520 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
521 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
522 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
523 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
524 (cons :tag "Color and Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
525 (choice :tag "Type"
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
526 (const :tag "Filled box" box)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
527 (const :tag "Vertical bar" bar)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
528 (const :tag "Horisontal bar" hbar)
55271
d7007197f057 Change cursor-type block to hollow.
Kim F. Storm <storm@cua.dk>
parents: 55267
diff changeset
529 (const :tag "Hollow box" hollow))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
530 (color :tag "Color")))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
531 :group 'cua)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
532
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
533
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
534 ;;; Rectangle support is in cua-rect.el
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
535
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
536 (autoload 'cua-set-rectangle-mark "cua-rect" nil t nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
537
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
538 ;; Stub definitions until it is loaded
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
539
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
540 (when (not (featurep 'cua-rect))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
541 (defvar cua--rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
542 (setq cua--rectangle nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
543 (defvar cua--last-killed-rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
544 (setq cua--last-killed-rectangle nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
545
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
546
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
547
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
548 ;;; Global Mark support is in cua-gmrk.el
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
549
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
550 (autoload 'cua-toggle-global-mark "cua-gmrk.el" nil t nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
551
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
552 ;; Stub definitions until cua-gmrk.el is loaded
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
553
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
554 (when (not (featurep 'cua-gmrk))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
555 (defvar cua--global-mark-active)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
556 (setq cua--global-mark-active nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
557
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
558
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
559 (provide 'cua-base)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
560
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
561 (eval-when-compile
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
562 (require 'cua-rect)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
563 (require 'cua-gmrk)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
564 )
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
565
45074
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
566
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
567 ;;; Low-level Interface
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
568
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
569 (defvar cua-inhibit-cua-keys nil
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
570 "Buffer-local variable that may disable the cua keymappings.")
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
571 (make-variable-buffer-local 'cua-inhibit-cua-keys)
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
572
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
573 ;;; Aux. variables
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
574
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
575 ;; Current region was started using cua-set-mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
576 (defvar cua--explicit-region-start nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
577
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
578 ;; Latest region was started using shifted movement command.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
579 (defvar cua--last-region-shifted nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
580
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
581 ;; buffer + point prior to current command when rectangle is active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
582 ;; checked in post-command hook to see if point was moved
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
583 (defvar cua--buffer-and-point-before-command nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
584
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
585 ;; status string for mode line indications
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
586 (defvar cua--status-string nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
587
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
588 (defvar cua--debug nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
589
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
590
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
591 ;;; Prefix key override mechanism
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
592
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
593 ;; The prefix override (when mark-active) operates in three substates:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
594 ;; [1] Before using a prefix key
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
595 ;; [2] Immediately after using a prefix key
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
596 ;; [3] A fraction of a second later
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
597
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
598 ;; In state [1], the cua--prefix-override-keymap is active.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
599 ;; This keymap binds the C-x and C-c prefix keys to the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
600 ;; cua--prefix-override-handler function.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
601
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
602 ;; When a prefix key is typed in state [1], cua--prefix-override-handler
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
603 ;; will push back the keys already read to the event queue. If input is
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
604 ;; pending, it changes directly to state [3]. Otherwise, a short timer [T]
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
605 ;; is started, and it changes to state [2].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
606
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
607 ;; In state [2], the cua--prefix-override-keymap is inactive. Instead the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
608 ;; cua--prefix-repeat-keymap is active. This keymap binds C-c C-c and C-x
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
609 ;; C-x to the cua--prefix-repeat-handler function.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
610
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
611 ;; If the prefix key is repeated in state [2], cua--prefix-repeat-handler
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
612 ;; will cancel [T], back the keys already read (except for the second prefix
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
613 ;; keys) to the event queue, and changes to state [3].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
614
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
615 ;; The basic cua--cua-keys-keymap binds [C-x timeout] to kill-region and
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
616 ;; [C-c timeout] to copy-region-as-kill, so if [T] times out in state [2],
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
617 ;; the cua--prefix-override-timeout function will push a `timeout' event on
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
618 ;; the event queue, and changes to state [3].
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
619
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
620 ;; In state [3] both cua--prefix-override-keymap and cua--prefix-repeat-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
621 ;; are inactive, so the timeout in cua-global-keymap binding is used, or the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
622 ;; normal prefix key binding from the global or local map will be used.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
623
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
624 ;; The pre-command hook (executed as a consequence of the timeout or normal
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
625 ;; prefix key binding) will cancel [T] and change from state [3] back to
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
626 ;; state [1]. So cua--prefix-override-handler and cua--prefix-repeat-handler
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
627 ;; are always called with state reset to [1]!
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
628
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
629 ;; State [1] is recognized by cua--prefix-override-timer is nil,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
630 ;; state [2] is recognized by cua--prefix-override-timer is a timer, and
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
631 ;; state [3] is recognized by cua--prefix-override-timer is t.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
632
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
633 (defvar cua--prefix-override-timer nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
634 (defvar cua--prefix-override-length nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
635
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
636 (defun cua--prefix-override-replay (arg repeat)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
637 (let* ((keys (this-command-keys))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
638 (i (length keys))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
639 (key (aref keys (1- i))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
640 (setq cua--prefix-override-length (- i repeat))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
641 (setq cua--prefix-override-timer
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
642 (or
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
643 ;; In state [2], change to state [3]
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
644 (> repeat 0)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
645 ;; In state [1], change directly to state [3]
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
646 (and cua-check-pending-input (input-pending-p))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
647 ;; In state [1], [T] disabled, so change to state [3]
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
648 (not (numberp cua-prefix-override-inhibit-delay))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
649 (<= cua-prefix-override-inhibit-delay 0)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
650 ;; In state [1], start [T] and change to state [2]
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
651 (run-with-timer cua-prefix-override-inhibit-delay nil
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
652 'cua--prefix-override-timeout)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
653 ;; Don't record this command
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
654 (setq this-command last-command)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
655 ;; Restore the prefix arg
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
656 (setq prefix-arg arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
657 (reset-this-command-lengths)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
658 ;; Push the key back on the event queue
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
659 (setq unread-command-events (cons key unread-command-events))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
660
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
661 (defun cua--prefix-override-handler (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
662 "Start timer waiting for prefix key to be followed by another key.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
663 Repeating prefix key when region is active works as a single prefix key."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
664 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
665 (cua--prefix-override-replay arg 0))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
666
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
667 (defun cua--prefix-repeat-handler (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
668 "Repeating prefix key when region is active works as a single prefix key."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
669 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
670 (cua--prefix-override-replay arg 1))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
671
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
672 (defun cua--prefix-copy-handler (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
673 "Copy region/rectangle, then replay last key."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
674 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
675 (if cua--rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
676 (cua-copy-rectangle arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
677 (cua-copy-region arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
678 (let ((keys (this-single-command-keys)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
679 (setq unread-command-events
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
680 (cons (aref keys (1- (length keys))) unread-command-events))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
681
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
682 (defun cua--prefix-cut-handler (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
683 "Cut region/rectangle, then replay last key."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
684 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
685 (if cua--rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
686 (cua-cut-rectangle arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
687 (cua-cut-region arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
688 (let ((keys (this-single-command-keys)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
689 (setq unread-command-events
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
690 (cons (aref keys (1- (length keys))) unread-command-events))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
691
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
692 (defun cua--prefix-override-timeout ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
693 (setq cua--prefix-override-timer t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
694 (when (= (length (this-command-keys)) cua--prefix-override-length)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
695 (setq unread-command-events (cons 'timeout unread-command-events))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
696 (if prefix-arg
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
697 (reset-this-command-lengths)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
698 (setq overriding-terminal-local-map nil))
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
699 (cua--select-keymaps)))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
700
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
701
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
702 ;;; Aux. functions
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
703
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
704 (defun cua--fallback ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
705 ;; Execute original command
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
706 (setq this-command this-original-command)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
707 (call-interactively this-command))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
708
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
709 (defun cua--keep-active ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
710 (setq mark-active t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
711 deactivate-mark nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
712
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
713 (defun cua--deactivate (&optional now)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
714 (setq cua--explicit-region-start nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
715 (if (not now)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
716 (setq deactivate-mark t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
717 (setq mark-active nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
718 (run-hooks 'deactivate-mark-hook)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
719
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
720
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
721 ;; The current register prefix
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
722 (defvar cua--register nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
723
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
724 (defun cua--prefix-arg (arg)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
725 (setq cua--register
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
726 (and cua-enable-register-prefix
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
727 (integerp arg) (>= arg 0) (< arg 10)
45952
ec1df96b1c23 (cua--prefix-arg): Make register prefixes
Kim F. Storm <storm@cua.dk>
parents: 45597
diff changeset
728 (let* ((prefix (aref (this-command-keys) 0))
ec1df96b1c23 (cua--prefix-arg): Make register prefixes
Kim F. Storm <storm@cua.dk>
parents: 45597
diff changeset
729 (ctrl-u-prefix (and (integerp prefix)
45954
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
730 (= prefix ?\C-u))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
731 (cond
45954
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
732 ((eq cua-enable-register-prefix 'not-ctrl-u)
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
733 (not ctrl-u-prefix))
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
734 ((eq cua-enable-register-prefix 'ctrl-u-only)
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
735 ctrl-u-prefix)
871fe6a1f35a Corrected last fix.
Kim F. Storm <storm@cua.dk>
parents: 45952
diff changeset
736 (t t)))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
737 (+ arg ?0)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
738 (if cua--register nil arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
739
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
740 ;;; Enhanced undo - restore rectangle selections
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
741
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
742 (defun cua-undo (&optional arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
743 "Undo some previous changes.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
744 Knows about CUA rectangle highlighting in addition to standard undo."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
745 (interactive "*P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
746 (if (fboundp 'cua--rectangle-undo)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
747 (cua--rectangle-undo arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
748 (undo arg)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
749
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
750 ;;; Region specific commands
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
751
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
752 (defvar cua--last-deleted-region-pos nil)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
753 (defvar cua--last-deleted-region-text nil)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
754
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
755 (defun cua-delete-region ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
756 "Delete the active region.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
757 Save a copy in register 0 if `cua-delete-copy-to-register-0' is non-nil."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
758 (interactive)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
759 (let ((start (mark)) (end (point)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
760 (or (<= start end)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
761 (setq start (prog1 end (setq end start))))
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
762 (setq cua--last-deleted-region-text (buffer-substring start end))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
763 (if cua-delete-copy-to-register-0
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
764 (set-register ?0 cua--last-deleted-region-text))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
765 (delete-region start end)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
766 (setq cua--last-deleted-region-pos
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
767 (cons (current-buffer)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
768 (and (consp buffer-undo-list)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
769 (car buffer-undo-list))))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
770 (cua--deactivate)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
771
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
772 (defun cua-replace-region ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
773 "Replace the active region with the character you type."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
774 (interactive)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
775 (cua-delete-region)
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
776 (unless (eq this-original-command this-command)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
777 (cua--fallback)))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
778
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
779 (defun cua-copy-region (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
780 "Copy the region to the kill ring.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
781 With numeric prefix arg, copy to register 0-9 instead."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
782 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
783 (setq arg (cua--prefix-arg arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
784 (setq cua--last-killed-rectangle nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
785 (let ((start (mark)) (end (point)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
786 (or (<= start end)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
787 (setq start (prog1 end (setq end start))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
788 (if cua--register
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
789 (copy-to-register cua--register start end nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
790 (copy-region-as-kill start end))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
791 (if cua-keep-region-after-copy
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
792 (cua--keep-active)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
793 (cua--deactivate))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
794
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
795 (defun cua-cut-region (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
796 "Cut the region and copy to the kill ring.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
797 With numeric prefix arg, copy to register 0-9 instead."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
798 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
799 (setq cua--last-killed-rectangle nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
800 (if buffer-read-only
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
801 (cua-copy-region arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
802 (setq arg (cua--prefix-arg arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
803 (let ((start (mark)) (end (point)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
804 (or (<= start end)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
805 (setq start (prog1 end (setq end start))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
806 (if cua--register
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
807 (copy-to-register cua--register start end t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
808 (kill-region start end)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
809 (cua--deactivate)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
810
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
811 ;;; Generic commands for regions, rectangles, and global marks
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
812
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
813 (defun cua-cancel ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
814 "Cancel the active region, rectangle, or global mark."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
815 (interactive)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
816 (setq mark-active nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
817 (setq cua--explicit-region-start nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
818 (if (fboundp 'cua--cancel-rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
819 (cua--cancel-rectangle)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
820
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
821 (defun cua-paste (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
822 "Paste last cut or copied region or rectangle.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
823 An active region is deleted before executing the command.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
824 With numeric prefix arg, paste from register 0-9 instead.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
825 If global mark is active, copy from register or one character."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
826 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
827 (setq arg (cua--prefix-arg arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
828 (let ((regtxt (and cua--register (get-register cua--register)))
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
829 (count (prefix-numeric-value arg))
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
830 paste-column paste-lines)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
831 (cond
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
832 ((and cua--register (not regtxt))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
833 (message "Nothing in register %c" cua--register))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
834 (cua--global-mark-active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
835 (if regtxt
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
836 (cua--insert-at-global-mark regtxt)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
837 (when (not (eobp))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
838 (cua--insert-at-global-mark (buffer-substring (point) (+ (point) count)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
839 (forward-char count))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
840 (buffer-read-only
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
841 (message "Cannot paste into a read-only buffer"))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
842 (t
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
843 ;; Must save register here, since delete may override reg 0.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
844 (if mark-active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
845 ;; Before a yank command, make sure we don't yank
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
846 ;; the same region that we are going to delete.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
847 ;; That would make yank a no-op.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
848 (if cua--rectangle
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
849 (progn
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
850 (goto-char (min (mark) (point)))
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
851 (setq paste-column (cua--rectangle-left))
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
852 (setq paste-lines (cua--delete-rectangle))
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
853 (if (= paste-lines 1)
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
854 (setq paste-lines nil))) ;; paste all
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
855 (if (string= (buffer-substring (point) (mark))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
856 (car kill-ring))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
857 (current-kill 1))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
858 (cua-delete-region)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
859 (cond
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
860 (regtxt
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
861 (cond
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
862 ((consp regtxt) (cua--insert-rectangle regtxt))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
863 ((stringp regtxt) (insert-for-yank regtxt))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
864 (t (message "Unknown data in register %c" cua--register))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
865 ((and cua--last-killed-rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
866 (eq (and kill-ring (car kill-ring)) (car cua--last-killed-rectangle)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
867 (let ((pt (point)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
868 (when (not (eq buffer-undo-list t))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
869 (setq this-command 'cua--paste-rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
870 (undo-boundary)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
871 (setq buffer-undo-list (cons pt buffer-undo-list)))
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
872 (cua--insert-rectangle (cdr cua--last-killed-rectangle)
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
873 nil paste-column paste-lines)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
874 (if arg (goto-char pt))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
875 (t (yank arg)))))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
876
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
877 (defun cua-paste-pop (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
878 "Replace a just-pasted text or rectangle with a different text.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
879 See `yank-pop' for details."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
880 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
881 (if (eq last-command 'cua--paste-rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
882 (progn
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
883 (undo)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
884 (yank arg))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
885 (yank-pop (prefix-numeric-value arg))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
886
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
887 (defun cua-exchange-point-and-mark (arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
888 "Exchanges point and mark, but don't activate the mark.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
889 Activates the mark if a prefix argument is given."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
890 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
891 (if arg
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
892 (setq mark-active t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
893 (let (mark-active)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
894 (exchange-point-and-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
895 (if cua--rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
896 (cua--rectangle-corner 0)))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
897
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
898 ;; Typed text that replaced the highlighted region.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
899 (defvar cua--repeat-replace-text nil)
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
900
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
901 (defun cua-repeat-replace-region (arg)
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
902 "Repeat replacing text of highlighted region with typed text.
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
903 Searches for the next streach of text identical to the region last
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
904 replaced by typing text over it and replaces it with the same streach
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
905 of text."
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
906 (interactive "P")
45597
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
907 (when cua--last-deleted-region-pos
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
908 (save-excursion
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
909 (save-restriction
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
910 (set-buffer (car cua--last-deleted-region-pos))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
911 (widen)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
912 ;; Find the text that replaced the region via the undo list.
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
913 (let ((ul buffer-undo-list)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
914 (elt (cdr cua--last-deleted-region-pos))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
915 u s e)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
916 (when elt
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
917 (while (consp ul)
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
918 (setq u (car ul) ul (cdr ul))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
919 (cond
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
920 ((eq u elt) ;; got it
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
921 (setq ul nil))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
922 ((and (consp u) (integerp (car u)) (integerp (cdr u)))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
923 (if (and s (= (cdr u) s))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
924 (setq s (car u))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
925 (setq s (car u) e (cdr u)))))))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
926 (setq cua--repeat-replace-text
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
927 (cond ((and s e (<= s e) (= s (mark t)))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
928 (buffer-substring-no-properties s e))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
929 ((and (null s) (eq u elt)) ;; nothing inserted
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
930 "")
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
931 (t
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
932 (message "Cannot locate replacement text")
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
933 nil))))))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
934 (setq cua--last-deleted-region-pos nil))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
935 (if (and cua--last-deleted-region-text
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
936 cua--repeat-replace-text
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
937 (search-forward cua--last-deleted-region-text nil t nil))
c85054b077e6 (cua--last-deleted-region-pos)
Kim F. Storm <storm@cua.dk>
parents: 45541
diff changeset
938 (replace-match cua--repeat-replace-text arg t)))
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
939
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
940 (defun cua-help-for-region (&optional help)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
941 "Show region specific help in echo area."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
942 (interactive)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
943 (message
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
944 (concat (if help "C-?:help " "")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
945 "C-z:undo C-x:cut C-c:copy C-v:paste S-ret:rect")))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
946
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
947
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
948 ;;; Shift activated / extended region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
949
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
950 (defun cua-set-mark (&optional arg)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
951 "Set mark at where point is, clear mark, or jump to mark.
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
952
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
953 With no prefix argument, clear mark if already set. Otherwise, set
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
954 mark, and push old mark position on local mark ring; also push mark on
54851
99eea8becc4f (cua-read-only-cursor-color)
Kim F. Storm <storm@cua.dk>
parents: 53167
diff changeset
955 global mark ring if last mark was set in another buffer.
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
956
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
957 With argument, jump to mark, and pop a new position for mark off
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
958 the local mark ring \(this does not affect the global mark ring\).
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
959 Use \\[pop-global-mark] to jump to a mark off the global mark ring
50382
9bf67e990ee1 (cua-set-mark): Unconditionally repeat
Kim F. Storm <storm@cua.dk>
parents: 50295
diff changeset
960 \(see `pop-global-mark'\).
9bf67e990ee1 (cua-set-mark): Unconditionally repeat
Kim F. Storm <storm@cua.dk>
parents: 50295
diff changeset
961
9bf67e990ee1 (cua-set-mark): Unconditionally repeat
Kim F. Storm <storm@cua.dk>
parents: 50295
diff changeset
962 Repeating the command without the prefix jumps to the next position
9bf67e990ee1 (cua-set-mark): Unconditionally repeat
Kim F. Storm <storm@cua.dk>
parents: 50295
diff changeset
963 off the local \(or global\) mark ring.
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
964
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
965 With a double \\[universal-argument] prefix argument, unconditionally set mark."
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
966 (interactive "P")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
967 (cond
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
968 ((and (consp arg) (> (prefix-numeric-value arg) 4))
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
969 (push-mark-command nil))
45541
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
970 ((eq last-command 'pop-to-mark-command)
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
971 (setq this-command 'pop-to-mark-command)
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
972 (pop-to-mark-command))
50382
9bf67e990ee1 (cua-set-mark): Unconditionally repeat
Kim F. Storm <storm@cua.dk>
parents: 50295
diff changeset
973 ((and (eq last-command 'pop-global-mark) (not arg))
50253
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
974 (setq this-command 'pop-global-mark)
e902117d7494 (cua-set-mark): Doc fixes.
Kim F. Storm <storm@cua.dk>
parents: 50060
diff changeset
975 (pop-global-mark))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
976 (arg
45541
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
977 (setq this-command 'pop-to-mark-command)
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
978 (pop-to-mark-command))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
979 (mark-active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
980 (cua--deactivate)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
981 (message "Mark Cleared"))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
982 (t
45541
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
983 (push-mark-command nil nil)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
984 (setq cua--explicit-region-start t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
985 (setq cua--last-region-shifted nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
986 (if cua-enable-region-auto-help
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
987 (cua-help-for-region t)))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
988
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
989 (defvar cua--standard-movement-commands
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
990 '(forward-char backward-char
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
991 next-line previous-line
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
992 forward-word backward-word
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
993 end-of-line beginning-of-line
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
994 end-of-buffer beginning-of-buffer
55263
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
995 scroll-up scroll-down cua-scroll-up cua-scroll-down
53167
cf6233022d1d (cua--standard-movement-commands): Add forward-sentence and backward-sentence.
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
996 forward-sentence backward-sentence
cf6233022d1d (cua--standard-movement-commands): Add forward-sentence and backward-sentence.
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
997 forward-paragraph backward-paragraph)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
998 "List of standard movement commands.
50057
bf90e6638915 (cua--standard-movement-commands): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49898
diff changeset
999 Extra commands should be added to `cua-movement-commands'")
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1000
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1001 (defvar cua-movement-commands nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1002 "User may add additional movement commands to this list.")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1003
56433
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1004 (defvar cua--preserve-mark-commands
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1005 '(end-of-buffer beginning-of-buffer)
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1006 "List of movement commands that move the mark.
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1007 CUA will preserve the previous mark position if a mark is already
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1008 active before one of these commands is executed.")
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1009
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1010 (defvar cua--undo-push-mark nil)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1011
55263
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1012 ;;; Scrolling commands which does not signal errors at top/bottom
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1013 ;;; of buffer at first key-press (instead moves to top/bottom
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1014 ;;; of buffer).
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1015
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1016 (defun cua-scroll-up (&optional arg)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1017 "Scroll text of current window upward ARG lines; or near full screen if no ARG.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1018 If window cannot be scrolled further, move cursor to bottom line instead.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1019 A near full screen is `next-screen-context-lines' less than a full screen.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1020 Negative ARG means scroll downward.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1021 If ARG is the atom `-', scroll downward by nearly full screen."
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1022 (interactive "P")
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1023 (cond
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1024 ((eq arg '-) (cua-scroll-down nil))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1025 ((< (prefix-numeric-value arg) 0)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1026 (cua-scroll-down (- (prefix-numeric-value arg))))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1027 ((eobp)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1028 (scroll-up arg)) ; signal error
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1029 (t
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1030 (condition-case nil
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1031 (scroll-up arg)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1032 (end-of-buffer (goto-char (point-max)))))))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1033
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1034 (defun cua-scroll-down (&optional arg)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1035 "Scroll text of current window downward ARG lines; or near full screen if no ARG.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1036 If window cannot be scrolled further, move cursor to top line instead.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1037 A near full screen is `next-screen-context-lines' less than a full screen.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1038 Negative ARG means scroll upward.
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1039 If ARG is the atom `-', scroll upward by nearly full screen."
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1040 (interactive "P")
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1041 (cond
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1042 ((eq arg '-) (cua-scroll-up nil))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1043 ((< (prefix-numeric-value arg) 0)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1044 (cua-scroll-up (- (prefix-numeric-value arg))))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1045 ((bobp)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1046 (scroll-down arg)) ; signal error
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1047 (t
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1048 (condition-case nil
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1049 (scroll-down arg)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1050 (beginning-of-buffer (goto-char (point-min)))))))
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1051
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1052 ;;; Cursor indications
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1053
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1054 (defun cua--update-indications ()
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1055 (let* ((cursor
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1056 (cond
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1057 ((and cua--global-mark-active
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1058 cua-global-mark-cursor-color)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1059 cua-global-mark-cursor-color)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1060 ((and buffer-read-only
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1061 cua-read-only-cursor-color)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1062 cua-read-only-cursor-color)
56839
8425c441196c (cua-auto-expand-rectangles): Remove
Kim F. Storm <storm@cua.dk>
parents: 56433
diff changeset
1063 ((and cua-overwrite-cursor-color overwrite-mode)
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1064 cua-overwrite-cursor-color)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1065 (t cua-normal-cursor-color)))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1066 (color (if (consp cursor) (cdr cursor) cursor))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1067 (type (if (consp cursor) (car cursor) cursor)))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1068 (if (and color
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1069 (stringp color)
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1070 (not (equal color (frame-parameter nil 'cursor-color))))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1071 (set-cursor-color color))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1072 (if (and type
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1073 (symbolp type)
55336
33225d8d84ab (cua--update-indications): Fix last change.
Kim F. Storm <storm@cua.dk>
parents: 55271
diff changeset
1074 (not (eq type default-cursor-type)))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1075 (setq default-cursor-type type))))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1076
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1077
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1078 ;;; Pre-command hook
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1079
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1080 (defun cua--pre-command-handler ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1081 (condition-case nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1082 (let ((movement (or (memq this-command cua--standard-movement-commands)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1083 (memq this-command cua-movement-commands))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1084
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1085 ;; Cancel prefix key timeout if user enters another key.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1086 (when cua--prefix-override-timer
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1087 (if (timerp cua--prefix-override-timer)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1088 (cancel-timer cua--prefix-override-timer))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1089 (setq cua--prefix-override-timer nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1090
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1091 ;; Handle shifted cursor keys and other movement commands.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1092 ;; If region is not active, region is activated if key is shifted.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1093 ;; If region is active, region is cancelled if key is unshifted (and region not started with C-SPC).
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1094 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1095 (if movement
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1096 (cond
56433
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1097 ((memq 'shift (event-modifiers
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1098 (aref (if window-system
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1099 (this-single-command-raw-keys)
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1100 (this-single-command-keys)) 0)))
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1101 (if mark-active
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1102 (if (and (memq this-command cua--preserve-mark-commands)
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1103 (not inhibit-mark-movement))
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1104 (setq cua--undo-push-mark t
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1105 inhibit-mark-movement t))
45541
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
1106 (push-mark-command nil t))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1107 (setq cua--last-region-shifted t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1108 (setq cua--explicit-region-start nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1109 ((or cua--explicit-region-start cua--rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1110 (unless mark-active
45541
00093b6b87d7 (cua-set-mark): Align pop to marko
Kim F. Storm <storm@cua.dk>
parents: 45520
diff changeset
1111 (push-mark-command nil nil)))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1112 (t
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1113 ;; If we set mark-active to nil here, the region highlight will not be
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1114 ;; removed by the direct_output_ commands.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1115 (setq deactivate-mark t)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1116
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1117 ;; Handle delete-selection property on other commands
45062
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1118 (if (and mark-active (not deactivate-mark))
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1119 (let* ((ds (or (get this-command 'delete-selection)
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1120 (get this-command 'pending-delete)))
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1121 (nc (cond
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1122 ((not ds) nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1123 ((eq ds 'yank)
45062
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1124 'cua-paste)
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1125 ((eq ds 'kill)
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1126 (if cua--rectangle
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1127 'cua-copy-rectangle
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1128 'cua-copy-region))
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1129 ((eq ds 'supersede)
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1130 (if cua--rectangle
49020
860515917741 (cua--pre-command-handler): Corrected
Kim F. Storm <storm@cua.dk>
parents: 47777
diff changeset
1131 'cua-delete-rectangle
860515917741 (cua--pre-command-handler): Corrected
Kim F. Storm <storm@cua.dk>
parents: 47777
diff changeset
1132 'cua-delete-region))
45062
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1133 (t
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1134 (if cua--rectangle
49020
860515917741 (cua--pre-command-handler): Corrected
Kim F. Storm <storm@cua.dk>
parents: 47777
diff changeset
1135 'cua-delete-rectangle ;; replace?
860515917741 (cua--pre-command-handler): Corrected
Kim F. Storm <storm@cua.dk>
parents: 47777
diff changeset
1136 'cua-replace-region)))))
45062
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1137 (if nc
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1138 (setq this-original-command this-command
3c062ba50b96 (cua--pre-command-handler): Only interpret delete-selection property if mark-active.
Kim F. Storm <storm@cua.dk>
parents: 45024
diff changeset
1139 this-command nc)))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1140
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1141 ;; Detect extension of rectangles by mouse or other movement
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1142 (setq cua--buffer-and-point-before-command
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1143 (if cua--rectangle (cons (current-buffer) (point))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1144 )
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1145 (error nil)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1146
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1147 ;;; Post-command hook
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1148
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1149 (defun cua--post-command-handler ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1150 (condition-case nil
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1151 (progn
56433
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1152 (when cua--undo-push-mark
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1153 (setq cua--undo-push-mark nil
a7600d0e7fdc (cua--preserve-mark-commands): New defvar.
Kim F. Storm <storm@cua.dk>
parents: 55341
diff changeset
1154 inhibit-mark-movement nil))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1155 (when cua--global-mark-active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1156 (cua--global-mark-post-command))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1157 (when (fboundp 'cua--rectangle-post-command)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1158 (cua--rectangle-post-command))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1159 (setq cua--buffer-and-point-before-command nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1160 (if (or (not mark-active) deactivate-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1161 (setq cua--explicit-region-start nil))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1162
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1163 ;; Debugging
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1164 (if cua--debug
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1165 (cond
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1166 (cua--rectangle (cua--rectangle-assert))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1167 (mark-active (message "Mark=%d Point=%d Expl=%s"
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1168 (mark t) (point) cua--explicit-region-start))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1169
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1170 ;; Disable transient-mark-mode if rectangle active in current buffer.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1171 (if (not (window-minibuffer-p (selected-window)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1172 (setq transient-mark-mode (and (not cua--rectangle)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1173 (if cua-highlight-region-shift-only
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1174 (not cua--explicit-region-start)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1175 t))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1176 (if cua-enable-cursor-indications
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1177 (cua--update-indications))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1178
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1179 (cua--select-keymaps)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1180 )
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1181
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1182 (error nil)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1183
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1184
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1185 ;;; Keymaps
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1186
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1187 (defun cua--M/H-key (map key fct)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1188 ;; bind H-KEY or M-KEY to FCT in MAP
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1189 (if (eq key 'space) (setq key ? ))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1190 (unless (listp key) (setq key (list key)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1191 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1192
45502
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1193 (defun cua--self-insert-char-p (def)
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1194 ;; Return DEF if current key sequence is self-inserting in
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1195 ;; global-map.
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1196 (if (memq (global-key-binding (this-single-command-keys))
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1197 '(self-insert-command self-insert-iso))
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1198 def nil))
3cea63601c2a (cua--self-insert-char-p): New function.
Kim F. Storm <storm@cua.dk>
parents: 45278
diff changeset
1199
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1200 (defvar cua-global-keymap (make-sparse-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1201 "Global keymap for cua-mode; users may add to this keymap.")
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1202
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1203 (defvar cua--cua-keys-keymap (make-sparse-keymap))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1204 (defvar cua--prefix-override-keymap (make-sparse-keymap))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1205 (defvar cua--prefix-repeat-keymap (make-sparse-keymap))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1206 (defvar cua--global-mark-keymap (make-sparse-keymap)) ; Initalized when cua-gmrk.el is loaded
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1207 (defvar cua--rectangle-keymap (make-sparse-keymap)) ; Initalized when cua-rect.el is loaded
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1208 (defvar cua--region-keymap (make-sparse-keymap))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1209
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1210 (defvar cua--ena-cua-keys-keymap nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1211 (defvar cua--ena-prefix-override-keymap nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1212 (defvar cua--ena-prefix-repeat-keymap nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1213 (defvar cua--ena-region-keymap nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1214 (defvar cua--ena-global-mark-keymap nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1215
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1216 (defvar cua--keymap-alist
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1217 `((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1218 (cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1219 (cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1220 (cua--ena-global-mark-keymap . ,cua--global-mark-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1221 (cua--rectangle . ,cua--rectangle-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1222 (cua--ena-region-keymap . ,cua--region-keymap)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1223 (cua-mode . ,cua-global-keymap)))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1224
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1225 (defun cua--select-keymaps ()
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1226 ;; Setup conditions for selecting the proper keymaps in cua--keymap-alist.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1227 (setq cua--ena-region-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1228 (and mark-active (not deactivate-mark)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1229 (setq cua--ena-prefix-override-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1230 (and cua--ena-region-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1231 cua-enable-cua-keys
45074
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
1232 (not cua-inhibit-cua-keys)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1233 (or (eq cua-enable-cua-keys t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1234 (not cua--explicit-region-start))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1235 (not executing-kbd-macro)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1236 (not cua--prefix-override-timer)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1237 (setq cua--ena-prefix-repeat-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1238 (and cua--ena-region-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1239 (timerp cua--prefix-override-timer)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1240 (setq cua--ena-cua-keys-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1241 (and cua-enable-cua-keys
45074
d57f600f5b7e (cua-inhibit-cua-keys): New buffer-local variable.
Kim F. Storm <storm@cua.dk>
parents: 45062
diff changeset
1242 (not cua-inhibit-cua-keys)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1243 (or (eq cua-enable-cua-keys t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1244 cua--last-region-shifted)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1245 (setq cua--ena-global-mark-keymap
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1246 (and cua--global-mark-active
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1247 (not (window-minibuffer-p)))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1248
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1249 (defvar cua--keymaps-initalized nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1250
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1251 (defun cua--init-keymaps ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1252 (unless (eq cua-use-hyper-key 'only)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1253 (define-key cua-global-keymap [(shift return)] 'cua-set-rectangle-mark))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1254 (when cua-use-hyper-key
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1255 (cua--M/H-key cua-global-keymap 'space 'cua-set-rectangle-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1256 (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1257
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1258 (define-key cua-global-keymap [(shift control ? )] 'cua-toggle-global-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1259
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1260 ;; replace region with rectangle or element on kill ring
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1261 (define-key cua-global-keymap [remap yank] 'cua-paste)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1262 (define-key cua-global-keymap [remap clipboard-yank] 'cua-paste)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1263 ;; replace current yank with previous kill ring element
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1264 (define-key cua-global-keymap [remap yank-pop] 'cua-paste-pop)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1265 ;; set mark
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1266 (define-key cua-global-keymap [remap set-mark-command] 'cua-set-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1267 ;; undo
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1268 (define-key cua-global-keymap [remap undo] 'cua-undo)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1269 (define-key cua-global-keymap [remap advertised-undo] 'cua-undo)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1270
55263
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1271 ;; scrolling
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1272 (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1273 (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down)
eb737a4709cb (cua--standard-movement-commands):
Kim F. Storm <storm@cua.dk>
parents: 54851
diff changeset
1274
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1275 (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1276 (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1277 (define-key cua--cua-keys-keymap [(control z)] 'undo)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1278 (define-key cua--cua-keys-keymap [(control v)] 'yank)
45520
f62b4c7276d7 (cua--repeat-replace-text): New variable.
Kim F. Storm <storm@cua.dk>
parents: 45502
diff changeset
1279 (define-key cua--cua-keys-keymap [(meta v)] 'cua-repeat-replace-region)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1280 (define-key cua--cua-keys-keymap [remap exchange-point-and-mark] 'cua-exchange-point-and-mark)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1281
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1282 (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1283 (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1284
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1285 (define-key cua--prefix-repeat-keymap [(control x) (control x)] 'cua--prefix-repeat-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1286 (define-key cua--prefix-repeat-keymap [(control x) up] 'cua--prefix-cut-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1287 (define-key cua--prefix-repeat-keymap [(control x) down] 'cua--prefix-cut-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1288 (define-key cua--prefix-repeat-keymap [(control x) left] 'cua--prefix-cut-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1289 (define-key cua--prefix-repeat-keymap [(control x) right] 'cua--prefix-cut-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1290 (define-key cua--prefix-repeat-keymap [(control c) (control c)] 'cua--prefix-repeat-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1291 (define-key cua--prefix-repeat-keymap [(control c) up] 'cua--prefix-copy-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1292 (define-key cua--prefix-repeat-keymap [(control c) down] 'cua--prefix-copy-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1293 (define-key cua--prefix-repeat-keymap [(control c) left] 'cua--prefix-copy-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1294 (define-key cua--prefix-repeat-keymap [(control c) right] 'cua--prefix-copy-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1295
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49430
diff changeset
1296 ;; Enable shifted fallbacks for C-x and C-c when region is active
49430
b8d252e5954b * emulation/cua-base.el (cua--init-keymaps): Move C-S-x and C-S-c
Kim F. Storm <storm@cua.dk>
parents: 49020
diff changeset
1297 (define-key cua--region-keymap [(shift control x)] 'Control-X-prefix)
b8d252e5954b * emulation/cua-base.el (cua--init-keymaps): Move C-S-x and C-S-c
Kim F. Storm <storm@cua.dk>
parents: 49020
diff changeset
1298 (define-key cua--region-keymap [(shift control c)] 'mode-specific-command-prefix)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1299 ;; replace current region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1300 (define-key cua--region-keymap [remap self-insert-command] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1301 (define-key cua--region-keymap [remap self-insert-iso] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1302 (define-key cua--region-keymap [remap insert-register] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1303 (define-key cua--region-keymap [remap newline-and-indent] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1304 (define-key cua--region-keymap [remap newline] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1305 (define-key cua--region-keymap [remap open-line] 'cua-replace-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1306 ;; delete current region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1307 (define-key cua--region-keymap [remap delete-backward-char] 'cua-delete-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1308 (define-key cua--region-keymap [remap backward-delete-char] 'cua-delete-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1309 (define-key cua--region-keymap [remap backward-delete-char-untabify] 'cua-delete-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1310 (define-key cua--region-keymap [remap delete-char] 'cua-delete-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1311 ;; kill region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1312 (define-key cua--region-keymap [remap kill-region] 'cua-cut-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1313 ;; copy region
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1314 (define-key cua--region-keymap [remap copy-region-as-kill] 'cua-copy-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1315 (define-key cua--region-keymap [remap kill-ring-save] 'cua-copy-region)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1316 ;; cancel current region/rectangle
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1317 (define-key cua--region-keymap [remap keyboard-escape-quit] 'cua-cancel)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1318 (define-key cua--region-keymap [remap keyboard-quit] 'cua-cancel)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1319 )
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1320
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1321 ;; State prior to enabling cua-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1322 ;; Value is a list with the following elements:
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1323 ;; transient-mark-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1324 ;; delete-selection-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1325 ;; pc-selection-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1326
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1327 (defvar cua--saved-state nil)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1328
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1329 ;;;###autoload
50636
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1330 (define-minor-mode cua-mode
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1331 "Toggle CUA key-binding mode.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1332 When enabled, using shifted movement keys will activate the region (and
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1333 highlight the region using `transient-mark-mode'), and typed text replaces
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1334 the active selection. C-z, C-x, C-c, and C-v will undo, cut, copy, and
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1335 paste (in addition to the normal emacs bindings)."
50636
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1336 :global t
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1337 :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1338 :require 'cua-base
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1339 :link '(emacs-commentary-link "cua-base.el")
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1340 :version "21.4"
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1341 (setq mark-even-if-inactive t)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1342 (setq highlight-nonselected-windows nil)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1343 (make-variable-buffer-local 'cua--explicit-region-start)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1344 (make-variable-buffer-local 'cua--status-string)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1345
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1346 (unless cua--keymaps-initalized
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1347 (cua--init-keymaps)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1348 (setq cua--keymaps-initalized t))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1349
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1350 (if cua-mode
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1351 (progn
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1352 (add-hook 'pre-command-hook 'cua--pre-command-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1353 (add-hook 'post-command-hook 'cua--post-command-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1354 (if (and cua-enable-modeline-indications (not (assoc 'cua-mode minor-mode-alist)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1355 (setq minor-mode-alist (cons '(cua-mode cua--status-string) minor-mode-alist)))
55267
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1356 (if cua-enable-cursor-indications
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1357 (cua--update-indications)))
4a6854d33d2b * emulation/cua-base.el: Add support for changing cursor types;
Kim F. Storm <storm@cua.dk>
parents: 55263
diff changeset
1358
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1359 (remove-hook 'pre-command-hook 'cua--pre-command-handler)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1360 (remove-hook 'post-command-hook 'cua--post-command-handler))
45225
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1361
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1362 (if (not cua-mode)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1363 (setq emulation-mode-map-alists (delq 'cua--keymap-alist emulation-mode-map-alists))
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1364 (add-to-list 'emulation-mode-map-alists 'cua--keymap-alist)
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1365 (cua--select-keymaps))
76c3f51638bd (cua-mode): Misc. changes to use
Kim F. Storm <storm@cua.dk>
parents: 45074
diff changeset
1366
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1367 (if (fboundp 'cua--rectangle-on-off)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1368 (cua--rectangle-on-off cua-mode))
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1369
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1370 (cond
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1371 (cua-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1372 (setq cua--saved-state
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1373 (list
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1374 transient-mark-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1375 (and (boundp 'delete-selection-mode) delete-selection-mode)
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1376 (and (boundp 'pc-selection-mode) pc-selection-mode)))
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1377 (if (and (boundp 'delete-selection-mode) delete-selection-mode)
51587
d7e174e9d6eb (cua-mode): Use explicit arg to turn off minor modes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50636
diff changeset
1378 (delete-selection-mode -1))
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1379 (if (and (boundp 'pc-selection-mode) pc-selection-mode)
51587
d7e174e9d6eb (cua-mode): Use explicit arg to turn off minor modes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50636
diff changeset
1380 (pc-selection-mode -1))
55341
7ee62cfb248c (cua-mode): Deactivate mark when cua-mode is enabled.
Kim F. Storm <storm@cua.dk>
parents: 55336
diff changeset
1381 (cua--deactivate)
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1382 (setq transient-mark-mode (and cua-mode
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1383 (if cua-highlight-region-shift-only
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1384 (not cua--explicit-region-start)
50636
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1385 t))))
45278
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1386 (cua--saved-state
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1387 (setq transient-mark-mode (car cua--saved-state))
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1388 (if (nth 1 cua--saved-state)
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1389 (delete-selection-mode 1))
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1390 (if (nth 2 cua--saved-state)
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1391 (pc-selection-mode 1))
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1392 (if (interactive-p)
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1393 (message "CUA mode disabled.%s%s%s%s"
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1394 (if (nth 1 cua--saved-state) " Delete-Selection" "")
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1395 (if (and (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " and" "")
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1396 (if (nth 2 cua--saved-state) " PC-Selection" "")
97b1e590eb61 (cua-enable-cursor-indications): Default off.
Kim F. Storm <storm@cua.dk>
parents: 45231
diff changeset
1397 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
50636
0af2d4122c02 (cua-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50382
diff changeset
1398 (setq cua--saved-state nil))))
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1399
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1400 (defun cua-debug ()
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1401 "Toggle cua debugging."
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1402 (interactive)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1403 (setq cua--debug (not cua--debug)))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1404
49898
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1405 ;; Install run-time check for older versions of CUA-mode which does not
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1406 ;; work with GNU Emacs version 21.4 and newer.
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1407 ;;
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1408 ;; Except for version 1.2, all of the 1.x and 2.x version of cua-mode
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1409 ;; provided the `CUA-mode' feature. Since this is no longer true,
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1410 ;; we can warn the user if the `CUA-mode' feature is ever provided.
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1411
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1412 ;;;###autoload (eval-after-load 'CUA-mode
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1413 ;;;###autoload '(error (concat "\n\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1414 ;;;###autoload "CUA-mode is now part of the standard GNU Emacs distribution,\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1415 ;;;###autoload "so you may now enable and customize CUA via the Options menu.\n\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1416 ;;;###autoload "Your " (file-name-nondirectory user-init-file) " loads an older version of CUA-mode which does\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1417 ;;;###autoload "not work correctly with this version of GNU Emacs.\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1418 ;;;###autoload "To correct this, remove the loading and customization of the\n"
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1419 ;;;###autoload "old version from the " user-init-file " file.\n\n")))
53baa12e5cee Add run-time check to catch users trying
Kim F. Storm <storm@cua.dk>
parents: 49598
diff changeset
1420
50060
b3e355e69315 Provide `cua' feature.
Kim F. Storm <storm@cua.dk>
parents: 50057
diff changeset
1421 (provide 'cua)
b3e355e69315 Provide `cua' feature.
Kim F. Storm <storm@cua.dk>
parents: 50057
diff changeset
1422
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51587
diff changeset
1423 ;;; arch-tag: 21fb6289-ba25-4fee-bfdc-f9fb351acf05
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1424 ;;; cua-base.el ends here