unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Josh Moller-Mara <jmm@cns.nyu.edu>
Cc: 61700@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: 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	[thread overview]
Message-ID: <87wn4891q6.fsf@gmail.com> (raw)
In-Reply-To: <87wn4amraf.fsf@cns.nyu.edu> (Josh Moller-Mara's message of "Tue,  21 Feb 2023 17:18:16 -0800")

>>>>> On Tue, 21 Feb 2023 17:18:16 -0800, Josh Moller-Mara <jmm@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
-- 





  reply	other threads:[~2023-02-23  9:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22  1:18 bug#61700: 30.0.50; insert-kbd-macro fails for named macro but not last macro Josh Moller-Mara
2023-02-23  9:21 ` Robert Pluim [this message]
2023-02-23 12:59   ` Robert Pluim
2023-02-23 16:00     ` Eli Zaretskii
2023-02-23 16:30       ` Robert Pluim
2023-02-23 16:44         ` Eli Zaretskii
2023-02-23 18:28     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-24 10:44       ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wn4891q6.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=61700@debbugs.gnu.org \
    --cc=jmm@cns.nyu.edu \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).