Edits to Window Sizes node of Lisp manual.

* doc/lispref/windows.texi (Window Sizes): Copyedits.  Document
window-text-height.  Remove window-min-height and window-min-width
discussion, referring instead to Emacs manual.
(Splitting Windows, Resizing Windows): Add xref to Emacs manual.
This commit is contained in:
Chong Yidong 2011-11-08 15:43:30 +08:00
parent 105216ed03
commit a79db6e012
2 changed files with 151 additions and 257 deletions

View file

@ -1,3 +1,10 @@
2011-11-08 Chong Yidong <cyd@gnu.org>
* windows.texi (Window Sizes): Copyedits. Document
window-text-height. Remove window-min-height and window-min-width
discussion, referring instead to Emacs manual.
(Splitting Windows, Resizing Windows): Add xref to Emacs manual.
2011-11-07 Glenn Morris <rgm@gnu.org>
* windows.texi (Choosing Window): Fix keybinding typo.

View file

@ -340,13 +340,12 @@ internal window). The @var{edges} element is a list @code{(@var{left}
@cindex window size
@cindex size of window
Emacs windows are rectangular. The structure of a live window can be
roughly sketched as follows:
The following schematic shows the structure of a live window:
@smallexample
@group
_________________________________________
^ |______________ Header Line_______________|
_________________________________________
^ |______________ Header Line_______________|
| |LS|LF|LM| |RM|RF|RS| ^
| | | | | | | | | |
Window | | | | Text Area | | | | Window
@ -362,295 +361,177 @@ roughly sketched as follows:
@end smallexample
@cindex window body
@cindex text area of a window
@cindex body of a window
The text area constitutes the body of the window. In its most simple
form, a window consists of its body alone. LS and RS stand for the left
and right scroll bar (@pxref{Scroll Bars}) respectively. Only one of
them can be present at any time. LF and RF denote the left and right
fringe, see @ref{Fringes}. LM and RM, finally, stand for the left and
right display margin, see @ref{Display Margins}. The header line, if
present, is located above theses areas, the mode line below, see
@ref{Mode Line Format}.
At the center of the window is the @dfn{text area}, or @dfn{body},
where the buffer text is displayed. On each side of the text area is
a series of vertical areas; from innermost to outermost, these are the
left and right margins, denoted by LM and RM in the schematic
(@pxref{Display Margins}); the left and right fringes, denoted by LF
and RF (@pxref{Fringes}); and the left or right scroll bar, only one of
which is present at any time, denoted by LS and RS (@pxref{Scroll
Bars}). At the top of the window is an optional header line
(@pxref{Header Lines}), and at the bottom of the window is the mode
line (@pxref{Mode Line Format}).
Emacs provides several functions for finding the height and width of
a window. Most of these functions report the values as integer
multiples of the default character height and width. On a graphical
display, the actual screen size of this default height and width are
those specified by the frame's default font. Hence, if the buffer
contains text that is displayed in a different size, the reported
height and width of the window may differ from the actual number of
text lines or columns displayed in it.
@cindex window height
@cindex total window height
@cindex height of a window
@cindex total height of a window
The @dfn{total height of a window} is specified as the total number of
lines occupied by the window. Any mode or header line is included in a
window's total height. For an internal window, the total height is
calculated recursively from the total heights of its child windows.
@cindex window width
@cindex total window width
@cindex width of a window
@cindex total width of a window
The @dfn{total width of a window} denotes the total number of columns of
the window. Any scroll bar and the column of @samp{|} characters that
separate the window from its right sibling are included in a window's
total width. On a window-system, fringes and display margins are
included in a window's total width too. For an internal window, the
total width is calculated recursively from the total widths of its child
windows.
@cindex total size of a window
@cindex total window size
The following function is the standard interface for getting the total
size of any window:
@defun window-total-size &optional window &optional horizontal
This function returns the total number of lines of @var{window}. The
argument @var{window} can denote any window and defaults to the selected
one. If @var{window} is live, the return value includes any header or
mode lines of @var{window}. If @var{window} is internal, the return
value is the sum of the total heights of @var{window}'s child windows
provided these are vertically combined and the height of @var{window}'s
first child if they are horizontally combined.
If the optional argument @var{horizontal} is non-@code{nil}, this
function returns the total number of columns of @var{window}. If
@var{window} is live, the return value includes any vertical divider
column or scroll bars of @var{window}. On a window-system, the return
value includes the space occupied by any margins and fringes of
@var{window} too. If @var{window} is internal, the return value is the
sum of the total widths of @var{window}'s child windows provided these
are horizontally combined and the width of @var{window}'s first child
otherwise.
@end defun
Alternatively, the following two functions can be used to retrieve
either the total height or the total width of a window:
The @dfn{total height} of a window is the distance between the top
and bottom of the window, including the header line (if one exists)
and the mode line. The @dfn{total width} of a window is the distance
between the left and right edges of the mode line. Note that the
height of a frame is not the same as the height of its windows, since
a frame may also contain an echo area, menu bar, and tool bar
(@pxref{Size and Position}).
@defun window-total-height &optional window
This function returns the total number of lines of @var{window}.
@var{window} can be any window and defaults to the selected one. The
return value includes @var{window}'s mode line and header line, if any.
If @var{window} is internal the return value is the sum of heights of
@var{window}'s child windows for a vertical combination and the height
of @var{window}'s first child otherwise.
This function returns the total height, in lines, of the window
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window. If @var{window} is an internal window, the
return value is the total height occupied by its descendant windows.
@end defun
@defun window-total-width &optional window
This function returns the total number of columns of @var{window}.
@var{window} can be any window and defaults to the selected one. The
return value includes any vertical dividers or scrollbars of
@var{window}. On a window-system the return value also includes the
space occupied by any margins and fringes of @var{window}. If
@var{window} is internal, the return value is the sum of the widths of
@var{window}'s child windows for a horizontal combination and the width
of @var{window}'s first child otherwise.
This function returns the total width, in columns, of the window
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window. If @var{window} is internal, the return value
is the total width occupied by its descendant windows.
@end defun
The total height of any window is usually less than the height of the
window's frame, because the latter may also include the minibuffer
window. Depending on the toolkit in use, the frame height can also
include the menu bar and the tool bar (@pxref{Size and Position}).
Therefore, in general it is not straightforward to compare window and
frame heights. The following function is useful to determine whether
there are no other windows above or below a specified window.
@cindex full-height window
@defun window-full-height-p &optional window
This function returns non-@code{nil} if there is no other window above
or below @var{window} on the containing frame. More precisely, this
function returns @code{t} if and only if the total height of
@var{window} equals the total height of the root window (@pxref{Windows
and Frames}) of @var{window}'s frame. The @var{window} argument may
denote any window and defaults to the selected one.
@defun window-total-size &optional window horizontal
This function returns either the total height or width of the window
@var{window}. If @var{horizontal} is omitted or @code{nil}, this is
equivalent to calling @code{window-total-height} for @var{window};
otherwise it is equivalent to calling @code{window-total-width} for
@var{window}.
@end defun
@cindex full-width window
The following function can be used to determine whether there are no
other windows on the left or right of a specified window.
@cindex full-height window
The following functions can be used to determine whether a given
window has any adjacent windows.
@defun window-full-width-p &optional window
This function returns non-@code{nil} if there are no other windows on
the left or right of @var{window}; @code{nil} otherwise. More
precisely, this function returns @code{t} if and only if the total width
of @var{window} equals the total width of the root window
(@pxref{Windows and Frames}) of @var{window}'s frame. The @var{window}
argument may denote any window and defaults to the selected one.
@defun window-full-height-p &optional window
This function returns non-@code{nil} if @var{window} has no other
window above or below it in its frame, i.e. its total height equals
the total height of the root window on that frame. If @var{window} is
omitted or @code{nil}, it defaults to the selected window.
@end defun
@cindex top line of window
@cindex left column of window
The windows of a frame are unambiguously characterized by the
combination of their top line and left column within that frame.
@defun window-full-width-p &optional window
This function returns non-@code{nil} if @var{window} has no other
window to the left or right in its frame, i.e. its total width equals
that of the root window on that frame. If @var{window} is omitted or
@code{nil}, it defaults to the selected window.
@end defun
@cindex window position
The following functions can be used to determine the position of a
window relative to the window area of its frame:
@defun window-top-line &optional window
This function returns the top line of @var{window}. The argument
@var{window} can denote any window and defaults to the selected one.
This function returns the distance, in lines, between the top of
@var{window} and the top of the frame's window area. For instance,
the return value is 0 if there is no window above @var{window}. If
@var{window} is omitted or @code{nil}, it defaults to the selected
window.
@end defun
@defun window-left-column &optional window
This function returns the left column of @var{window}. The argument
@var{window} can denote any window and defaults to the selected one.
This function returns the distance, in columns, between the left edge
of @var{window} and the left edge of the frame's window area. For
instance, the return value is 0 if there is no window to the left of
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window.
@end defun
For a frame displaying one window only, that window's top line and left
column are both zero. When a frame displays a window @var{WB} below a
window @var{WA}, the top line of @var{WB} can be calculated by adding
the total height of @var{WA} to the top line of @var{WA}. When a frame
displays a window @var{WR} on the right of a window @var{WL}, the left
column of @var{WR} can be calculated by adding the total width of
@var{WL} to the left column of @var{WL}.
@cindex window body height
@cindex body height of a window
The @dfn{body height of a window} is specified as the total number of
lines occupied by the window's text area. Mode or header lines are not
included in a window's body height.
@cindex window body width
@cindex body width of a window
The @dfn{body width of a window} denotes the total number of columns
occupied by the window's text area. Scroll bars or columns of @samp{|}
characters that separate side-by-side windows are not included in a
window's body width.
@cindex body size of a window
@cindex window body size
@cindex canonical units of window/frame size
The following functions retrieve height and width of the body of a
live window. Note that the values these functions return are measured
in @dfn{canonical units}, i.e.@: for the default frame's face. If the
window shows some characters with non-default face, e.g., if the font
of some characters is larger or smaller than the default font, the
values returned by these functions will not match the actual number of
lines or characters per line shown in the window. To get the actual
number of columns and lines, move to the last character in the line
(e.g., with @code{end-of-visual-line}) or to the last line of the
window (e.g., with @code{window-end}), and use @code{posn-at-point} to
find the line or column there.
@defun window-body-size &optional window horizontal
This function returns the number of lines of @var{window}'s text area.
@var{window} must be a live window and defaults to the selected one.
The return value does not count any mode or header line of @var{window}.
Optional argument @var{horizontal} non-@code{nil} means to return the
number of columns of @var{window}'s text area. In this case the return
value does not include any vertical divider or scroll bar owned by
@var{window}. On a window-system the return value does not include the
number of columns used for @var{window}'s fringes or display margins
either.
@end defun
The @dfn{body height} of a window is the height of its text area,
which does not include the mode or header line. Similarly, the
@dfn{body width} is the width of the text area, which does not include
the scroll bar, fringes, or margins.
@defun window-body-height &optional window
This function returns the number of lines of @var{window}'s body.
@var{window} must be a live window and defaults to the selected one.
This function returns the body height, in lines, of the window
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window; otherwise it must be a live window.
The return value does not include @var{window}'s mode line and header
line, if any. If a line at the bottom of the window is only partially
visible, that line is included in the return value. If you do not
want to include a partially visible bottom line in the return value,
use @code{window-text-height} instead.
If there is a partially-visible line at the bottom of the text area,
that counts as a whole line; to exclude such a partially-visible line,
use @code{window-text-height}, below.
@end defun
@defun window-body-width &optional window
This function returns the number of columns of @var{window}'s body.
@var{window} must be a live window and defaults to the selected one.
The return value does not include any vertical dividers or scroll bars
owned by @var{window}. On a window-system the return value does not
include the number of columns used for @var{window}'s fringes or
display margins either.
This function returns the body width, in columns, of the window
@var{window}. If @var{window} is omitted or @code{nil}, it defaults
to the selected window; otherwise it must be a live window.
@end defun
The following functions have been used in earlier versions of Emacs.
They are still supported but due to the confusing nomenclature they
should not be used any more in future code.
@defun window-height &optional window
This function is an alias for `window-total-height', see above.
@defun window-body-size &optional window horizontal
This function returns the body height or body width of @var{window}.
If @var{horizontal} is omitted or @code{nil}, it is equivalent to
calling @code{window-body-height} for @var{window}; otherwise it is
equivalent to calling @code{window-body-width}.
@end defun
@defun window-width &optional window
This function is an alias for `window-body-width', see above.
@defun window-text-height &optional window
This function is like @code{window-body-height}, except that any
partially-visible line at the bottom of the text area is not counted.
@end defun
@cindex minimum window size
The following two options constrain the sizes of windows to a minimum
height and width. Their values are honored when windows are split
(@pxref{Splitting Windows}) or resized (@pxref{Resizing Windows}). Any
request to make a window smaller than specified here will usually result
in an error.
@defopt window-min-height
The value of this variable specifies how short a window may be. The
value is measured in line units and has to account for any header or
mode line. The default value for this option is @code{4}. Values less
than @code{1} are ignored.
@end defopt
@defopt window-min-width
The value of this variable specifies how narrow a window may be. The
value is measured in characters and includes any margins, fringes,
scroll bar and vertical divider column. The default value for this
option is @code{10}. A value less than @code{2} is ignored.
@end defopt
Applications should not rebind these variables. To shrink a specific
window to a height or width less than the one specified here, they
should rather invoke @code{window-resize} (@pxref{Resizing Windows})
with a non-@code{nil} @var{ignore} argument. The function
@code{split-window} (@pxref{Splitting Windows}) can make a window
smaller than specified here by calling it with a non-@code{nil}
@var{size} argument. Interactively, the values specified here cannot be
overridden.
Earlier versions of Emacs could delete a window when its size dropped
below @code{window-min-height} or @code{window-min-width}. As a rule,
the current version of Emacs does no more delete windows by side-effect.
The only exception to this rule are requests to resize a frame which may
implicitly delete windows when they do not fit on the frame any more,
see @ref{Size and Position}.
The size of a window can be fixed which means that it cannot be split
(@pxref{Splitting Windows}) or resized (@pxref{Resizing Windows}).
For compatibility with previous versions of Emacs,
@code{window-height} is an alias for @code{window-body-height}, and
@code{window-width} is an alias for @code{window-body-width}. These
aliases are considered obsolete and will be removed in the future.
@cindex fixed-size window
Commands that change the size of windows (@pxref{Resizing Windows}),
or split them (@pxref{Splitting Windows}), obey the variables
@code{window-min-height} and @code{window-min-width}, which specify
the smallest allowable window height and width. @xref{Change
Window,,Deleting and Rearranging Windows, emacs, The GNU Emacs
Manual}. They also obey the variable @code{window-size-fixed}, with
which a window can be @dfn{fixed} in size:
@defvar window-size-fixed
If this variable is non-@code{nil}, in a given buffer, then the size of
any window displaying that buffer remains fixed unless you either
explicitly change it or Emacs has no other choice.
If this buffer-local variable is non-@code{nil}, the size of any
window displaying the buffer cannot normally be changed. Deleting a
window or changing the frame's size may still change its size, if
there is no choice.
If the value is @code{height}, then only the window's height is fixed;
if the value is @code{width}, then only the window's width is fixed.
Any other non-@code{nil} value fixes both the width and the height.
This variable automatically becomes buffer-local when set.
@end defvar
Commands supposed to explicitly change the size of windows such as
@code{enlarge-window} (@pxref{Resizing Windows}) get an error if they
had to change a window size which is fixed. Other functions like
@code{window-resize} (@pxref{Resizing Windows}) have an optional
@var{ignore} argument which allows to change the size of fixed-size
windows.
Deleting a window or changing a frame's size may change the size of a
fixed-size window, if there is no other alternative.
The height of a vertical combination of windows cannot be changed
when the height of all these windows is fixed. Its width cannot be
changed if the width of at least one of these windows is fixed.
Similarly, the width of a horizontal combination of windows cannot be
changed when the width of all these windows is fixed. Its height cannot
be changed if the height of at least one of these windows is fixed.
The next function allows to check whether the size of an arbitrary
window is fixed.
@defun window-size-fixed-p &optional window horizontal
This function returns non-@code{nil} if @var{window}'s height is fixed.
The argument @var{window} can be an arbitrary window and defaults to the
selected one. Optional argument @var{horizontal} non-@code{nil} means
return non-@code{nil} if @var{window}'s width is fixed.
This function returns a non-@code{nil} value if @var{window}'s height
is fixed. If @var{window} is omitted or @code{nil}, it defaults to
the selected window. If the optional argument @var{horizontal} is
non-@code{nil}, the return value is non-@code{nil} if @var{window}'s
width is fixed.
If this function returns @code{nil}, this does not necessarily mean that
@var{window} can be resized in the desired direction. The function
@code{window-resizable} (@pxref{Resizing Windows}) can tell that.
A @code{nil} return value does not necessarily mean that @var{window}
can be resized in the desired direction. To determine that, use the
function @code{window-resizable}. @xref{Resizing Windows}.
@end defun
@ -703,13 +584,17 @@ shrunk by -@var{delta} lines or columns, this function returns the
minimum value in the range from @var{delta} to 0 that can be used for
shrinking @var{window}.
Optional argument @var{ignore} non-@code{nil} means ignore any
restrictions imposed by the variables @code{window-min-height} or
@code{window-min-width} and @code{window-size-fixed}. In this case the
minimum height of a window is specified as the minimum number of lines
that allow viewing any header or mode line and at least one line of the
text area of window. The minimum width of a window includes any
fringes, margins and the scroll bar as well as two text columns.
Normally, the customizable variables @code{window-min-height} and
@code{window-min-width} specify the smallest allowable size of a
window. @xref{Change Window,,Deleting and Rearranging Windows,
emacs, The GNU Emacs Manual}. If resizing would result in making any
window smaller than this, this function usually signals an error.
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}. In that case, the minimum-height
window consists of a header (if any), a mode line, plus a text area
one line tall; the minimum-width window consists of any fringes,
margins and scroll bar, plus a text area two columns wide.
If @var{ignore} denotes a window, this means to ignore restrictions for
that window only. If @var{ignore} equals the constant @code{safe}, this
@ -801,7 +686,7 @@ If @var{delta} is greater zero, this moves the edge downwards or to the
right. If @var{delta} is less than zero, this moves the edge upwards or
to the left. If the edge can't be moved by @var{delta} lines or columns,
it is moved as far as possible in the desired direction but no error is
signalled.
signaled.
This function tries to resize windows adjacent to the edge that is
moved. Only if this is insufficient, it will also resize windows not
@ -820,7 +705,7 @@ contents exactly. The default for @var{window} is the selected window.
The optional argument @var{max-height} specifies the maximum total
height the window is allowed to be; @code{nil} means use the maximum
permissible height of a window on @var{window}'s frame. The optional
argument @var{min-height} specifies the minimum toatl height for the
argument @var{min-height} specifies the minimum total height for the
window; @code{nil} means use @code{window-min-height}. All these height
values include the mode line and/or header line.
@ -912,12 +797,14 @@ tall. If @var{size} is omitted or @code{nil}, then @var{window} is
divided evenly into two parts. (If there is an odd line, it is
allocated to the new window.)
If splitting would result in making a window smaller than
@code{window-min-height} or @code{window-min-width} (@pxref{Window
Sizes}), this function usually signals an error. However, if @var{size}
is non-@code{nil} and valid, a new window of the requested size is
created. (A size value would be invalid if it assigned less than one
line or less than two columns to the new window.)
Normally, the customizable variables @code{window-min-height} and
@code{window-min-width} specify the smallest allowable size of a
window. @xref{Change Window,,Deleting and Rearranging Windows, emacs,
The GNU Emacs Manual}. If splitting would result in making a window
smaller than this, this function usually signals an error. However,
if @var{size} is non-@code{nil} and valid, a new window of the
requested size is created, provided it has enough space for a text
area one line tall and/or two columns wide.
Optional third argument @var{side} @code{nil} (or @code{below})
specifies that the new window shall be located below @var{window}. The
@ -1105,7 +992,7 @@ desired configuration as depicted below.
The scenario sketched above is the standard way to obtain the desired
configuration. In Emacs 23 it was also the only way to do that since
Emacs 23 did't allow splitting internal windows.
Emacs 23 didn't allow splitting internal windows.
With Emacs 24 you can also proceed as follows: Split an initial window
@code{W6} by evaluating @code{(split-window W6 -3)} to produce the
@ -1833,7 +1720,7 @@ This function does not select a window that has a non-@code{nil}
@end deffn
The following function returns a copy of the list of windows in the
cyclic odering.
cyclic ordering.
@defun window-list-1 &optional window &optional minibuf &optional all_frames
This function returns a list of live windows. The optional arguments
@ -1843,7 +1730,7 @@ in the list. See the description of @code{next-window} for details.
The optional argument @var{window} specifies the first window to list
and defaults to the selected window. If @var{window} is not on the list
of windows returned, some other window will be listed first but no error
is signalled.
is signaled.
@end defun
The functions described below use @code{window-list-1} for generating a
@ -1956,7 +1843,7 @@ This function makes @var{window} display @var{buffer-or-name} and
returns @code{nil}. The argument @var{window} has to denote a live
window and defaults to the selected one. The argument
@var{buffer-or-name} must specify a buffer or the name of an existing
buffer. An error is signalled when @var{window} is @dfn{strongly}
buffer. An error is signaled when @var{window} is @dfn{strongly}
dedicated to its buffer (@pxref{Dedicated Windows}) and does not already
display @var{buffer-or-name}.
@ -2043,7 +1930,7 @@ If a window displaying @var{buffer-or-name} is dedicated
(@pxref{Dedicated Windows}) and is not the only window on its frame,
that window is deleted. If that window is the only window on its frame
and there are other frames on the frame's terminal, that frame is dealt
with by the function spcecified by @code{frame-auto-hide-function}
with by the function specified by @code{frame-auto-hide-function}
(@pxref{Quitting Windows}). Otherwise, the buffer provided by the
function @code{switch-to-prev-buffer} (@pxref{Window History}) is
displayed in the window instead.
@ -3281,7 +3168,7 @@ 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, that puts the line containing
If @var{count} is a non-negative 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