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: Eli Zaretskii <eliz@gnu.org>
Cc: 67650@debbugs.gnu.org
Subject: bug#67650: [PATCH] ; Hide completion preview when switching windows
Date: Wed, 06 Dec 2023 14:33:01 +0100	[thread overview]
Message-ID: <m1il5blalu.fsf@sp-byods-145-109-54-47.wireless.uva.nl> (raw)
In-Reply-To: <83r0jz4jvd.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Dec 2023 14:04:54 +0200")

Hi Eli,

Eli Zaretskii <eliz@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@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





  reply	other threads:[~2023-12-06 13:33 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 [this message]
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

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=m1il5blalu.fsf@sp-byods-145-109-54-47.wireless.uva.nl \
    --to=bug-gnu-emacs@gnu.org \
    --cc=67650@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --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).