unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Eshel Yaron <me@eshelyaron.com>
Cc: 67650@debbugs.gnu.org
Subject: bug#67650: [PATCH] ; Hide completion preview when switching windows
Date: Wed, 06 Dec 2023 21:02:47 +0200	[thread overview]
Message-ID: <83v89b2lyg.fsf@gnu.org> (raw)
In-Reply-To: <m1r0jzfalv.fsf@dazzs-mbp.home> (message from Eshel Yaron on Wed,  06 Dec 2023 19:29:32 +0100)

> From: Eshel Yaron <me@eshelyaron.com>
> Cc: 67650@debbugs.gnu.org
> Date: Wed, 06 Dec 2023 19:29:32 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > OK, I understand.  However, it means that now we will not only slow
> > down every command in the buffer that has the completion-preview mode
> > turned on, but we will also slow down every redisplay cycle, even if
> > the buffer was not switched.
> 
> How so?  The docstring of `window-selection-change-functions` says:
> 
>   Functions specified buffer-locally are called for each window showing
>   the corresponding buffer if and only if that window has been selected
>   or deselected since the last redisplay.
> 
> And indeed I see that the function this patch adds to that hook is only
> called in those circumstances.  What performance impact do you envision
> for other redisplay cycles?

Look at the implementation.  Each redisplay cycle we call
run_window_change_functions, which then needs to decide whether to run
any of the window-change related hooks, and for which windows.  IOW,
before we determine whether a window was selected or deselected, we
need to examine them all.  This wastes CPU cycles.

I'm also worried about code that runs from with-selected-window and
similar macros, about code that selects and then deselects the
mini-window, and other similar "temporary changes" of the selected
window.

> > I think we should find a better way of doing this.
> 
> I was also a bit uneasy with extending another hook at first, so I
> appreciate your scrutiny, and I'd love to consider different ways to
> achieve what we want here.  But so far this is the best way I came up
> with, and after testing it and examining the specifics of the case I
> feel that it's not such a bad solution.
> 
> > How about that idle timer idea we discussed earlier?
> 
> I'm not sure I see how that would solve this issue, because we want to
> dismiss the preview as soon as you switch windows, and I imagine that an
> ideal timer would instead be less prompt to react to such a change.
> What do you have in mind?

Whether a timer will be prompt or not is determined by the time
interval programmed into the timer.  A small enough interval is
indistinguishable from "as soon as".

We pop down other features using timers, for example tooltips.  It
doesn't look bad in practice.

Also, window-selection-change-functions cannot perform redisplay
(because they are called in the middle of redisplay), so the effect
will be seen only upon the next redisplay cycle -- not immediately
anyway.

> I also feel that we shouldn't underrate the ability of the current
> approach to display the preview immediately.  In fact, one user said
> that Completion Preview mode "seems more smooth and efficient" then the
> package he was using before, which I attribute to this exact property of
> showing the preview without delay.

Maybe so, but adding too much stuff to these hooks is inelegant, to
say the least, and basically I'm reluctant to admit more and more of
such features.  We already have too many features on these hooks.  And
users rightfully complain that Emacs feels sluggish, except if you
invoke "emacs -Q".

> I share the concern that you're expressing towards excessive use of
> hooks, but I can't currently think of further cases in which we'll
> /need/ any hook but `post-command-hook` for showing/hiding the preview,
> and I think that we're still in the safe zone with this patch.

Well, please try to find alternative implementation ideas, as I'm very
unhappy about going this way.  Again, I suspect this is not the last
hook you'd want to employ for this feature, we are just starting down
that road.

> Perhaps we should wait a few days to see if other suggestions come up?

Fine by me.





  reply	other threads:[~2023-12-06 19:02 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 [this message]
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=83v89b2lyg.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=67650@debbugs.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).