Improve documentation of 'insert-kbd-macro'

* lisp/macros.el (insert-kbd-macro): Update documentation
of what happens when no macro name is supplied.

* doc/emacs/kmacro.texi (Save Keyboard Macro): Document
saving 'last-kbd-macro'.  (Bug#77317)
This commit is contained in:
Adam Sjøgren 2025-04-20 18:44:16 +02:00 committed by Eli Zaretskii
parent 925ac2ef70
commit 0c55cd0e17
2 changed files with 8 additions and 4 deletions

View file

@ -472,9 +472,9 @@ C-x C-k b 4
will bind the last keyboard macro to the key sequence @kbd{C-x C-k 4}. will bind the last keyboard macro to the key sequence @kbd{C-x C-k 4}.
@findex insert-kbd-macro @findex insert-kbd-macro
Once a macro has a command name, you can save its definition in a file. You can save a macro's definition in a file. Then it can be used in
Then it can be used in another editing session. First, visit the file another editing session. First, visit the file you want to save the
you want to save the definition in. Then use this command: definition in. Then use this command:
@example @example
M-x insert-kbd-macro @key{RET} @var{macroname} @key{RET} M-x insert-kbd-macro @key{RET} @var{macroname} @key{RET}
@ -494,6 +494,9 @@ additional Lisp code to record the keys (if any) that you have bound
to @var{macroname}, so that the macro will be reassigned the same keys to @var{macroname}, so that the macro will be reassigned the same keys
when you load the file. when you load the file.
If you do not give @code{insert-kbd-macro} a macro name, it will
insert Lisp code to restore the @code{last-kdb-macro}.
@node Edit Keyboard Macro @node Edit Keyboard Macro
@section Editing a Keyboard Macro @section Editing a Keyboard Macro

View file

@ -49,7 +49,8 @@
;;;###autoload ;;;###autoload
(defun insert-kbd-macro (macroname &optional keys) (defun insert-kbd-macro (macroname &optional keys)
"Insert in buffer the definition of kbd macro MACRONAME, as Lisp code. "Insert in buffer the definition of kbd macro MACRONAME, as Lisp code.
MACRONAME should be a symbol. MACRONAME should be a symbol; if none is given, the function inserts
the definition of `last-kdb-macro'.
Optional second arg KEYS means also record the keys it is on Optional second arg KEYS means also record the keys it is on
\(this is the prefix argument, when calling interactively). \(this is the prefix argument, when calling interactively).