GNU bug report logs - #61700
30.0.50; insert-kbd-macro fails for named macro but not last macro

Previous Next

Package: emacs;

Reported by: Josh Moller-Mara <jmm <at> cns.nyu.edu>

Date: Wed, 22 Feb 2023 04:56:04 UTC

Severity: normal

Tags: fixed

Found in version 30.0.50

Fixed in version 29.1

Done: Robert Pluim <rpluim <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 61700 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Josh Moller-Mara <jmm <at> cns.nyu.edu>
Cc: 61700 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#61700: 30.0.50; insert-kbd-macro fails for named macro but
 not last macro
Date: Thu, 23 Feb 2023 10:21:05 +0100
>>>>> On Tue, 21 Feb 2023 17:18:16 -0800, Josh Moller-Mara <jmm <at> cns.nyu.edu> said:

    Josh> Using “M-x insert-kbd-macro” can insert an incorrect kmacro form for a
    Josh> named macro, while still correctly inserting the “last-kbd-macro”.

    Josh> To see this, we’ll define a macro that simply inserts the HTML string
    Josh> “<b>hello</b>” (press F3, type the previous string, then press F4).
    Josh> We’ll name this macro “bold-hello” using “C-x C-k n”.

    Josh> Inserting the definition to the last macro (using “M-x insert-kbd-macro”
    Josh> and leaving the prompt blank) returns:

    Josh> (setq last-kbd-macro
    Josh>    (kmacro "< b > H e l l o < / b >"))

    Josh> Inserting the definition to “bold-hello” (using “M-x insert-kbd-macro”
    Josh> and typing “bold-hello” at the prompt) returns:

    Josh> (defalias 'bold-hello
    Josh>    (kmacro "<b> H e l l o < / b >"))

    Josh> Notice the difference in “< b >” vs “<b>”.  The “bold-hello” command
    Josh> doesn’t work, printing the message:

    Josh> “After 0 kbd macro iterations: Keyboard macro terminated by a command ringing the bell”

    Josh> I think this may have to do with the use of “key-parse” in “kmacro” (see
    Josh> “(find-function 'kmacro)”).

    Josh> (key-parse "<b>hello</b>") returns
    Josh> “[b 104 101 108 108 111 60 47 98 62]”
    Josh> but
    Josh> (macro--string-to-vector "<b>hello</b>") returns
    Josh> “[60 98 62 104 101 108 108 111 60 47 98 62]”

    Josh> The latter form is used in “insert-kbd-macro” when inserting
    Josh> “last-kbd-macro”.

This fails in emacs-29 as well. Stefan, you rewrote this code to
use oclosures, any ideas? I guess we could just use
macro--string-to-vector in both cases, but youʼre the expert here :-)

    Josh> You can also quickly replicate the issue by evaluating the following
    Josh> form:

    Josh> (progn
    Josh>   (setq last-kbd-macro "<b>hello</b>")
    Josh>   (kmacro-name-last-macro 'bold-hello)
    Josh>   (let ((temp-buffer (generate-new-buffer "*macros*")))
    Josh>     (with-current-buffer temp-buffer
    Josh>       (insert-kbd-macro (intern ""))
    Josh>       (insert-kbd-macro 'bold-hello))
    Josh>     (display-buffer temp-buffer)))

Robert
-- 




This bug report was last modified 2 years and 87 days ago.

Previous Next


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