Function: kmacro-call-macro
kmacro-call-macro is an autoloaded, interactive and byte-compiled
function defined in kmacro.el.gz.
Signature
(kmacro-call-macro ARG &optional NO-REPEAT END-MACRO MACRO)
Documentation
Call the keyboard MACRO that you defined with C-x ( (kmacro-start-macro).
A prefix argument serves as a repeat count. Zero means repeat until error.
MACRO defaults to last-kbd-macro.
When you call the macro, you can call the macro again by repeating
just the last key in the key sequence that you used to call this
command. See kmacro-call-repeat-key and kmacro-call-repeat-with-arg
for details on how to adjust or disable this behavior.
To give a macro a name so you can call it even after defining others,
use C-x C-k n (kmacro-name-last-macro).
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/kmacro.el.gz
;;;###autoload
(defun kmacro-call-macro (arg &optional no-repeat end-macro macro)
"Call the keyboard MACRO that you defined with \\[kmacro-start-macro].
A prefix argument serves as a repeat count. Zero means repeat until error.
MACRO defaults to `last-kbd-macro'.
When you call the macro, you can call the macro again by repeating
just the last key in the key sequence that you used to call this
command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
for details on how to adjust or disable this behavior.
To give a macro a name so you can call it even after defining others,
use \\[kmacro-name-last-macro]."
(interactive "p")
(let ((repeat-key (and (or (and (null no-repeat)
(> (length (this-single-command-keys)) 1))
;; Used when we're in the process of repeating.
(eq no-repeat 'repeating))
last-input-event)))
(if end-macro
(kmacro-end-macro arg) ; modifies last-kbd-macro
(let ((last-kbd-macro (or macro last-kbd-macro)))
(call-last-kbd-macro arg #'kmacro-loop-setup-function)))
(when (consp arg)
(setq arg (car arg)))
(when (and (or (null arg) (> arg 0))
(setq repeat-key
(if (eq kmacro-call-repeat-key t)
repeat-key
kmacro-call-repeat-key)))
;; Issue a hint to the user, if the echo area isn't in use.
(unless (current-message)
(message "(Type %s to repeat macro%s)"
(format-kbd-macro (vector repeat-key) nil)
(if (and kmacro-call-repeat-with-arg
arg (> arg 1))
(format " %d times" arg) "")))
;; Can't use the `keep-pred' arg because this overlay keymap
;; needs to be removed during the next run of the kmacro
;; (i.e. we must add and remove this map at each repetition).
(set-transient-map
(let ((map (make-sparse-keymap)))
(define-key map (vector repeat-key)
(let ((ra (and kmacro-call-repeat-with-arg arg))
(m (if end-macro
last-kbd-macro
(or macro last-kbd-macro))))
(lambda ()
(interactive)
(kmacro-call-macro ra 'repeating nil m))))
map)))))