unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: ahprae@protonmail.com, 72419@debbugs.gnu.org,
	Visuwesh <visuweshm@gmail.com>
Subject: bug#72419: 31.0.50; Macro editing can't deal with event appliers
Date: Tue, 20 Aug 2024 15:04:37 -0400	[thread overview]
Message-ID: <jwvr0ajqbaf.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86le0v17cl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 17 Aug 2024 18:45:14 +0300")

> Thanks.  This seems to be a very old bug.  Looks like indeed macro
> editing was not adapted to support event modifier-applying commands,
> or maybe it's a problem with function-key-map.

AFAICT the problem is not specific to event modifier-applying thingies
but to any use of a function binding (i.e. a dynamic remapping) in
`(local-)function-key-map`.

The ugly hack below seems to work for the given recipe, but I tried
a related recipe:

    emacs -Q --nw -f xterm-mouse-mode
    C-x (
    click mouse-1 somewhere to move point
    C-x )
    M-x kmacro-edit-macro RET

and the resulting macro still doesn't look right at all.


        Stefan


diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index c63f7f30c5e..28f74e03b4a 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -593,16 +593,26 @@ edmacro-format-keys
 			      (prog1 (vconcat "C-u " (cl-subseq rest-mac 1 i) " ")
 				(cl-callf cl-subseq rest-mac i)))))))
 	     (bind-len (apply #'max 1
+			      ;; FIXME: Pass `maps' to `lookup-key' directly!
 			      (cl-loop for map in maps
                                        for b = (lookup-key map rest-mac)
                                        when b collect b)))
 	     (key (cl-subseq rest-mac 0 bind-len))
 	     (fkey nil) tlen tkey
+	     ;; FIXME: Pass `maps' to `lookup-key' directly!
 	     (bind (or (cl-loop for map in maps for b = (lookup-key map key)
                                 thereis (and (not (integerp b)) b))
 		       (and (setq fkey (lookup-key local-function-key-map rest-mac))
 			    (setq tlen fkey tkey (cl-subseq rest-mac 0 tlen)
 				  fkey (lookup-key local-function-key-map tkey))
+                            (progn
+                              (when (functionp fkey)
+                                (let ((unread-command-events
+                                       (append (cl-subseq rest-mac tlen) nil)))
+                                  (setq fkey (funcall fkey ""))
+                                  (setq rest-mac (vconcat tkey unread-command-events))))
+                              t)
+			    ;; FIXME: Pass `maps' to `lookup-key' directly!
 			    (cl-loop for map in maps
                                      for b = (lookup-key map fkey)
                                      when (and (not (integerp b)) b)






      parent reply	other threads:[~2024-08-20 19:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02 12:36 bug#72419: 31.0.50; Macro editing can't deal with event appliers Alexander Prähauser via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-17  7:36 ` Eli Zaretskii
2024-08-17  9:39   ` Visuwesh
2024-08-17 10:56     ` Eli Zaretskii
2024-08-17 14:20       ` Visuwesh
2024-08-17 15:45         ` Eli Zaretskii
2024-08-19 18:37           ` Alexander Prähauser via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-20 19:04           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

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=jwvr0ajqbaf.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=72419@debbugs.gnu.org \
    --cc=ahprae@protonmail.com \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=visuweshm@gmail.com \
    /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).