Mercurial > emacs
annotate lisp/kmacro.el @ 46969:f0c8da8c1856
Remove macro related bindings (now in kmacro.el).
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 20 Aug 2002 09:05:33 +0000 |
parents | 7e8358ec31ba |
children | 88b4ed0b18c9 |
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) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
181 map) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
182 "Keymap for keyboard macro commands.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
183 (defalias 'kmacro-keymap kmacro-keymap) |
46083 | 184 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
185 ;;; Provide some binding for startup: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
186 ;;;###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
|
187 ;;;###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
|
188 ;;;###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
|
189 ;;;###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
|
190 ;;;###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
|
191 ;;;###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
|
192 ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap) |
46083 | 193 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
194 (if kmacro-call-mouse-event |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
195 (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
|
196 |
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 ;;; Keyboard macro counter |
46083 | 200 |
201 (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
|
202 "*Current keyboard macro counter.") |
46083 | 203 |
204 (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
|
205 "*Current keyboard macro counter format.") |
46083 | 206 |
207 (defvar kmacro-counter-format-start kmacro-counter-format | |
208 "Macro format at start of macro execution.") | |
209 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
210 (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
|
211 "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
|
212 |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
213 (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
|
214 |
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 (defun kmacro-insert-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
217 "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
|
218 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
|
219 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
220 (if (and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
221 (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
|
222 (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
|
223 (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
|
224 |
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 (defun kmacro-set-format (format) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
227 "Set macro counter FORMAT." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
228 (interactive "sMacro Counter Format (printf format): ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
229 (setq kmacro-counter-format |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
230 (if (equal format "") "%d" format)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
231 ;; 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
|
232 (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
|
233 (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
|
234 |
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 (defun kmacro-display-counter (&optional value) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
237 "Display current counter value." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
238 (unless value (setq value kmacro-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
239 (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
|
240 |
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 (defun kmacro-set-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
243 "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
|
244 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
|
245 (interactive "NMacro counter value: ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
246 (setq kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
247 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
|
248 kmacro-counter-value-start |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
249 arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
250 (unless executing-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
251 (kmacro-display-counter))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
252 |
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 (defun kmacro-add-counter (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
255 "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
|
256 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
|
257 (interactive "NAdd to macro counter: ") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
258 (let ((last kmacro-last-counter)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
259 (setq kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
260 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
|
261 last |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
262 kmacro-counter (+ kmacro-counter arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
263 (unless executing-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
264 (kmacro-display-counter))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
265 |
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 (defun kmacro-loop-setup-function () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
268 "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
|
269 ;; 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
|
270 ;; 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
|
271 (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
|
272 ;; 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
|
273 (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
|
274 ;; Return non-nil to continue execution. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
275 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
276 |
46083 | 277 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
278 ;;; Keyboard macro ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
279 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
280 (defvar kmacro-ring nil |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
281 "The keyboard macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
282 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
|
283 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
|
284 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
|
285 and `kmacro-counter-format'.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
286 |
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 (defun kmacro-ring-head () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
289 "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
|
290 (and last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
291 (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
|
292 |
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 (defun kmacro-push-ring (&optional elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
295 "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
|
296 (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
|
297 (let ((len (length kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
298 (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
|
299 (if (>= len kmacro-ring-max) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
300 (setcdr (nthcdr len kmacro-ring) nil))))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
301 |
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 (defun kmacro-split-ring-element (elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
304 (setq last-kbd-macro (car elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
305 kmacro-counter (nth 1 elt) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
306 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
|
307 |
46083 | 308 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
309 (defun kmacro-pop-ring1 (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
310 "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
|
311 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
|
312 (prog1 (car kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
313 (unless raw |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
314 (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
|
315 (setq kmacro-ring (cdr kmacro-ring)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
316 |
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 (defun kmacro-pop-ring (&optional raw) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
319 "Pop head element off macro ring. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
320 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
|
321 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
322 (kmacro-pop-ring1 raw))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
323 |
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 (defun kmacro-ring-length () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
326 "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
|
327 (+ (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
|
328 |
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 (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
|
331 "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
|
332 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
|
333 (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
|
334 (kmacro-pop-ring1)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
335 (cond |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
336 ((null last-kbd-macro) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
337 (message "No keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
338 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
339 ((and (null none) (null kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
340 (message "Only one keyboard macro defined.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
341 t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
342 (t nil))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
343 |
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 (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
|
346 "Display a keyboard MACRO." |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
347 (if macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
348 (let* ((x 60) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
349 (m (format-kbd-macro macro)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
350 (l (length m)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
351 (z (and nil trunc (> l x)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
352 (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
|
353 (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
|
354 (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
|
355 |
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 (defun kmacro-call-ring-2nd (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
358 "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
|
359 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
360 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
361 ;; 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
|
362 (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
|
363 (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
|
364 (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
|
365 (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
|
366 |
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 (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
|
369 "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
|
370 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
371 (kmacro-call-ring-2nd arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
372 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
373 (kmacro-repeat-loop))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
374 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
375 (put 'kmacro-call-ring-2nd-rep 'kmacro-repeat 'head) |
46083 | 376 |
377 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
378 (defun kmacro-view-ring-2nd () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
379 "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
|
380 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
381 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
382 (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
|
383 |
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 (defun kmacro-repeat-loop () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
386 "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
|
387 (when kmacro-repeat-no-prefix |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
388 (let (cmd done repeat) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
389 (while (and last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
390 (not done) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
391 (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
|
392 (setq repeat (get cmd 'kmacro-repeat))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
393 (clear-this-command-keys t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
394 (cond |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
395 ((eq repeat 'ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
396 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
397 (let ((kmacro-repeat-no-prefix nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
398 (funcall cmd nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
399 (kmacro-display last-kbd-macro t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
400 ((eq repeat 'head) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
401 (funcall cmd nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
402 ((eq repeat 'stop) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
403 (funcall cmd nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
404 (setq done t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
405 (setq last-input-event nil))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
406 (when last-input-event |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
407 (clear-this-command-keys t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
408 (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
|
409 |
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 (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
|
412 "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
|
413 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
|
414 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
415 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
416 (kmacro-push-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
417 (let* ((len (length kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
418 (tail (nthcdr (- len 2) kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
419 (elt (car (cdr tail)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
420 (setcdr tail nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
421 (kmacro-split-ring-element elt)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
422 (kmacro-display last-kbd-macro t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
423 (kmacro-repeat-loop))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
424 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
425 (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
|
426 |
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 (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
|
429 "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
|
430 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
|
431 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
432 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
433 (let ((cur (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
434 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
435 (if kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
436 (nconc kmacro-ring (list cur)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
437 (setq kmacro-ring (list cur)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
438 (kmacro-display last-kbd-macro t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
439 (kmacro-repeat-loop))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
440 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
441 (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
|
442 |
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 (defun kmacro-swap-ring () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
445 "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
|
446 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
447 (unless (kmacro-ring-empty-p) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
448 (let ((cur (kmacro-ring-head))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
449 (kmacro-pop-ring1) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
450 (kmacro-push-ring cur)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
451 (kmacro-display last-kbd-macro t))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
452 |
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 (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
|
455 "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
|
456 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
457 (unless (kmacro-ring-empty-p t) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
458 (if (null kmacro-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
459 (setq last-kbd-macro nil) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
460 (kmacro-pop-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
461 (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
|
462 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
463 (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
|
464 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
465 ;;; Traditional bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
466 |
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 ;;;###autoload |
46083 | 469 (defun kmacro-start-macro (arg) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
470 "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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
477 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
|
478 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
|
479 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
|
480 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
481 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
|
482 defining the macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
483 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
488 (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
|
489 (message "Already defining keyboard macro.") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
490 (let ((append (and arg (listp arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
491 (unless append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
492 (if last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
493 (let ((len (length kmacro-ring))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
494 (setq kmacro-ring |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
495 (cons |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
496 (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
|
497 kmacro-ring)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
498 (if (>= len kmacro-ring-max) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
499 (setcdr (nthcdr len kmacro-ring) nil)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
500 (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
|
501 kmacro-counter-value-start kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
502 kmacro-last-counter kmacro-counter |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
503 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
|
504 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
505 (start-kbd-macro append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
506 (and append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
507 (if kmacro-execute-before-append |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
508 (> (car arg) 4) |
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 |
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 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
513 (defun kmacro-end-macro (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
514 "Finish defining a keyboard macro. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
515 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
|
516 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
|
517 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
|
518 under that name. |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
519 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
520 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
|
521 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
|
522 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
|
523 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
524 (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
|
525 (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
|
526 (message "Ignore empty macro") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
527 (kmacro-pop-ring))) |
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 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
530 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
531 (defun kmacro-call-macro (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
532 "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
|
533 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
534 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
|
535 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
536 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
|
537 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
|
538 (interactive "p") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
539 (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
|
540 |
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 ;;; Combined function key bindings: |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
544 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
545 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
546 (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
|
547 "Set `kmacro-counter' to ARG or 0 if missing, and `start-kbd-macro'. |
46083 | 548 With \\[universal-argument], append to current keyboard macro (keep kmacro-counter). |
549 | |
550 When defining/executing macro, insert macro counter and increment with | |
551 ARG or 1 if missing. | |
552 With \\[universal-argument], insert previous kmacro-counter (but do not modify counter). | |
553 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
554 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. |
46083 | 555 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
|
556 (interactive "P") |
46083 | 557 (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
|
558 (kmacro-insert-counter arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
559 (kmacro-start-macro arg))) |
46083 | 560 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
561 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
562 ;;;###autoload |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
563 (defun kmacro-end-or-call-macro (arg) |
46083 | 564 "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
|
565 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
|
566 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
|
567 (interactive "P") |
46083 | 568 (cond |
569 (defining-kbd-macro | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
570 (kmacro-end-macro arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
571 ((and arg (listp arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
572 (kmacro-call-ring-2nd 1)) |
46083 | 573 (t |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
574 (kmacro-call-macro arg)))) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
575 |
46083 | 576 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
577 (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
|
578 "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
|
579 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
580 (kmacro-end-or-call-macro arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
581 (kmacro-repeat-loop)) |
46083 | 582 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
583 (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
|
584 |
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 ;;;###autoload |
46083 | 587 (defun kmacro-end-call-mouse (event) |
588 "Move point to the position clicked with the mouse and call last kbd macro. | |
589 If kbd macro currently being defined end it before activating it." | |
590 (interactive "e") | |
591 (when defining-kbd-macro | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
592 (end-kbd-macro)) |
46083 | 593 (mouse-set-point event) |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
594 (kmacro-call-macro nil)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
595 |
46083 | 596 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
597 ;;; Misc. commands |
46083 | 598 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
599 (defun kmacro-bind-to-key (arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
600 "When not defining or executing a macro, offer to bind last macro to a key." |
46083 | 601 (interactive "p") |
602 (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
|
603 (if defining-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
604 (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
|
605 (unless last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
606 (error "No keyboard macro defined")) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
607 (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
|
608 (unless (equal key-seq "") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
609 (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
|
610 |
46083 | 611 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
612 (defun kmacro-view-macro (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
613 "Display the last keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
614 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
615 (kmacro-display last-kbd-macro)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
616 |
46083 | 617 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
618 (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
|
619 "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
|
620 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
621 (kmacro-view-macro arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
622 (if last-kbd-macro |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
623 (kmacro-repeat-loop))) |
46083 | 624 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
625 (put 'kmacro-view-macro-rep 'kmacro-repeat 'head) |
46083 | 626 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
627 (defun kmacro-edit-macro (&optional arg) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
628 "Edit last keyboard macro." |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
629 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
630 (edit-kbd-macro "\r" arg)) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
631 |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
632 (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
|
633 |
46083 | 634 |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
635 (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
|
636 "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
|
637 (interactive "P") |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
638 (kmacro-edit-macro arg)) |
46083 | 639 |
640 | |
46961
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
641 (defun kmacro-edit-lossage () |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
642 "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
|
643 (interactive) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
644 (kmacro-push-ring) |
7e8358ec31ba
Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents:
46099
diff
changeset
|
645 (edit-kbd-macro "\C-hl")) |
46083 | 646 |
647 | |
46099
d441fc235798
Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46085
diff
changeset
|
648 (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
|
649 ;;; kmacro.el ends here |