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 13:59:40 +0100 [thread overview]
Message-ID: <87r0ug8rlv.fsf@gmail.com> (raw)
In-Reply-To: <87wn4891q6.fsf@gmail.com> (Robert Pluim's message of "Thu, 23 Feb 2023 10:21:05 +0100")
>>>>> On Thu, 23 Feb 2023 10:21:05 +0100, Robert Pluim <rpluim@gmail.com> said:
Robert> This fails in emacs-29 as well. Stefan, you rewrote this code to
Robert> use oclosures, any ideas? I guess we could just use
Robert> macro--string-to-vector in both cases, but youʼre the expert here :-)
The following passes 'make bootstrap' and 'make check'.
Iʼve probably committed a heinous crime by autoloading an internal
function, but that seemed cleaner than "(require 'macros)" in two
places.
Robert
--
diff --git c/lisp/kmacro.el i/lisp/kmacro.el
index 94d8794bd23..411f981d47b 100644
--- c/lisp/kmacro.el
+++ i/lisp/kmacro.el
@@ -380,7 +380,10 @@ kmacro-view-item-no
(defun kmacro-ring-head ()
"Return pseudo head element in macro ring."
(and last-kbd-macro
- (kmacro last-kbd-macro kmacro-counter kmacro-counter-format-start)))
+ (kmacro (if (stringp last-kbd-macro)
+ (macro--string-to-vector last-kbd-macro)
+ last-kbd-macro)
+ kmacro-counter kmacro-counter-format-start)))
(defun kmacro-push-ring (&optional elt)
@@ -841,8 +844,6 @@ kmacro-lambda-form
(setq mac (nth 0 mac)))
(when (stringp mac)
;; `kmacro' interprets a string according to `key-parse'.
- (require 'macros)
- (declare-function macro--string-to-vector "macros")
(setq mac (macro--string-to-vector mac)))
(kmacro mac counter format)))
diff --git c/lisp/macros.el i/lisp/macros.el
index 59c7796551f..e00aedc82b0 100644
--- c/lisp/macros.el
+++ i/lisp/macros.el
@@ -46,6 +46,7 @@ macros--insert-vector-macro
" ")
?\]))
+;;;###autoload
(defun macro--string-to-vector (str)
"Convert an old-style string key sequence to the vector form."
(let ((vec (string-to-vector str)))
diff --git c/test/lisp/kmacro-tests.el i/test/lisp/kmacro-tests.el
index 551fd8b60fc..a325220e8d9 100644
--- c/test/lisp/kmacro-tests.el
+++ i/test/lisp/kmacro-tests.el
@@ -614,6 +614,20 @@ kmacro-tests-name-last-macro-bind-and-rebind
(kmacro-tests-should-insert "bb"
(kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test))))
+;; Bug#61700 inserting named macro when the definition contains things
+;; that `key-parse' thinks are named keys
+(kmacro-tests-deftest kmacro-tests-name-last-macro-key-parse-syntax ()
+ "Name last macro can rebind a symbol it binds."
+ ;; Make sure our symbol is unbound.
+ (when (fboundp 'kmacro-tests-symbol-for-test)
+ (fmakunbound 'kmacro-tests-symbol-for-test))
+ (setplist 'kmacro-tests-symbol-for-test nil)
+ (kmacro-tests-define-macro "<b> hello </>")
+ (kmacro-name-last-macro 'kmacro-tests-symbol-for-test)
+ ;; Now run the function bound to the symbol.
+ (kmacro-tests-should-insert "<b> hello </>"
+ (kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test))))
+
(kmacro-tests-deftest kmacro-tests-store-in-register ()
"Macro can be stored in and retrieved from a register."
(use-local-map kmacro-tests-keymap)
next prev parent reply other threads:[~2023-02-23 12:59 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
2023-02-23 12:59 ` Robert Pluim [this message]
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=87r0ug8rlv.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).