]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/macros.el (insert-kbd-macro): Fix anonymous case (bug#77317)
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 31 Mar 2025 15:36:20 +0000 (11:36 -0400)
committerEshel Yaron <me@eshelyaron.com>
Mon, 31 Mar 2025 18:40:09 +0000 (20:40 +0200)
(cherry picked from commit 10eb57169da01f3f96a5954aa42673d10086824f)

lisp/macros.el

index 64b78d1cdf4d0980fddcf5556da1b3eaffca77af..ae721b44669f3f638d932e35e03165cf13f046d7 100644 (file)
@@ -72,14 +72,14 @@ use this command, and then save the file."
          (setq macroname 'last-kbd-macro definition last-kbd-macro)
          (insert "(setq "))
       (setq definition (symbol-function macroname))
+      (when (or (stringp definition) (vectorp definition))
+        (setq definition (kmacro (kmacro--to-vector definition))))
       ;; Prefer `defalias' over `fset' since it additionally keeps
       ;; track of the file where the users added it, and it interacts
       ;; better with `advice-add' (and hence things like ELP).
       (insert "(defalias '"))
     (prin1 macroname (current-buffer))
     (insert "\n   ")
-    (when (or (stringp definition) (vectorp definition))
-      (setq definition (kmacro (kmacro--to-vector definition))))
     (if (kmacro-p definition)
         (let ((vecdef  (kmacro--keys     definition))
               (counter (kmacro--counter definition))
@@ -93,8 +93,7 @@ use this command, and then save the file."
             (insert " ")
             (prin1 format (current-buffer)))
           (insert ")"))
-      ;; FIXME: Shouldn't this signal an error?
-      (prin1 definition (current-buffer)))
+        (prin1 `(key-parse ,(key-description definition)) (current-buffer)))
     (insert ")\n")
     (if keys
         (let ((keys (or (and (symbol-function macroname)