From 0c55cd0e176cc73178e8f18d959d5a6f9bf632de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Sj=C3=B8gren?= Date: Sun, 20 Apr 2025 18:44:16 +0200 Subject: [PATCH] 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) --- doc/emacs/kmacro.texi | 9 ++++++--- lisp/macros.el | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi index 62f275de259..09c6c5d4675 100644 --- a/doc/emacs/kmacro.texi +++ b/doc/emacs/kmacro.texi @@ -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}. @findex insert-kbd-macro - Once a macro has a command name, you can save its definition in a file. -Then it can be used in another editing session. First, visit the file -you want to save the definition in. Then use this command: + You can save a macro's definition in a file. Then it can be used in +another editing session. First, visit the file you want to save the +definition in. Then use this command: @example 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 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 @section Editing a Keyboard Macro diff --git a/lisp/macros.el b/lisp/macros.el index fe79fe10f98..59554773629 100644 --- a/lisp/macros.el +++ b/lisp/macros.el @@ -49,7 +49,8 @@ ;;;###autoload (defun insert-kbd-macro (macroname &optional keys) "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 \(this is the prefix argument, when calling interactively).