This section describes how a Lisp program can take action whenever a
window displays a different part of its buffer or a different buffer.
There are three actions that can change this: scrolling the window,
switching buffers in the window, and changing the size of the window.
The first two actions run window-scroll-functions
; the last runs
window-size-change-functions
. The paradigmatic use of these
hooks is Lazy Lock mode; see section `Font Lock Support Modes' in The GNU Emacs Manual.
Displaying a different buffer in the window also runs these functions.
These functions cannot expect window-end
(see section The Window Start Position)
to return a meaningful value, because that value is updated only by
redisplaying the buffer. So if one of these functions needs to know the
last character that will fit in the window with its current
display-start position, it has to find that character using
vertical-motion
(see section Motion by Screen Lines).
Each function receives the frame as its sole argument. There is no direct way to find out which windows on that frame have changed size, or precisely how. However, if a size-change function records, at each call, the existing windows and their sizes, it can also compare the present sizes and the previous sizes.
Creating or deleting windows counts as a size change, and therefore causes these functions to be called. Changing the frame size also counts, because it changes the sizes of the existing windows.
It is not a good idea to use save-window-excursion
(see section Window Configurations) in these functions, because that always counts as a
size change, and it would cause these functions to be called over and
over. In most cases, save-selected-window
(see section Selecting Windows) is what you need here.
Go to the first, previous, next, last section, table of contents.