GNU bug report logs - #72419
31.0.50; Macro editing can't deal with event appliers

Previous Next

Package: emacs;

Reported by: Alexander Prähauser <ahprae <at> protonmail.com>

Date: Fri, 2 Aug 2024 12:38:02 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ahprae <at> protonmail.com, 72419 <at> debbugs.gnu.org, Visuwesh <visuweshm <at> 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
> 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)





This bug report was last modified 358 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.