unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: 67650@debbugs.gnu.org
Subject: bug#67650: [PATCH] ; Hide completion preview when switching windows
Date: Wed, 06 Dec 2023 21:54:20 +0100	[thread overview]
Message-ID: <m14jgvf3wj.fsf@dazzs-mbp.home> (raw)
In-Reply-To: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> (Dmitry Gutov's message of "Wed, 6 Dec 2023 22:02:25 +0200")

Dmitry Gutov <dmitry@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.





      reply	other threads:[~2023-12-06 20:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 20:26 bug#67650: [PATCH] ; Hide completion preview when switching windows Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-06 12:04 ` Eli Zaretskii
2023-12-06 13:33   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-06 16:43     ` Eli Zaretskii
2023-12-06 18:29       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-06 19:02         ` Eli Zaretskii
2023-12-06 21:16           ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-09  9:08             ` Eli Zaretskii
2023-12-06 20:02 ` Dmitry Gutov
2023-12-06 20:54   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m14jgvf3wj.fsf@dazzs-mbp.home \
    --to=bug-gnu-emacs@gnu.org \
    --cc=67650@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=me@eshelyaron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).