@code{window-width} is an alias for @code{window-body-width}. These
aliases are considered obsolete and will be removed in the future.
+ The pixel heights of a window's mode and header line can be retrieved
+with the functions given below. Their return value is usually accurate
+unless the window has not been displayed before: In that case, the
+return value is based on an estimate of the font used for the window's
+frame.
+
+@defun window-mode-line-height &optional window
+This function returns the height in pixels of @var{window}'s mode line.
+@var{window} must be a live window and defaults to the selected one. If
+@var{window} has no mode line, the return value is zero.
+@end defun
+
+@defun window-header-line-height &optional window
+This function returns the height in pixels of @var{window}'s header
+line. @var{window} must be a live window and defaults to the selected
+one. If @var{window} has no header line, the return value is zero.
+@end defun
+
+Functions for retrieving the height and/or width of window dividers
+(@pxref{Window Dividers}), fringes (@pxref{Fringes}), scroll bars
+(@pxref{Scroll Bars}), and display margins (@pxref{Display Margins}) are
+described in the corresponding sections.
+
@cindex fixed-size window
@vindex window-min-height
@vindex window-min-width
@xref{Resizing Windows}.
@end defvar
+The following function tells how small a specific window can get taking
+into account the sizes of its areas and the values of
+@code{window-min-height}, @code{window-min-width} and
+@code{window-size-fixed}.
+
+@defun window-min-size &optional window horizontal ignore pixelwise
+This function returns the minimum size of @var{window}. @var{window}
+must be a valid window and defaults to the selected one. The optional
+argument @var{horizontal} non-@code{nil} means to return the minimum
+number of columns of @var{window}; otherwise return the minimum number
+of @var{window}'s lines.
+
+The return value makes sure that all components of @var{window} remain
+fully visible if @var{window}'s size were actually set to it. With
+@var{horizontal} @code{nil} it includes the mode and header line and the
+bottom divider. With @var{horizontal} non-@code{nil} it includes the
+fringes, a scroll bar, and a right divider, if present. It does not,
+however, include the space reserved for the margins.
+
+The optional argument @var{ignore}, if non-@code{nil}, means ignore
+restrictions imposed by fixed size windows, @code{window-min-height} or
+@code{window-min-width} settings. If @var{ignore} equals @code{safe},
+live windows may get as small as @code{window-safe-min-height} lines and
+@code{window-safe-min-width} columns. If @var{ignore} is a window,
+ignore restrictions for that window only. Any other non-@code{nil}
+value means ignore all of the above restrictions for all windows.
+
+The optional argument @var{pixelwise} non-@code{nil} means to return the
+minimum size of @var{window} counted in pixels.
+@end defun
@node Resizing Windows
@section Resizing Windows
that the window cannot be resized.
Normally, the variables @code{window-min-height} and
-@code{window-min-width} specify the smallest allowable window size.
-@xref{Change Window,, Deleting and Rearranging Windows, emacs, The GNU
-Emacs Manual}. However, if the optional argument @var{ignore} is
-non-@code{nil}, this function ignores @code{window-min-height} and
+@code{window-min-width} specify the smallest allowable window size
+(@pxref{Window Sizes}). However, if the optional argument @var{ignore}
+is non-@code{nil}, this function ignores @code{window-min-height} and
@code{window-min-width}, as well as @code{window-size-fixed}. Instead,
it considers the minimum-height window to be one consisting of a header,
a mode line and a bottom divider (if any), plus a text area one line
The optional argument @var{ignore} has the same meaning as for the
function @code{window-resizable} above.
-If the optional argument @code{pixelwise} is non-@code{nil},
+If the optional argument @var{pixelwise} is non-@code{nil},
@var{delta} will be interpreted as pixels.
The choice of which window edges this function alters depends on the
@cindex pixelwise, resizing windows
@defopt window-resize-pixelwise
-If the value of this user option is non-@code{nil}, window resizing
-operations will be pixelwise. This currently affects the following
-functions: @code{split-window}, @code{maximize-window},
-@code{minimize-window}, @code{fit-window-to-buffer} and
-@code{fit-frame-to-buffer}, and all functions that symmetrically
-resize a parent window.
+If the value of this option is non-@code{nil}, windows are resized in
+units of pixels. This currently affects functions like
+@code{split-window} (@pxref{Splitting Windows}), @code{maximize-window},
+@code{minimize-window}, @code{fit-window-to-buffer},
+@code{shrink-window-if-larger-than-buffer} (all listed below) and
+@code{fit-frame-to-buffer} (@pxref{Size and Position}).
Note that when a frame's pixel size is not a multiple of the frame's
character size, at least one window may get resized pixelwise even if
-this option is nil. The default value of this user option is
+this option is @code{nil}. The default value of this option is
@code{nil}.
@end defopt
The following commands resize windows in more specific ways. When
called interactively, they act on the selected window.
-@deffn Command fit-window-to-buffer &optional window max-height min-height override
-This command adjusts the height of @var{window} to fit the text in it.
-It returns non-@code{nil} if it was able to resize @var{window}, and
-@code{nil} otherwise. If @var{window} is omitted or @code{nil}, it
-defaults to the selected window. Otherwise, it should be a live
-window.
+@deffn Command fit-window-to-buffer &optional window max-height min-height max-width min-width
+This command adjusts the height or width of @var{window} to fit the text
+in it. It returns non-@code{nil} if it was able to resize @var{window},
+and @code{nil} otherwise. If @var{window} is omitted or @code{nil}, it
+defaults to the selected window. Otherwise, it should be a live window.
+
+If @var{window} is part of a vertical combination, this function adjusts
+@var{window}'s height. The new height is calculated from the actual
+height of the accessible portion of its buffer. The optional argument
+@var{max-height}, if non-@code{nil}, specifies the maximum total height
+that this function can give @var{window}. The optional argument
+@var{min-height}, if non-@code{nil}, specifies the minimum total height
+that it can give, which overrides the variable @code{window-min-height}.
+Both @var{max-height} and @var{min-height} are specified in lines and
+include mode and header line and a bottom divider, if any.
+
+If @var{window} is part of a horizontal combination and the value of the
+option @code{fit-window-to-buffer-horizontally} (see below) is
+non-@code{nil}, this function adjusts @var{window}'s height. The new
+width of @var{window} is calculated from the maximum length of its
+buffer's lines that follow the current start position of @var{window}.
+The optional argument @var{max-width} specifies a maximum width and
+defaults to the width of @var{window}'s frame. The optional argument
+@var{min-width} specifies a minimum width and defaults to
+@code{window-min-width}. Both @var{max-width} and @var{min-width} are
+specified in columns and include fringes, margins and scrollbars, if
+any.
-The optional argument @var{max-height}, if non-@code{nil}, specifies
-the maximum total height that this function can give @var{window}.
-The optional argument @var{min-height}, if non-@code{nil}, specifies
-the minimum total height that it can give, which overrides the
-variable @code{window-min-height}.
+If the option @code{fit-frame-to-buffer} (see below) is non-@code{nil},
+this function will try to resize the frame of @var{window} to fit its
+contents by calling @code{fit-frame-to-buffer} (@pxref{Size and
+Position}).
+@end deffn
-If the optional argument @var{override} is non-@code{nil}, this
-function ignores any size restrictions imposed by
-@code{window-min-height} and @code{window-min-width}.
+@defopt fit-window-to-buffer-horizontally
+If this is non-@code{nil}, @code{fit-window-to-buffer} can resize
+windows horizontally. If this is @code{nil} (the default)
+@code{fit-window-to-buffer} never resizes windows horizontally. If this
+is @code{only}, it can resize windows horizontally only. Any other
+value means @code{fit-window-to-buffer} can resize windows in both
+dimensions.
+@end defopt
-@vindex fit-frame-to-buffer
-If the option @code{fit-frame-to-buffer} is non-@code{nil}, this
-command may resize the frame to fit its contents.
-@end deffn
+@defopt fit-frame-to-buffer
+If this option is non-@code{nil}, @code{fit-window-to-buffer} can fit a
+frame to its buffer. A frame is fit if and only if its root window is a
+live window and this option is non-@code{nil}. If this is
+@code{horizontally}, frames are fit horizontally only. If this is
+@code{vertically}, frames are fit vertically only. Any other
+non-@code{nil} value means frames can be resized in both dimensions.
+@end defopt
@deffn Command shrink-window-if-larger-than-buffer &optional window
This command attempts to reduce @var{window}'s height as much as
This command does nothing if the window is already too short to
display all of its buffer, or if any of the buffer is scrolled
off-screen, or if the window is the only live window in its frame.
+
+This command calls @code{fit-window-to-buffer} (see above) to do its
+work.
@end deffn
+
@cindex balancing window sizes
@deffn Command balance-windows &optional window-or-frame
This function balances windows in a way that gives more space to
This section describes functions for creating a new window by
@dfn{splitting} an existing one.
-@defun split-window &optional window size side
+@defun split-window &optional window size side pixelwise
This function creates a new live window next to the window
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window. That window is ``split'', and reduced in
window is given @minus{}@var{size} lines (or columns).
If @var{size} is @code{nil}, this function obeys the variables
-@code{window-min-height} and @code{window-min-width}. @xref{Change
-Window,,Deleting and Rearranging Windows, emacs, The GNU Emacs
-Manual}. Thus, it signals an error if splitting would result in
-making a window smaller than those variables specify. However, a
+@code{window-min-height} and @code{window-min-width} (@pxref{Window
+Sizes}). Thus, it signals an error if splitting would result in making
+a window smaller than those variables specify. However, a
non-@code{nil} value for @var{size} causes those variables to be
-ignored; in that case, the smallest allowable window is considered to
-be one that has space for a text area one line tall and/or two columns
+ignored; in that case, the smallest allowable window is considered to be
+one that has space for a text area one line tall and/or two columns
wide.
+Hence, if @var{size} is specified, it's the caller's responsibility to
+check whether the emanating windows are large enough to encompass all
+areas like a mode line or a scroll bar. The function
+@code{window-min-size} (@pxref{Window Sizes}) can be used to determine
+the minimum requirements of @var{window} in this regard. Since the new
+window usually ``inherits'' areas like the mode line or the scroll bar
+from @var{window}, that function is also a good guess for the minimum
+size of the new window. The caller should specify a smaller size only
+if it correspondingly removes an inherited area before the next
+redisplay.
+
The optional third argument @var{side} determines the position of the
new window relative to @var{window}. If it is @code{nil} or
@code{below}, the new window is placed below @var{window}. If it is
window is placed on the left of @var{window}. In both these cases,
@var{size} specifies a total window width, in columns.
+The optional fourth argument @var{pixelwise}, if non-@code{nil}, means
+to interpret @var{size} in units of pixels, instead of lines and
+columns.
+
If @var{window} is a live window, the new window inherits various
properties from it, including margins and scroll bars. If
@var{window} is an internal window, the new window inherits the
@defun select-window window &optional norecord
This function makes @var{window} the selected window and the window
selected within its frame (@pxref{Basic Windows}) and selects that
-frame. @var{window} must be a live window. This function also makes
-@var{window}'s buffer (@pxref{Buffers and Windows}) current and sets
-that buffer's value of @code{point} to the value of @code{window-point}
-(@pxref{Window Point}) in @var{window}. The return value is
-@var{window}.
+frame. It also makes @var{window}'s buffer (@pxref{Buffers and
+Windows}) current and sets that buffer's value of @code{point} to the
+value of @code{window-point} (@pxref{Window Point}) in @var{window}.
+@var{window} must be a live window. The return value is @var{window}.
By default, this function also moves @var{window}'s buffer to the front
-of the buffer list (@pxref{The Buffer List}), and makes @var{window} the
+of the buffer list (@pxref{Buffer List}), and makes @var{window} the
most recently selected window. However, if the optional argument
@var{norecord} is non-@code{nil}, these additional actions are omitted.
+
+This function runs @code{buffer-list-update-hook} (@pxref{Buffer List})
+unless @var{norecord} is non-@code{nil}. Note that applications and
+internal routines often temporarily select a window in order to simplify
+coding. As a rule, such selections (including those made by the macros
+@code{save-selected-window} and @code{with-selected-window} below) are
+not recorded thus avoiding to pollute @code{buffer-list-update-hook}.
+Selections that ``really count'' are those causing a visible change in
+the next redisplay of @var{window}'s frame and should be always
+recorded. This also means that to run a function each time a window
+gets selected, putting it on @code{buffer-list-update-hook} should be
+the right choice.
@end defun
@cindex most recently selected windows
return value is the buffer switched to.
If @var{buffer-or-name} is @code{nil}, it defaults to the buffer
-returned by @code{other-buffer} (@pxref{The Buffer List}). If
+returned by @code{other-buffer} (@pxref{Buffer List}). If
@var{buffer-or-name} is a string that is not the name of any existing
buffer, this function creates a new buffer with that name; the new
buffer's major mode is determined by the variable @code{major-mode}
Normally, the specified buffer is put at the front of the buffer
list---both the global buffer list and the selected frame's buffer
-list (@pxref{The Buffer List}). However, this is not done if the
+list (@pxref{Buffer List}). However, this is not done if the
optional argument @var{norecord} is non-@code{nil}.
Sometimes, @code{switch-to-buffer} may be unable to display the buffer
was switched to.
If @var{buffer-or-name} is @code{nil}, it defaults to the buffer
-returned by @code{other-buffer} (@pxref{The Buffer List}). If
+returned by @code{other-buffer} (@pxref{Buffer List}). If
@var{buffer-or-name} is a string that is not the name of any existing
buffer, this function creates a new buffer with that name; the new
buffer's major mode is determined by the variable @code{major-mode}
@item
A number specifies the desired height of the new window. An integer
-number specifies the number of lines of the window. A floating point
+specifies the number of lines of the window. A floating-point
number gives the fraction of the window's height with respect to the
height of the frame's root window.
@item
A number specifies the desired width of the new window. An integer
-number specifies the number of columns of the window. A floating point
+specifies the number of columns of the window. A floating-point
number gives the fraction of the window's width with respect to the
width of the frame's root window.
windows are dedicated to another buffer (@pxref{Dedicated Windows}).
@end defun
+@defun display-buffer-no-window buffer alist
+If @var{alist} has a non-@code{nil} @code{allow-no-window} entry, then
+this function does not display @code{buffer}. This allows to override
+the default action and avoid displaying the buffer. It is assumed that
+when the caller specifies a non-@code{nil} @code{allow-no-window} value
+it can handle a @code{nil} value returned from @code{display-buffer} in
+this case.
+@end defun
+
To illustrate the use of action functions, consider the following
example.
If repeated invocations of this command have already shown all buffers
previously shown in @var{window}, further invocations will show buffers
-from the buffer list of the frame @var{window} appears on (@pxref{The
-Buffer List}), trying to skip buffers that are already shown in another
-window on that frame.
+from the buffer list of the frame @var{window} appears on (@pxref{Buffer
+List}), trying to skip buffers that are already shown in another window
+on that frame.
@end deffn
@deffn Command switch-to-next-buffer &optional window
If there is no recent invocation of @code{switch-to-prev-buffer} that
can be undone, this function tries to show a buffer from the buffer list
-of the frame @var{window} appears on (@pxref{The Buffer List}).
+of the frame @var{window} appears on (@pxref{Buffer List}).
@end deffn
By default @code{switch-to-prev-buffer} and @code{switch-to-next-buffer}
behaves like @code{delete-windows-on} otherwise.
@c FIXME: Does replace-buffer-in-windows _delete_ a window in case (1)?
- When @code{bury-buffer} (@pxref{The Buffer List}) operates on the
+ When @code{bury-buffer} (@pxref{Buffer List}) operates on the
selected window (which shows the buffer that shall be buried), it
handles case (2) by calling @code{frame-auto-hide-function}
(@pxref{Quitting Windows}) to deal with the selected frame. The other
hand, a window has been reused for displaying the buffer, you might
prefer showing the buffer previously shown in that window, by calling the
function @code{switch-to-prev-buffer} (@pxref{Window History}).
-Finally, you might want to either bury (@pxref{The Buffer List}) or kill
+Finally, you might want to either bury (@pxref{Buffer List}) or kill
(@pxref{Killing Buffers}) the window's buffer.
The following command uses information on how the window for
The function specified by this option is called to automatically hide
frames. This function is called with one argument---a frame.
-The function specified here is called by @code{bury-buffer} (@pxref{The
-Buffer List}) when the selected window is dedicated and shows the buffer
-to bury. It is also called by @code{quit-restore-window} (see above)
-when the frame of the window to quit has been specially created for
-displaying that window's buffer and the buffer is not killed.
+The function specified here is called by @code{bury-buffer}
+(@pxref{Buffer List}) when the selected window is dedicated and shows
+the buffer to bury. It is also called by @code{quit-restore-window}
+(see above) when the frame of the window to quit has been specially
+created for displaying that window's buffer and the buffer is not
+killed.
The default is to call @code{iconify-frame} (@pxref{Visibility of
Frames}). Alternatively, you may specify either @code{delete-frame}
right of the rightmost column, and the Y coordinate one row down from
the bottommost row.
-Note that these are the actual outer edges of the window, including
-any header line, mode line, scroll bar, fringes, and display margins.
-On a text terminal, if the window has a neighbor on its right, its
-right edge includes the separator line between the window and its
+Note that these are the actual outer edges of the window, including any
+header line, mode line, scroll bar, fringes, window divider and display
+margins. On a text terminal, if the window has a neighbor on its right,
+its right edge includes the separator line between the window and its
neighbor.
@end defun
@defun window-inside-edges &optional window
This function is similar to @code{window-edges}, but the returned edge
values are for the text area of the window. They exclude any header
-line, mode line, scroll bar, fringes, display margins, and vertical
-separator.
+line, mode line, scroll bar, fringes, window divider, display margins,
+and vertical separator.
@end defun
@defun window-top-line &optional window
@item header-line
The coordinates are in the header line of @var{window}.
+@item right-divider
+The coordinates are in the divider separating @var{window} from a
+window on the right.
+
+@item right-divider
+The coordinates are in the divider separating @var{window} from a
+window beneath.
+
@item vertical-line
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
the display screen. @var{window} must specify a live window.
@end defun
+@defun window-pixel-left &optional window
+This function returns the left pixel edge of window @var{window}.
+@var{window} must be a valid window and defaults to the selected one.
+@end defun
+
+@defun window-pixel-top &optional window
+This function returns the top pixel edge of window @var{window}.
+@var{window} must be a valid window and defaults to the selected one.
+@end defun
+
+
@node Window Configurations
@section Window Configurations
@cindex window configurations
A @dfn{window configuration} records the entire layout of one
frame---all windows, their sizes, which buffers they contain, how those
-buffers are scrolled, and their values of point and the mark; also their
+buffers are scrolled, and their value of point; also their
fringes, margins, and scroll bar settings. It also includes the value
of @code{minibuffer-scroll-window}. As a special exception, the window
configuration does not record the value of point in the selected window
@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
+structure of windows, but ignores the values of point 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.
+saved point.
@end defun
@defun window-configuration-frame config