From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel@gnu.org
Subject: Re: Window change functions
Date: Sat, 05 Jan 2019 01:13:12 -0500 [thread overview]
Message-ID: <jwv4lanpry1.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5C249D21.7070508@gmx.at> (martin rudalics's message of "Thu, 27 Dec 2018 10:36:33 +0100")
> There are several reasons that favor delaying:
>
> (1) When finishing a window excursion by restoring the previous
> configuration we should run 'window-configuration-change-hook' if
> and only if something really changed. Telling whether something
> really changed is hard and I doubt current Emacs does it right.
I can't remember the last time I found save-window-excursion to be
useful, so I don't find this use case important.
> (2) 'balance-windows-area' is a good example for why we should delay
> calling size change functions IMO: Its intermediate steps are not
> really interesting for any client of that hook.
This is indeed a valid case. While I do use balance-windows-area, I'm
not sure how important this is, tho.
> (3) Delaying hooks and running them all in one bunch allows to
> reliably look at possibly related changes by consulting the
> 'window-old-...' functions.
I don't understand this. If we run the hook right away, the old state
is easy to get to as well, isn't it?
> (4) Some clients do the delaying themselves by putting an according
> function on 'post-command-hook'. This won't be needed any more
> with delayed execution.
The flip side is that while it's currently easy to delay the execution
using post-command-hook, it will be impossible to *un*delay the
execution with the new setup. That's what worries me.
> Note that 'window-size-change-functions' are currently already run
> right in the middle of redisplay. Often, window sizes are correct
> only *after* redisplay. Think of minibuffer window resizing or
OK, miniwindow resizing is a valid case.
>> Hmm... so to detect when a specific buffer stops being displayed you
>> need to use the global part of the hook and you're not told which was
>> the previously displayed buffer, so you need to keep track of
>> that yourself.
>
> Correct. The right position to detect when a "specific buffer stops
> being displayed" is (1) 'kill-buffer-hook' and *would be* (2) a
> 'before-delete-window-hook' because right after its deletion a window
> might get GCed immediately and (2) would not have anything else but
> the buffer itself to work upon. So if someone sees a need for (2)
> please tell me and I'll add such a hook (it won't cost much but some
> lines in the manual).
If we run window-buffer-change-functions eagerly (i.e. from
set-window-buffer, as well as when creating/deleting a window), then
it's easy to let the hook access the "old buffer" that's being replaced
(we can even pass it as a parameter to the hook functions).
>> IIUC this hook is hence also run for changes to frame-selected-window,
>> even when that frame is not selected? I wonder if it's a good idea.
>> frame-selected-window is a fairly obscure detail, in my experience.
> If someone changes it separately (that is, sets it for a non-selected
> frame), there is now a hook to trace that.
Right, and my question is: why bother? I think it makes the API more
complex with zero benefit.
> He could try it though.
Didn't notice anything funny.
Stefan
next prev parent reply other threads:[~2019-01-05 6:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-25 9:41 Window change functions martin rudalics
2018-12-25 20:13 ` Gnus crash (was: Window change functions) Juri Linkov
2018-12-25 20:39 ` Gnus crash Stefan Monnier
2018-12-26 9:19 ` Paul Eggert
2018-12-26 22:22 ` Juri Linkov
2018-12-26 19:55 ` Window change functions Stefan Monnier
2018-12-27 9:36 ` martin rudalics
2018-12-27 15:56 ` Eli Zaretskii
2019-01-05 6:17 ` Stefan Monnier
2019-01-05 7:20 ` Eli Zaretskii
2019-01-05 10:18 ` martin rudalics
2019-01-06 17:22 ` Stefan Monnier
2019-01-07 9:03 ` martin rudalics
2019-01-08 18:10 ` Stefan Monnier
2019-01-09 10:02 ` martin rudalics
2019-01-11 9:23 ` martin rudalics
2019-01-05 6:13 ` Stefan Monnier [this message]
2019-01-05 10:18 ` martin rudalics
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv4lanpry1.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=rudalics@gmx.at \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.