From: Po Lu Date: Sun, 2 Mar 2025 08:00:33 +0000 (+0800) Subject: Enable kmacro-call-macro to function in some circumstances X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=91d510341c0309276fd7b301c01d5802ca4c618a;p=emacs.git Enable kmacro-call-macro to function in some circumstances * 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) --- diff --git a/lisp/kmacro.el b/lisp/kmacro.el index faf21e82452..12fb8b44385 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -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))