From 269d337f9191cb58e70f93f8aae47a9bd8d635f9 Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Sat, 8 Mar 2025 07:38:38 -0800 Subject: [PATCH] Make windmove repetition more robust Munge this-command when we hit a movement barrier so we override only on the very next command instead of at the end of a sequence of movement commands that didn't encounter a barrier. * (windmove-do-window-select): Use last-command to remember that we hit a barrier. --- lisp/windmove.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/windmove.el b/lisp/windmove.el index d1b40ef23bd..4d122c08158 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -385,11 +385,13 @@ the second invocation will override the `no-other-window' property. CALLING-COMMAND is the command that called this function, used to detect repeated commands." (let* ((repeated-command - (and calling-command (eq last-command calling-command))) + (and calling-command + windmove-allow-repeated-command-override + (eq last-command + (intern (format "%s-override" calling-command))))) (other-window (windmove-find-other-window dir arg window))) - (when (and (null other-window) - repeated-command windmove-allow-repeated-command-override) + (when (and (null other-window) repeated-command) (setf other-window (window-in-direction dir window t arg windmove-wrap-around t))) ;; Create window if needed @@ -411,6 +413,11 @@ repeated commands." windmove-allow-repeated-command-override) (let ((test-window (window-in-direction dir window t arg windmove-wrap-around t))) (when test-window + ;; Remember that we stopped at a boundary so we don't override + ;; a no-other-window before telling the user about it during a + ;; multi-command movement sequence. + (setf this-command + (intern (format "%s-override" calling-command))) (user-error "No window %s (repeat to override)" dir)))) (cond ((null other-window)