Re: window-buffer-change-functions & window-size-change-functions

Joost Kremers <[email protected]> Wed, 01 Jul 2026 18:09:57 +0200
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Hi Stéphane,

Thanks for your reply.

On Tue, Jun 30 2026, Stéphane Marks wrote:
> On Tue, Jun 30, 2026 at 2:16 PM Joost Kremers <[email protected]>
> wrote:
[...]
>> I'm looking specifically for a way to distinguish the case where a new
>> buffer is displayed in a window from the case where a window size is
>> changed. Going by the names, `window-size-change-functions` and
>> `window-buffer-change-functions` seem to allow me to do that, but
>> apparently the former is also called upon buffer-change.
>
> Consider using a window-buffer-change-functions function: after ensuring
> the object is a window (it can be called with a frame as you probably
> know), call window-old-buffer with the window and if it reports the same
> buffer as window-buffer does, then it's not a new buffer for that window.

I've tried this with `window-buffer-change-functions`, but it doesn't seem
to work for buffer size changes. `window-size-change-functions` does work,
though, and using `window-old-buffer` I can indeed distinguish between
buffer switches and window size changes.

> If you want to exclude minibuffer window changes, call
> active-minibuffer-window to see if the selected window is associated with a
> minibuffer.

I'm actually using the buffer-local value of `window-*-change-functions`,
so that already excludes the minibuffer.

Joost


-- 
Joost Kremers
Life has its moments