GNU bug report logs - #77317
31.0.50; insert-kbd-macro RET produces elisp that does not work

Previous Next

Package: emacs;

Reported by: Adam Sjøgren <asjo <at> koldfront.dk>

Date: Thu, 27 Mar 2025 18:39:02 UTC

Severity: normal

Found in version 31.0.50

Done: Adam Sjøgren <asjo <at> koldfront.dk>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Adam Sjøgren <asjo <at> koldfront.dk>
Cc: 77317 <at> debbugs.gnu.org
Subject: bug#77317: 31.0.50; insert-kbd-macro RET produces elisp that does not work
Date: Fri, 28 Mar 2025 13:50:33 -0400
> The generated code looks like this:
>
>     (setq last-kbd-macro
>        (kmacro "A B B A"))

Hmm... this is nicely readable, but indeed it bumps into the following
problem:

A keyboard macro is made of 3 elements: the sequence of events, of
course, but also a counter and format string.
The "currently installed" (aka "last") keyboard macro stores those
3 pieces of info in, respectively:

    last-kbd-macro
    kmacro-counter
    kmacro-counter-format

When saved elsewhere (e.g. in the `kmacro-ring` or in an init file),
these three elements are bundled into a single `kmacro` object.

So to avoid the error you're seeing, as the code currently stands, the
`(setq last-kbd-macro (kmacro ...))` should be replaced with either
a call to `kmacro-split-ring-element` or something which has the same
effect:

    (defun kmacro-split-ring-element (elt)
      (setq last-kbd-macro (kmacro--keys elt)
            kmacro-counter (kmacro--counter elt)
            kmacro-counter-format-start (kmacro--format elt)))

🙁

Maybe a better fix would be to "force" the user to give a name to the
macro before inserting it.

Could you explain exactly how you bumped into this problem, more
specifically what was your intention behind the use of
`insert-kbd-macro` without giving the macro a name?


        Stefan





This bug report was last modified 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.