unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61700: 30.0.50; insert-kbd-macro fails for named macro but not last macro
@ 2023-02-22  1:18 Josh Moller-Mara
  2023-02-23  9:21 ` Robert Pluim
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Moller-Mara @ 2023-02-22  1:18 UTC (permalink / raw)
  To: 61700

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

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

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

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

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

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

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

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

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

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

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


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

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




In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.35, cairo version 1.16.0)
Repository revision: 2c7e87c73a90effab66fa7c783855199880315d3
Repository branch: master
System Description: NixOS 22.11 (Raccoon)

Configured using:
 'configure
 --prefix=/nix/store/bdg6d4gm3ma2hja63hbxwrkaap04j2c6-emacs-pgtk-20230217.0
 --disable-build-details --with-modules --with-pgtk
 --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM GTK3 ZLIB





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-24 10:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).