@item
how recently the window was selected
+
+@item
+fringe settings
+
+@item
+display margins
+
+@item
+scroll-bar settings
@end itemize
@cindex multiple windows
window @var{window} remains the selected window, but occupies only
part of its former screen area. The rest is occupied by a newly created
window which is returned as the value of this function.
+This function returns the newly created window.
If @var{horizontal} is non-@code{nil}, then @var{window} splits into
two side by side windows. The original window @var{window} keeps the
This function returns non-@code{nil} if there is only one window. The
argument @var{no-mini}, if non-@code{nil}, means don't count the
minibuffer even if it is active; otherwise, the minibuffer window is
-included, if active, in the total number of windows, which is compared
-against one.
+counted when it is active.
The argument @var{all-frames} specifies which frames to consider. Here
are the possible values and their meanings:
which the cursor appears and to which many commands apply.
@end defun
-@defun select-window window
+@defun select-window window &optional norecord
This function makes @var{window} the selected window. The cursor then
appears in @var{window} (on redisplay). The buffer being displayed in
@var{window} is immediately designated the current buffer.
+Normally @var{window}'s selected buffer is moved to the front of the
+buffer list, but if @var{norecord} is non-@code{nil}, the buffer list
+order is unchanged.
+
The return value is @var{window}.
@example
@end defun
@defmac save-selected-window forms@dots{}
-This macro records the selected window, executes @var{forms}
-in sequence, then restores the earlier selected window.
-
-This macro does not save or restore anything about the sizes, arrangement
-or contents of windows; therefore, if the @var{forms} change them,
-the change persists.
+This macro records the selected window of each frame, executes
+@var{forms} in sequence, then restores the earlier selected windows.
+
+This macro does not save or restore anything about the sizes,
+arrangement or contents of windows; therefore, if the @var{forms}
+change them, the change persists. If the previously selected window
+of some frame is no longer live at the time of exit from this form,
+that frame's selected window is left alone.
+@end defmac
-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.
+@defmac with-selected-window window forms@dots{}
+This macro selects @var{window} (without changing the buffer list),
+executes @var{forms} in sequence, then restores the previously
+selected window (unless that window is no longer alive). It is similar
+to @code{save-selected-window} except that it explicitly selects
+@var{window} and that it does not alter the buffer list sequence.
@end defmac
@cindex finding windows
@defun get-window-with-predicate predicate &optional minibuf all-frames default
This function returns a window satisfying @var{predicate}. It cycles
through all visible windows using @code{walk-windows} (@pxref{Cyclic
-Window Ordering}), calling @var{predicate} on each one one of them
+Window Ordering}), calling @var{predicate} on each one of them
with that window as its argument. The function returns the first
window for which @var{predicate} returns a non-@code{nil} value; if
that never happens, it returns @var{default}.
@item 0
Consider all windows in all visible or iconified frames.
+@item a frame
+Consider all windows on that frame.
+
@item anything else
Consider precisely the windows in @var{window}'s frame, and no others.
@end table
employ heuristics in choosing or creating a window; use these functions
when you need complete control.
-@defun set-window-buffer window buffer-or-name
+@defun set-window-buffer window buffer-or-name &optional keep-margins
This function makes @var{window} display @var{buffer-or-name} as its
contents. It returns @code{nil}. This is the fundamental primitive
for changing which buffer is displayed in a window, and all ways
@result{} nil
@end group
@end example
+
+Normally, displaying @var{buffer} in @var{window} resets the window's
+display margins, fringe widths, scroll bar settings, and position
+based on the local variables of @var{buffer}. However, if
+@var{keep-margins} is non-@code{nil}, the display margins and fringe
+widths of @var{window} remain unchanged. @xref{Fringes}.
@end defun
@defun window-buffer &optional window
The @code{switch-to-buffer} function is often used interactively, as
the binding of @kbd{C-x b}. It is also used frequently in programs. It
-always returns @code{nil}.
+returns the buffer that it switched to.
@end deffn
@deffn Command switch-to-buffer-other-window buffer-or-name &optional 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
-its frame.
+its frame. The return value is the buffer that was switched to.
+If @var{buffer-or-name} is @code{nil}, that means to choose some
+other buffer, but you don't specify which.
If the variable @code{pop-up-frames} is non-@code{nil},
@code{pop-to-buffer} looks for a window in any visible frame already
heights if the buffer gets displayed in an existing window, above or
beneath another existing window. If @code{even-window-heights} is
@code{t}, the default, window heights will be evened out. If
-@code{even-window-heights} is @code{nil}, the orginal window heights
+@code{even-window-heights} is @code{nil}, the original window heights
will be left alone.
@end defopt
@end defopt
@c Emacs 19 feature
-@defvar pop-up-frame-function
+@defopt pop-up-frame-function
This variable specifies how to make a new frame if @code{pop-up-frames}
is non-@code{nil}.
function, which should return a frame. The default value of the
variable is a function that creates a frame using parameters from
@code{pop-up-frame-alist}.
-@end defvar
+@end defopt
@defopt pop-up-frame-alist
This variable holds an alist specifying frame parameters used when
By default, special display means to give the buffer a dedicated frame.
If an element is a list, instead of a string, then the @sc{car} of the
-list is the buffer name, and the rest of the list says how to create the
-frame. There are two possibilities for the rest of the list. It can be
-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.)
+list is the buffer name, and the rest of the list says how to create
+the frame. There are two possibilities for the rest of the list (its
+@sc{cdr}). It can be 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.)
+
+For example:
+
+@example
+(("myfile" (minibuffer) (menu-bar-lines . 0)))
+@end example
+
+@noindent
+specifies to display a buffer named @samp{myfile} in a dedicated frame
+with specified @code{minibuffer} and @code{menu-bar-lines} parameters.
+
+The list of frame parameters can also use the phony frame parameters
+@code{same-frame} and @code{same-window}. If the specified frame
+parameters include @code{(same-window . @var{value})} and @var{value}
+is non-@code{nil}, that means to display the buffer in the current
+selected window. Otherwise, if they include @code{(same-frame .
+@var{value})} and @var{value} is non-@code{nil}, that means to display
+the buffer in a new window in the currently selected frame.
@end defopt
@defopt special-display-regexps
other buffer.
@defun window-dedicated-p window
-This function returns @code{t} if @var{window} is marked as dedicated;
-otherwise @code{nil}.
+This function returns non-@code{nil} if @var{window} is marked as
+dedicated; otherwise @code{nil}.
@end defun
@defun set-window-dedicated-p window flag
is @code{next-screen-context-lines} lines less than the usable height of
the window (not counting its mode line).
-@code{scroll-up} returns @code{nil}.
+@code{scroll-up} returns @code{nil}, unless it gets an error
+because it can't scroll any further.
@end deffn
@deffn Command scroll-down &optional count
is @code{next-screen-context-lines} lines less than the usable height of
the window (not counting its mode line).
-@code{scroll-down} returns @code{nil}.
+@code{scroll-down} returns @code{nil}, unless it gets an error because
+it can't scroll any further.
@end deffn
@deffn Command scroll-other-window &optional count
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.
+redisplay scrolls the text automatically (if possible) to move point
+out of the margin, closer to the center of the window.
@end defopt
@defopt scroll-conservatively
This variable controls how scrolling is done automatically when point
-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.
+moves off the screen (or into the scroll margin). If the value is a
+positive integer @var{n}, then redisplay scrolls the text up to
+@var{n} lines in either direction, if that will bring point back into
+proper view. This action is called @dfn{conservative scrolling}.
+Otherwise, scrolling happens in the usual way, under the control of
+other variables such as @code{scroll-up-aggressively} and
+@code{scroll-down-aggressively}.
+
+The default value is zero, which means that conservative scrolling
+never happens.
@end defopt
@defopt scroll-down-aggressively
@deffn Command recenter &optional count
@cindex centering point
-This function scrolls the selected window to put the text where point
-is located at a specified vertical position within the window.
+This function scrolls the text in the selected window so that point is
+displayed at a specified vertical position within the window. It does
+not ``move point'' with respect to the text.
-If @var{count} is a nonnegative number, it puts the line containing
-point @var{count} lines down from the top of the window. If @var{count}
-is a negative number, then it counts upward from the bottom of the
-window, so that @minus{}1 stands for the last usable line in the window.
-If @var{count} is a non-@code{nil} list, then it stands for the line in
-the middle of the window.
+If @var{count} is a nonnegative number, that puts the line containing
+point @var{count} lines down from the top of the window. If
+@var{count} is a negative number, then it counts upward from the
+bottom of the window, so that @minus{}1 stands for the last usable
+line in the window. If @var{count} is a non-@code{nil} list, then it
+stands for the line in the middle of the window.
If @var{count} is @code{nil}, @code{recenter} puts the line containing
point in the middle of the window, then clears and redisplays the entire
left you can scroll, but eventually all the text will disappear off the
left edge.
-@vindex automatic-hscrolling
- In Emacs 21, redisplay automatically alters the horizontal scrolling
-of a window as necessary to ensure that point is always visible, if
-@code{automatic-hscrolling} is set. However, you can still set the
-horizontal scrolling value explicitly. The value you specify serves as
-a lower bound for automatic scrolling, i.e. automatic scrolling
-will not scroll a window to a column less than the specified one.
+@vindex auto-hscroll-mode
+ If @code{auto-hscroll-mode} is set, redisplay automatically alters
+the horizontal scrolling of a window as necessary to ensure that point
+is always visible. However, you can still set the horizontal
+scrolling value explicitly. The value you specify serves as a lower
+bound for automatic scrolling, i.e. automatic scrolling will not
+scroll a window to a column less than the specified one.
@deffn Command scroll-left &optional count
This function scrolls the selected window @var{count} columns to the
@end defun
@defun set-window-hscroll window columns
-This function sets the number of columns from the left margin that
-@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.
-Fractional values of @var{columns} are not supported at present.
+This function sets horizontal scrolling of @var{window}. The value of
+@var{columns} specifies the amount of scrolling, in terms of columns
+from the left margin. The argument @var{columns} should be zero or
+positive; if not, it is taken as zero. Fractional values of
+@var{columns} are not supported at present.
+
+Note that @code{set-window-hscroll} may appear not to work if you test
+it by evaluating a call with @kbd{M-:} in a simple way. What happens
+is that the function sets the horizontal scroll value and returns, but
+then redisplay adjusts the horizontal scrolling to make point visible,
+and this overrides what the function did. You can observe the
+function's effect if you call it while point is sufficiently far from
+the left margin that it will remain visible.
The value returned is @var{columns}.
@defun window-height &optional window
This function returns the number of lines in @var{window}, including
its mode line and header line, if any. If @var{window} fills its
-entire frame except for the echo area, and there is no tool bar, this
-is typically one less than the value of @code{frame-height} on that
-frame.
+entire frame except for the echo area, this is typically one less than
+the value of @code{frame-height} on that frame.
If @var{window} is @code{nil}, the function uses the selected window.
@tindex window-body-height
@defun window-body-height &optional window
-Like @code{window-height} but the value does not include the
+Like @code{window-height} but the value does not include the
mode line (if any) or the header line (if any).
@end defun
the window and that neighbor. Since the width of the window does not
include this separator, the width does not usually equal the difference
between the right and left edges.
+@end defun
-Here is the result obtained on a typical 24-line terminal with just one
-window:
+@defun window-inside-edges window
+This is similar to @code{window-edges}, but the edge values
+it returns include only the text area of the window. They
+do not include the header line, mode line, scroll bar or
+vertical separator, fringes, or display margins.
+@end defun
+
+Here are the results obtained on a typical 24-line terminal with just
+one window, with menu bar enabled:
@example
@group
(window-edges (selected-window))
- @result{} (0 0 80 23)
+ @result{} (0 1 80 23)
+@end group
+@group
+(window-inside-edges (selected-window))
+ @result{} (0 1 80 22)
@end group
@end example
@noindent
The bottom edge is at line 23 because the last line is the echo area.
-
-If @var{window} is at the upper left corner of its frame, then
-@var{bottom} is the same as the value of @code{(window-height)},
-@var{right} is almost the same as the value of @code{(window-width)},
-and @var{top} and @var{left} are zero. For example, the edges of the
-following window are @w{@samp{0 0 8 5}}. Assuming that the frame has
-more than 8 columns, the last column of the window (column 7) holds a
-border rather than text. The last row (row 4) holds the mode line,
-shown here with @samp{xxxxxxxxx}.
+The bottom inside edge is at line 22, which is the window's mode line.
+
+If @var{window} is at the upper left corner of its frame, and there is
+no menu bar, then @var{bottom} returned by @code{window-edges} is the
+same as the value of @code{(window-height)}, @var{right} is almost the
+same as the value of @code{(window-width)}, and @var{top} and
+@var{left} are zero. For example, the edges of the following window
+are @w{@samp{0 0 8 5}}. Assuming that the frame has more than 8
+columns, the last column of the window (column 7) holds a border
+rather than text. The last row (row 4) holds the mode line, shown
+here with @samp{xxxxxxxxx}.
@example
@group
In the following example, let's suppose that the frame is 7
columns wide. Then the edges of the left window are @w{@samp{0 0 4 3}}
-and the edges of the right window are @w{@samp{4 0 8 3}}.
+and the edges of the right window are @w{@samp{4 0 7 3}}.
+The inside edges of the left window are @w{@samp{0 0 3 2}},
+and the inside edges of the right window are @w{@samp{4 0 7 2}},
@example
@group
0 34 7
@end group
@end example
+
+@defun window-pixel-edges window
+This function is like @code{window-edges} except that, on a graphical
+display, the edge values are measured in pixels instead of in
+character lines and columns.
+@end defun
+
+@defun window-inside-pixel-edges window
+This function is like @code{window-inside-edges} except that, on a
+graphical display, the edge values are measured in pixels instead of
+in character lines and columns.
@end defun
@node Resizing Windows
have a scroll bar; positions in a scroll bar are considered outside the
window for these purposes.
+@item left-fringe
+@itemx right-fringe
+The coordinates are in the left or right fringe of the window.
+
+@item left-margin
+@itemx right-margin
+The coordinates are in the left or right margin of the window.
+
@item nil
The coordinates are not in any part of @var{window}.
@end table
@cindex saving window information
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
-configuration previously saved.
-
- If you want to record all frames instead of just one, use a frame
-configuration instead of a window configuration. @xref{Frame
-Configurations}.
+frame---all windows, their sizes, which buffers they contain, what
+part of each buffer is displayed, and the values of point and the
+mark; also their fringes, margins, and scroll bar settings. 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 selected window for the current
+buffer; its value is not saved in the window configuration.
+
+ You can bring back an entire previous layout by restoring a window
+configuration previously saved. If you want to record all frames
+instead of just one, use a frame configuration instead of a window
+configuration. @xref{Frame Configurations}.
@defun current-window-configuration &optional frame
-This function returns a new object representing @var{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.
-
-If @var{frame} is omitted, the selected frame is used.
+This function returns a new object representing @var{frame}'s current
+window configuration. If @var{frame} is omitted, the selected frame
+is used.
@end defun
@defun set-window-configuration configuration
However, it does not include the value of point in the current buffer;
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.
+Don't use this construct when @code{save-selected-window} is sufficient.
Exit from @code{save-window-excursion} always triggers execution of the
@code{window-size-change-functions}. (It doesn't know how to tell
@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.
+but none are implemented. It is not clear they are useful enough to
+be worth implementing. See the file @file{winner.el} for some more
+operations on windows configurations.
@node Window Hooks
@section Hooks for Window Scrolling and Changes
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}.
+hooks is in the implementation of Lazy Lock mode; see @file{lazy-lock.el}.
@defvar window-scroll-functions
This variable holds a list of functions that Emacs should call before
window. The frame whose window configuration has changed is the
selected frame when this hook runs.
@end defvar
+
+@ignore
+ arch-tag: 3f6c36e8-df49-4986-b757-417feed88be3
+@end ignore