Clarify buffer-local behavior of 'window-buffer-change-functions'

* doc/lispref/windows.texi (Window Hooks): Explain how to
discern calls for 'window-buffer-change-functions' where a
buffer was removed from the window from those where a buffer is
now shown in that window.
This commit is contained in:
Martin Rudalics 2025-10-17 10:24:53 +02:00
parent 3e78f6487d
commit 3fd24aee7e

View file

@ -7424,6 +7424,24 @@ once for the buffer currently shown in the window. In either case the
window is passed as argument and the respective buffer is made
temporarily current.
If you are using the buffer-local version of this hook, you may want to
discern the case where the buffer was removed from a window from the
case where the buffer is now shown in that window. Let @code{window}
denote the window argument passed to a function on this hook: To detect
the case where the buffer was removed from @code{window} use the idiom
@example
(eq (window-old-buffer window) (current-buffer))
@end example
while to detect whether the buffer is now shown in @code{window} use
@example
(eq (window-buffer window) (current-buffer))
@end example
instead.
Functions specified by the default value are called for a frame if at
least one window on that frame has been added, deleted or assigned
another buffer since the last time window change functions were run.