Subject: Re: bug#78945: 30.1; C-x 4 4 and C-x 5 5 do not work with `dired-mouse-find-file'

From: Stefan Monnier <[email-masked]>
Date: Mon, 07 Jul 2025 15:20:42 -0400

>> The "normal" way to disable the override is by consuming it:
>>
>>                        ;; Reset display-buffer-overriding-action
>>                        ;; after the first display-buffer action (bug#39722).
>>                        (funcall clearfun)
>>
>> I'm not suggesting we leave the override active "indefinitely" for as
>> long as no `display-buffer` used it, but I don't expect any serious
>> problem if the override lingers a bit longer.
>
> The only potential problem is mistyped keys or accidental clicks.
> But since it's very rare then maybe this patch is ok:
>
> diff --git a/lisp/window.el b/lisp/window.el
> index ea102706ecb..a25af158a73 100644
> --- a/lisp/window.el
> +++ b/lisp/window.el
> @@ -9673,9 +9680,9 @@ display-buffer-override-next-command
>                       ;; 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 down event in anticipation
> +                     ;; of mouse release or double click event.
> +                     (mouse-event-p last-input-event))
>                (funcall exitfun))))
>      ;; Call post-function after the next command finishes (bug#49057).
>      (add-hook 'post-command-hook postfun)

LGTM.

`help--read-key-sequence` combines it with a time-limit because we don't
want `C-h k` to sit there indefinitely, but it doesn't seem needed here,
indeed, since in most cases the override will have been
disabled/consumed by an intervening `display-buffer` anyway.

        Stefan