From 90a6c7dc7cf6d971dd2033ba13a5b08e5c80c091 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 9 Jul 2025 09:46:46 +0300 Subject: [PATCH] Handle multiple mouse events in display-buffer-override-next-command * lisp/window.el (display-buffer-override-next-command): Use 'mouse-event-p' to wait for more following mouse events. * lisp/frame.el (other-frame-prefix): * lisp/tab-bar.el (other-tab-prefix): * lisp/windmove.el (windmove-display-in-direction): * lisp/window.el (other-window-prefix, same-window-prefix): Update the docstring to explain the behavior in regard to multiple consecutive mouse events (bug#78945). (cherry picked from commit 280d6f70a356dc24a7026c00cbcbd116c2f7c7ed) --- lisp/frame.el | 3 +++ lisp/tab-bar.el | 3 +++ lisp/windmove.el | 3 +++ lisp/window.el | 12 +++++++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lisp/frame.el b/lisp/frame.el index 5f8fd53290f..03cff754bfe 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1262,6 +1262,9 @@ that variable should be nil." "Display the buffer of the next command in a new frame. The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). +In case of multiple consecutive mouse events such as , +a mouse release event , , +all bound commands are handled until one of them displays a buffer. Creates a new frame before displaying the buffer. When `switch-to-buffer-obey-display-actions' is non-nil, `switch-to-buffer' commands are also supported." diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 9fc255b5684..76c7909cd0a 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -3027,6 +3027,9 @@ files will be visited." "Display the buffer of the next command in a new tab. The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). +In case of multiple consecutive mouse events such as , +a mouse release event , , +all bound commands are handled until one of them displays a buffer. Creates a new tab before displaying the buffer, or switches to the tab that already contains that buffer. When `switch-to-buffer-obey-display-actions' is non-nil, diff --git a/lisp/windmove.el b/lisp/windmove.el index a46eaaadbb6..6e670e6c0aa 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -441,6 +441,9 @@ When `switch-to-buffer-obey-display-actions' is non-nil, "Display the next buffer in the window at direction DIR. The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). +In case of multiple consecutive mouse events such as , +a mouse release event , , +all bound commands are handled until one of them displays a buffer. Create a new window if there is no window in that direction. By default, select the new window with a displayed buffer. diff --git a/lisp/window.el b/lisp/window.el index f8f9e3113ad..61626f5a3e7 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4017,6 +4017,9 @@ always effectively nil." "Display the buffer of the next command in a new window. The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). +In case of multiple consecutive mouse events such as , +a mouse release event , , +all bound commands are handled until one of them displays a buffer. Creates a new window before displaying the buffer. When `switch-to-buffer-obey-display-actions' is non-nil, `switch-to-buffer' commands are also supported." @@ -4037,6 +4040,9 @@ When `switch-to-buffer-obey-display-actions' is non-nil, "Display the buffer of the next command in the same window. The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). +In case of multiple consecutive mouse events such as , +a mouse release event , , +all bound commands are handled until one of them displays a buffer. Even when the default rule should display the buffer in a new window, force its display in the already selected window. When `switch-to-buffer-obey-display-actions' is non-nil, @@ -9631,9 +9637,9 @@ to deactivate this overriding action." ;; But don't remove immediately after ;; adding the hook by the same command below. (eq this-command command) - ;; Don't exit on mouse down event - ;; in anticipation of mouse release event. - (memq 'down (event-modifiers last-input-event))) + ;; Don't exit on mouse events in anticipation + ;; of more related events like double click. + (mouse-event-p last-input-event)) (funcall exitfun)))) ;; Call post-function after the next command finishes (bug#49057). (add-hook 'post-command-hook postfun) -- 2.39.5