Mercurial > emacs
annotate lisp/kmacro.el @ 74890:3c0aa07a07ec
*** empty log message ***
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 25 Dec 2006 01:08:43 +0000 |
parents | d1491c6ae65d |
children | 3886a659959b f1d13e615070 |
rev | line source |
---|---|
46083 | 1 ;;; kmacro.el --- enhanced keyboard macros |
2 | |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64762
diff
changeset
|
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
46083 | 4 |
5 ;; Author: Kim F. Storm <storm@cua.dk> | |
46085
33538dc6ac79
Fixed copyright and keywords.
Kim F. Storm <storm@cua.dk>
parents:
46083
diff
changeset
|
6 ;; Keywords: keyboard convenience |
46083 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
46083 | 24 |
25 ;;; Commentary: | |
26 | |
74195 | 27 ;; The kmacro package provides the user interface to emacs' basic |
28 ;; keyboard macro functionality. With kmacro, two function keys are | |
29 ;; dedicated to keyboard macros, by default F3 and F4. | |
46083 | 30 |
74195 | 31 ;; Note: The traditional bindings C-x (, C-x ), and C-x e are still |
32 ;; supported, but for some users these bindings are too hard to type | |
33 ;; to be really useful for doing small repeated tasks. | |
34 | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
35 ;; To start defining a keyboard macro, use F3. To end the macro, |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
36 ;; use F4, and to call the macro also use F4. This makes it very |
46083 | 37 ;; easy to repeat a macro immediately after defining it. |
38 ;; | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
39 ;; You can call the macro repeatedly by pressing F4 multiple times, or |
46083 | 40 ;; you can give a numeric prefix argument specifying the number of |
41 ;; times to repeat the macro. Macro execution automatically | |
42 ;; terminates when point reaches the end of the buffer or if an error | |
43 ;; is signalled by ringing the bell. | |
44 | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
45 ;; When you define a macro with F3/F4, it is automatically added to |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
46 ;; the head of the "keyboard macro ring", and F4 actually executes the |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
47 ;; first element of the macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
48 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
49 ;; Note: an empty macro is never added to the macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
50 ;; |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
51 ;; You can execute the second element on the macro ring with C-u F4 or |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
52 ;; C-x C-k C-l, you can use C-x C-k C-p and C-x C-k C-n to cycle |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
53 ;; through the macro ring, and you can swap the first and second |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
54 ;; elements with C-x C-k C-t. To delete the first element in the |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
55 ;; macro ring, use C-x C-k C-d. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
56 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
57 ;; You can also use C-x C-k C-s to start a macro, and C-x C-k C-k to |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
58 ;; end it; then use C-k to execute it immediately, or C-x C-k C-k to |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
59 ;; execute it later. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
60 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
61 ;; In general, immediately after using C-x C-k followed by one of C-k, |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
62 ;; C-l, C-p, or C-n, you can further cycle the macro ring using C-p or |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
63 ;; C-n, execute the first or second macro using C-k or C-l, delete |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
64 ;; the head macro with C-d, or edit the current macro with C-e without |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
65 ;; repeating the C-x C-k prefix. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
66 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
67 ;; If you enter F3 while defining the macro, the numeric value of |
46083 | 68 ;; `kmacro-counter' is inserted using the `kmacro-counter-format', and |
69 ;; `kmacro-counter' is incremented by 1 (or the numeric prefix value | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
70 ;; of F3). |
46083 | 71 ;; |
72 ;; The initial value of `kmacro-counter' is 0, or the numeric prefix | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
73 ;; value given to F3 when starting the macro. |
46083 | 74 ;; |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
75 ;; Now, each time you call the macro using F4, the current |
46083 | 76 ;; value of `kmacro-counter' is inserted and incremented, making it |
77 ;; easy to insert incremental numbers in the buffer. | |
78 ;; | |
79 ;; Example: | |
80 ;; | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
81 ;; The following sequence: M-5 F3 x M-2 F3 y F4 F4 F4 F4 |
46083 | 82 ;; inserts the following string: x5yx7yx9yx11y |
83 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
84 ;; A macro can also be called using a mouse click, default S-mouse-3. |
46083 | 85 ;; This calls the macro at the point where you click the mouse. |
86 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
87 ;; You can edit the last macro using C-x C-k C-e. |
46083 | 88 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
89 ;; You can append to the last macro using C-u F3. |
46083 | 90 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
91 ;; You can set the macro counter using C-x C-k C-c, add to it using C-x C-k C-a, |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
92 ;; and you can set the macro counter format with C-x C-k C-f. |
46083 | 93 |
94 ;; The following key bindings are performed: | |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
95 ;; |
46083 | 96 ;; Normal While defining macro |
97 ;; --------------------------- ------------------------------ | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
98 ;; f3 Define macro Insert current counter value |
46083 | 99 ;; Prefix arg specifies initial and increase counter by prefix |
100 ;; counter value (default 0) (default increment: 1) | |
101 ;; | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
102 ;; C-u f3 APPENDs to last macro |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
103 ;; |
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
104 ;; f4 Call last macro End macro |
46083 | 105 ;; Prefix arg specifies number |
106 ;; of times to execute macro. | |
107 ;; | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
108 ;; C-u f4 Swap last and head of macro ring. |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
109 ;; |
46083 | 110 ;; S-mouse-3 Set point at click and End macro and execute macro at |
111 ;; execute last macro. click. | |
112 | |
113 ;;; Code: | |
114 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
115 ;; Customization: |
46083 | 116 |
117 (defgroup kmacro nil | |
118 "Simplified keyboard macro user interface." | |
119 :group 'keyboard | |
120 :group 'convenience | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58718
diff
changeset
|
121 :version "22.1" |
46083 | 122 :link '(emacs-commentary-link :tag "Commentary" "kmacro.el") |
123 :link '(emacs-library-link :tag "Lisp File" "kmacro.el")) | |
124 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
125 (defcustom kmacro-call-mouse-event 'S-mouse-3 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
126 "The mouse event used by kmacro to call a macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
127 Set to nil if no mouse binding is desired." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
128 :type 'symbol |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
129 :group 'kmacro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
130 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
131 (defcustom kmacro-ring-max 8 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
132 "Maximum number of keyboard macros to save in macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
133 :type 'integer |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
134 :group 'kmacro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
135 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
136 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
137 (defcustom kmacro-execute-before-append t |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
138 "Controls whether appending to a macro starts by executing the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
139 If non-nil, using a single \\[universal-argument] prefix executes the macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
140 before appending, while more than one \\[universal-argument] prefix does not |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
141 execute the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
142 Otherwise, a single \\[universal-argument] prefix does not execute the |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
143 macro, while more than one \\[universal-argument] prefix causes the |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
144 macro to be executed before appending to it." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
145 :type 'boolean |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
146 :group 'kmacro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
147 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
148 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
149 (defcustom kmacro-repeat-no-prefix t |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
150 "Allow repeating certain macro commands without entering the C-x C-k prefix." |
46083 | 151 :type 'boolean |
152 :group 'kmacro) | |
153 | |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
154 (defcustom kmacro-call-repeat-key t |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
155 "Allow repeating macro call using last key or a specific key." |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
156 :type '(choice (const :tag "Disabled" nil) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
157 (const :tag "Last key" t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
158 (character :tag "Character" :value ?e) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
159 (symbol :tag "Key symbol" :value RET)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
160 :group 'kmacro) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
161 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
162 (defcustom kmacro-call-repeat-with-arg nil |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
163 "Repeat macro call with original arg when non-nil; repeat once if nil." |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
164 :type 'boolean |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
165 :group 'kmacro) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
166 |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
167 (defcustom kmacro-step-edit-mini-window-height 0.75 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
168 "Override `max-mini-window-height' when step edit keyboard macro." |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
169 :type 'number |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
170 :group 'kmacro) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
171 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
172 ;; Keymap |
46083 | 173 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
174 (defvar kmacro-keymap |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
175 (let ((map (make-sparse-keymap))) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
176 ;; Start, end, execute macros |
47448
3a43982413a6
(kmacro-keymap): Changed bindings:
Kim F. Storm <storm@cua.dk>
parents:
47389
diff
changeset
|
177 (define-key map "s" 'kmacro-start-macro) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
178 (define-key map "\C-s" 'kmacro-start-macro) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
179 (define-key map "\C-k" 'kmacro-end-or-call-macro-repeat) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
180 (define-key map "r" 'apply-macro-to-region-lines) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
181 (define-key map "q" 'kbd-macro-query) ;; Like C-x q |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
182 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
183 ;; macro ring |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
184 (define-key map "\C-n" 'kmacro-cycle-ring-next) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
185 (define-key map "\C-p" 'kmacro-cycle-ring-previous) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
186 (define-key map "\C-v" 'kmacro-view-macro-repeat) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
187 (define-key map "\C-d" 'kmacro-delete-ring-head) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
188 (define-key map "\C-t" 'kmacro-swap-ring) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
189 (define-key map "\C-l" 'kmacro-call-ring-2nd-repeat) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
190 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
191 ;; macro counter |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
192 (define-key map "\C-f" 'kmacro-set-format) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
193 (define-key map "\C-c" 'kmacro-set-counter) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
194 (define-key map "\C-i" 'kmacro-insert-counter) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
195 (define-key map "\C-a" 'kmacro-add-counter) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
196 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
197 ;; macro editing |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
198 (define-key map "\C-e" 'kmacro-edit-macro-repeat) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
199 (define-key map "\r" 'kmacro-edit-macro) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
200 (define-key map "e" 'edit-kbd-macro) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
201 (define-key map "l" 'kmacro-edit-lossage) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
202 (define-key map " " 'kmacro-step-edit-macro) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
203 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
204 ;; naming and binding |
47448
3a43982413a6
(kmacro-keymap): Changed bindings:
Kim F. Storm <storm@cua.dk>
parents:
47389
diff
changeset
|
205 (define-key map "b" 'kmacro-bind-to-key) |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
206 (define-key map "n" 'kmacro-name-last-macro) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
207 map) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
208 "Keymap for keyboard macro commands.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
209 (defalias 'kmacro-keymap kmacro-keymap) |
46083 | 210 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
211 ;;; Provide some binding for startup: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
212 ;;;###autoload (global-set-key "\C-x(" 'kmacro-start-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
213 ;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
214 ;;;###autoload (global-set-key "\C-xe" 'kmacro-end-and-call-macro) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
215 ;;;###autoload (global-set-key [f3] 'kmacro-start-macro-or-insert-counter) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
216 ;;;###autoload (global-set-key [f4] 'kmacro-end-or-call-macro) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
217 ;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
218 ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap) |
46083 | 219 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
220 (if kmacro-call-mouse-event |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
221 (global-set-key (vector kmacro-call-mouse-event) 'kmacro-end-call-mouse)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
222 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
223 |
57854
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
224 ;;; Called from keyboard-quit |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
225 |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
226 (defun kmacro-keyboard-quit () |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
227 (or (not defining-kbd-macro) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
228 (eq defining-kbd-macro 'append) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
229 (kmacro-ring-empty-p) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
230 (kmacro-pop-ring))) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
231 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
232 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
233 ;;; Keyboard macro counter |
46083 | 234 |
235 (defvar kmacro-counter 0 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
236 "*Current keyboard macro counter.") |
46083 | 237 |
58718
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
238 (defvar kmacro-default-counter-format "%d") |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
239 |
46083 | 240 (defvar kmacro-counter-format "%d" |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
241 "*Current keyboard macro counter format.") |
46083 | 242 |
243 (defvar kmacro-counter-format-start kmacro-counter-format | |
244 "Macro format at start of macro execution.") | |
245 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
246 (defvar kmacro-counter-value-start kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
247 "Macro counter at start of macro execution.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
248 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
249 (defvar kmacro-last-counter 0 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
250 "Last counter inserted by key macro.") |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
251 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
252 (defvar kmacro-initial-counter-value nil |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
253 "Initial counter value for the next keyboard macro to be defined.") |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
254 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
255 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
256 (defun kmacro-insert-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
257 "Insert macro counter and increment with ARG or 1 if missing. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
258 With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
259 (interactive "P") |
57439
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
260 (if kmacro-initial-counter-value |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
261 (setq kmacro-counter kmacro-initial-counter-value |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
262 kmacro-initial-counter-value nil)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
263 (if (and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
264 (insert (format kmacro-counter-format kmacro-last-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
265 (insert (format kmacro-counter-format kmacro-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
266 (kmacro-add-counter (prefix-numeric-value arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
267 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
268 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
269 (defun kmacro-set-format (format) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
270 "Set macro counter FORMAT." |
58718
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
271 (interactive "sMacro Counter Format: ") |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
272 (setq kmacro-counter-format |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
273 (if (equal format "") "%d" format)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
274 ;; redefine initial macro counter if we are not executing a macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
275 (if (not (or defining-kbd-macro executing-kbd-macro)) |
58718
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
276 (setq kmacro-default-counter-format kmacro-counter-format))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
277 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
278 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
279 (defun kmacro-display-counter (&optional value) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
280 "Display current counter value." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
281 (unless value (setq value kmacro-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
282 (message "New macro counter value: %s (%d)" (format kmacro-counter-format value) value)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
283 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
284 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
285 (defun kmacro-set-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
286 "Set kmacro-counter to ARG or prompt if missing. |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
287 With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
288 (interactive "NMacro counter value: ") |
57439
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
289 (if (not (or defining-kbd-macro executing-kbd-macro)) |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
290 (kmacro-display-counter (setq kmacro-initial-counter-value arg)) |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
291 (setq kmacro-last-counter kmacro-counter |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
292 kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
293 kmacro-counter-value-start |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
294 arg)) |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
295 (unless executing-kbd-macro |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
296 (kmacro-display-counter)))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
297 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
298 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
299 (defun kmacro-add-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
300 "Add numeric prefix arg (prompt if missing) to macro counter. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
301 With \\[universal-argument], restore previous counter value." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
302 (interactive "NAdd to macro counter: ") |
57439
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
303 (if kmacro-initial-counter-value |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
304 (setq kmacro-counter kmacro-initial-counter-value |
e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
Kim F. Storm <storm@cua.dk>
parents:
57293
diff
changeset
|
305 kmacro-initial-counter-value nil)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
306 (let ((last kmacro-last-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
307 (setq kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
308 kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
309 last |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
310 kmacro-counter (+ kmacro-counter arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
311 (unless executing-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
312 (kmacro-display-counter))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
313 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
314 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
315 (defun kmacro-loop-setup-function () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
316 "Function called prior to each iteration of macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
317 ;; Restore macro counter format to initial format, so it is ok to change |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
318 ;; counter format in the macro without restoring it. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
319 (setq kmacro-counter-format kmacro-counter-format-start) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
320 ;; Save initial counter value so we can restore it with C-u kmacro-set-counter. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
321 (setq kmacro-counter-value-start kmacro-counter) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
322 ;; Return non-nil to continue execution. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
323 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
324 |
46083 | 325 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
326 ;;; Keyboard macro ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
327 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
328 (defvar kmacro-ring nil |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
329 "The keyboard macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
330 Each element is a list (MACRO COUNTER FORMAT). Actually, the head of |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
331 the macro ring (when defining or executing) is not stored in the ring; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
332 instead it is available in the variables `last-kbd-macro', `kmacro-counter', |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
333 and `kmacro-counter-format'.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
334 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
335 ;; Remember what we are currently looking at with kmacro-view-macro. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
336 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
337 (defvar kmacro-view-last-item nil) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
338 (defvar kmacro-view-item-no 0) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
339 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
340 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
341 (defun kmacro-ring-head () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
342 "Return pseudo head element in macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
343 (and last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
344 (list last-kbd-macro kmacro-counter kmacro-counter-format-start))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
345 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
346 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
347 (defun kmacro-push-ring (&optional elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
348 "Push ELT or current macro onto `kmacro-ring'." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
349 (when (setq elt (or elt (kmacro-ring-head))) |
70513
111b83914201
(kmacro-push-ring): Let-bind history-delete-duplicates
Kim F. Storm <storm@cua.dk>
parents:
70419
diff
changeset
|
350 (let ((history-delete-duplicates nil)) |
111b83914201
(kmacro-push-ring): Let-bind history-delete-duplicates
Kim F. Storm <storm@cua.dk>
parents:
70419
diff
changeset
|
351 (add-to-history 'kmacro-ring elt kmacro-ring-max)))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
352 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
353 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
354 (defun kmacro-split-ring-element (elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
355 (setq last-kbd-macro (car elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
356 kmacro-counter (nth 1 elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
357 kmacro-counter-format-start (nth 2 elt))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
358 |
46083 | 359 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
360 (defun kmacro-pop-ring1 (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
361 "Pop head element off macro ring (no check). |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
362 Non-nil arg RAW means just return raw first element." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
363 (prog1 (car kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
364 (unless raw |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
365 (kmacro-split-ring-element (car kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
366 (setq kmacro-ring (cdr kmacro-ring)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
367 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
368 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
369 (defun kmacro-pop-ring (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
370 "Pop head element off macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
371 Non-nil arg RAW means just return raw first element." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
372 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
373 (kmacro-pop-ring1 raw))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
374 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
375 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
376 (defun kmacro-ring-empty-p (&optional none) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
377 "Tell user and return t if `last-kbd-macro' is nil or `kmacro-ring' is empty. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
378 Check only `last-kbd-macro' if optional arg NONE is non-nil." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
379 (while (and (null last-kbd-macro) kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
380 (kmacro-pop-ring1)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
381 (cond |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
382 ((null last-kbd-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
383 (message "No keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
384 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
385 ((and (null none) (null kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
386 (message "Only one keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
387 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
388 (t nil))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
389 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
390 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
391 (defun kmacro-display (macro &optional trunc descr empty) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
392 "Display a keyboard MACRO. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
393 Optional arg TRUNC non-nil specifies to limit width of macro to 60 chars. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
394 Optional arg DESCR is descriptive text for macro; default is \"Macro:\". |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
395 Optional arg EMPTY is message to print if no macros are defined." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
396 (if macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
397 (let* ((x 60) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
398 (m (format-kbd-macro macro)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
399 (l (length m)) |
58718
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
400 (z (and trunc (> l x)))) |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
401 (message "%s%s: %s%s" (or descr "Macro") |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
402 (if (= kmacro-counter 0) "" |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
403 (format " [%s]" |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
404 (format kmacro-counter-format-start kmacro-counter))) |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
405 (if z (substring m 0 (1- x)) m) (if z "..." ""))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
406 (message (or empty "No keyboard macros defined")))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
407 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
408 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
409 (defun kmacro-repeat-on-last-key (keys) |
72518
0457084ce167
(kmacro-repeat-on-last-key): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
70513
diff
changeset
|
410 "Process kmacro commands keys immediately after cycling the ring." |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
411 (setq keys (vconcat keys)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
412 (let ((n (1- (length keys))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
413 cmd done repeat) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
414 (while (and last-kbd-macro |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
415 (not done) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
416 (aset keys n (read-event)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
417 (setq cmd (key-binding keys t)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
418 (setq repeat (get cmd 'kmacro-repeat))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
419 (clear-this-command-keys t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
420 (cond |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
421 ((eq repeat 'ring) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
422 (if kmacro-ring |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
423 (let ((kmacro-repeat-no-prefix nil)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
424 (funcall cmd nil)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
425 (kmacro-display last-kbd-macro t))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
426 ((eq repeat 'head) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
427 (let ((kmacro-repeat-no-prefix nil)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
428 (funcall cmd nil))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
429 ((eq repeat 'stop) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
430 (funcall cmd nil) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
431 (setq done t))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
432 (setq last-input-event nil))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
433 (when last-input-event |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
434 (clear-this-command-keys t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
435 (setq unread-command-events (list last-input-event)))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
436 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
437 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
438 (defun kmacro-get-repeat-prefix () |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
439 (let (keys) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
440 (and kmacro-repeat-no-prefix |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
441 (setq keys (this-single-command-keys)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
442 (> (length keys) 1) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
443 keys))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
444 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
445 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
446 (defun kmacro-exec-ring-item (item arg) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
447 "Execute item ITEM from the macro ring." |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
448 ;; Use counter and format specific to the macro on the ring! |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
449 (let ((kmacro-counter (nth 1 item)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
450 (kmacro-counter-format-start (nth 2 item))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
451 (execute-kbd-macro (car item) arg #'kmacro-loop-setup-function) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
452 (setcar (cdr item) kmacro-counter))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
453 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
454 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
455 (defun kmacro-call-ring-2nd (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
456 "Execute second keyboard macro at in macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
457 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
458 (unless (kmacro-ring-empty-p) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
459 (kmacro-exec-ring-item (car kmacro-ring) arg))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
460 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
461 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
462 (defun kmacro-call-ring-2nd-repeat (arg) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
463 "Execute second keyboard macro at in macro ring. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
464 This is like `kmacro-call-ring-2nd', but allows repeating macro commands |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
465 without repeating the prefix." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
466 (interactive "P") |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
467 (let ((keys (kmacro-get-repeat-prefix))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
468 (kmacro-call-ring-2nd arg) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
469 (if (and kmacro-ring keys) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
470 (kmacro-repeat-on-last-key keys)))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
471 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
472 (put 'kmacro-call-ring-2nd-repeat 'kmacro-repeat 'head) |
46083 | 473 |
474 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
475 (defun kmacro-view-ring-2nd () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
476 "Display the current head of the keyboard macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
477 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
478 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
479 (kmacro-display (car (car kmacro-ring)) "2nd macro"))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
480 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
481 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
482 (defun kmacro-cycle-ring-next (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
483 "Move to next keyboard macro in keyboard macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
484 Displays the selected macro in the echo area." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
485 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
486 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
487 (kmacro-push-ring) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
488 (let* ((keys (kmacro-get-repeat-prefix)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
489 (len (length kmacro-ring)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
490 (tail (nthcdr (- len 2) kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
491 (elt (car (cdr tail)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
492 (setcdr tail nil) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
493 (kmacro-split-ring-element elt) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
494 (kmacro-display last-kbd-macro t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
495 (if keys |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
496 (kmacro-repeat-on-last-key keys))))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
497 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
498 (put 'kmacro-cycle-ring-next 'kmacro-repeat 'ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
499 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
500 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
501 (defun kmacro-cycle-ring-previous (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
502 "Move to previous keyboard macro in keyboard macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
503 Displays the selected macro in the echo area." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
504 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
505 (unless (kmacro-ring-empty-p) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
506 (let ((keys (kmacro-get-repeat-prefix)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
507 (cur (kmacro-ring-head))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
508 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
509 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
510 (nconc kmacro-ring (list cur)) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
511 (setq kmacro-ring (list cur))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
512 (kmacro-display last-kbd-macro t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
513 (if keys |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
514 (kmacro-repeat-on-last-key keys))))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
515 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
516 (put 'kmacro-cycle-ring-previous 'kmacro-repeat 'ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
517 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
518 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
519 (defun kmacro-swap-ring () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
520 "Swap first two elements on keyboard macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
521 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
522 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
523 (let ((cur (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
524 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
525 (kmacro-push-ring cur)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
526 (kmacro-display last-kbd-macro t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
527 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
528 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
529 (defun kmacro-delete-ring-head (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
530 "Delete current macro from keyboard macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
531 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
532 (unless (kmacro-ring-empty-p t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
533 (if (null kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
534 (setq last-kbd-macro nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
535 (kmacro-pop-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
536 (kmacro-display last-kbd-macro t nil "Keyboard macro ring is now empty."))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
537 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
538 (put 'kmacro-delete-ring-head 'kmacro-repeat 'head) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
539 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
540 ;;; Traditional bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
541 |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
542 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
543 ;;;###autoload |
46083 | 544 (defun kmacro-start-macro (arg) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
545 "Record subsequent keyboard input, defining a keyboard macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
546 The commands are recorded even as they are executed. |
47051
11f467f2a131
(kmacro-start-macro): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
46972
diff
changeset
|
547 Use \\[kmacro-end-macro] to finish recording and make the macro available. |
47457
cff78e8e5a0a
(kmacro-start-macro): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
47448
diff
changeset
|
548 Use \\[kmacro-end-and-call-macro] to execute the macro. |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
549 |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
550 Non-nil arg (prefix arg) means append to last macro defined. |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
551 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
552 With \\[universal-argument] prefix, append to last keyboard macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
553 defined. Depending on `kmacro-execute-before-append', this may begin |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
554 by re-executing the last macro as if you typed it again. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
555 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
556 Otherwise, it sets `kmacro-counter' to ARG or 0 if missing before |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
557 defining the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
558 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
559 Use \\[kmacro-insert-counter] to insert (and increment) the macro counter. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
560 The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
561 The format of the counter can be modified via \\[kmacro-set-format]. |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
562 |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
563 Use \\[kmacro-name-last-macro] to give it a permanent name. |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
564 Use \\[kmacro-bind-to-key] to bind it to a key sequence." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
565 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
566 (if (or defining-kbd-macro executing-kbd-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
567 (message "Already defining keyboard macro.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
568 (let ((append (and arg (listp arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
569 (unless append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
570 (if last-kbd-macro |
70419
c18be7440465
(kmacro-push-ring): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
571 (kmacro-push-ring |
c18be7440465
(kmacro-push-ring): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
572 (list last-kbd-macro kmacro-counter kmacro-counter-format-start))) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
573 (setq kmacro-counter (or (if arg (prefix-numeric-value arg)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
574 kmacro-initial-counter-value |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
575 0) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
576 kmacro-initial-counter-value nil |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
577 kmacro-counter-value-start kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
578 kmacro-last-counter kmacro-counter |
58718
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
579 kmacro-counter-format kmacro-default-counter-format |
9a437a7c791c
(kmacro-default-counter-format): New var.
Luc Teirlinck <teirllm@auburn.edu>
parents:
57854
diff
changeset
|
580 kmacro-counter-format-start kmacro-default-counter-format)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
581 |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
582 (start-kbd-macro append |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
583 (and append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
584 (if kmacro-execute-before-append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
585 (> (car arg) 4) |
57854
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
586 (= (car arg) 4)))) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
587 (if (and defining-kbd-macro append) |
b017a1c31a53
(group kmacro): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57439
diff
changeset
|
588 (setq defining-kbd-macro 'append))))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
589 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
590 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
591 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
592 (defun kmacro-end-macro (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
593 "Finish defining a keyboard macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
594 The definition was started by \\[kmacro-start-macro]. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
595 The macro is now available for use via \\[kmacro-call-macro], |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
596 or it can be given a name with \\[kmacro-name-last-macro] and then invoked |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
597 under that name. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
598 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
599 With numeric arg, repeat macro now that many times, |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
600 counting the definition just completed as the first repetition. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
601 An argument of zero means repeat until error." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
602 (interactive "P") |
61130
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
603 ;; Isearch may push the kmacro-end-macro key sequence onto the macro. |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
604 ;; Just ignore it when executing the macro. |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
605 (unless executing-kbd-macro |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
606 (end-kbd-macro arg #'kmacro-loop-setup-function) |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
607 (when (and last-kbd-macro (= (length last-kbd-macro) 0)) |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
608 (message "Ignore empty macro") |
71175894291a
(kmacro-end-macro): Isearch may store this command
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
609 (kmacro-pop-ring)))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
610 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
611 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
612 ;;;###autoload |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
613 (defun kmacro-call-macro (arg &optional no-repeat end-macro) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
614 "Call the last keyboard macro that you defined with \\[kmacro-start-macro]. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
615 A prefix argument serves as a repeat count. Zero means repeat until error. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
616 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
617 When you call the macro, you can call the macro again by repeating |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
618 just the last key in the key sequence that you used to call this |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
619 command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg' |
63254
c51ca04c4fc7
(kmacro-call-macro): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62026
diff
changeset
|
620 for details on how to adjust or disable this behavior. |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
621 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
622 To make a macro permanent so you can call it even after defining |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
623 others, use \\[kmacro-name-last-macro]." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
624 (interactive "p") |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
625 (let ((repeat-key (and (null no-repeat) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
626 (> (length (this-single-command-keys)) 1) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
627 last-input-event)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
628 repeat-key-str) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
629 (if end-macro |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
630 (kmacro-end-macro arg) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
631 (call-last-kbd-macro arg #'kmacro-loop-setup-function)) |
47361
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
632 (when (consp arg) |
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
633 (setq arg (car arg))) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
634 (when (and (or (null arg) (> arg 0)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
635 (setq repeat-key |
47361
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
636 (if (eq kmacro-call-repeat-key t) |
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
637 repeat-key |
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
638 kmacro-call-repeat-key))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
639 (setq repeat-key-str (format-kbd-macro (vector repeat-key) nil)) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
640 (while repeat-key |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
641 (message "(Type %s to repeat macro%s)" |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
642 repeat-key-str |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
643 (if (and kmacro-call-repeat-with-arg |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
644 arg (> arg 1)) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
645 (format " %d times" arg) "")) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
646 (if (equal repeat-key (read-event)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
647 (progn |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
648 (clear-this-command-keys t) |
47361
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
649 (call-last-kbd-macro (and kmacro-call-repeat-with-arg arg) |
5e3418a37a64
(kmacro-call-macro): Deal with a non-numeric prefix arg.
Miles Bader <miles@gnu.org>
parents:
47310
diff
changeset
|
650 #'kmacro-loop-setup-function) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
651 (setq last-input-event nil)) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
652 (setq repeat-key nil))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
653 (when last-input-event |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
654 (clear-this-command-keys t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
655 (setq unread-command-events (list last-input-event)))))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
656 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
657 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
658 ;;; Combined function key bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
659 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
660 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
661 (defun kmacro-start-macro-or-insert-counter (arg) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
662 "Record subsequent keyboard input, defining a keyboard macro. |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
663 The commands are recorded even as they are executed. |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
664 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
665 Sets the `kmacro-counter' to ARG (or 0 if no prefix arg) before defining the |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
666 macro. |
46083 | 667 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
668 With \\[universal-argument], appends to current keyboard macro (keeping |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
669 the current value of `kmacro-counter'). |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
670 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
671 When defining/executing macro, inserts macro counter and increments |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
672 the counter with ARG or 1 if missing. With \\[universal-argument], |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
673 inserts previous kmacro-counter (but do not modify counter). |
46083 | 674 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
675 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. |
46083 | 676 The format of the counter can be modified via \\[kmacro-set-format]." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
677 (interactive "P") |
46083 | 678 (if (or defining-kbd-macro executing-kbd-macro) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
679 (kmacro-insert-counter arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
680 (kmacro-start-macro arg))) |
46083 | 681 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
682 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
683 ;;;###autoload |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
684 (defun kmacro-end-or-call-macro (arg &optional no-repeat) |
46083 | 685 "End kbd macro if currently being defined; else call last kbd macro. |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
686 With numeric prefix ARG, repeat macro that many times. |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
687 With \\[universal-argument], call second macro in macro ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
688 (interactive "P") |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
689 (cond |
46083 | 690 (defining-kbd-macro |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
691 (if kmacro-call-repeat-key |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
692 (kmacro-call-macro arg no-repeat t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
693 (kmacro-end-macro arg))) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
694 ((and (eq this-command 'kmacro-view-macro) ;; We are in repeat mode! |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
695 kmacro-view-last-item) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
696 (kmacro-exec-ring-item (car kmacro-view-last-item) arg)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
697 ((and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
698 (kmacro-call-ring-2nd 1)) |
46083 | 699 (t |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
700 (kmacro-call-macro arg no-repeat)))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
701 |
46083 | 702 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
703 (defun kmacro-end-or-call-macro-repeat (arg) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
704 "As `kmacro-end-or-call-macro' but allows repeat without repeating prefix." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
705 (interactive "P") |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
706 (let ((keys (kmacro-get-repeat-prefix))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
707 (kmacro-end-or-call-macro arg t) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
708 (if keys |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
709 (kmacro-repeat-on-last-key keys)))) |
46083 | 710 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
711 (put 'kmacro-end-or-call-macro-repeat 'kmacro-repeat 'head) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
712 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
713 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
714 ;;;###autoload |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
715 (defun kmacro-end-and-call-macro (arg &optional no-repeat) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
716 "Call last keyboard macro, ending it first if currently being defined. |
50425
5f447cd26b30
(kmacro-end-and-call-macro): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
49597
diff
changeset
|
717 With numeric prefix ARG, repeat macro that many times. |
5f447cd26b30
(kmacro-end-and-call-macro): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
49597
diff
changeset
|
718 Zero argument means repeat until there is an error. |
5f447cd26b30
(kmacro-end-and-call-macro): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
49597
diff
changeset
|
719 |
5f447cd26b30
(kmacro-end-and-call-macro): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
49597
diff
changeset
|
720 To give a macro a permanent name, so you can call it |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
721 even after defining other macros, use \\[kmacro-name-last-macro]." |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
722 (interactive "P") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
723 (if defining-kbd-macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
724 (kmacro-end-macro nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
725 (kmacro-call-macro arg no-repeat)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
726 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
727 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
728 ;;;###autoload |
46083 | 729 (defun kmacro-end-call-mouse (event) |
730 "Move point to the position clicked with the mouse and call last kbd macro. | |
731 If kbd macro currently being defined end it before activating it." | |
732 (interactive "e") | |
733 (when defining-kbd-macro | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
734 (end-kbd-macro)) |
46083 | 735 (mouse-set-point event) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
736 (kmacro-call-macro nil t)) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
737 |
46083 | 738 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
739 ;;; Misc. commands |
46083 | 740 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
741 ;; An idea for macro bindings: |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
742 ;; Create a separate keymap installed as a minor-mode keymap (e.g. in |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
743 ;; the emulation-mode-map-alists) in which macro bindings are made |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
744 ;; independent of any other bindings. When first binding is made, |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
745 ;; the kemap is created, installed, and enabled. Key seq. C-x C-k + |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
746 ;; can then be used to toggle the use of this keymap on and off. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
747 ;; This means that it would be safe(r) to bind ordinary keys like |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
748 ;; letters and digits, provided that we inhibit the keymap while |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
749 ;; executing the macro later on (but that's controversial...) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
750 |
57293
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
751 (defun kmacro-lambda-form (mac &optional counter format) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
752 "Create lambda form for macro bound to symbol or key." |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
753 (if counter |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
754 (setq mac (list mac counter format))) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
755 `(lambda (&optional arg) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
756 "Keyboard macro." |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
757 (interactive "p") |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
758 (kmacro-exec-ring-item ',mac arg))) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
759 |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
760 (defun kmacro-extract-lambda (mac) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
761 "Extract kmacro from a kmacro lambda form." |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
762 (and (consp mac) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
763 (eq (car mac) 'lambda) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
764 (setq mac (assoc 'kmacro-exec-ring-item mac)) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
765 (consp (cdr mac)) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
766 (consp (car (cdr mac))) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
767 (consp (cdr (car (cdr mac)))) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
768 (setq mac (car (cdr (car (cdr mac))))) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
769 (listp mac) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
770 (= (length mac) 3) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
771 (arrayp (car mac)) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
772 mac)) |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
773 |
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
774 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
775 (defun kmacro-bind-to-key (arg) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
776 "When not defining or executing a macro, offer to bind last macro to a key. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
777 The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
778 through [C-x C-k Z] are reserved for user bindings, and to bind to |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
779 one of these sequences, just enter the digit or letter, rather than |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
780 the whole sequence. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
781 |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
782 You can bind to any valid key sequence, but if you try to bind to |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
783 a key with an existing command binding, you will be asked for |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
784 confirmation whether to replace that binding. Note that the |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
785 binding is made in the `global-map' keymap, so the macro binding |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
786 may be shaded by a local key binding." |
46083 | 787 (interactive "p") |
788 (if (or defining-kbd-macro executing-kbd-macro) | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
789 (if defining-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
790 (message "Cannot save macro while defining it.")) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
791 (unless last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
792 (error "No keyboard macro defined")) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
793 (let ((key-seq (read-key-sequence "Bind last macro to key: ")) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
794 ok cmd) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
795 (when (= (length key-seq) 1) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
796 (let ((ch (aref key-seq 0))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
797 (if (or (and (>= ch ?0) (<= ch ?9)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
798 (and (>= ch ?A) (<= ch ?Z))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
799 (setq key-seq (concat "\C-x\C-k" key-seq) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
800 ok t)))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
801 (when (and (not (equal key-seq "")) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
802 (or ok |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
803 (not (setq cmd (key-binding key-seq))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
804 (stringp cmd) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
805 (vectorp cmd) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
806 (yes-or-no-p (format "%s runs command %S. Bind anyway? " |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
807 (format-kbd-macro key-seq) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
808 cmd)))) |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
809 (define-key global-map key-seq |
57293
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
810 (kmacro-lambda-form (kmacro-ring-head))) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
811 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
812 |
46083 | 813 |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
814 (defun kmacro-name-last-macro (symbol) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
815 "Assign a name to the last keyboard macro defined. |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
816 Argument SYMBOL is the name to define. |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
817 The symbol's function definition becomes the keyboard macro string. |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
818 Such a \"function\" cannot be called from Lisp, but it is a valid editor command." |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
819 (interactive "SName for last kbd macro: ") |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
820 (or last-kbd-macro |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
821 (error "No keyboard macro defined")) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
822 (and (fboundp symbol) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
823 (not (get symbol 'kmacro)) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
824 (not (stringp (symbol-function symbol))) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
825 (not (vectorp (symbol-function symbol))) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
826 (error "Function %s is already defined and not a keyboard macro" |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
827 symbol)) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
828 (if (string-equal symbol "") |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
829 (error "No command name given")) |
57293
cf6524063a28
(kmacro-lambda-form, kmacro-extract-lambda): Add.
Kim F. Storm <storm@cua.dk>
parents:
57078
diff
changeset
|
830 (fset symbol (kmacro-lambda-form (kmacro-ring-head))) |
57040
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
831 (put symbol 'kmacro t)) |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
832 |
0a2bd8959135
(kmacro-bind-to-key): Associate dedicated macro
Kim F. Storm <storm@cua.dk>
parents:
54547
diff
changeset
|
833 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
834 (defun kmacro-view-macro (&optional arg) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
835 "Display the last keyboard macro. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
836 If repeated, it shows previous elements in the macro ring." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
837 (interactive) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
838 (cond |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
839 ((or (kmacro-ring-empty-p) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
840 (not (eq last-command 'kmacro-view-macro))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
841 (setq kmacro-view-last-item nil)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
842 ((null kmacro-view-last-item) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
843 (setq kmacro-view-last-item kmacro-ring |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
844 kmacro-view-item-no 2)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
845 ((consp kmacro-view-last-item) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
846 (setq kmacro-view-last-item (cdr kmacro-view-last-item) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
847 kmacro-view-item-no (1+ kmacro-view-item-no))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
848 (t |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
849 (setq kmacro-view-last-item nil))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
850 (setq this-command 'kmacro-view-macro |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
851 last-command this-command) ;; in case we repeat |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
852 (kmacro-display (if kmacro-view-last-item |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
853 (car (car kmacro-view-last-item)) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
854 last-kbd-macro) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
855 nil |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
856 (if kmacro-view-last-item |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
857 (concat (cond ((= kmacro-view-item-no 2) "2nd") |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
858 ((= kmacro-view-item-no 3) "3nd") |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
859 (t (format "%dth" kmacro-view-item-no))) |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
860 " previous macro") |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
861 "Last macro"))) |
46083 | 862 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
863 (defun kmacro-view-macro-repeat (&optional arg) |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
864 "Display the last keyboard macro. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
865 If repeated, it shows previous elements in the macro ring. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
866 To execute the displayed macro ring item without changing the macro ring, |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
867 just enter C-k. |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
868 This is like `kmacro-view-macro', but allows repeating macro commands |
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
869 without repeating the prefix." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
870 (interactive) |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
871 (let ((keys (kmacro-get-repeat-prefix))) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
872 (kmacro-view-macro arg) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
873 (if (and last-kbd-macro keys) |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
874 (kmacro-repeat-on-last-key keys)))) |
46083 | 875 |
52223
d37e0b4125e8
(kmacro-keymap): Group related bindings in
Kim F. Storm <storm@cua.dk>
parents:
50425
diff
changeset
|
876 (put 'kmacro-view-macro-repeat 'kmacro-repeat 'ring) |
46083 | 877 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
878 |
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
879 (defun kmacro-edit-macro-repeat (&optional arg) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
880 "Edit last keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
881 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
882 (edit-kbd-macro "\r" arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
883 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
884 (put 'kmacro-edit-macro-repeat 'kmacro-repeat 'stop) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
885 |
46083 | 886 |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
887 (defun kmacro-edit-macro (&optional arg) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
888 "As edit last keyboard macro, but without kmacro-repeat property." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
889 (interactive "P") |
47094
cbc107c19e30
Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents:
47051
diff
changeset
|
890 (edit-kbd-macro "\r" arg)) |
46083 | 891 |
892 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
893 (defun kmacro-edit-lossage () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
894 "Edit most recent 100 keystrokes as a keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
895 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
896 (kmacro-push-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
897 (edit-kbd-macro "\C-hl")) |
46083 | 898 |
899 | |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
900 ;;; Single-step editing of keyboard macros |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
901 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
902 (defvar kmacro-step-edit-active) ;; step-editing active |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
903 (defvar kmacro-step-edit-new-macro) ;; storage for new macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
904 (defvar kmacro-step-edit-inserting) ;; inserting into macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
905 (defvar kmacro-step-edit-appending) ;; append to end of macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
906 (defvar kmacro-step-edit-replace) ;; replace orig macro when done |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
907 (defvar kmacro-step-edit-prefix-index) ;; index of first prefix arg key |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
908 (defvar kmacro-step-edit-key-index) ;; index of current key |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
909 (defvar kmacro-step-edit-action) ;; automatic action on next pre-command hook |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
910 (defvar kmacro-step-edit-help) ;; kmacro step edit help enabled |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
911 (defvar kmacro-step-edit-num-input-keys) ;; to ignore duplicate pre-command hook |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
912 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
913 (defvar kmacro-step-edit-map (make-sparse-keymap) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
914 "Keymap that defines the responses to questions in `kmacro-step-edit-macro'. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
915 This keymap is an extension to the `query-replace-map', allowing the |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
916 following additional answers: `insert', `insert-1', `replace', `replace-1', |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
917 `append', `append-end', `act-repeat', `skip-end', `skip-keep'.") |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
918 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
919 ;; query-replace-map answers include: `act', `skip', `act-and-show', |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
920 ;; `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
921 ;; `automatic', `backup', `exit-prefix', and `help'.") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
922 ;; Also: `quit', `edit-replacement' |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
923 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
924 (set-keymap-parent kmacro-step-edit-map query-replace-map) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
925 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
926 (define-key kmacro-step-edit-map "\t" 'act-repeat) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
927 (define-key kmacro-step-edit-map [tab] 'act-repeat) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
928 (define-key kmacro-step-edit-map "\C-k" 'skip-rest) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
929 (define-key kmacro-step-edit-map "c" 'automatic) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
930 (define-key kmacro-step-edit-map "f" 'skip-keep) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
931 (define-key kmacro-step-edit-map "q" 'quit) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
932 (define-key kmacro-step-edit-map "d" 'skip) |
47565
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
933 (define-key kmacro-step-edit-map "\C-d" 'skip) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
934 (define-key kmacro-step-edit-map "i" 'insert) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
935 (define-key kmacro-step-edit-map "I" 'insert-1) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
936 (define-key kmacro-step-edit-map "r" 'replace) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
937 (define-key kmacro-step-edit-map "R" 'replace-1) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
938 (define-key kmacro-step-edit-map "a" 'append) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
939 (define-key kmacro-step-edit-map "A" 'append-end) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
940 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
941 (defvar kmacro-step-edit-prefix-commands |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
942 '(universal-argument universal-argument-more universal-argument-minus |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
943 digit-argument negative-argument) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
944 "Commands which builds up a prefix arg for the current command") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
945 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
946 (defun kmacro-step-edit-prompt (macro index) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
947 ;; Show step-edit prompt |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
948 (let ((keys (and (not kmacro-step-edit-appending) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
949 index (substring macro index executing-kbd-macro-index))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
950 (future (and (not kmacro-step-edit-appending) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
951 (substring macro executing-kbd-macro-index))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
952 (message-log-max nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
953 (curmsg (current-message))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
954 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
955 ;; TODO: Scroll macro if max-mini-window-height is too small. |
57078
778b22aae530
(kmacro-step-edit-prompt): Add "%s" format to message.
Kim F. Storm <storm@cua.dk>
parents:
57040
diff
changeset
|
956 (message "%s" |
778b22aae530
(kmacro-step-edit-prompt): Add "%s" format to message.
Kim F. Storm <storm@cua.dk>
parents:
57040
diff
changeset
|
957 (concat |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
958 (format "Macro: %s%s%s%s%s\n" |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
959 (format-kbd-macro kmacro-step-edit-new-macro 1) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
960 (if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "") |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
961 (propertize (if keys (format-kbd-macro keys) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
962 (if kmacro-step-edit-appending "<APPEND>" "<INSERT>")) 'face 'region) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
963 (if future " " "") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
964 (if future (format-kbd-macro future) "")) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
965 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
966 ((minibufferp) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
967 (format "%s\n%s\n" |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
968 (propertize "\ |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
969 minibuffer " 'face 'header-line) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
970 (buffer-substring (point-min) (point-max)))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
971 (curmsg |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
972 (format "%s\n%s\n" |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
973 (propertize "\ |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
974 echo area " 'face 'header-line) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
975 curmsg)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
976 (t "")) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
977 (if keys |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
978 (format "%s\n%s%s %S [yn iIaArR C-k kq!] " |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
979 (propertize "\ |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
980 --------------Step Edit Keyboard Macro [?: help]---------------" 'face 'mode-line) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
981 (if kmacro-step-edit-help "\ |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
982 Step: y/SPC: execute next, d/n/DEL: skip next, f: skip but keep |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
983 TAB: execute while same, ?: toggle help |
47389 | 984 Edit: i: insert, r: replace, a: append, A: append at end, |
985 I/R: insert/replace with one sequence, | |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
986 End: !/c: execute rest, C-k: skip rest and save, q/C-g: quit |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
987 ---------------------------------------------------------------- |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
988 " "") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
989 (propertize "Next command:" 'face 'bold) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
990 this-command) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
991 (propertize |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
992 (format "Type key sequence%s to insert and execute%s: " |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
993 (if (numberp kmacro-step-edit-inserting) "" "s") |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
994 (if (numberp kmacro-step-edit-inserting) "" " (end with C-j)")) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
995 'face 'bold)))))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
996 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
997 (defun kmacro-step-edit-query () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
998 ;; Pre-command hook function for step-edit in "command" mode |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
999 (let ((resize-mini-windows t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1000 (max-mini-window-height kmacro-step-edit-mini-window-height) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1001 act restore-index next-index) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1002 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1003 ;; Handle commands which reads additional input using read-char. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1004 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1005 ((and (eq this-command 'quoted-insert) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1006 (not (eq kmacro-step-edit-action t))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1007 ;; Find the actual end of this key sequence. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1008 ;; Must be able to backtrack in case we actually execute it. |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1009 (setq restore-index executing-kbd-macro-index) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1010 (let (unread-command-events) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1011 (quoted-insert 0) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1012 (when unread-command-events |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1013 (setq executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events)) |
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1014 next-index executing-kbd-macro-index))))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1015 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1016 ;; Query the user; stop macro exection temporarily |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1017 (let ((macro executing-kbd-macro) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1018 (executing-kbd-macro nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1019 (defining-kbd-macro nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1020 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1021 ;; Any action requested by previous command |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1022 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1023 ((eq kmacro-step-edit-action t) ;; Reentry for actual command @ end of prefix arg. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1024 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1025 ((eq this-command 'quoted-insert) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1026 (clear-this-command-keys) ;; recent-keys actually |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1027 (let (unread-command-events) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1028 (quoted-insert (prefix-numeric-value current-prefix-arg)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
1029 (setq kmacro-step-edit-new-macro |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1030 (vconcat kmacro-step-edit-new-macro (recent-keys))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1031 (when unread-command-events |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1032 (setq kmacro-step-edit-new-macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1033 (substring kmacro-step-edit-new-macro 0 (- (length unread-command-events))) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1034 executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events))))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1035 (setq current-prefix-arg nil |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1036 prefix-arg nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1037 (setq act 'ignore)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1038 (t |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1039 (setq act 'act))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1040 (setq kmacro-step-edit-action nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1041 ((eq this-command kmacro-step-edit-action) ;; TAB -> activate while same command |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1042 (setq act 'act)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1043 (t |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1044 (setq kmacro-step-edit-action nil))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1045 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1046 ;; Handle prefix arg, or query user |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1047 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1048 (act act) ;; set above |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1049 ((memq this-command kmacro-step-edit-prefix-commands) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1050 (unless kmacro-step-edit-prefix-index |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1051 (setq kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1052 (setq act 'universal-argument)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1053 ((eq this-command 'universal-argument-other-key) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1054 (setq act 'universal-argument)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1055 (t |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1056 (kmacro-step-edit-prompt macro (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1057 (setq act (lookup-key kmacro-step-edit-map |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1058 (vector (with-current-buffer (current-buffer) (read-event)))))))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1059 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1060 ;; Resume macro execution and perform the action |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1061 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1062 ((eq act 'universal-argument) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1063 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1064 ((cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1065 ((eq act 'act) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1066 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1067 ((eq act 'act-repeat) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1068 (setq kmacro-step-edit-action this-command) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1069 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1070 ((eq act 'quit) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1071 (setq kmacro-step-edit-replace nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1072 (setq kmacro-step-edit-active 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1073 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1074 ((eq act 'skip) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1075 (setq kmacro-step-edit-prefix-index nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1076 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1077 ((eq act 'skip-keep) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1078 (setq this-command 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1079 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1080 ((eq act 'skip-rest) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1081 (setq kmacro-step-edit-active 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1082 nil) |
47565
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1083 ((memq act '(automatic exit)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1084 (setq kmacro-step-edit-active nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1085 (setq act t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1086 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1087 ((member act '(insert-1 insert)) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1088 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1089 (setq kmacro-step-edit-inserting (if (eq act 'insert-1) 1 t)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1090 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1091 ((member act '(replace-1 replace)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1092 (setq kmacro-step-edit-inserting (if (eq act 'replace-1) 1 t)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1093 (setq kmacro-step-edit-prefix-index nil) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1094 (if (= executing-kbd-macro-index (length executing-kbd-macro)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1095 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1096 kmacro-step-edit-appending t)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1097 nil) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1098 ((eq act 'append) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1099 (setq kmacro-step-edit-inserting t) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1100 (if (= executing-kbd-macro-index (length executing-kbd-macro)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1101 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1102 kmacro-step-edit-appending t)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1103 t) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1104 ((eq act 'append-end) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1105 (if (= executing-kbd-macro-index (length executing-kbd-macro)) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1106 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1107 kmacro-step-edit-inserting t |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1108 kmacro-step-edit-appending t) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1109 (setq kmacro-step-edit-active 'append-end)) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1110 (setq act t) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1111 t) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1112 ((eq act 'help) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1113 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1114 (setq kmacro-step-edit-help (not kmacro-step-edit-help)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1115 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1116 (t ;; Ignore unknown responses |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1117 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1118 nil)) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1119 (if (> executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1120 (setq kmacro-step-edit-new-macro |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1121 (vconcat kmacro-step-edit-new-macro |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47565
diff
changeset
|
1122 (substring executing-kbd-macro |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1123 (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1124 (if (eq act t) nil executing-kbd-macro-index))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1125 kmacro-step-edit-prefix-index nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1126 (if restore-index |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1127 (setq executing-kbd-macro-index restore-index))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1128 (t |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1129 (setq this-command 'ignore))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1130 (setq kmacro-step-edit-key-index next-index))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1131 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1132 (defun kmacro-step-edit-insert () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1133 ;; Pre-command hook function for step-edit in "insert" mode |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1134 (let ((resize-mini-windows t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1135 (max-mini-window-height kmacro-step-edit-mini-window-height) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1136 (macro executing-kbd-macro) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1137 (executing-kbd-macro nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1138 (defining-kbd-macro nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1139 cmd keys next-index) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1140 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1141 kmacro-step-edit-prefix-index nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1142 (kmacro-step-edit-prompt macro nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1143 ;; Now, we have read a key sequence from the macro, but we don't want |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1144 ;; to execute it yet. So push it back and read another sequence. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1145 (reset-this-command-lengths) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1146 (setq keys (read-key-sequence nil nil nil nil t)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1147 (setq cmd (key-binding keys t nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1148 (if (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1149 ((null cmd) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1150 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1151 ((eq cmd 'quoted-insert) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1152 (clear-this-command-keys) ;; recent-keys actually |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1153 (quoted-insert (prefix-numeric-value current-prefix-arg)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1154 (setq current-prefix-arg nil |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1155 prefix-arg nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1156 (setq keys (vconcat keys (recent-keys))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1157 (when (numberp kmacro-step-edit-inserting) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1158 (setq kmacro-step-edit-inserting nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1159 (when unread-command-events |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1160 (setq keys (substring keys 0 (- (length unread-command-events))) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1161 executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events)) |
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1162 next-index executing-kbd-macro-index |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1163 unread-command-events nil))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1164 (setq cmd 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1165 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1166 ((memq cmd kmacro-step-edit-prefix-commands) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1167 (setq universal-argument-num-events 0) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1168 (reset-this-command-lengths) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1169 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1170 ((eq cmd 'universal-argument-other-key) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1171 (setq kmacro-step-edit-action t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1172 (setq universal-argument-num-events 0) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1173 (reset-this-command-lengths) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1174 (if (numberp kmacro-step-edit-inserting) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1175 (setq kmacro-step-edit-inserting nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1176 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1177 ((numberp kmacro-step-edit-inserting) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1178 (setq kmacro-step-edit-inserting nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1179 nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1180 ((equal keys "\C-j") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1181 (setq kmacro-step-edit-inserting nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1182 (setq kmacro-step-edit-action nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1183 ;; Forget any (partial) prefix arg from next command |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1184 (setq kmacro-step-edit-prefix-index nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1185 (reset-this-command-lengths) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1186 (setq overriding-terminal-local-map nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1187 (setq universal-argument-num-events nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1188 (setq next-index kmacro-step-edit-key-index) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1189 t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1190 (t nil)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1191 (setq this-command 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1192 (setq this-command cmd) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1193 (if (memq this-command '(self-insert-command digit-argument)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1194 (setq last-command-char (aref keys (1- (length keys))))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1195 (if keys |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1196 (setq kmacro-step-edit-new-macro (vconcat kmacro-step-edit-new-macro keys)))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1197 (setq kmacro-step-edit-key-index next-index))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1198 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1199 (defun kmacro-step-edit-pre-command () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1200 (remove-hook 'post-command-hook 'kmacro-step-edit-post-command) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1201 (when kmacro-step-edit-active |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1202 (cond |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1203 ((eq kmacro-step-edit-active 'ignore) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1204 (setq this-command 'ignore)) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1205 ((eq kmacro-step-edit-active 'append-end) |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1206 (if (= executing-kbd-macro-index (length executing-kbd-macro)) |
47388
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1207 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1208 kmacro-step-edit-inserting t |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1209 kmacro-step-edit-appending t |
56bcf85aafae
(kmacro-call-macro): Rephrase repeat prompt.
Kim F. Storm <storm@cua.dk>
parents:
47361
diff
changeset
|
1210 kmacro-step-edit-active t))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1211 ((/= kmacro-step-edit-num-input-keys num-input-keys) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1212 (if kmacro-step-edit-inserting |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1213 (kmacro-step-edit-insert) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1214 (kmacro-step-edit-query)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1215 (setq kmacro-step-edit-num-input-keys num-input-keys) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1216 (if (and kmacro-step-edit-appending (not kmacro-step-edit-inserting)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1217 (setq kmacro-step-edit-appending nil |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1218 kmacro-step-edit-active 'ignore))))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1219 (when (eq kmacro-step-edit-active t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1220 (add-hook 'post-command-hook 'kmacro-step-edit-post-command t))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1221 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1222 (defun kmacro-step-edit-minibuf-setup () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1223 (remove-hook 'pre-command-hook 'kmacro-step-edit-pre-command t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1224 (when kmacro-step-edit-active |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1225 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil t))) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1226 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1227 (defun kmacro-step-edit-post-command () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1228 (remove-hook 'pre-command-hook 'kmacro-step-edit-pre-command) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1229 (when kmacro-step-edit-active |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1230 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1231 (if kmacro-step-edit-key-index |
62026
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1232 (setq executing-kbd-macro-index kmacro-step-edit-key-index) |
00ec9db40868
Use executing-kbd-macro-index variable.
Kim F. Storm <storm@cua.dk>
parents:
61130
diff
changeset
|
1233 (setq kmacro-step-edit-key-index executing-kbd-macro-index)))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1234 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1235 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1236 (defun kmacro-step-edit-macro () |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1237 "Step edit and execute last keyboard macro. |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1238 |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1239 To customize possible responses, change the \"bindings\" in `kmacro-step-edit-map'." |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1240 (interactive) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1241 (let ((kmacro-step-edit-active t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1242 (kmacro-step-edit-new-macro "") |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1243 (kmacro-step-edit-inserting nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1244 (kmacro-step-edit-appending nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1245 (kmacro-step-edit-replace t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1246 (kmacro-step-edit-prefix-index nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1247 (kmacro-step-edit-key-index 0) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1248 (kmacro-step-edit-action nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1249 (kmacro-step-edit-help nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1250 (kmacro-step-edit-num-input-keys num-input-keys) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1251 (pre-command-hook pre-command-hook) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1252 (post-command-hook post-command-hook) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1253 (minibuffer-setup-hook minibuffer-setup-hook)) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1254 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1255 (add-hook 'post-command-hook 'kmacro-step-edit-post-command t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1256 (add-hook 'minibuffer-setup-hook 'kmacro-step-edit-minibuf-setup t) |
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1257 (call-last-kbd-macro nil nil) |
47565
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1258 (when (and kmacro-step-edit-replace |
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1259 kmacro-step-edit-new-macro |
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1260 (not (equal last-kbd-macro kmacro-step-edit-new-macro))) |
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1261 (kmacro-push-ring) |
a02c3a1fc1ab
(kmacro-step-edit-query): Use RET to execute rest of
Kim F. Storm <storm@cua.dk>
parents:
47457
diff
changeset
|
1262 (setq last-kbd-macro kmacro-step-edit-new-macro)))) |
47310
5a8754f590f4
(kmacro-end-and-call-macro): New command to end and
Kim F. Storm <storm@cua.dk>
parents:
47094
diff
changeset
|
1263 |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
1264 (provide 'kmacro) |
52401 | 1265 |
1266 ;;; arch-tag: d3fe0b24-ae41-47de-a4d6-41a77d5559f0 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
1267 ;;; kmacro.el ends here |