@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/windows
@node Windows, Frames, Buffers, Top
displayed in windows.
@menu
-* Basic Windows:: Basic information on using windows.
-* Splitting Windows:: Splitting one window into two windows.
-* Deleting Windows:: Deleting a window gives its space to other windows.
-* Selecting Windows:: The selected window is the one that you edit in.
-* Cyclic Window Ordering:: Moving around the existing windows.
-* Buffers and Windows:: Each window displays the contents of a buffer.
-* Displaying Buffers:: Higher-lever functions for displaying a buffer
- and choosing a window for it.
-* Choosing Window:: How to choose a window for displaying a buffer.
-* Window Point:: Each window has its own location of point.
-* Window Start:: The display-start position controls which text
- is on-screen in the window.
-* Vertical Scrolling:: Moving text up and down in the window.
-* Horizontal Scrolling:: Moving text sideways on the window.
-* Size of Window:: Accessing the size of a window.
-* Resizing Windows:: Changing the size of a window.
-* Coordinates and Windows::Converting coordinates to windows.
-* Window Configurations:: Saving and restoring the state of the screen.
+* Basic Windows:: Basic information on using windows.
+* Splitting Windows:: Splitting one window into two windows.
+* Deleting Windows:: Deleting a window gives its space to other windows.
+* Selecting Windows:: The selected window is the one that you edit in.
+* Cyclic Window Ordering:: Moving around the existing windows.
+* Buffers and Windows:: Each window displays the contents of a buffer.
+* Displaying Buffers:: Higher-lever functions for displaying a buffer
+ and choosing a window for it.
+* Choosing Window:: How to choose a window for displaying a buffer.
+* Window Point:: Each window has its own location of point.
+* Window Start:: The display-start position controls which text
+ is on-screen in the window.
+* Vertical Scrolling:: Moving text up and down in the window.
+* Horizontal Scrolling:: Moving text sideways on the window.
+* Size of Window:: Accessing the size of a window.
+* Resizing Windows:: Changing the size of a window.
+* Coordinates and Windows:: Converting coordinates to windows.
+* Window Configurations:: Saving and restoring the state of the screen.
+* Window Hooks:: Hooks for scrolling, window size changes,
+ redisplay going past a certain point,
+ or window configuration changes.
@end menu
@node Basic Windows
In each frame, at any time, one and only one window is designated as
@dfn{selected within the frame}. The frame's cursor appears in that
-window. At ant time, one frame is the selected frame; and the window
+window. At any time, one frame is the selected frame; and the window
selected within that frame is @dfn{the selected window}. The selected
window's buffer is usually the current buffer (except when
@code{set-buffer} has been used). @xref{Current Buffer}.
@item
containing frame
-@item
+@item
window height
-@item
+@item
window width
-@item
+@item
window edges with respect to the screen or frame
-@item
+@item
the buffer it displays
-@item
+@item
position within the buffer at the upper left of the window
-@item
+@item
amount of horizontal scrolling, in columns
-@item
+@item
point
-@item
+@item
the mark
-@item
+@item
how recently the window was selected
@end itemize
@cindex tiled windows
Most window systems support arbitrarily located overlapping windows.
In contrast, Emacs windows are @dfn{tiled}; they never overlap, and
-together they fill the whole screen or frame. Because of the way
-in which Emacs creates new windows and resizes them, you can't create
-every conceivable tiling of windows on an Emacs frame. @xref{Splitting
-Windows}, and @ref{Size of Window}.
+together they fill the whole screen or frame. Because of the way in
+which Emacs creates new windows and resizes them, not all conceivable
+tilings of windows on an Emacs frame are actually possible.
+@xref{Splitting Windows}, and @ref{Size of Window}.
@xref{Display}, for information on how the contents of the
window's buffer are displayed in the window.
@defun windowp object
- This function returns @code{t} if @var{object} is a window.
+This function returns @code{t} if @var{object} is a window.
@end defun
@node Splitting Windows
@group
;; @r{Returns window created}
-(setq w2 (split-window w 15))
+(setq w2 (split-window w 15))
@result{} #<window 28 on windows.texi>
@end group
@group
@smallexample
@group
- __________
- | | line 0
+ __________
+ | | line 0
| w |
|__________|
| | line 15
@smallexample
@group
column 35
- __________
- | | | line 0
+ __________
+ | | | line 0
| w | w3 |
|___|______|
| | line 15
@end smallexample
Normally, Emacs indicates the border between two side-by-side windows
-with a scroll bar (@pxref{X Frame Parameters,Scroll Bars}) or @samp{|}
+with a scroll bar (@pxref{Window Frame Parameters,Scroll Bars}) or @samp{|}
characters. The display table can specify alternative border
characters; see @ref{Display Tables}.
@end deffn
@deffn Command split-window-vertically size
-This function splits the selected window into two windows, one above
-the other, leaving the selected window with @var{size} lines.
+This function splits the selected window into two windows, one above the
+other, leaving the upper of the two windows selected, with @var{size}
+lines. (If @var{size} is negative, then the lower of the two windows
+gets @minus{} @var{size} lines and the upper window gets the rest, but
+the upper window is still the one selected.)
-This function is simply an interface to @code{split-windows}.
+This function is simply an interface to @code{split-window}.
Here is the complete function definition for it:
@smallexample
@group
(defun split-window-vertically (&optional arg)
- "Split current window into two windows, one above the other."
+ "Split current window into two windows, @dots{}"
(interactive "P")
(split-window nil (and arg (prefix-numeric-value arg))))
@end group
This function splits the selected window into two windows
side-by-side, leaving the selected window with @var{size} columns.
-This function is simply an interface to @code{split-windows}. Here is
+This function is simply an interface to @code{split-window}. Here is
the complete definition for @code{split-window-horizontally} (except for
part of the documentation string):
deletes any windows that aren't part of that configuration.
When you delete a window, the space it took up is given to one
-adjacent sibling. (In Emacs version 18, the space was divided evenly
-among all the siblings.)
+adjacent sibling.
@c Emacs 19 feature
@defun window-live-p window
@end defun
@deffn Command delete-window &optional window
-This function removes @var{window} from the display. If @var{window}
-is omitted, then the selected window is deleted. An error is signaled
-if there is only one window when @code{delete-window} is called.
-
-This function returns @code{nil}.
-
-When @code{delete-window} is called interactively, @var{window}
-defaults to the selected window.
+This function removes @var{window} from display, and returns @code{nil}.
+If @var{window} is omitted, then the selected window is deleted. An
+error is signaled if there is only one window when @code{delete-window}
+is called.
@end deffn
@deffn Command delete-other-windows &optional window
deleting the other windows in that frame. If @var{window} is omitted or
@code{nil}, then the selected window is used by default.
-The result is @code{nil}.
+The return value is @code{nil}.
@end deffn
@deffn Command delete-windows-on buffer &optional frame
single window showing another buffer chosen with @code{other-buffer}.
@xref{The Buffer List}.
-The argument @var{frame} controls which frames to operate on:
+The argument @var{frame} controls which frames to operate on. This
+function does not use it in quite the same way as the other functions
+which scan all windows; specifically, the values @code{t} and @code{nil}
+have the opposite of their meanings in other functions. Here are the
+full details:
@itemize @bullet
@item
-If it is @code{nil}, operate on the selected frame.
+If it is @code{nil}, operate on all frames.
@item
-If it is @code{t}, operate on all frames.
+If it is @code{t}, operate on the selected frame.
@item
If it is @code{visible}, operate on all visible frames.
-@item 0
+@item
If it is 0, operate on all visible or iconified frames.
@item
If it is a frame, operate on that frame.
@defmac save-selected-window forms@dots{}
This macro records the selected window, executes @var{forms}
in sequence, then restores the earlier selected window.
-It does not save or restore anything about the sizes, arrangement
+
+This macro does not save or restore anything about the sizes, arrangement
or contents of windows; therefore, if the @var{forms} change them,
-the changes are permanent.
+the change persists.
+
+Each frame, at any time, has a window selected within the frame. This
+macro saves only @emph{the} selected window; it does not save anything
+about other frames. If the @var{forms} select some other frame and
+alter the window selected within it, the change persists.
@end defmac
@cindex finding windows
the window that is first in the cyclic ordering of windows (see
following section), starting from the selected window.
-The argument @var{frame} controls which set of windows are
-considered. See @code{get-lru-window}, above.
+The argument @var{frame} controls which set of windows to
+consider. See @code{get-lru-window}, above.
@end defun
@node Cyclic Window Ordering
@section Cyclic Ordering of Windows
@cindex cyclic ordering of windows
@cindex ordering of windows, cyclic
-@cindex window ordering, cyclic
+@cindex window ordering, cyclic
When you use the command @kbd{C-x o} (@code{other-window}) to select
the next window, it moves through all the windows on the screen in a
Consider precisely the windows in @var{window}'s frame, and no others.
@end table
-This example assumes there are two windows, both displaying the
+This example assumes there are two windows, both displaying the
buffer @samp{windows.texi}:
@example
@deffn Command other-window count
This function selects the @var{count}th following window in the cyclic
-order. If count is negative, then it selects the @minus{}@var{count}th
-preceding window. It returns @code{nil}.
+order. If count is negative, then it moves back @minus{}@var{count}
+windows in the cycle, rather than forward. It returns @code{nil}.
In an interactive call, @var{count} is the numeric prefix argument.
@end deffn
@defun set-window-buffer window buffer-or-name
This function makes @var{window} display @var{buffer-or-name} as its
-contents. It returns @code{nil}.
+contents. It returns @code{nil}. This is the fundamental primitive
+for changing which buffer is displayed in a window, and all ways
+of doing that call this function.
@example
@group
@end itemize
@end defun
+@defun get-buffer-window-list buffer-or-name &optional minibuf all-frames
+This function returns a list of all the windows currently displaying
+@var{buffer-or-name}.
+
+The two optional arguments work like the optional arguments of
+@code{next-window} (@pxref{Cyclic Window Ordering}); they are @emph{not}
+like the single optional argument of @code{get-buffer-window}. Perhaps
+we should change @code{get-buffer-window} in the future to make it
+compatible with the other functions.
+
+The argument @var{all-frames} controls which windows to consider.
+
+@itemize @bullet
+@item
+If it is @code{nil}, consider windows on the selected frame.
+@item
+If it is @code{t}, consider windows on all frames.
+@item
+If it is @code{visible}, consider windows on all visible frames.
+@item
+If it is 0, consider windows on all visible or iconified frames.
+@item
+If it is a frame, consider windows on that frame.
+@end itemize
+@end defun
+
+@defvar buffer-display-time
+@tindex buffer-display-time
+This variable records the time at which a buffer was last made visible
+in a window. It is always local in each buffer; each time
+@code{set-window-buffer} is called, it sets this variable to
+@code{(current-time)} in the specified buffer (@pxref{Time of Day}).
+When a buffer is first created, @code{buffer-display-time} starts out
+with the value @code{nil}.
+@end defvar
+
@node Displaying Buffers
@section Displaying Buffers in Windows
@cindex switching to a buffer
@ifinfo
@xref{Buffers and Windows}, for
@end ifinfo
-low-level functions that give you more precise control.
+low-level functions that give you more precise control. All of these
+functions work by calling @code{set-window-buffer}.
Do not use the functions in this section in order to make a buffer
current so that a Lisp program can access or modify it; they are too
drastic for that purpose, since they change the display of buffers in
-windows, which is gratuitous and will surprise the user. Instead, use
-@code{set-buffer} (@pxref{Current Buffer}) and @code{save-excursion}
-(@pxref{Excursions}), which designate buffers as current for programmed
-access without affecting the display of buffers in windows.
+windows, which would be gratuitous and surprise the user. Instead, use
+@code{set-buffer} and @code{save-current-buffer} (@pxref{Current
+Buffer}), which designate buffers as current for programmed access
+without affecting the display of buffers in windows.
@deffn Command switch-to-buffer buffer-or-name &optional norecord
This function makes @var{buffer-or-name} the current buffer, and also
set according to the variable @code{default-major-mode}. @xref{Auto
Major Mode}.
-Normally the specified buffer is put at the front of the buffer list.
-This affects the operation of @code{other-buffer}. However, if
+Normally the specified buffer is put at the front of the buffer list
+(both the selected frame's buffer list and the frame-independent buffer
+list). This affects the operation of @code{other-buffer}. However, if
@var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer
List}.
always returns @code{nil}.
@end deffn
-@deffn Command switch-to-buffer-other-window buffer-or-name
+@deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord
This function makes @var{buffer-or-name} the current buffer and
displays it in a window not currently selected. It then selects that
window. The handling of the buffer is the same as in
this purpose. If the selected window is already displaying the buffer,
then it continues to do so, but another window is nonetheless found to
display it in as well.
+
+This function updates the buffer list just like @code{switch-to-buffer}
+unless @var{norecord} is non-@code{nil}.
@end deffn
-@defun pop-to-buffer buffer-or-name &optional other-window
+@defun pop-to-buffer buffer-or-name &optional other-window norecord
This function makes @var{buffer-or-name} the current buffer and
switches to it in some window, preferably not the window previously
selected. The ``popped-to'' window becomes the selected window within
buffer, a buffer by that name is created. The major mode for the new
buffer is set according to the variable @code{default-major-mode}.
@xref{Auto Major Mode}.
+
+This function updates the buffer list just like @code{switch-to-buffer}
+unless @var{norecord} is non-@code{nil}.
@end defun
@deffn Command replace-buffer-in-windows buffer
functions and commands use this subroutine. Here we describe how to use
@code{display-buffer} and how to customize it.
-@deffn Command display-buffer buffer-or-name &optional not-this-window
+@deffn Command display-buffer buffer-or-name &optional not-this-window frame
This command makes @var{buffer-or-name} appear in some window, like
@code{pop-to-buffer}, but it does not select that window and does not
make the buffer current. The identity of the selected window is
@code{display-buffer} returns the window chosen to display
@var{buffer-or-name}.
+If the argument @var{frame} is non-@code{nil}, it specifies which frames
+to check when deciding whether the buffer is already displayed. If the
+buffer is already displayed in some window on one of these frames,
+@code{display-buffer} simply returns that window. Here are the possible
+values of @var{frame}:
+
+@itemize @bullet
+@item
+If it is @code{nil}, consider windows on the selected frame.
+@item
+If it is @code{t}, consider windows on all frames.
+@item
+If it is @code{visible}, consider windows on all visible frames.
+@item
+If it is 0, consider windows on all visible or iconified frames.
+@item
+If it is a frame, consider windows on that frame.
+@end itemize
+
Precisely how @code{display-buffer} finds or creates a window depends on
the variables described below.
@end deffn
more information about frame parameters.
@end defvar
-@defvar special-display-buffer-names
+@defopt special-display-buffer-names
A list of buffer names for buffers that should be displayed specially.
If the buffer's name is in this list, @code{display-buffer} handles the
buffer specially.
an alist, specifying frame parameters, or it can contain a function and
arguments to give to it. (The function's first argument is always the
buffer to be displayed; the arguments from the list come after that.)
-@end defvar
+@end defopt
-@defvar special-display-regexps
+@defopt special-display-regexps
A list of regular expressions that specify buffers that should be
displayed specially. If the buffer's name matches any of the regular
expressions in this list, @code{display-buffer} handles the buffer
If an element is a list, instead of a string, then the @sc{car} of the
list is the regular expression, and the rest of the list says how to
create the frame. See above, under @code{special-display-buffer-names}.
-@end defvar
+@end defopt
@defvar special-display-function
This variable holds the function to call to display a buffer specially.
@c Emacs 19 feature
@cindex dedicated window
A window can be marked as ``dedicated'' to its buffer. Then
-@code{display-buffer} does not try to use that window.
+@code{display-buffer} will not try to use that window to display any
+other buffer.
@defun window-dedicated-p window
This function returns @code{t} if @var{window} is marked as dedicated;
window opened on the buffer if such a window exists.
@item
-Selecting a window sets the value of point in its buffer to the window's
-value of point. Conversely, deselecting a window sets the window's
-value of point from that of the buffer. Thus, when you switch between
-windows that display a given buffer, the point value for the selected
-window is in effect in the buffer, while the point values for the other
-windows are stored in those windows.
+Selecting a window sets the value of point in its buffer from the
+window's value of point. Conversely, deselecting a window sets the
+window's value of point from that of the buffer. Thus, when you switch
+between windows that display a given buffer, the point value for the
+selected window is in effect in the buffer, while the point values for
+the other windows are stored in those windows.
@item
As long as the selected window displays the current buffer, the window's
@cindex window top line
This function returns the display-start position of window
@var{window}. If @var{window} is @code{nil}, the selected window is
-used. For example,
+used. For example,
@example
@group
description of @code{count-lines} in @ref{Text Lines}.
@end defun
-@defun window-end &optional window
+@defun window-end &optional window update
This function returns the position of the end of the display in window
@var{window}. If @var{window} is @code{nil}, the selected window is
used.
Simply changing the buffer text or moving point does not update the
value that @code{window-end} returns. The value is updated only when
-Emacs redisplays and redisplay actually finishes.
+Emacs redisplays and redisplay completes without being preempted.
If the last redisplay of @var{window} was preempted, and did not finish,
Emacs does not know the position of the end of display in that window.
-In that case, this function returns a value that is not correct. In a
-future version, @code{window-end} will return @code{nil} in that case.
-@ignore
-in that case, this function returns @code{nil}. You can compute where
-the end of the window @emph{would} have been, if redisplay had finished,
-like this:
+In that case, this function returns @code{nil}.
-@example
-(save-excursion
- (goto-char (window-start window))
- (vertical-motion (1- (window-height window))
- window)
- (point))
-@end example
-@end ignore
+If @var{update} is non-@code{nil}, @code{window-end} always returns
+an up-to-date value for where the window ends. If the saved value is
+valid, @code{window-end} returns that; otherwise it computes the correct
+value by scanning the buffer text.
@end defun
@defun set-window-start window position &optional noforce
which buffer to scroll.
@end defvar
-@defopt scroll-step
+@tindex scroll-margin
+@defopt scroll-margin
+This option specifies the size of the scroll margin---a minimum number
+of lines between point and the top or bottom of a window. Whenever
+point gets within this many lines of the top or bottom of the window,
+the window scrolls automatically (if possible) to move point out of the
+margin, closer to the center of the window.
+@end defopt
+
+@tindex scroll-conservatively
+@defopt scroll-conservatively
This variable controls how scrolling is done automatically when point
-moves off the screen. If the value is zero, then redisplay scrolls the
-text to center point vertically in the window. If the value is a
-positive integer @var{n}, then redisplay brings point back on screen by
-scrolling @var{n} lines in either direction, if possible; otherwise, it
-centers point. The default value is zero.
+moves off the screen (or into the scroll margin). If the value is zero,
+then redisplay scrolls the text to center point vertically in the
+window. If the value is a positive integer @var{n}, then redisplay
+scrolls the window up to @var{n} lines in either direction, if that will
+bring point back into view. Otherwise, it centers point. The default
+value is zero.
+@end defopt
+
+@defopt scroll-step
+This variable is an older variant of @code{scroll-conservatively}. The
+difference is that it if its value is @var{n}, that permits scrolling
+only by precisely @var{n} lines, not a smaller number. This feature
+does not work with @code{scroll-margin}. The default value is zero.
+@end defopt
+
+@tindex scroll-preserve-screen-position
+@defopt scroll-preserve-screen-position
+If this option is non-@code{nil}, the scroll functions move point so
+that the vertical position of the cursor is unchanged, when that is
+possible.
@end defopt
@defopt next-screen-context-lines
(defun line-to-top-of-window ()
"Scroll current line to top of window.
Replaces three keystroke sequence C-u 0 C-l."
- (interactive)
+ (interactive)
(recenter 0))
-(global-set-key [kp-multiply] 'line-to-top-of-window)
+(global-set-key [kp-multiply] 'line-to-top-of-window)
@end group
@end example
@end deffn
@section Horizontal Scrolling
@cindex horizontal scrolling
- Because we read English first from top to bottom and second from left
-to right, horizontal scrolling is not like vertical scrolling. Vertical
-scrolling involves selection of a contiguous portion of text to display.
-Horizontal scrolling causes part of each line to go off screen. The
-amount of horizontal scrolling is therefore specified as a number of
-columns rather than as a position in the buffer. It has nothing to do
-with the display-start position returned by @code{window-start}.
+ Because we read English from left to right in the ``inner loop'', and
+from top to bottom in the ``outer loop'', horizontal scrolling is not
+like vertical scrolling. Vertical scrolling involves selection of a
+contiguous portion of text to display, but horizontal scrolling causes
+part of each line to go off screen. The amount of horizontal scrolling
+is therefore specified as a number of columns rather than as a position
+in the buffer. It has nothing to do with the display-start position
+returned by @code{window-start}.
Usually, no horizontal scrolling is in effect; then the leftmost
column is at the left edge of the window. In this state, scrolling to
@defun set-window-hscroll window columns
This function sets the number of columns from the left margin that
-@var{window} is scrolled to the value of @var{columns}. The argument
+@var{window} is scrolled from the value of @var{columns}. The argument
@var{columns} should be zero or positive; if not, it is taken as zero.
The value returned is @var{columns}.
@example
@group
(defun hscroll-on-screen (window position)
- (save-excursion
+ (save-excursion
(goto-char position)
- (and
+ (and
(>= (- (current-column) (window-hscroll window)) 0)
(< (- (current-column) (window-hscroll window))
(window-width window)))))
The following three functions return size information about a window:
@defun window-height &optional window
-This function returns the number of lines in @var{window}, including
-its mode line. If @var{window} fills its entire frame, this is one less
-than the value of @code{frame-height} on that frame (since the last line
-is always reserved for the minibuffer).
+This function returns the number of lines in @var{window}, including its
+mode line. If @var{window} fills its entire frame, this is typically
+one less than the value of @code{frame-height} on that frame (since the
+last line is always reserved for the minibuffer).
If @var{window} is @code{nil}, the function uses the selected window.
@example
@group
- 0
+ 0
_______
- 0 | |
- | |
- | |
- | |
+ 0 | |
+ | |
+ | |
+ | |
xxxxxxxxx 4
- 7
+ 7
@end group
@end example
@example
@group
___ ___
- | | |
- | | |
- xxxxxxxxx
+ | | |
+ | | |
+ xxxxxxxxx
0 34 7
@end group
than the minimum size (@code{window-min-height} and
@code{window-min-width}), @code{enlarge-window} deletes the window.
-@code{enlarge-window} returns @code{nil}.
+@code{enlarge-window} returns @code{nil}.
@end deffn
@deffn Command enlarge-window-horizontally columns
@end example
@end deffn
+@deffn Command shrink-window-if-larger-than-buffer window
+This command shrinks @var{window} to be as small as possible while still
+showing the full contents of its buffer---but not less than
+@code{window-min-height} lines.
+
+However, the command does nothing if the window is already too small to
+display the whole text of the buffer, or if part of the contents are
+currently scrolled off screen, or if the window is not the full width of
+its frame, or if the window is the only window in its frame.
+@end deffn
+
@cindex minimum window size
The following two variables constrain the window-size-changing
functions to a minimum height and width.
@defopt window-min-width
The value of this variable determines how narrow a window may become
-before it automatically deleted. Making a window smaller than
+before it is automatically deleted. Making a window smaller than
@code{window-min-width} automatically deletes it, and no window may be
created narrower than this. The absolute minimum width is one; any
value below that is ignored. The default value is 10.
@end defopt
-@defvar window-size-change-functions
-This variable holds a list of functions to be called if the size of any
-window changes for any reason. The functions are called just once per
-redisplay, and just once for each frame on which size changes have
-occurred.
-
-Each function receives the frame as its sole argument. There is no
-direct way to find out which windows changed size, or precisely how;
-however, if your size-change function keeps track, after each change, of
-the windows that interest you, you can figure out what has changed by
-comparing the old size data with the new.
-
-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 @code{save-window-excursion} 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,
-@code{save-selected-window} is what you need here.
-@end defvar
-
@node Coordinates and Windows
@section Coordinates and Windows
This function checks whether a particular frame position falls within
the window @var{window}.
-@need 3000
-The argument @var{coordinates} is a cons cell of this form:
+The argument @var{coordinates} is a cons cell of the form @code{(@var{x}
+. @var{y})}. The coordinates @var{x} and @var{y} are measured in
+characters, and count from the top left corner of the screen or frame.
-@example
-(@var{x} . @var{y})
-@end example
-
-@noindent
-The coordinates @var{x} and @var{y} are measured in characters, and
-count from the top left corner of the screen or frame.
-
-The value of @code{coordinates-in-window-p} is non-@code{nil} if the
-coordinates are inside @var{window}. The value also indicates what part
-of the window the position is in, as follows:
+The value returned by @code{coordinates-in-window-p} is non-@code{nil}
+if the coordinates are inside @var{window}. The value also indicates
+what part of the window the position is in, as follows:
@table @code
@item (@var{relx} . @var{rely})
@item vertical-split
The coordinates are in the vertical line between @var{window} and its
-neighbor to the right. This value occurs only if the window doesn't
+neighbor to the right. This value occurs only if the window doesn't
have a scroll bar; positions in a scroll bar are considered outside the
window.
@cindex window configurations
@cindex saving window information
- A @dfn{window configuration} records the entire layout of a
+ A @dfn{window configuration} records the entire layout of one
frame---all windows, their sizes, which buffers they contain, what part
of each buffer is displayed, and the values of point and the mark. You
can bring back an entire previous layout by restoring a window
Configurations}.
@defun current-window-configuration
-This function returns a new object representing Emacs's current window
-configuration, namely the number of windows, their sizes and current
-buffers, which window is the selected window, and for each window the
-displayed buffer, the display-start position, and the positions of point
-and the mark. An exception is made for point in the current buffer,
-whose value is not saved.
+This function returns a new object representing the selected frame's
+current window configuration, including the number of windows, their
+sizes and current buffers, which window is the selected window, and for
+each window the displayed buffer, the display-start position, and the
+positions of point and the mark. It also includes the values of
+@code{window-min-height}, @code{window-min-width} and
+@code{minibuffer-scroll-window}. An exception is made for point in the
+current buffer, whose value is not saved.
@end defun
@defun set-window-configuration configuration
-This function restores the configuration of Emacs's windows and
-buffers to the state specified by @var{configuration}. The argument
-@var{configuration} must be a value that was previously returned by
-@code{current-window-configuration}.
-
-This function always counts as a window size change and triggers
-execution of the @code{window-size-change-functions}. (It doesn't know
-how to tell whether the new configuration actually differs from the old
-one.)
+This function restores the configuration of windows and buffers as
+specified by @var{configuration}. The argument @var{configuration} must
+be a value that was previously returned by
+@code{current-window-configuration}. This configuration is restored in
+the frame from which @var{configuration} was made, whether that frame is
+selected or not. This always counts as a window size change and
+triggers execution of the @code{window-size-change-functions}
+(@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
+know how to tell whether the new configuration actually differs from the
+old one.
+
+If the frame which @var{configuration} was saved from is dead, all this
+function does is restore the three variables @code{window-min-height},
+@code{window-min-width} and @code{minibuffer-scroll-window}.
Here is a way of using this function to get the same effect
as @code{save-window-excursion}:
configuration includes the value of point and the portion of the buffer
that is visible. It also includes the choice of selected window.
However, it does not include the value of point in the current buffer;
-use @code{save-excursion} if you wish to preserve that.
+use @code{save-excursion} also, if you wish to preserve that.
Don't use this construct when @code{save-selected-window} is all you need.
@defun window-configuration-p object
This function returns @code{t} if @var{object} is a window configuration.
+@end defun
+
+@defun compare-window-configurations config1 config2
+This function compares two window configurations as regards the
+structure of windows, but ignores the values of point and mark and the
+saved scrolling positions---it can return @code{t} even if those
+aspects differ.
+
+The function @code{equal} can also compare two window configurations; it
+regards configurations as unequal if they differ in any respect, even a
+saved point or mark.
@end defun
Primitives to look inside of window configurations would make sense,
but none are implemented. It is not clear they are useful enough to be
worth implementing.
+
+@node Window Hooks
+@section Hooks for Window Scrolling and Changes
+
+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 @code{window-scroll-functions}; the last runs
+@code{window-size-change-functions}. The paradigmatic use of these
+hooks is in the implementation of Lazy Lock mode; see @ref{Support
+Modes, Lazy Lock, Font Lock Support Modes, emacs, The GNU Emacs Manual}.
+
+@defvar window-scroll-functions
+This variable holds a list of functions that Emacs should call before
+redisplaying a window with scrolling. It is not a normal hook, because
+each function is called with two arguments: the window, and its new
+display-start position.
+
+Displaying a different buffer in the window also runs these functions.
+
+These functions must be careful in using @code{window-end}
+(@pxref{Window Start}); if you need an up-to-date value, you must use
+the @var{update} argument to ensure you get it.
+@end defvar
+
+@defvar window-size-change-functions
+This variable holds a list of functions to be called if the size of any
+window changes for any reason. The functions are called just once per
+redisplay, and just once for each frame on which size changes have
+occurred.
+
+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 @code{save-window-excursion} (@pxref{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, @code{save-selected-window} (@pxref{Selecting
+Windows}) is what you need here.
+@end defvar
+
+@defvar redisplay-end-trigger-functions
+@tindex redisplay-end-trigger-functions
+This abnormal hook is run whenever redisplay in a window uses text that
+extends past a specified end trigger position. You set the end trigger
+position with the function @code{set-window-redisplay-end-trigger}. The
+functions are called with two arguments: the window, and the end trigger
+position. Storing @code{nil} for the end trigger position turns off the
+feature, and the trigger value is automatically reset to @code{nil} just
+after the hook is run.
+@end defvar
+
+@defun set-window-redisplay-end-trigger window position
+@tindex set-window-redisplay-end-trigger
+This function sets @var{window}'s end trigger position at
+@var{position}.
+@end defun
+
+@defun window-redisplay-end-trigger window
+@tindex window-redisplay-end-trigger
+This function returns @var{window}'s current end trigger position.
+@end defun
+
+@defvar window-configuration-change-hook
+@tindex window-configuration-change-hook
+A normal hook that is run every time you change the window configuration
+of an existing frame. This includes splitting or deleting windows,
+changing the sizes of windows, or displaying a different buffer in a
+window. The frame whose window configuration has changed is the
+selected frame when this hook runs.
+@end defvar