Subject: bug#77317: 31.0.50; insert-kbd-macro RET produces elisp that does not work

From: Adam Sjøgren <[email-masked]>
Date: Thu, 27 Mar 2025 19:37:39 +0100

If I record a macro, for instance by pressing C-x ( A B B A C-x ) I can
do M-x insert-kbd-macro RET to have elisp representing that macro
inserted in the current buffer.

If I evaluate that code and then try to execute the macro with C-x e, I
get the error: "Keyboard macros must be strings or vectors".

I was expecting the macro to be executed, inserting "ABBA".

The generated code looks like this:

    (setq last-kbd-macro
       (kmacro "A B B A"))

and if I evaluate it, *Messages* contains:

    #[256 "\301\242\302^[^\\305\300^B\306#\210\301^L\240*\207" [[65 66
     66 65] (0) "%d" kmacro-counter-format-start kmacro-counter
     execute-kbd-macro kmacro-loop-setup-function] 5 kmacro]

and pressing C-x e to execute the macro results in the above mentioned
error.

(Naming the macro and inserting it creates a defalias, which works -
it's only the last-kbd-macro case that does not work.)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.16.0) of 2025-03-08 built on tullinup
Repository revision: e78470fd1b2200b44dfb2465e39d7b31674bbc2a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure -C --with-tree-sitter --with-xinput2 --without-pgtk
 --with-native-compilation=aot'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils macros cl-seq cl-extra help-mode edmacro comp-run comp-common
rx kmacro byte-opt gv bytecomp byte-compile cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames native-compile emacs)

Memory information:
((conses 16 69445 18686) (symbols 48 6645 0) (strings 32 18633 1517)
 (string-bytes 1 595563) (vectors 16 11875)
 (vector-slots 8 161807 10397) (floats 8 30 4) (intervals 56 286 23)
 (buffers 992 12))

-- 
 "You know how everyone says you should stop and            Adam Sjøgren
  smell the roses? Well, this morning I did. *Big      [email-masked]
  deal!* They smelled like a bunch of dumb flowers!
  It was the most mundane experience I've ever had!"