GNU bug report logs -
#67650
[PATCH] ; Hide completion preview when switching windows
Previous Next
Reported by: Eshel Yaron <me <at> eshelyaron.com>
Date: Tue, 5 Dec 2023 20:27:02 UTC
Severity: normal
Tags: patch
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 67650 <at> debbugs.gnu.org (full text, mbox):
Hi Eli,
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Date: Tue, 05 Dec 2023 21:26:27 +0100
>> From: Eshel Yaron via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> This patch ensures that we dismiss the completion preview when users
>> switch to another window. Previously, the completion preview would
>> remain in a window after switching to another window showing another
>> buffer, since the `post-command-hook` that Completion Preview mode sets
>> up locally doesn't run after a command switches to another buffer.
>
> Sorry, I don't understand:
No problem, let's clarify.
> why does it matter whether post-command-hook runs _after_ switching to
> another buffer?
Since then the value of `post-command-hook` is no longer the
buffer-local value you had in the buffer where you invoked the command,
and in our case that buffer-local value is the one that includes
`completion-preview--post-command`, where we would update (or dismiss)
the completion preview for that (original) buffer.
> When and why would a command that caused post-command-hook invocation
> NOT need to dismiss the preview?
What do you mean? All commands "cause `post-command-hook`", no?
We show/hide/update the preview during `post-command-hook`. So for
example, when `post-command-hook` runs after `self-insert-command`, we
don't dismiss the preview, in fact we show it. Does that make sense?
> If post-command-hook should always dismiss the preview
That's not the case, see above.
> then we shouldn't need another hook, right?
Even if it were the case, we would need to handle the case when
`post-command-hook` runs in a different buffer, with a different
buffer-local value, after switching. And indeed we need to handle that
case, which is what this patch does.
Here's a recipe that you can try to see this patch in action:
1. emacs -Q
2. M-x completion-preview-mode RET
3. Type `(def` and see the preview appears
4. C-x 4 b foo RET
Without this patch, you'd now see the preview linger in the window
showing the *scratch* buffer. With this patch, the preview disappears
as soon as you switch to the other window.
Best,
Eshel
This bug report was last modified 1 year and 168 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.