Mercurial > emacs
annotate lisp/kmacro.el @ 47048:6d670ccc1c02
*** empty log message ***
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 27 Aug 2002 01:02:01 +0000 |
parents | 88b4ed0b18c9 |
children | 11f467f2a131 |
rev | line source |
---|---|
46083 | 1 ;;; kmacro.el --- enhanced keyboard macros |
2 | |
46085
33538dc6ac79
Fixed copyright and keywords.
Kim F. Storm <storm@cua.dk>
parents:
46083
diff
changeset
|
3 ;; Copyright (C) 2002 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 | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; The kmacro package is an alternative user interface to emacs' | |
28 ;; keyboard macro functionality. This functionality is normally bound | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
29 ;; to C-x (, C-x ), and C-x e, but these bindings are too hard to |
46083 | 30 ;; type to be really useful for doing small repeated tasks. |
31 | |
32 ;; With kmacro, two function keys are dedicated to keyboard macros, | |
33 ;; by default F7 and F8. Personally, I prefer F1 and F2, but those | |
34 ;; keys already have default bindings. | |
35 ;; | |
36 ;; To start defining a keyboard macro, use F7. To end the macro, | |
37 ;; use F8, and to call the macro also use F8. This makes it very | |
38 ;; easy to repeat a macro immediately after defining it. | |
39 ;; | |
40 ;; You can call the macro repeatedly by pressing F8 multiple times, or | |
41 ;; you can give a numeric prefix argument specifying the number of | |
42 ;; times to repeat the macro. Macro execution automatically | |
43 ;; terminates when point reaches the end of the buffer or if an error | |
44 ;; is signalled by ringing the bell. | |
45 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
46 ;; When you define a macro with F7/F8, it is automatically added to |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
47 ;; the head of the "keyboard macro ring", and F8 actually executes the |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
48 ;; first element of the macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
49 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
50 ;; 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
|
51 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
52 ;; You can execute the second element on the macro ring with C-u F8 or |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
53 ;; 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
|
54 ;; 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
|
55 ;; 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
|
56 ;; 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
|
57 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
58 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
59 ;; 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
|
60 ;; 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
|
61 ;; execute it later. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
62 ;; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
63 ;; 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
|
64 ;; 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
|
65 ;; 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
|
66 ;; 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
|
67 ;; 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
|
68 |
46083 | 69 ;; If you enter F7 while defining the macro, the numeric value of |
70 ;; `kmacro-counter' is inserted using the `kmacro-counter-format', and | |
71 ;; `kmacro-counter' is incremented by 1 (or the numeric prefix value | |
72 ;; of F7). | |
73 ;; | |
74 ;; The initial value of `kmacro-counter' is 0, or the numeric prefix | |
75 ;; value given to F7 when starting the macro. | |
76 ;; | |
77 ;; Now, each time you call the macro using F8, the current | |
78 ;; value of `kmacro-counter' is inserted and incremented, making it | |
79 ;; easy to insert incremental numbers in the buffer. | |
80 ;; | |
81 ;; Example: | |
82 ;; | |
83 ;; The following sequence: M-5 F7 x M-2 F7 y F8 F8 F8 F8 | |
84 ;; inserts the following string: x5yx7yx9yx11y | |
85 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
86 ;; A macro can also be called using a mouse click, default S-mouse-3. |
46083 | 87 ;; This calls the macro at the point where you click the mouse. |
88 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
89 ;; You can edit the last macro using C-x C-k C-e. |
46083 | 90 |
91 ;; You can append to the last macro using C-u F7. | |
92 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
93 ;; 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
|
94 ;; and you can set the macro counter format with C-x C-k C-f. |
46083 | 95 |
96 ;; The following key bindings are performed: | |
97 ;; | |
98 ;; Normal While defining macro | |
99 ;; --------------------------- ------------------------------ | |
100 ;; f7 Define macro Insert current counter value | |
101 ;; Prefix arg specifies initial and increase counter by prefix | |
102 ;; counter value (default 0) (default increment: 1) | |
103 ;; | |
104 ;; C-u f7 APPENDs to last macro | |
105 ;; | |
106 ;; f8 Call last macro End macro | |
107 ;; Prefix arg specifies number | |
108 ;; of times to execute macro. | |
109 ;; | |
110 ;; C-u f8 Swap last and head of macro ring. | |
111 ;; | |
112 ;; S-mouse-3 Set point at click and End macro and execute macro at | |
113 ;; execute last macro. click. | |
114 | |
115 ;;; Code: | |
116 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
117 ;; Customization: |
46083 | 118 |
119 (defgroup kmacro nil | |
120 "Simplified keyboard macro user interface." | |
121 :group 'keyboard | |
122 :group 'convenience | |
123 :link '(emacs-commentary-link :tag "Commentary" "kmacro.el") | |
124 :link '(emacs-library-link :tag "Lisp File" "kmacro.el")) | |
125 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
126 (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
|
127 "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
|
128 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
|
129 :type 'symbol |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
130 :group 'kmacro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
131 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
132 (defcustom kmacro-ring-max 8 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
133 "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
|
134 :type 'integer |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
135 :group 'kmacro) |
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 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
138 (defcustom kmacro-execute-before-append t |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
139 "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
|
140 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
|
141 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
|
142 execute the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 :type 'boolean |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
147 :group 'kmacro) |
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 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
150 (defcustom kmacro-repeat-no-prefix t |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
151 "Allow repeating certain macro commands without entering the C-x C-k prefix." |
46083 | 152 :type 'boolean |
153 :group 'kmacro) | |
154 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
155 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
156 ;; Keymap |
46083 | 157 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
158 (defvar kmacro-keymap |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
159 (let ((map (make-sparse-keymap))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
160 (define-key map "\C-s" 'kmacro-start-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
161 (define-key map "\C-k" 'kmacro-end-or-call-macro-rep) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
162 (define-key map "\C-e" 'kmacro-edit-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
163 (define-key map "\r" 'kmacro-edit-macro-nr) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
164 (define-key map "l" 'kmacro-edit-lossage) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
165 (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
|
166 (define-key map "\C-a" 'kmacro-add-counter) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
167 (define-key map "\C-v" 'kmacro-view-macro-rep) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
168 (define-key map "\C-l" 'kmacro-call-ring-2nd-rep) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
169 (define-key map "\C-r" 'kmacro-view-ring-2nd) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
170 (define-key map "\C-n" 'kmacro-cycle-ring-next) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
171 (define-key map "\C-p" 'kmacro-cycle-ring-previous) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
172 (define-key map "\C-f" 'kmacro-set-format) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
173 (define-key map "\C-c" 'kmacro-set-counter) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
174 (define-key map "\C-t" 'kmacro-swap-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
175 (define-key map "\C-b" 'kmacro-bind-to-key) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
176 (define-key map "\C-d" 'kmacro-delete-ring-head) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
177 ;; Compatibility bindings |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
178 (define-key map "q" 'kbd-macro-query) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
179 (define-key map "n" 'name-last-kbd-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
180 (define-key map "e" 'edit-kbd-macro) |
46972
88b4ed0b18c9
Bind C-x C-k r to apply-macro-to-region-lines.
Kim F. Storm <storm@cua.dk>
parents:
46961
diff
changeset
|
181 (define-key map "r" 'apply-macro-to-region-lines) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
182 map) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
183 "Keymap for keyboard macro commands.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
184 (defalias 'kmacro-keymap kmacro-keymap) |
46083 | 185 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
186 ;;; Provide some binding for startup: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
187 ;;;###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
|
188 ;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
189 ;;;###autoload (global-set-key "\C-xe" 'kmacro-call-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
190 ;;;###autoload (global-set-key [f7] 'kmacro-start-macro-or-insert-counter) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
191 ;;;###autoload (global-set-key [f8] 'kmacro-end-or-call-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
192 ;;;###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
|
193 ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap) |
46083 | 194 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
195 (if kmacro-call-mouse-event |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
196 (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
|
197 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
198 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
199 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
200 ;;; Keyboard macro counter |
46083 | 201 |
202 (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
|
203 "*Current keyboard macro counter.") |
46083 | 204 |
205 (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
|
206 "*Current keyboard macro counter format.") |
46083 | 207 |
208 (defvar kmacro-counter-format-start kmacro-counter-format | |
209 "Macro format at start of macro execution.") | |
210 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
211 (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
|
212 "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
|
213 |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
214 (defvar kmacro-last-counter 0 "Last counter inserted by key macro.") |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
215 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
216 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
217 (defun kmacro-insert-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
218 "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
|
219 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
|
220 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
221 (if (and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
222 (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
|
223 (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
|
224 (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
|
225 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
226 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
227 (defun kmacro-set-format (format) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
228 "Set macro counter FORMAT." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
229 (interactive "sMacro Counter Format (printf format): ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
230 (setq kmacro-counter-format |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
231 (if (equal format "") "%d" format)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
232 ;; 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
|
233 (if (not (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
|
234 (setq kmacro-counter-format-start kmacro-counter-format))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
235 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
236 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
237 (defun kmacro-display-counter (&optional value) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
238 "Display current counter value." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
239 (unless value (setq value kmacro-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
240 (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
|
241 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
242 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
243 (defun kmacro-set-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
244 "Set kmacro-counter to ARG or prompt if missing. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
245 With \\[universal-argument], reset counter to its value prior to this iteration of the macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
246 (interactive "NMacro counter value: ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
247 (setq kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
248 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
|
249 kmacro-counter-value-start |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
250 arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
251 (unless executing-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
252 (kmacro-display-counter))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
253 |
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 (defun kmacro-add-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
256 "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
|
257 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
|
258 (interactive "NAdd to macro counter: ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
259 (let ((last kmacro-last-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
260 (setq kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
261 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
|
262 last |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
263 kmacro-counter (+ kmacro-counter arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
264 (unless executing-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
265 (kmacro-display-counter))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
266 |
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 (defun kmacro-loop-setup-function () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
269 "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
|
270 ;; 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
|
271 ;; 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
|
272 (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
|
273 ;; 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
|
274 (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
|
275 ;; Return non-nil to continue execution. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
276 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
277 |
46083 | 278 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
279 ;;; Keyboard macro ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
280 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
281 (defvar kmacro-ring nil |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
282 "The keyboard macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
283 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
|
284 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
|
285 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
|
286 and `kmacro-counter-format'.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
287 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
288 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
289 (defun kmacro-ring-head () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
290 "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
|
291 (and last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
292 (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
|
293 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
294 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
295 (defun kmacro-push-ring (&optional elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
296 "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
|
297 (when (setq elt (or elt (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
298 (let ((len (length kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
299 (setq kmacro-ring (cons elt kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
300 (if (>= len kmacro-ring-max) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
301 (setcdr (nthcdr len kmacro-ring) nil))))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
302 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
303 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
304 (defun kmacro-split-ring-element (elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
305 (setq last-kbd-macro (car elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
306 kmacro-counter (nth 1 elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
307 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
|
308 |
46083 | 309 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
310 (defun kmacro-pop-ring1 (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
311 "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
|
312 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
|
313 (prog1 (car kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
314 (unless raw |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
315 (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
|
316 (setq kmacro-ring (cdr kmacro-ring)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
317 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
318 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
319 (defun kmacro-pop-ring (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
320 "Pop head element off macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
321 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
|
322 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
323 (kmacro-pop-ring1 raw))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
324 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
325 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
326 (defun kmacro-ring-length () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
327 "Return length of macro ring, including pseudo head." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
328 (+ (if last-kbd-macro 1 0) (length kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
329 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
330 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
331 (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
|
332 "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
|
333 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
|
334 (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
|
335 (kmacro-pop-ring1)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
336 (cond |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
337 ((null last-kbd-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
338 (message "No keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
339 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
340 ((and (null none) (null kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
341 (message "Only one keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
342 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
343 (t nil))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
344 |
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 (defun kmacro-display (macro &optional trunc descr empty ) |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
347 "Display a keyboard MACRO." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
348 (if macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
349 (let* ((x 60) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
350 (m (format-kbd-macro macro)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
351 (l (length m)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
352 (z (and nil trunc (> l x)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
353 (message (format "%s: %s%s" (or descr "Macro") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
354 (if z (substring m 0 (1- x)) m) (if z "..." "")))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
355 (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
|
356 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
357 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
358 (defun kmacro-call-ring-2nd (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
359 "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
|
360 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
361 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
362 ;; should use counter format specific to the macro on the ring! |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
363 (let ((kmacro-counter (nth 1 (car kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
364 (kmacro-counter-format-start (nth 2 (car kmacro-ring)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
365 (execute-kbd-macro (car (car kmacro-ring)) arg #'kmacro-loop-setup-function) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
366 (setcar (cdr (car kmacro-ring)) kmacro-counter)))) |
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-call-ring-2nd-rep (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
370 "Like `kmacro-call-ring-2nd', but allow repeat without kmacro prefix." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
371 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
372 (kmacro-call-ring-2nd arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
373 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
374 (kmacro-repeat-loop))) |
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 (put 'kmacro-call-ring-2nd-rep 'kmacro-repeat 'head) |
46083 | 377 |
378 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
379 (defun kmacro-view-ring-2nd () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
380 "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
|
381 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
382 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
383 (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
|
384 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
385 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
386 (defun kmacro-repeat-loop () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
387 "Process kmacro commands keys immidiately after cycling the ring." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
388 (when kmacro-repeat-no-prefix |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
389 (let (cmd done repeat) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
390 (while (and last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
391 (not done) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
392 (setq cmd (lookup-key kmacro-keymap (vector (read-event)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
393 (setq repeat (get cmd 'kmacro-repeat))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
394 (clear-this-command-keys t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
395 (cond |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
396 ((eq repeat 'ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
397 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
398 (let ((kmacro-repeat-no-prefix nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
399 (funcall cmd nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
400 (kmacro-display last-kbd-macro t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
401 ((eq repeat 'head) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
402 (funcall cmd nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
403 ((eq repeat 'stop) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
404 (funcall cmd nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
405 (setq done t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
406 (setq last-input-event nil))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
407 (when last-input-event |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
408 (clear-this-command-keys t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
409 (setq unread-command-events (list last-input-event))))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
410 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
411 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
412 (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
|
413 "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
|
414 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
|
415 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
416 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
417 (kmacro-push-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
418 (let* ((len (length kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
419 (tail (nthcdr (- len 2) kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
420 (elt (car (cdr tail)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
421 (setcdr tail nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
422 (kmacro-split-ring-element elt)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
423 (kmacro-display last-kbd-macro t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
424 (kmacro-repeat-loop))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
425 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
426 (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
|
427 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
428 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
429 (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
|
430 "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
|
431 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
|
432 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
433 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
434 (let ((cur (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
435 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
436 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
437 (nconc kmacro-ring (list cur)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
438 (setq kmacro-ring (list cur)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
439 (kmacro-display last-kbd-macro t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
440 (kmacro-repeat-loop))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
441 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
442 (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
|
443 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
444 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
445 (defun kmacro-swap-ring () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
446 "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
|
447 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
448 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
449 (let ((cur (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
450 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
451 (kmacro-push-ring cur)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
452 (kmacro-display last-kbd-macro t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
453 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
454 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
455 (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
|
456 "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
|
457 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
458 (unless (kmacro-ring-empty-p t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
459 (if (null kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
460 (setq last-kbd-macro nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
461 (kmacro-pop-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
462 (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
|
463 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
464 (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
|
465 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
466 ;;; Traditional bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
467 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
468 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
469 ;;;###autoload |
46083 | 470 (defun kmacro-start-macro (arg) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
471 "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
|
472 The commands are recorded even as they are executed. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
473 Use \\[end-kbd-macro] to finish recording and make the macro available. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
474 Use \\[call-last-kbd-macro] to execute the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
475 Use \\[name-last-kbd-macro] to give it a permanent name. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
476 Non-nil arg (prefix arg) means append to last macro defined; |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
477 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
478 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
|
479 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
|
480 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
|
481 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
482 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
|
483 defining the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
484 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
485 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
|
486 The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
487 The format of the counter can be modified via \\[kmacro-set-format]." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
488 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
489 (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
|
490 (message "Already defining keyboard macro.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
491 (let ((append (and arg (listp arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
492 (unless append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
493 (if last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
494 (let ((len (length kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
495 (setq kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
496 (cons |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
497 (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
|
498 kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
499 (if (>= len kmacro-ring-max) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
500 (setcdr (nthcdr len kmacro-ring) nil)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
501 (setq kmacro-counter (if arg (prefix-numeric-value arg) 0) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
502 kmacro-counter-value-start kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
503 kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
504 kmacro-counter-format-start kmacro-counter-format)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
505 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
506 (start-kbd-macro append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
507 (and append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
508 (if kmacro-execute-before-append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
509 (> (car arg) 4) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
510 (= (car arg) 4))))))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
511 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
512 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
513 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
514 (defun kmacro-end-macro (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
515 "Finish defining a keyboard macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
516 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
|
517 The macro is now available for use via \\[kmacro-call-macro], |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
518 or it can be given a name with \\[name-last-kbd-macro] and then invoked |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
519 under that name. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
520 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
521 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
|
522 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
|
523 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
|
524 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
525 (end-kbd-macro arg #'kmacro-loop-setup-function) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
526 (when (and last-kbd-macro (= (length last-kbd-macro) 0)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
527 (message "Ignore empty macro") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
528 (kmacro-pop-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
529 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
530 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
531 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
532 (defun kmacro-call-macro (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
533 "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
|
534 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
535 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
|
536 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
537 To make a macro permanent so you can call it even after |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
538 defining others, use M-x name-last-kbd-macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
539 (interactive "p") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
540 (call-last-kbd-macro arg #'kmacro-loop-setup-function)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
541 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
542 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
543 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
544 ;;; Combined function key bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
545 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
546 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
547 (defun kmacro-start-macro-or-insert-counter (arg) |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
548 "Set `kmacro-counter' to ARG or 0 if missing, and `start-kbd-macro'. |
46083 | 549 With \\[universal-argument], append to current keyboard macro (keep kmacro-counter). |
550 | |
551 When defining/executing macro, insert macro counter and increment with | |
552 ARG or 1 if missing. | |
553 With \\[universal-argument], insert previous kmacro-counter (but do not modify counter). | |
554 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
555 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. |
46083 | 556 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
|
557 (interactive "P") |
46083 | 558 (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
|
559 (kmacro-insert-counter arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
560 (kmacro-start-macro arg))) |
46083 | 561 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
562 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
563 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
564 (defun kmacro-end-or-call-macro (arg) |
46083 | 565 "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
|
566 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
|
567 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
|
568 (interactive "P") |
46083 | 569 (cond |
570 (defining-kbd-macro | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
571 (kmacro-end-macro arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
572 ((and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
573 (kmacro-call-ring-2nd 1)) |
46083 | 574 (t |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
575 (kmacro-call-macro arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
576 |
46083 | 577 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
578 (defun kmacro-end-or-call-macro-rep (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
579 "As `kmacro-end-or-call-macro' but allows repeat without kmacro prefix." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
580 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
581 (kmacro-end-or-call-macro arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
582 (kmacro-repeat-loop)) |
46083 | 583 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
584 (put 'kmacro-end-or-call-macro-rep 'kmacro-repeat 'head) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
585 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
586 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
587 ;;;###autoload |
46083 | 588 (defun kmacro-end-call-mouse (event) |
589 "Move point to the position clicked with the mouse and call last kbd macro. | |
590 If kbd macro currently being defined end it before activating it." | |
591 (interactive "e") | |
592 (when defining-kbd-macro | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
593 (end-kbd-macro)) |
46083 | 594 (mouse-set-point event) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
595 (kmacro-call-macro nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
596 |
46083 | 597 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
598 ;;; Misc. commands |
46083 | 599 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
600 (defun kmacro-bind-to-key (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
601 "When not defining or executing a macro, offer to bind last macro to a key." |
46083 | 602 (interactive "p") |
603 (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
|
604 (if defining-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
605 (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
|
606 (unless last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
607 (error "No keyboard macro defined")) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
608 (let ((key-seq (read-key-sequence "Bind last macro to key: "))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
609 (unless (equal key-seq "") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
610 (define-key global-map key-seq last-kbd-macro))))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
611 |
46083 | 612 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
613 (defun kmacro-view-macro (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
614 "Display the last keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
615 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
616 (kmacro-display last-kbd-macro)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
617 |
46083 | 618 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
619 (defun kmacro-view-macro-rep (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
620 "Like `kmacro-view-macro', but allow repeat without kmacro prefix." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
621 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
622 (kmacro-view-macro arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
623 (if last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
624 (kmacro-repeat-loop))) |
46083 | 625 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
626 (put 'kmacro-view-macro-rep 'kmacro-repeat 'head) |
46083 | 627 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
628 (defun kmacro-edit-macro (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
629 "Edit last keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
630 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
631 (edit-kbd-macro "\r" arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
632 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
633 (put 'kmacro-edit-macro 'kmacro-repeat 'stop) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
634 |
46083 | 635 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
636 (defun kmacro-edit-macro-nr (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
637 "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
|
638 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
639 (kmacro-edit-macro arg)) |
46083 | 640 |
641 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
642 (defun kmacro-edit-lossage () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
643 "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
|
644 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
645 (kmacro-push-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
646 (edit-kbd-macro "\C-hl")) |
46083 | 647 |
648 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
649 (provide 'kmacro) |
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
650 ;;; kmacro.el ends here |