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 #26 received at 67650 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 05/12/2023 22:26, Eshel Yaron via Bug reports for GNU Emacs, the
> Swiss army knife of text editors wrote:
>> 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.
>
> Another way to do this would look like this:
>
> diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el
> index 1d5f1253702..f2560a98b23 100644
> --- a/lisp/completion-preview.el
> +++ b/lisp/completion-preview.el
> @@ -182,6 +182,7 @@ completion-preview--make-overlay
> (eq (get-text-property 0 'face previous)
> (get-text-property 0 'face string)))
> (add-text-properties 0 1 '(cursor 1) string)
> + (overlay-put completion-preview--overlay 'window (selected-window))
> (overlay-put completion-preview--overlay 'after-string string))
> completion-preview--overlay))
>
We actually have that already (a few lines above in this function),
but it doesn't do the trick. This makes the overlay appear only in
the selected window when you're editing a buffer that's displayed
in multiple windows, but it doesn't make the overlay go away when
you switch to another window.
> You could also move some cleanup logic to pre-command-hook, which
> should be fine with the buffer-locality of the value.
Yes, I'm not sure if that's better than
`window-selection-change-functions` though in terms of performance,
and we'd need to put in some extra work to know if the command is
going to select another window.
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.