1 ;;; kmacro.el --- enhanced keyboard macros
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006,
4 ;; 2007 Free Software Foundation, Inc.
6 ;; Author: Kim F. Storm <storm@cua.dk>
7 ;; Keywords: keyboard convenience
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; The kmacro package provides the user interface to emacs' basic
29 ;; keyboard macro functionality. With kmacro, two function keys are
30 ;; dedicated to keyboard macros, by default F3 and F4.
32 ;; Note: The traditional bindings C-x (, C-x ), and C-x e are still
33 ;; supported, but for some users these bindings are too hard to type
34 ;; to be really useful for doing small repeated tasks.
36 ;; To start defining a keyboard macro, use F3. To end the macro,
37 ;; use F4, and to call the macro also use F4. This makes it very
38 ;; easy to repeat a macro immediately after defining it.
40 ;; You can call the macro repeatedly by pressing F4 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.
46 ;; When you define a macro with F3/F4, it is automatically added to
47 ;; the head of the "keyboard macro ring", and F4 actually executes the
48 ;; first element of the macro ring.
50 ;; Note: an empty macro is never added to the macro ring.
52 ;; You can execute the second element on the macro ring with C-u F4 or
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
54 ;; through the macro ring, and you can swap the first and second
55 ;; elements with C-x C-k C-t. To delete the first element in the
56 ;; macro ring, use C-x C-k C-d.
58 ;; You can also use C-x C-k C-s to start a macro, and C-x C-k C-k to
59 ;; end it; then use C-k to execute it immediately, or C-x C-k C-k to
62 ;; In general, immediately after using C-x C-k followed by one of C-k,
63 ;; C-l, C-p, or C-n, you can further cycle the macro ring using C-p or
64 ;; C-n, execute the first or second macro using C-k or C-l, delete
65 ;; the head macro with C-d, or edit the current macro with C-e without
66 ;; repeating the C-x C-k prefix.
68 ;; If you enter F3 while defining the macro, the numeric value of
69 ;; `kmacro-counter' is inserted using the `kmacro-counter-format', and
70 ;; `kmacro-counter' is incremented by 1 (or the numeric prefix value
73 ;; The initial value of `kmacro-counter' is 0, or the numeric prefix
74 ;; value given to F3 when starting the macro.
76 ;; Now, each time you call the macro using F4, the current
77 ;; value of `kmacro-counter' is inserted and incremented, making it
78 ;; easy to insert incremental numbers in the buffer.
82 ;; The following sequence: M-5 F3 x M-2 F3 y F4 F4 F4 F4
83 ;; inserts the following string: x5yx7yx9yx11y
85 ;; A macro can also be called using a mouse click, default S-mouse-3.
86 ;; This calls the macro at the point where you click the mouse.
88 ;; You can edit the last macro using C-x C-k C-e.
90 ;; You can append to the last macro using C-u F3.
92 ;; You can set the macro counter using C-x C-k C-c, add to it using C-x C-k C-a,
93 ;; and you can set the macro counter format with C-x C-k C-f.
95 ;; The following key bindings are performed:
97 ;; Normal While defining macro
98 ;; --------------------------- ------------------------------
99 ;; f3 Define macro Insert current counter value
100 ;; Prefix arg specifies initial and increase counter by prefix
101 ;; counter value (default 0) (default increment: 1)
103 ;; C-u f3 APPENDs to last macro
105 ;; f4 Call last macro End macro
106 ;; Prefix arg specifies number
107 ;; of times to execute macro.
109 ;; C-u f4 Swap last and head of macro ring.
111 ;; S-mouse-3 Set point at click and End macro and execute macro at
112 ;; execute last macro. click.
119 "Simplified keyboard macro user interface."
123 :link
'(emacs-commentary-link :tag
"Commentary" "kmacro.el")
124 :link
'(emacs-library-link :tag
"Lisp File" "kmacro.el"))
126 (defcustom kmacro-call-mouse-event
'S-mouse-3
127 "The mouse event used by kmacro to call a macro.
128 Set to nil if no mouse binding is desired."
132 (defcustom kmacro-ring-max
8
133 "Maximum number of keyboard macros to save in macro ring."
138 (defcustom kmacro-execute-before-append t
139 "Controls whether appending to a macro starts by executing the macro.
140 If non-nil, using a single \\[universal-argument] prefix executes the macro
141 before appending, while more than one \\[universal-argument] prefix does not
143 Otherwise, a single \\[universal-argument] prefix does not execute the
144 macro, while more than one \\[universal-argument] prefix causes the
145 macro to be executed before appending to it."
150 (defcustom kmacro-repeat-no-prefix t
151 "Allow repeating certain macro commands without entering the C-x C-k prefix."
155 (defcustom kmacro-call-repeat-key t
156 "Allow repeating macro call using last key or a specific key."
157 :type
'(choice (const :tag
"Disabled" nil
)
158 (const :tag
"Last key" t
)
159 (character :tag
"Character" :value ?e
)
160 (symbol :tag
"Key symbol" :value RET
))
163 (defcustom kmacro-call-repeat-with-arg nil
164 "Repeat macro call with original arg when non-nil; repeat once if nil."
168 (defcustom kmacro-step-edit-mini-window-height
0.75
169 "Override `max-mini-window-height' when step edit keyboard macro."
175 (defvar kmacro-keymap
176 (let ((map (make-sparse-keymap)))
177 ;; Start, end, execute macros
178 (define-key map
"s" 'kmacro-start-macro
)
179 (define-key map
"\C-s" 'kmacro-start-macro
)
180 (define-key map
"\C-k" 'kmacro-end-or-call-macro-repeat
)
181 (define-key map
"r" 'apply-macro-to-region-lines
)
182 (define-key map
"q" 'kbd-macro-query
) ;; Like C-x q
185 (define-key map
"\C-n" 'kmacro-cycle-ring-next
)
186 (define-key map
"\C-p" 'kmacro-cycle-ring-previous
)
187 (define-key map
"\C-v" 'kmacro-view-macro-repeat
)
188 (define-key map
"\C-d" 'kmacro-delete-ring-head
)
189 (define-key map
"\C-t" 'kmacro-swap-ring
)
190 (define-key map
"\C-l" 'kmacro-call-ring-2nd-repeat
)
193 (define-key map
"\C-f" 'kmacro-set-format
)
194 (define-key map
"\C-c" 'kmacro-set-counter
)
195 (define-key map
"\C-i" 'kmacro-insert-counter
)
196 (define-key map
"\C-a" 'kmacro-add-counter
)
199 (define-key map
"\C-e" 'kmacro-edit-macro-repeat
)
200 (define-key map
"\r" 'kmacro-edit-macro
)
201 (define-key map
"e" 'edit-kbd-macro
)
202 (define-key map
"l" 'kmacro-edit-lossage
)
203 (define-key map
" " 'kmacro-step-edit-macro
)
205 ;; naming and binding
206 (define-key map
"b" 'kmacro-bind-to-key
)
207 (define-key map
"n" 'kmacro-name-last-macro
)
209 "Keymap for keyboard macro commands.")
210 (defalias 'kmacro-keymap kmacro-keymap
)
212 ;;; Provide some binding for startup:
213 ;;;###autoload (global-set-key "\C-x(" 'kmacro-start-macro)
214 ;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro)
215 ;;;###autoload (global-set-key "\C-xe" 'kmacro-end-and-call-macro)
216 ;;;###autoload (global-set-key [f3] 'kmacro-start-macro-or-insert-counter)
217 ;;;###autoload (global-set-key [f4] 'kmacro-end-or-call-macro)
218 ;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap)
219 ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap)
221 (if kmacro-call-mouse-event
222 (global-set-key (vector kmacro-call-mouse-event
) 'kmacro-end-call-mouse
))
225 ;;; Called from keyboard-quit
227 (defun kmacro-keyboard-quit ()
228 (or (not defining-kbd-macro
)
229 (eq defining-kbd-macro
'append
)
230 (kmacro-ring-empty-p)
234 ;;; Keyboard macro counter
236 (defvar kmacro-counter
0
237 "*Current keyboard macro counter.")
239 (defvar kmacro-default-counter-format
"%d")
241 (defvar kmacro-counter-format
"%d"
242 "*Current keyboard macro counter format.")
244 (defvar kmacro-counter-format-start kmacro-counter-format
245 "Macro format at start of macro execution.")
247 (defvar kmacro-counter-value-start kmacro-counter
248 "Macro counter at start of macro execution.")
250 (defvar kmacro-last-counter
0
251 "Last counter inserted by key macro.")
253 (defvar kmacro-initial-counter-value nil
254 "Initial counter value for the next keyboard macro to be defined.")
257 (defun kmacro-insert-counter (arg)
258 "Insert macro counter and increment with ARG or 1 if missing.
259 With \\[universal-argument], insert previous `kmacro-counter' (but do not modify counter)."
261 (if kmacro-initial-counter-value
262 (setq kmacro-counter kmacro-initial-counter-value
263 kmacro-initial-counter-value nil
))
264 (if (and arg
(listp arg
))
265 (insert (format kmacro-counter-format kmacro-last-counter
))
266 (insert (format kmacro-counter-format kmacro-counter
))
267 (kmacro-add-counter (prefix-numeric-value arg
))))
270 (defun kmacro-set-format (format)
271 "Set macro counter FORMAT."
272 (interactive "sMacro Counter Format: ")
273 (setq kmacro-counter-format
274 (if (equal format
"") "%d" format
))
275 ;; redefine initial macro counter if we are not executing a macro.
276 (if (not (or defining-kbd-macro executing-kbd-macro
))
277 (setq kmacro-default-counter-format kmacro-counter-format
)))
280 (defun kmacro-display-counter (&optional value
)
281 "Display current counter value."
282 (unless value
(setq value kmacro-counter
))
283 (message "New macro counter value: %s (%d)" (format kmacro-counter-format value
) value
))
286 (defun kmacro-set-counter (arg)
287 "Set `kmacro-counter' to ARG or prompt if missing.
288 With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro."
289 (interactive "NMacro counter value: ")
290 (if (not (or defining-kbd-macro executing-kbd-macro
))
291 (kmacro-display-counter (setq kmacro-initial-counter-value arg
))
292 (setq kmacro-last-counter kmacro-counter
293 kmacro-counter
(if (and current-prefix-arg
(listp current-prefix-arg
))
294 kmacro-counter-value-start
296 (unless executing-kbd-macro
297 (kmacro-display-counter))))
300 (defun kmacro-add-counter (arg)
301 "Add numeric prefix arg (prompt if missing) to macro counter.
302 With \\[universal-argument], restore previous counter value."
303 (interactive "NAdd to macro counter: ")
304 (if kmacro-initial-counter-value
305 (setq kmacro-counter kmacro-initial-counter-value
306 kmacro-initial-counter-value nil
))
307 (let ((last kmacro-last-counter
))
308 (setq kmacro-last-counter kmacro-counter
309 kmacro-counter
(if (and current-prefix-arg
(listp current-prefix-arg
))
311 kmacro-counter
(+ kmacro-counter arg
))))
312 (unless executing-kbd-macro
313 (kmacro-display-counter)))
316 (defun kmacro-loop-setup-function ()
317 "Function called prior to each iteration of macro."
318 ;; Restore macro counter format to initial format, so it is ok to change
319 ;; counter format in the macro without restoring it.
320 (setq kmacro-counter-format kmacro-counter-format-start
)
321 ;; Save initial counter value so we can restore it with C-u kmacro-set-counter.
322 (setq kmacro-counter-value-start kmacro-counter
)
323 ;; Return non-nil to continue execution.
327 ;;; Keyboard macro ring
329 (defvar kmacro-ring nil
330 "The keyboard macro ring.
331 Each element is a list (MACRO COUNTER FORMAT). Actually, the head of
332 the macro ring (when defining or executing) is not stored in the ring;
333 instead it is available in the variables `last-kbd-macro', `kmacro-counter',
334 and `kmacro-counter-format'.")
336 ;; Remember what we are currently looking at with kmacro-view-macro.
338 (defvar kmacro-view-last-item nil
)
339 (defvar kmacro-view-item-no
0)
342 (defun kmacro-ring-head ()
343 "Return pseudo head element in macro ring."
345 (list last-kbd-macro kmacro-counter kmacro-counter-format-start
)))
348 (defun kmacro-push-ring (&optional elt
)
349 "Push ELT or current macro onto `kmacro-ring'."
350 (when (setq elt
(or elt
(kmacro-ring-head)))
351 (let ((history-delete-duplicates nil
))
352 (add-to-history 'kmacro-ring elt kmacro-ring-max
))))
355 (defun kmacro-split-ring-element (elt)
356 (setq last-kbd-macro
(car elt
)
357 kmacro-counter
(nth 1 elt
)
358 kmacro-counter-format-start
(nth 2 elt
)))
361 (defun kmacro-pop-ring1 (&optional raw
)
362 "Pop head element off macro ring (no check).
363 Non-nil arg RAW means just return raw first element."
364 (prog1 (car kmacro-ring
)
366 (kmacro-split-ring-element (car kmacro-ring
)))
367 (setq kmacro-ring
(cdr kmacro-ring
))))
370 (defun kmacro-pop-ring (&optional raw
)
371 "Pop head element off macro ring.
372 Non-nil arg RAW means just return raw first element."
373 (unless (kmacro-ring-empty-p)
374 (kmacro-pop-ring1 raw
)))
377 (defun kmacro-ring-empty-p (&optional none
)
378 "Tell user and return t if `last-kbd-macro' is nil or `kmacro-ring' is empty.
379 Check only `last-kbd-macro' if optional arg NONE is non-nil."
380 (while (and (null last-kbd-macro
) kmacro-ring
)
383 ((null last-kbd-macro
)
384 (message "No keyboard macro defined.")
386 ((and (null none
) (null kmacro-ring
))
387 (message "Only one keyboard macro defined.")
392 (defun kmacro-display (macro &optional trunc descr empty
)
393 "Display a keyboard MACRO.
394 Optional arg TRUNC non-nil specifies to limit width of macro to 60 chars.
395 Optional arg DESCR is descriptive text for macro; default is \"Macro:\".
396 Optional arg EMPTY is message to print if no macros are defined."
399 (m (format-kbd-macro macro
))
401 (z (and trunc
(> l x
))))
402 (message "%s%s: %s%s" (or descr
"Macro")
403 (if (= kmacro-counter
0) ""
405 (format kmacro-counter-format-start kmacro-counter
)))
406 (if z
(substring m
0 (1- x
)) m
) (if z
"..." "")))
407 (message (or empty
"No keyboard macros defined"))))
410 (defun kmacro-repeat-on-last-key (keys)
411 "Process kmacro commands keys immediately after cycling the ring."
412 (setq keys
(vconcat keys
))
413 (let ((n (1- (length keys
)))
415 (while (and last-kbd-macro
417 (aset keys n
(read-event))
418 (setq cmd
(key-binding keys t
))
419 (setq repeat
(get cmd
'kmacro-repeat
)))
420 (clear-this-command-keys t
)
424 (let ((kmacro-repeat-no-prefix nil
))
426 (kmacro-display last-kbd-macro t
)))
428 (let ((kmacro-repeat-no-prefix nil
))
433 (setq last-input-event nil
)))
434 (when last-input-event
435 (clear-this-command-keys t
)
436 (setq unread-command-events
(list last-input-event
))))
439 (defun kmacro-get-repeat-prefix ()
441 (and kmacro-repeat-no-prefix
442 (setq keys
(this-single-command-keys))
447 (defun kmacro-exec-ring-item (item arg
)
448 "Execute item ITEM from the macro ring."
449 ;; Use counter and format specific to the macro on the ring!
450 (let ((kmacro-counter (nth 1 item
))
451 (kmacro-counter-format-start (nth 2 item
)))
452 (execute-kbd-macro (car item
) arg
#'kmacro-loop-setup-function
)
453 (setcar (cdr item
) kmacro-counter
)))
456 (defun kmacro-call-ring-2nd (arg)
457 "Execute second keyboard macro in macro ring."
459 (unless (kmacro-ring-empty-p)
460 (kmacro-exec-ring-item (car kmacro-ring
) arg
)))
463 (defun kmacro-call-ring-2nd-repeat (arg)
464 "Execute second keyboard macro in macro ring.
465 This is like `kmacro-call-ring-2nd', but allows repeating macro commands
466 without repeating the prefix."
468 (let ((keys (kmacro-get-repeat-prefix)))
469 (kmacro-call-ring-2nd arg
)
470 (if (and kmacro-ring keys
)
471 (kmacro-repeat-on-last-key keys
))))
473 (put 'kmacro-call-ring-2nd-repeat
'kmacro-repeat
'head
)
476 (defun kmacro-view-ring-2nd ()
477 "Display the current head of the keyboard macro ring."
479 (unless (kmacro-ring-empty-p)
480 (kmacro-display (car (car kmacro-ring
)) "2nd macro")))
483 (defun kmacro-cycle-ring-next (&optional arg
)
484 "Move to next keyboard macro in keyboard macro ring.
485 Displays the selected macro in the echo area."
487 (unless (kmacro-ring-empty-p)
489 (let* ((keys (kmacro-get-repeat-prefix))
490 (len (length kmacro-ring
))
491 (tail (nthcdr (- len
2) kmacro-ring
))
492 (elt (car (cdr tail
))))
494 (kmacro-split-ring-element elt
)
495 (kmacro-display last-kbd-macro t
)
497 (kmacro-repeat-on-last-key keys
)))))
499 (put 'kmacro-cycle-ring-next
'kmacro-repeat
'ring
)
502 (defun kmacro-cycle-ring-previous (&optional arg
)
503 "Move to previous keyboard macro in keyboard macro ring.
504 Displays the selected macro in the echo area."
506 (unless (kmacro-ring-empty-p)
507 (let ((keys (kmacro-get-repeat-prefix))
508 (cur (kmacro-ring-head)))
511 (nconc kmacro-ring
(list cur
))
512 (setq kmacro-ring
(list cur
)))
513 (kmacro-display last-kbd-macro t
)
515 (kmacro-repeat-on-last-key keys
)))))
517 (put 'kmacro-cycle-ring-previous
'kmacro-repeat
'ring
)
520 (defun kmacro-swap-ring ()
521 "Swap first two elements on keyboard macro ring."
523 (unless (kmacro-ring-empty-p)
524 (let ((cur (kmacro-ring-head)))
526 (kmacro-push-ring cur
))
527 (kmacro-display last-kbd-macro t
)))
530 (defun kmacro-delete-ring-head (&optional arg
)
531 "Delete current macro from keyboard macro ring."
533 (unless (kmacro-ring-empty-p t
)
534 (if (null kmacro-ring
)
535 (setq last-kbd-macro nil
)
537 (kmacro-display last-kbd-macro t nil
"Keyboard macro ring is now empty.")))
539 (put 'kmacro-delete-ring-head
'kmacro-repeat
'head
)
541 ;;; Traditional bindings:
545 (defun kmacro-start-macro (arg)
546 "Record subsequent keyboard input, defining a keyboard macro.
547 The commands are recorded even as they are executed.
548 Use \\[kmacro-end-macro] to finish recording and make the macro available.
549 Use \\[kmacro-end-and-call-macro] to execute the macro.
551 Non-nil arg (prefix arg) means append to last macro defined.
553 With \\[universal-argument] prefix, append to last keyboard macro
554 defined. Depending on `kmacro-execute-before-append', this may begin
555 by re-executing the last macro as if you typed it again.
557 Otherwise, it sets `kmacro-counter' to ARG or 0 if missing before
560 Use \\[kmacro-insert-counter] to insert (and increment) the macro counter.
561 The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
562 The format of the counter can be modified via \\[kmacro-set-format].
564 Use \\[kmacro-name-last-macro] to give it a permanent name.
565 Use \\[kmacro-bind-to-key] to bind it to a key sequence."
567 (if (or defining-kbd-macro executing-kbd-macro
)
568 (message "Already defining keyboard macro.")
569 (let ((append (and arg
(listp arg
))))
573 (list last-kbd-macro kmacro-counter kmacro-counter-format-start
)))
574 (setq kmacro-counter
(or (if arg
(prefix-numeric-value arg
))
575 kmacro-initial-counter-value
577 kmacro-initial-counter-value nil
578 kmacro-counter-value-start kmacro-counter
579 kmacro-last-counter kmacro-counter
580 kmacro-counter-format kmacro-default-counter-format
581 kmacro-counter-format-start kmacro-default-counter-format
))
583 (start-kbd-macro append
585 (if kmacro-execute-before-append
588 (if (and defining-kbd-macro append
)
589 (setq defining-kbd-macro
'append
)))))
593 (defun kmacro-end-macro (arg)
594 "Finish defining a keyboard macro.
595 The definition was started by \\[kmacro-start-macro].
596 The macro is now available for use via \\[kmacro-call-macro],
597 or it can be given a name with \\[kmacro-name-last-macro] and then invoked
600 With numeric arg, repeat macro now that many times,
601 counting the definition just completed as the first repetition.
602 An argument of zero means repeat until error."
604 ;; Isearch may push the kmacro-end-macro key sequence onto the macro.
605 ;; Just ignore it when executing the macro.
606 (unless executing-kbd-macro
607 (end-kbd-macro arg
#'kmacro-loop-setup-function
)
608 (when (and last-kbd-macro
(= (length last-kbd-macro
) 0))
609 (setq last-kbd-macro nil
)
610 (message "Ignore empty macro")
611 ;; Don't call `kmacro-ring-empty-p' to avoid its messages.
612 (while (and (null last-kbd-macro
) kmacro-ring
)
613 (kmacro-pop-ring1)))))
617 (defun kmacro-call-macro (arg &optional no-repeat end-macro
)
618 "Call the last keyboard macro that you defined with \\[kmacro-start-macro].
619 A prefix argument serves as a repeat count. Zero means repeat until error.
621 When you call the macro, you can call the macro again by repeating
622 just the last key in the key sequence that you used to call this
623 command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
624 for details on how to adjust or disable this behavior.
626 To make a macro permanent so you can call it even after defining
627 others, use \\[kmacro-name-last-macro]."
629 (let ((repeat-key (and (null no-repeat
)
630 (> (length (this-single-command-keys)) 1)
634 (kmacro-end-macro arg
)
635 (call-last-kbd-macro arg
#'kmacro-loop-setup-function
))
637 (setq arg
(car arg
)))
638 (when (and (or (null arg
) (> arg
0))
640 (if (eq kmacro-call-repeat-key t
)
642 kmacro-call-repeat-key
)))
643 (setq repeat-key-str
(format-kbd-macro (vector repeat-key
) nil
))
645 (message "(Type %s to repeat macro%s)"
647 (if (and kmacro-call-repeat-with-arg
649 (format " %d times" arg
) ""))
650 (if (equal repeat-key
(read-event))
652 (clear-this-command-keys t
)
653 (call-last-kbd-macro (and kmacro-call-repeat-with-arg arg
)
654 #'kmacro-loop-setup-function
)
655 (setq last-input-event nil
))
656 (setq repeat-key nil
)))
657 (when last-input-event
658 (clear-this-command-keys t
)
659 (setq unread-command-events
(list last-input-event
))))))
662 ;;; Combined function key bindings:
665 (defun kmacro-start-macro-or-insert-counter (arg)
666 "Record subsequent keyboard input, defining a keyboard macro.
667 The commands are recorded even as they are executed.
669 Sets the `kmacro-counter' to ARG (or 0 if no prefix arg) before defining the
672 With \\[universal-argument], appends to current keyboard macro (keeping
673 the current value of `kmacro-counter').
675 When defining/executing macro, inserts macro counter and increments
676 the counter with ARG or 1 if missing. With \\[universal-argument],
677 inserts previous `kmacro-counter' (but do not modify counter).
679 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
680 The format of the counter can be modified via \\[kmacro-set-format]."
682 (if (or defining-kbd-macro executing-kbd-macro
)
683 (kmacro-insert-counter arg
)
684 (kmacro-start-macro arg
)))
688 (defun kmacro-end-or-call-macro (arg &optional no-repeat
)
689 "End kbd macro if currently being defined; else call last kbd macro.
690 With numeric prefix ARG, repeat macro that many times.
691 With \\[universal-argument], call second macro in macro ring."
695 (if kmacro-call-repeat-key
696 (kmacro-call-macro arg no-repeat t
)
697 (kmacro-end-macro arg
)))
698 ((and (eq this-command
'kmacro-view-macro
) ;; We are in repeat mode!
699 kmacro-view-last-item
)
700 (kmacro-exec-ring-item (car kmacro-view-last-item
) arg
))
701 ((and arg
(listp arg
))
702 (kmacro-call-ring-2nd 1))
704 (kmacro-call-macro arg no-repeat
))))
707 (defun kmacro-end-or-call-macro-repeat (arg)
708 "As `kmacro-end-or-call-macro' but allows repeat without repeating prefix."
710 (let ((keys (kmacro-get-repeat-prefix)))
711 (kmacro-end-or-call-macro arg t
)
713 (kmacro-repeat-on-last-key keys
))))
715 (put 'kmacro-end-or-call-macro-repeat
'kmacro-repeat
'head
)
719 (defun kmacro-end-and-call-macro (arg &optional no-repeat
)
720 "Call last keyboard macro, ending it first if currently being defined.
721 With numeric prefix ARG, repeat macro that many times.
722 Zero argument means repeat until there is an error.
724 To give a macro a permanent name, so you can call it
725 even after defining other macros, use \\[kmacro-name-last-macro]."
727 (if defining-kbd-macro
728 (kmacro-end-macro nil
))
729 (kmacro-call-macro arg no-repeat
))
733 (defun kmacro-end-call-mouse (event)
734 "Move point to the position clicked with the mouse and call last kbd macro.
735 If kbd macro currently being defined end it before activating it."
737 (when defining-kbd-macro
739 (mouse-set-point event
)
740 (kmacro-call-macro nil t
))
745 ;; An idea for macro bindings:
746 ;; Create a separate keymap installed as a minor-mode keymap (e.g. in
747 ;; the emulation-mode-map-alists) in which macro bindings are made
748 ;; independent of any other bindings. When first binding is made,
749 ;; the kemap is created, installed, and enabled. Key seq. C-x C-k +
750 ;; can then be used to toggle the use of this keymap on and off.
751 ;; This means that it would be safe(r) to bind ordinary keys like
752 ;; letters and digits, provided that we inhibit the keymap while
753 ;; executing the macro later on (but that's controversial...)
755 (defun kmacro-lambda-form (mac &optional counter format
)
756 "Create lambda form for macro bound to symbol or key."
758 (setq mac
(list mac counter format
)))
759 `(lambda (&optional arg
)
762 (kmacro-exec-ring-item ',mac arg
)))
764 (defun kmacro-extract-lambda (mac)
765 "Extract kmacro from a kmacro lambda form."
767 (eq (car mac
) 'lambda
)
768 (setq mac
(assoc 'kmacro-exec-ring-item mac
))
770 (consp (car (cdr mac
)))
771 (consp (cdr (car (cdr mac
))))
772 (setq mac
(car (cdr (car (cdr mac
)))))
779 (defun kmacro-bind-to-key (arg)
780 "When not defining or executing a macro, offer to bind last macro to a key.
781 The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A]
782 through [C-x C-k Z] are reserved for user bindings, and to bind to
783 one of these sequences, just enter the digit or letter, rather than
786 You can bind to any valid key sequence, but if you try to bind to
787 a key with an existing command binding, you will be asked for
788 confirmation whether to replace that binding. Note that the
789 binding is made in the `global-map' keymap, so the macro binding
790 may be shaded by a local key binding."
792 (if (or defining-kbd-macro executing-kbd-macro
)
793 (if defining-kbd-macro
794 (message "Cannot save macro while defining it."))
795 (unless last-kbd-macro
796 (error "No keyboard macro defined"))
797 (let ((key-seq (read-key-sequence "Bind last macro to key: "))
799 (when (= (length key-seq
) 1)
800 (let ((ch (aref key-seq
0)))
801 (if (and (integerp ch
)
802 (or (and (>= ch ?
0) (<= ch ?
9))
803 (and (>= ch ?A
) (<= ch ?Z
))))
804 (setq key-seq
(concat "\C-x\C-k" key-seq
)
806 (when (and (not (equal key-seq
"\a"))
808 (not (setq cmd
(key-binding key-seq
)))
811 (yes-or-no-p (format "%s runs command %S. Bind anyway? "
812 (format-kbd-macro key-seq
)
814 (define-key global-map key-seq
815 (kmacro-lambda-form (kmacro-ring-head)))
816 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq
))))))
819 (defun kmacro-name-last-macro (symbol)
820 "Assign a name to the last keyboard macro defined.
821 Argument SYMBOL is the name to define.
822 The symbol's function definition becomes the keyboard macro string.
823 Such a \"function\" cannot be called from Lisp, but it is a valid editor command."
824 (interactive "SName for last kbd macro: ")
826 (error "No keyboard macro defined"))
827 (and (fboundp symbol
)
828 (not (get symbol
'kmacro
))
829 (not (stringp (symbol-function symbol
)))
830 (not (vectorp (symbol-function symbol
)))
831 (error "Function %s is already defined and not a keyboard macro"
833 (if (string-equal symbol
"")
834 (error "No command name given"))
835 (fset symbol
(kmacro-lambda-form (kmacro-ring-head)))
836 (put symbol
'kmacro t
))
839 (defun kmacro-view-macro (&optional arg
)
840 "Display the last keyboard macro.
841 If repeated, it shows previous elements in the macro ring."
844 ((or (kmacro-ring-empty-p)
845 (not (eq last-command
'kmacro-view-macro
)))
846 (setq kmacro-view-last-item nil
))
847 ((null kmacro-view-last-item
)
848 (setq kmacro-view-last-item kmacro-ring
849 kmacro-view-item-no
2))
850 ((consp kmacro-view-last-item
)
851 (setq kmacro-view-last-item
(cdr kmacro-view-last-item
)
852 kmacro-view-item-no
(1+ kmacro-view-item-no
)))
854 (setq kmacro-view-last-item nil
)))
855 (setq this-command
'kmacro-view-macro
856 last-command this-command
) ;; in case we repeat
857 (kmacro-display (if kmacro-view-last-item
858 (car (car kmacro-view-last-item
))
861 (if kmacro-view-last-item
862 (concat (cond ((= kmacro-view-item-no
2) "2nd")
863 ((= kmacro-view-item-no
3) "3nd")
864 (t (format "%dth" kmacro-view-item-no
)))
868 (defun kmacro-view-macro-repeat (&optional arg
)
869 "Display the last keyboard macro.
870 If repeated, it shows previous elements in the macro ring.
871 To execute the displayed macro ring item without changing the macro ring,
873 This is like `kmacro-view-macro', but allows repeating macro commands
874 without repeating the prefix."
876 (let ((keys (kmacro-get-repeat-prefix)))
877 (kmacro-view-macro arg
)
878 (if (and last-kbd-macro keys
)
879 (kmacro-repeat-on-last-key keys
))))
881 (put 'kmacro-view-macro-repeat
'kmacro-repeat
'ring
)
884 (defun kmacro-edit-macro-repeat (&optional arg
)
885 "Edit last keyboard macro."
887 (edit-kbd-macro "\r" arg
))
889 (put 'kmacro-edit-macro-repeat
'kmacro-repeat
'stop
)
892 (defun kmacro-edit-macro (&optional arg
)
893 "As edit last keyboard macro, but without kmacro-repeat property."
895 (edit-kbd-macro "\r" arg
))
898 (defun kmacro-edit-lossage ()
899 "Edit most recent 100 keystrokes as a keyboard macro."
902 (edit-kbd-macro "\C-hl"))
905 ;;; Single-step editing of keyboard macros
907 (defvar kmacro-step-edit-active
) ;; step-editing active
908 (defvar kmacro-step-edit-new-macro
) ;; storage for new macro
909 (defvar kmacro-step-edit-inserting
) ;; inserting into macro
910 (defvar kmacro-step-edit-appending
) ;; append to end of macro
911 (defvar kmacro-step-edit-replace
) ;; replace orig macro when done
912 (defvar kmacro-step-edit-prefix-index
) ;; index of first prefix arg key
913 (defvar kmacro-step-edit-key-index
) ;; index of current key
914 (defvar kmacro-step-edit-action
) ;; automatic action on next pre-command hook
915 (defvar kmacro-step-edit-help
) ;; kmacro step edit help enabled
916 (defvar kmacro-step-edit-num-input-keys
) ;; to ignore duplicate pre-command hook
918 (defvar kmacro-step-edit-map
(make-sparse-keymap)
919 "Keymap that defines the responses to questions in `kmacro-step-edit-macro'.
920 This keymap is an extension to the `query-replace-map', allowing the
921 following additional answers: `insert', `insert-1', `replace', `replace-1',
922 `append', `append-end', `act-repeat', `skip-end', `skip-keep'.")
924 ;; query-replace-map answers include: `act', `skip', `act-and-show',
925 ;; `exit', `act-and-exit', `edit', `delete-and-edit', `recenter',
926 ;; `automatic', `backup', `exit-prefix', and `help'.")
927 ;; Also: `quit', `edit-replacement'
929 (set-keymap-parent kmacro-step-edit-map query-replace-map
)
931 (define-key kmacro-step-edit-map
"\t" 'act-repeat
)
932 (define-key kmacro-step-edit-map
[tab] 'act-repeat)
933 (define-key kmacro-step-edit-map "\C-k" 'skip-rest)
934 (define-key kmacro-step-edit-map "c" 'automatic)
935 (define-key kmacro-step-edit-map "f" 'skip-keep)
936 (define-key kmacro-step-edit-map "q" 'quit)
937 (define-key kmacro-step-edit-map "d" 'skip)
938 (define-key kmacro-step-edit-map "\C-d" 'skip)
939 (define-key kmacro-step-edit-map "i" 'insert)
940 (define-key kmacro-step-edit-map "I" 'insert-1)
941 (define-key kmacro-step-edit-map "r" 'replace)
942 (define-key kmacro-step-edit-map "R" 'replace-1)
943 (define-key kmacro-step-edit-map "a" 'append)
944 (define-key kmacro-step-edit-map "A" 'append-end)
946 (defvar kmacro-step-edit-prefix-commands
947 '(universal-argument universal-argument-more universal-argument-minus
948 digit-argument negative-argument)
949 "Commands which build up a prefix arg for the current command.")
951 (defun kmacro-step-edit-prompt (macro index)
952 ;; Show step-edit prompt
953 (let ((keys (and (not kmacro-step-edit-appending)
954 index (substring macro index executing-kbd-macro-index)))
955 (future (and (not kmacro-step-edit-appending)
956 (substring macro executing-kbd-macro-index)))
957 (message-log-max nil)
958 (curmsg (current-message)))
960 ;; TODO: Scroll macro if max-mini-window-height is too small.
963 (format "Macro: %s%s%s%s%s\n"
964 (format-kbd-macro kmacro-step-edit-new-macro 1)
965 (if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "")
966 (propertize (if keys (format-kbd-macro keys)
967 (if kmacro-step-edit-appending "<APPEND>" "<INSERT>")) 'face 'region)
969 (if future (format-kbd-macro future) ""))
974 minibuffer " 'face 'header-line)
975 (buffer-substring (point-min) (point-max))))
979 echo area " 'face 'header-line)
983 (format "%s\n%s%s %S [yn iIaArR C-k kq!] "
985 --------------Step Edit Keyboard Macro [?: help]---------------" 'face 'mode-line)
986 (if kmacro-step-edit-help "\
987 Step: y/SPC: execute next, d/n/DEL: skip next, f: skip but keep
988 TAB: execute while same, ?: toggle help
989 Edit: i: insert, r: replace, a: append, A: append at end,
990 I/R: insert/replace with one sequence,
991 End: !/c: execute rest, C-k: skip rest and save, q/C-g: quit
992 ----------------------------------------------------------------
994 (propertize "Next command:" 'face 'bold)
997 (format "Type key sequence%s to insert and execute%s: "
998 (if (numberp kmacro-step-edit-inserting) "" "s")
999 (if (numberp kmacro-step-edit-inserting) "" " (end with C-j)"))
1002 (defun kmacro-step-edit-query ()
1003 ;; Pre-command hook function for step-edit in "command" mode
1004 (let ((resize-mini-windows t)
1005 (max-mini-window-height kmacro-step-edit-mini-window-height)
1006 act restore-index next-index)
1008 ;; Handle commands which reads additional input using read-char.
1010 ((and (eq this-command 'quoted-insert)
1011 (not (eq kmacro-step-edit-action t)))
1012 ;; Find the actual end of this key sequence.
1013 ;; Must be able to backtrack in case we actually execute it.
1014 (setq restore-index executing-kbd-macro-index)
1015 (let (unread-command-events)
1017 (when unread-command-events
1018 (setq executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events))
1019 next-index executing-kbd-macro-index)))))
1021 ;; Query the user; stop macro exection temporarily
1022 (let ((macro executing-kbd-macro)
1023 (executing-kbd-macro nil)
1024 (defining-kbd-macro nil))
1026 ;; Any action requested by previous command
1028 ((eq kmacro-step-edit-action t) ;; Reentry for actual command @ end of prefix arg.
1030 ((eq this-command 'quoted-insert)
1031 (clear-this-command-keys) ;; recent-keys actually
1032 (let (unread-command-events)
1033 (quoted-insert (prefix-numeric-value current-prefix-arg))
1034 (setq kmacro-step-edit-new-macro
1035 (vconcat kmacro-step-edit-new-macro (recent-keys)))
1036 (when unread-command-events
1037 (setq kmacro-step-edit-new-macro
1038 (substring kmacro-step-edit-new-macro 0 (- (length unread-command-events)))
1039 executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events)))))
1040 (setq current-prefix-arg nil
1045 (setq kmacro-step-edit-action nil))
1046 ((eq this-command kmacro-step-edit-action) ;; TAB -> activate while same command
1049 (setq kmacro-step-edit-action nil)))
1051 ;; Handle prefix arg, or query user
1053 (act act) ;; set above
1054 ((memq this-command kmacro-step-edit-prefix-commands)
1055 (unless kmacro-step-edit-prefix-index
1056 (setq kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1057 (setq act 'universal-argument))
1058 ((eq this-command 'universal-argument-other-key)
1059 (setq act 'universal-argument))
1061 (kmacro-step-edit-prompt macro (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1062 (setq act (lookup-key kmacro-step-edit-map
1063 (vector (with-current-buffer (current-buffer) (read-event))))))))
1065 ;; Resume macro execution and perform the action
1067 ((eq act 'universal-argument)
1072 ((eq act 'act-repeat)
1073 (setq kmacro-step-edit-action this-command)
1076 (setq kmacro-step-edit-replace nil)
1077 (setq kmacro-step-edit-active 'ignore)
1080 (setq kmacro-step-edit-prefix-index nil)
1082 ((eq act 'skip-keep)
1083 (setq this-command 'ignore)
1085 ((eq act 'skip-rest)
1086 (setq kmacro-step-edit-active 'ignore)
1088 ((memq act '(automatic exit))
1089 (setq kmacro-step-edit-active nil)
1092 ((member act '(insert-1 insert))
1093 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1094 (setq kmacro-step-edit-inserting (if (eq act 'insert-1) 1 t))
1096 ((member act '(replace-1 replace))
1097 (setq kmacro-step-edit-inserting (if (eq act 'replace-1) 1 t))
1098 (setq kmacro-step-edit-prefix-index nil)
1099 (if (= executing-kbd-macro-index (length executing-kbd-macro))
1100 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil])
1101 kmacro-step-edit-appending t))
1104 (setq kmacro-step-edit-inserting t)
1105 (if (= executing-kbd-macro-index (length executing-kbd-macro))
1106 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil])
1107 kmacro-step-edit-appending t))
1109 ((eq act 'append-end)
1110 (if (= executing-kbd-macro-index (length executing-kbd-macro))
1111 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil])
1112 kmacro-step-edit-inserting t
1113 kmacro-step-edit-appending t)
1114 (setq kmacro-step-edit-active 'append-end))
1118 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1119 (setq kmacro-step-edit-help (not kmacro-step-edit-help))
1121 (t ;; Ignore unknown responses
1122 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1124 (if (> executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index))
1125 (setq kmacro-step-edit-new-macro
1126 (vconcat kmacro-step-edit-new-macro
1127 (substring executing-kbd-macro
1128 (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)
1129 (if (eq act t) nil executing-kbd-macro-index)))
1130 kmacro-step-edit-prefix-index nil))
1132 (setq executing-kbd-macro-index restore-index)))
1134 (setq this-command 'ignore)))
1135 (setq kmacro-step-edit-key-index next-index)))
1137 (defun kmacro-step-edit-insert ()
1138 ;; Pre-command hook function for step-edit in "insert" mode
1139 (let ((resize-mini-windows t)
1140 (max-mini-window-height kmacro-step-edit-mini-window-height)
1141 (macro executing-kbd-macro)
1142 (executing-kbd-macro nil)
1143 (defining-kbd-macro nil)
1144 cmd keys next-index)
1145 (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)
1146 kmacro-step-edit-prefix-index nil)
1147 (kmacro-step-edit-prompt macro nil)
1148 ;; Now, we have read a key sequence from the macro, but we don't want
1149 ;; to execute it yet. So push it back and read another sequence.
1150 (reset-this-command-lengths)
1151 (setq keys (read-key-sequence nil nil nil nil t))
1152 (setq cmd (key-binding keys t nil))
1156 ((eq cmd 'quoted-insert)
1157 (clear-this-command-keys) ;; recent-keys actually
1158 (quoted-insert (prefix-numeric-value current-prefix-arg))
1159 (setq current-prefix-arg nil
1161 (setq keys (vconcat keys (recent-keys)))
1162 (when (numberp kmacro-step-edit-inserting)
1163 (setq kmacro-step-edit-inserting nil)
1164 (when unread-command-events
1165 (setq keys (substring keys 0 (- (length unread-command-events)))
1166 executing-kbd-macro-index (- executing-kbd-macro-index (length unread-command-events))
1167 next-index executing-kbd-macro-index
1168 unread-command-events nil)))
1171 ((memq cmd kmacro-step-edit-prefix-commands)
1172 (setq universal-argument-num-events 0)
1173 (reset-this-command-lengths)
1175 ((eq cmd 'universal-argument-other-key)
1176 (setq kmacro-step-edit-action t)
1177 (setq universal-argument-num-events 0)
1178 (reset-this-command-lengths)
1179 (if (numberp kmacro-step-edit-inserting)
1180 (setq kmacro-step-edit-inserting nil))
1182 ((numberp kmacro-step-edit-inserting)
1183 (setq kmacro-step-edit-inserting nil)
1185 ((equal keys "\C-j")
1186 (setq kmacro-step-edit-inserting nil)
1187 (setq kmacro-step-edit-action nil)
1188 ;; Forget any (partial) prefix arg from next command
1189 (setq kmacro-step-edit-prefix-index nil)
1190 (reset-this-command-lengths)
1191 (setq overriding-terminal-local-map nil)
1192 (setq universal-argument-num-events nil)
1193 (setq next-index kmacro-step-edit-key-index)
1196 (setq this-command 'ignore)
1197 (setq this-command cmd)
1198 (if (memq this-command '(self-insert-command digit-argument))
1199 (setq last-command-char (aref keys (1- (length keys)))))
1201 (setq kmacro-step-edit-new-macro (vconcat kmacro-step-edit-new-macro keys))))
1202 (setq kmacro-step-edit-key-index next-index)))
1204 (defun kmacro-step-edit-pre-command ()
1205 (remove-hook 'post-command-hook 'kmacro-step-edit-post-command)
1206 (when kmacro-step-edit-active
1208 ((eq kmacro-step-edit-active 'ignore)
1209 (setq this-command 'ignore))
1210 ((eq kmacro-step-edit-active 'append-end)
1211 (if (= executing-kbd-macro-index (length executing-kbd-macro))
1212 (setq executing-kbd-macro (vconcat executing-kbd-macro [nil])
1213 kmacro-step-edit-inserting t
1214 kmacro-step-edit-appending t
1215 kmacro-step-edit-active t)))
1216 ((/= kmacro-step-edit-num-input-keys num-input-keys)
1217 (if kmacro-step-edit-inserting
1218 (kmacro-step-edit-insert)
1219 (kmacro-step-edit-query))
1220 (setq kmacro-step-edit-num-input-keys num-input-keys)
1221 (if (and kmacro-step-edit-appending (not kmacro-step-edit-inserting))
1222 (setq kmacro-step-edit-appending nil
1223 kmacro-step-edit-active 'ignore)))))
1224 (when (eq kmacro-step-edit-active t)
1225 (add-hook 'post-command-hook 'kmacro-step-edit-post-command t)))
1227 (defun kmacro-step-edit-minibuf-setup ()
1228 (remove-hook 'pre-command-hook 'kmacro-step-edit-pre-command t)
1229 (when kmacro-step-edit-active
1230 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil t)))
1232 (defun kmacro-step-edit-post-command ()
1233 (remove-hook 'pre-command-hook 'kmacro-step-edit-pre-command)
1234 (when kmacro-step-edit-active
1235 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil nil)
1236 (if kmacro-step-edit-key-index
1237 (setq executing-kbd-macro-index kmacro-step-edit-key-index)
1238 (setq kmacro-step-edit-key-index executing-kbd-macro-index))))
1241 (defun kmacro-step-edit-macro ()
1242 "Step edit and execute last keyboard macro.
1244 To customize possible responses, change the \"bindings\" in `kmacro-step-edit-map'."
1246 (let ((kmacro-step-edit-active t)
1247 (kmacro-step-edit-new-macro "")
1248 (kmacro-step-edit-inserting nil)
1249 (kmacro-step-edit-appending nil)
1250 (kmacro-step-edit-replace t)
1251 (kmacro-step-edit-prefix-index nil)
1252 (kmacro-step-edit-key-index 0)
1253 (kmacro-step-edit-action nil)
1254 (kmacro-step-edit-help nil)
1255 (kmacro-step-edit-num-input-keys num-input-keys)
1256 (pre-command-hook pre-command-hook)
1257 (post-command-hook post-command-hook)
1258 (minibuffer-setup-hook minibuffer-setup-hook))
1259 (add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil)
1260 (add-hook 'post-command-hook 'kmacro-step-edit-post-command t)
1261 (add-hook 'minibuffer-setup-hook 'kmacro-step-edit-minibuf-setup t)
1262 (call-last-kbd-macro nil nil)
1263 (when (and kmacro-step-edit-replace
1264 kmacro-step-edit-new-macro
1265 (not (equal last-kbd-macro kmacro-step-edit-new-macro)))
1267 (setq last-kbd-macro kmacro-step-edit-new-macro))))
1271 ;;; arch-tag: d3fe0b24-ae41-47de-a4d6-41a77d5559f0
1272 ;;; kmacro.el ends here