]> git.eshelyaron.com Git - emacs.git/commitdiff
Enable kmacro-call-macro to function in some circumstances
authorPo Lu <luangruo@yahoo.com>
Sun, 2 Mar 2025 08:00:33 +0000 (16:00 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 21:01:20 +0000 (22:01 +0100)
* lisp/kmacro.el (kmacro-call-macro): Enable to function when
the selected frame's terminal is different from that most
recently consulted by the event loop.

(cherry picked from commit 7fcb01e76ba9b2c74019f3863975cfe32c8b0da0)

lisp/kmacro.el

index faf21e8245219cce52e506d5fc663489d8ad0483..12fb8b4438507bb6c67c7db10854c3e80b971d99 100644 (file)
@@ -777,8 +777,20 @@ use \\[kmacro-name-last-macro]."
                         last-input-event)))
     (if end-macro
        (kmacro-end-macro arg)          ; modifies last-kbd-macro
+      ;; The effect of Fcall_last_kbd_macro must be reimplemented in
+      ;; Lisp, as the binding of `last-kbd-macro' might not take effect
+      ;; in the C function if the selected frame's terminal is not
+      ;; assigned as the current keyboard.
       (let ((last-kbd-macro (or macro last-kbd-macro)))
-       (call-last-kbd-macro arg #'kmacro-loop-setup-function)))
+        (setq this-command last-command)
+        (setq real-this-command last-kbd-macro)
+        (when defining-kbd-macro
+          (error "Can't execute anonymous macro while defining one"))
+        (unless last-kbd-macro
+          (error "No kbd macro has been defined"))
+       (execute-kbd-macro last-kbd-macro arg
+                           #'kmacro-loop-setup-function)
+        (setq this-command last-command)))
     (when (consp arg)
       (setq arg (car arg)))
     (when (and (or (null arg) (> arg 0))