DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T w

⟦827ed9f5d⟧ TextFile

    Length: 36074 (0x8cea)
    Types: TextFile
    Names: »windows.texinfo«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦c06c473ab⟧ »./UNRELEASED/lispref.tar.Z« 
        └─⟦1b57a2ffe⟧ 
            └─⟦this⟧ »windows.texinfo« 

TextFile

@setfilename ../info/windows
@node Windows, Positions, Buffers, Top
@chapter Windows

  This chapter describes most of the functions and variables related to
Emacs windows.  However, @pxref{Emacs Display}, and @ref{Changing
Buffers}, for more information.

@menu
* Window Basics::       
* Splitting Windows::   
* Deleting Windows::    
* Selecting Windows::   
* Cyclic Window Ordering::      
* Buffers and Windows:: 
* Window Point::        
* Vertical Scrolling::  
* Horizontal Scrolling::        
* Window Size:: 
* Window Configurations::       
@end menu

@node Window Basics, Splitting Windows, Windows, Windows
@section Window Basics

  A @dfn{window} is the physical area of a terminal in which a buffer is
displayed.  But the term is also used to refer to a
Lisp object.  Which is meant should be clear from the context.

  At all times, there is at least one window displayed on the screen,
and there is exactly one window that we call the @dfn{selected window}.
The cursor is in the selected window.  The selected window's buffer is
usually the current buffer, except temporarily during a command when
@code{set-buffer} has been used.  (@xref{Changing Buffers}.)

  For all intents and purposes, a window only exists as long as it is
displayed on the terminal.  Once removed from the display, the window
is effectively deleted and should not be used, @emph{even though there
may still be references to it} from other Lisp objects.
(@xref{Deleting Windows}.)

  Each window has the following attributes:

@itemize @bullet

@item 
window height

@item 
window width

@item 
window edges with respect to the screen

@item 
the buffer displayed

@item 
position within the buffer at the upper left of the window

@item 
how many horizontally scrolled columns

@item 
point

@item 
mark

@item 
position in the window circular list

@end itemize

  Applications use multiple windows for a variety of reasons, but most
often to give different views of the same object.  In Rmail, for
example, if you request a message header summary, you are given a second
window with the headers displayed within it.  In this window, you can
process a message by moving point to the line listing the message and
applying Rmail Summary Mode commands.

  For information about other techniques, @pxref{Major Modes, Major Modes,
Major Modes, emacs, The GNU Emacs Manual}.  Also, @pxref{Key Bindings,
Key Bindings, Key Bindings, emacs, The GNU Emacs Manual}.

  Use of the word `window' to refer to a view of a buffer was
established long ago in Emacs.  The metaphor was inspired by how you
look out a house window---at part (or sometimes all) of an overall view.
You see part (or sometimes all) of a buffer through an Emacs window.  In
Emacs, each window may look upon a different view, like different
windows of a house.

  The term ``window'' as used in this manual means something different
from the term as used in a window system like X.  In this manual, the
term ``window'' refers to one of several in the Emacs @dfn{screen}.  In
a system like X, the screen may happen to be one window in a window
system.  Expressed another way, Emacs's windows are in a screen that may
itself be a `window' of a windowing system.

@cindex screen of terminal
@cindex tiled windows
@cindex X Window System
  For those familiar with windowing systems, Emacs's windows are
rectangles tiled onto the rectangle of the screen, and every portion
of the screen is part of some window.  There are no areas which do not
belong to a window, except for the minibuffer (and even it acts like a
window sometimes).  This limitation helps avoid wasting the
historically scarce resource of screen space.  It also works very well
with character-only terminals.  Because of the way in which Emacs
creates new windows and resizes them, you can't create every
conceivable tiling on an Emacs screen.  @xref{Splitting Windows}.
Also, @pxref{Window Size}.

  @xref{Emacs Display}, for functions related to the Emacs screen.

@defun windowp object
  This function returns @code{t} if object is a window.
@end defun

@node Splitting Windows, Deleting Windows, Window Basics, Windows
@section Splitting Windows
@cindex splitting windows

  The functions described here split windows, as do two other functions,
@code{pop-to-buffer} and @code{display-buffer}.  (@xref{Changing Buffers}.)

  The distinction between these functions and the @code{pop-to-buffer}
and @code{display-buffer} functions is that the latter refer
specifically to buffers, while the functions described in this section
do not.  These functions let the two ``halves'' of the split window
display the previously visible buffer in the window that was split.

  The @code{split-window-horizontally} and the
@code{split-window-vertically} functions described in this section are
interfaces to the @code{split-windows} function.

@defun one-window-p &optional no-mini
  Returns non-@code{nil} if there is only one window.
Optional @var{no-mini} non-@code{nil} means don't count the minibuffer
even if it is active.
@end defun

@deffn Command split-window &optional window size horizontal
  This function splits @var{window} into two, leaving @var{size} lines in
@var{window} (which becomes the top window), and putting the rest of the
lines that @var{window} had into the new window.

  @code{split-window} returns the window created.  The original window
remains the selected window.

  If @var{horizontal} is non-@code{nil}, then @var{window} splits side by
side, leaving @var{size} columns in @var{window} (which becomes the
left-hand window), and putting the rest of the columns that @var{window}
had into the new window.

  If @var{window} is omitted, then the selected window is split.

  If @var{size} is omitted, then @var{window} is divided evenly into
two parts.  (If there is an odd line, it is allocated to the new
window.)

  When @code{split-window} is called interactively, @var{window}
defaults to the selected window, and @var{size} and @var{horizontal}
default to @code{nil}.

  The following example starts with one window on a screen that is 50
lines high by 80 columns wide; then the window is split.  (Also,
@pxref{Window Point}.)

@example
(setq w (selected-window))
     @result{} #<window 8 on windows.texinfo>
(window-edges)               ; @r{Edges in order: left--top--right--bottom}
     @result{} (0 0 80 49)

(setq w2 (split-window w 15))   ; @r{Returns window created}
     @result{} #<window 28 on windows.texinfo>
(window-edges w2)
     @result{} (0 15 80 49)  ; @r{Bottom window; top is line 15}
(window-edges w)
     @result{} (0 0 80 15)   ; @r{Top window}
@end example

The screen looks like this:

@group
@example

         __________   line 0
        |          |  
        |    w     |
        |__________|  line 15
        |          |
        |    w2    |
        |__________|  line 49

 column 1   column 80
@end example
@end group

Next, the top window is split horizontally:

@example
(setq w3 (split-window w 35 t))
     @result{} #<window 32 on windows.texinfo>
(window-edges w3)
     @result{} (35 0 80 15)  ; @r{Left edge at column 35}
(window-edges w)
     @result{} (0 0 35 15)   ; @r{Right edge at column 35}
(window-edges w2)
     @result{} (0 15 80 49)  ; @r{Bottom window unchanged}
@end example

Now, the screen looks like this:

@group
@example
     column 35
         __________   line 0
        |   |      |  
        | w |  w3  |
        |___|______|  line 15
        |          |
        |    w2    |
        |__________|  line 49

 column 1   column 80
@end example
@end group
@end deffn

@deffn Command split-window-vertically size
  This function splits the selected window into two, one above the
other, leaving the selected window with @var{size} lines.

  This function is simply an interface to @code{split-windows}.
Here is the complete function definition for it:

@example
(defun split-window-vertically (&optional arg)
  "Split selected window into two windows, one above the other.
This window becomes the uppermost of the two, and gets
ARG lines.  No arg means split equally."
  (interactive "P")
  (split-window nil (and arg (prefix-numeric-value arg))))
@end example
@end deffn

@deffn Command split-window-horizontally size
  This function splits the selected window into two,
side-by-side, leaving the selected window with @var{size} lines.

  This function is simply an interface to split-windows.  Here is the
complete definition for @code{split-window-horizontally}, except that
part of the documentation has been deleted to save space:

@example
(defun split-window-horizontally (&optional arg)
  "Split selected window into two windows side by side."
  (interactive "P")
  (split-window nil (and arg (prefix-numeric-value arg)) t))
@end example

@end deffn

@node Deleting Windows, Selecting Windows, Splitting Windows, Windows
@section Deleting Windows
@cindex deleting windows

  A deleted window no longer appears on the screen.  In Emacs version
18, the space it took up is divided proportionally among all siblings;
in version 19, the space is given to one adjacent sibling.

@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.  It
is an error if there is only one window being displayed when
@code{delete-window} executes.

@quotation
@findex window-point @r{example}
@b{Warning: } Erroneous information or fatal errors may result by using
a deleted window.  You can test whether a window has been deleted with
@code{(window-point @var{window})}.
@end quotation

  This function returns @code{nil}.

  When @code{delete-window} is called interactively, @var{window}
defaults to the selected window.

@end deffn

@deffn Command delete-other-windows window
  This function makes @var{window} the only window on the screen by
deleting all the other windows.  If @var{window} is omitted, then the
selected window is the one remaining.

  The result is @code{nil}.
@end deffn

@deffn Command delete-windows-on buffer
  This function deletes all windows showing @var{buffer}.  If there are
no windows showing @var{buffer}, then this function does nothing.  If
all windows are showing @var{buffer} (including the case where there is
only one window), then the screen reverts to having a single window
showing the buffer chosen by @code{other-buffer}.

  If there are several windows showing different buffers, then those
showing @var{buffer} are removed, and the others are expanded to fill the
void.

  The result is @code{nil}.
@end deffn

@node Selecting Windows, Cyclic Window Ordering, Deleting Windows, Windows
@section Selecting Windows
@cindex selecting windows

When a window is selected, the buffer in the window becomes the current
buffer.  The cursor will appear in it.

@defun selected-window
  This function returns the selected window.  This is the window in which the
cursor appears (and to which many commands apply).
@end defun

@defun select-window window
  This function makes @var{window} the selected window.  The cursor
then appears in @var{window} (on redisplay).  The current buffer changes
to @var{window}'s buffer

  It returns @var{window}.

@example
(setq w (next-window))
(select-window w)
     @result{} #<window 65 on windows.texinfo>
@end example
@end defun

@cindex finding windows
  Often you want to try to select the ``best'' window.  These functions
give you a choice of criteria with which to choose.

@defun get-lru-window
  This function returns the window least recently used or selected for
display.  The selected window is the most recently used window.

  The selected window can be the least recently used window if it is
the only window.  A newly created window becomes the least recently
used window until it is selected.  The minibuffer window is never
returned by this function.

@example
(get-lru-window)
     @result{} #<window 58 on windows.texinfo>
@end example
@end defun

@defun get-largest-window
  This function returns the window with the largest area (height times
width).  If the screen is not divided horizontally, then this is just
the window with the most lines.

  If there are two windows of the same size, then the function returns
the window which is first in the canonical ordering of windows,
starting from the seleted window.  The minibuffer is never considered
for ``largest''.
@end defun

@node Cyclic Window Ordering, Buffers and Windows, Selecting Windows, Windows
@comment  node-name,  next,  previous,  up
@section Cycling Through All Windows
@cindex cyclic window ordering
@cindex ordering of windows, cyclic
@cindex window ordering, cyclic 

  The order in which windows are selected by functions such as
@code{next-window}  depends on the order in which the screen or
the windows within the screen were split.

  If the screen (or window) was first split vertically (into windows
one above each other), and then the topmost window was split
horizontally, then the ordering is left to right in the top, and then
left to right in the next lower part of the screen, and so on.  If the
screen (or window) was first split horizontally, the ordering is top
to bottom in the left part, and so on.  Within each set of siblings,
the order is left to right, or top to bottom.

@defun next-window window &optional minibuf
@cindex minibuffer window
  This function returns the next window after @var{window} in the
canonical ordering of windows.  The successor to that window is the
window which would be selected by @code{(other-window 1)}.

  The ordering includes all the windows except perhaps the minibuffer.
The value of the argument @var{minibuf} determines whether the
minibuffer is in the window order.

  If @var{minibuf} is @code{t}, then the canonical ordering includes
the minibuffer window even if it is not active.  If @var{minibuf} is
neither @code{t} nor @code{nil}, then the minibuffer window is not
included even if it is active.  @xref{Minibuffers}, for what it means
for the minibuffer to be active.

  In the example, there are two windows in existence.  They both happen to
be displaying the same buffer.

@example
(selected-window)
     @result{} #<window 56 on windows.texinfo>
(next-window (selected-window))
     @result{} #<window 52 on windows.texinfo>
(next-window (next-window (selected-window)))
     @result{} #<window 56 on windows.texinfo>
@end example

  If @var{window} is the only window visible, then this function returns
@var{window}.
@end defun

@defun previous-window window
  This function returns the window preceding @var{window} in the
canonical ordering of windows.
@end defun

@deffn Command other-window count
  This function selects the @var{count'th} next window.  If count
is negative, then it selects the @var{count'th} previous window.

  It returns @code{nil}.

  When called interactively, it sets @var{count} to the processed prefix
argument.

  The canonical ordering of windows specifies the value of the
@var{count'th} next window.  
@end deffn

@node Buffers and Windows, Window Point, Cyclic Window Ordering, Windows
@section Buffers and Windows
@cindex examining windows
@cindex windows, controlling precisely
@cindex buffers, controlled in windows

  This section describes low level functions to examine windows or to
show buffers in windows in a precisely controlled fashion.

  @xref{Changing Buffers}, for related functions that find a window to
use and specify a buffer for it.  The functions described there are
easier to use than those described here.  Use those described here when
you need complete control.

@defun set-window-buffer window buffer-or-name
  This function makes @var{window} display @var{buffer-or-name} as its
contents.  It returns @var{buffer-or-name}.

@example
(set-window-buffer (selected-window) "foo")
     @result{} nil
@end example
@end defun

@defun window-buffer &optional window
  This function returns the buffer that @var{window} is displaying.  If
@var{window} is omitted, then this function returns the buffer for the
selected window.

@example
(window-buffer)
     @result{} #<buffer windows.texinfo>
@end example
@end defun

@defun get-buffer-window buffer-or-name
  This function returns a window currently displaying @var{buffer-or-name}, or
@code{nil} if there is none.  If there are several such windows, then the
function returns the window which is first in the canonical ordering of
windows, starting from the selected window.
@end defun

@deffn Command replace-buffer-in-windows buffer
  This function replaces @var{buffer} with some other buffer in all
windows showing it.  The other buffer used is chosen with
@code{other-buffer}; but in the usual applications of this function,
you don't care which other buffer is used.

  This function returns @code{nil}.
@end deffn

@node Window Point, Vertical Scrolling, Buffers and Windows, Windows
@section Window Point
@cindex window position
@cindex window point
@cindex position in window
@cindex point in window

  Each window has a value of point, which is independent of the value
of point in other windows on the same buffer.  

@itemize @bullet
@item
The window point is established when a window is first opened on a
buffer and the initial value of the window point is set to be the
value of the buffer's point or the window point of another window
opened on the buffer, if such a window exists.

@item
While the selected window displays the current buffer, the changing
the value of point in the window changes the value of point in the
buffer.

@item
When the last window opened on a buffer is deleted, the value of
point in the buffer is left set to the value of the window's point
before the window was deleted.  @xref{Positions}, for more details on
positions.
@end itemize

  As far as the user is concerned, point is where the cursor is, and
when the user switches to another buffer, the cursor jumps to the
position of point in that buffer.

@defun window-point window
  This function returns the current position of the point in @var{window}.
For a nonselected window, this is the value the point would have
if that window were selected.

  When @var{window} is the selected window and its buffer is also
currently selected, the value returned is the same as @code{(point)}.

  It would be more strictly correct to return the `top-level' value of
point, outside of any @code{save-excursion} forms.  But that is hard to
find. 
@end defun

@defun set-window-point window position
  This function positions the point in @var{window} at @var{position}
in @var{window}'s buffer.
@end defun

@defun window-start &optional window
@cindex window top line
  This function returns the position in the buffer displayed by
@var{window} at which the display starts.  This is the same number that
@code{(point)} returns when the cursor is positioned at the beginning of
the top line in the window.

  If @var{window} is @code{nil}, the selected window is used.

@example
(window-start)
     @result{} 7058
@end example
@end defun

@defun set-window-start window position &optional noforce
  This function makes the display in @var{window} start at @var{position} in
@var{window}'s buffer.  Normally the display starts at the beginning of
a line, although this is not required.

  Point is associated with a position within the buffer, and must be
visible.  In the case that this function completes in such a way that
point would not be visible on the screen, Emacs moves point so that
point is visible.  For example, if point is 1 and we attempt to set
the start of the window at 2, then the position of point would be
``above'' the window, except that Emacs re-positions point so that it
is visible.  (Point is placed in the left-most column of the middle
line of the window.)

@group
@example
;; @r{Here is what @samp{foo} looks like before executing}
;; @r{the @code{set-window-start} expression.}

---------- Buffer: foo ----------
@point{}This is the contents of buffer foo.
2
3
4
5
6
---------- Buffer: foo ----------

(set-window-start (selected-window) (1+ (window-start)))

;; @r{Here is what @samp{foo} looks like after executing}
;; @r{the @code{set-window-start} expression.}

---------- Buffer: foo ----------
his is the contents of buffer foo.
2
3
@point{}4
5
6
---------- Buffer: foo ----------

     @result{} 2
@end example
@end group

  However, when @var{noforce} is non-@code{nil}, the function does not
change the start position or the value of point if in changing the
start position it would move point off the
screen and then re-position it.  In this case, the function
has no effect.

  The function returns the requested starting position of the window,
regardless of whether the @var{noforce} option caused that position to
be overruled
@end defun

@defun pos-visible-in-window-p &optional position window
  This function returns @code{t}  if @var{position} is currently
visible on the screen in @var{window}, or if @var{position} is
currently out of view only because it has been scrolled horizontally.
The function returns @code{nil} if @var{position} is scrolled vertically
out of view.  @var{position} defaults to the current point;
@var{window}, to the selected window.

@example
(pos-visible-in-window-p (point) (selected-window))
@end example

 The @code{pos-visible-in-window-p} function will return @code{t} if
@var{position} is out of view only because it has been scrolled
horizontally.  Here is how you could test whether @var{position} is
visible when there is horizontal scrolling:

@example
(save-excursion 
  (goto-char @var{position})
  (and 
   (>= (- (current-column) (window-hscroll @var{window})) 0)
   (< (- (current-column) (window-hscroll @var{window}))
      (window-width @var{window}))))
@end example
@end defun

@node Vertical Scrolling, Horizontal Scrolling, Window Point, Windows
@section Vertical Scrolling
@cindex vertical scrolling

  Vertical scrolling changes the value returned by @code{window-start};
and may change the value of @code{window-point} to keep it on the screen.

  In the commands @code{scroll-up} and @code{scroll-down}, the directions
`up' and `down' refer to the motion of the text in the buffer at which
you are looking through the window.  You can imagine that the text is
written on a long roll of paper and that the scrolling commands move the
paper up and down.  Thus, if you are looking at text in the middle of a
buffer and repeatedly call @code{scroll-down}, you will eventually see
the beginning of the buffer.

  Some people have argued that the converse convention be used: that the
user imagine that the text does not move but the window does.  Then
`down' commands would take you to the end of the buffer.  However, the
position of a window on your terminal does not move, and short scrolling
commands clearly do move the text up or down, so the chosen convention
makes more sense.  Repeated `down' commands bring you to the beginning
of the buffer.

@deffn Command scroll-up &optional count
  This function scrolls text in the selected window upward @var{count} lines.
@var{count} defaults to @code{nil}.  If @var{count} is @code{nil},
then the length of the scroll is @code{next-screen-context-lines}
lines less than the height of the window in usable lines.

  @code{scroll-up} returns @code{nil}.
@end deffn

@deffn Command scroll-down &optional count
  This function scrolls the text in the selected window downward
@var{count} lines.  If @var{count} is omitted, then the length of the
scroll is @code{next-screen-context-lines} lines less than the height of
the window in usable lines.

  @code{scroll-down} returns @code{nil}.
@end deffn

@deffn Command scroll-other-window &optional count
  This function scrolls the text in the next window upward @var{count}
lines.  The next window is the one below (or to the right of) the
current one; or the one at the top (right hand side) of the screen if
the current one is at the bottom (left hand side).  More precisely, it
is the window returned by @code{(next-window)}.

  When the minibuffer is active, this command will attempt to scroll
the minibuffer if that is the next window.  If the minibuffer contains
just one line, that line will be redisplayed after the echo area
momentarily displays the message ``Beginning of buffer''.  

Also, see @code{minibuffer-scroll-window} in @ref{Minibuffer Odds and Ends}.
@end deffn

@defopt scroll-step
  The value of this variable is the number of lines Emacs should try
scrolling a window, when point moves out of the window.  If this value
is zero, the line that the point is on always goes to the center of
the window after the point moves off screen.

  If scrolling by @code{scroll-step} would fail to bring point back on screen,
then Emacs centers point anyway.
@end defopt

@defopt next-screen-context-lines
  The value of this variable is the number of lines of continuity to retain
when scrolling by screenfulls.  This means that when @code{scroll-up}
executes, this many lines that had been visible at the bottom of the
screen are now visible at the top of the screen.
The default value is @code{2}.
@end defopt

@deffn Command recenter &optional count
@cindex centering point
  This function re-positions the text displayed in the selected window.  It
puts the line containing point @var{count} lines down from the top of the
window and redraws only that window.  The text displayed in the other
windows does not move.

  If @var{count} is @code{nil}, then it puts the line containing point
in the center of the window, and redisplays the entire screen.  If
@var{count} is a non-@code{nil} list, then it puts the line containing
point in the center of the window, but only redisplays as much of the
window as necessary to position the text---only with @code{nil} does
it redisplay the entire screen.

  When @code{recenter} is called interactively, Emacs sets @var{count}
to the unprocessed prefix argument.  Thus, typing @kbd{C-u} as the
prefix sets the prefix argument to a non-@code{nil} list, while typing
@kbd{C-u 4} positions the line four lines from the top.

  Typing @kbd{C-u 0 C-l} positions the current line at the top of the
screen.  This action is so very handy that some people bind the command
to a function key.  For example,

@example
(defun line-to-top-of-screen ()
  "Moves line point is on to top of screen.
Replaces three keystroke sequence C-u 0 C-l."
  (interactive) 
  (recenter 0))

;; Bind function key PF6 on AAA terminal.
(global-set-key "\eOF" 'line-to-top-of-screen)  
@end example
@end deffn

@node Horizontal Scrolling, Window Size, Vertical Scrolling, Windows
@section Horizontal Scrolling
@cindex horizontal scrolling
  
  Horizontal scrolling is not like vertical scrolling; it is implemented
at a lower level and does not change the value returned by
@code{window-start}.  It leaves out certain columns of the display and
shows other columns (that may have no text in them).  Usually,
horizontal scrolling starts with the leftmost column at the left edge of
the window; in this case, the columns displayed cannot be scrolled to the
right.  Columns in the display can be scrolled to the right only after
they have first been scrolled left.  There is no limit to left
scrolling except the size of the largest integer, but if you scroll
farther than the length of the longest line on the screen, you won't
see anything but emptiness.

@deffn Command scroll-left count
  This function scrolls the selected window @var{count} columns to the left.
It scrolls to the right if @var{count} is negative.
@end deffn

@deffn Command scroll-right count
  This function scrolls the selected window @var{count} columns to the right.
It scrolls to the left if @var{count} is negative.

  Once you scroll a window as far right as it can go, trying to scroll
any farther has no effect.
@end deffn

@defun window-hscroll &optional window
  This function returns the number of columns by which @var{window} is
scrolled from the left margin.

  When the leftmost column is at the left edge of the window, this
function returns 0.  The value is never negative.

  If @var{window} is @code{nil}, the selected window is used.
@example
(window-hscroll)
     @result{} 0
@end example
@end defun

@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}.  @var{columns}
should be zero or positive.

  The value returned is @var{columns}.

@example
(set-window-hscroll (selected-window)  10)
     @result{} 10
@end example
@end defun

@node Window Size, Window Configurations, Horizontal Scrolling, Windows
@section Window Size
@cindex window resizing

  The window size functions fit into two classes: high level commands
that change the size of windows; and low level functions that access
window size.  Emacs does not permit overlapping windows or gaps, so
enlarging one window affects all of them.

@deffn Command enlarge-window size &optional horizontal
  This function makes the selected window @var{size} lines bigger,
stealing lines from neighboring windows.  It generally tries to steal
equal numbers of lines from the other windows.  If a window from which
lines are stolen shrinks below @code{window-min-height}, then that
window disappears.

  If @var{horizontal} is non-@code{nil}, then this function makes
@var{window} wider by @var{size} columns, stealing columns as it does
lines.  If a window from which lines are stolen shrinks below
@code{window-min-width}, then that window disappears.

  If the screen is smaller than @var{size} lines (or columns), then
the function makes the window occupy the entire height (or width) of
the screen.

  If @var{size} is negative, this function shrinks window instead by
@minus{}@var{size}.

  @code{enlarge-window} returns @code{nil}.  
@end deffn

@deffn Command enlarge-window-horizontally columns
  This function makes the selected window @var{columns} wider.

  It is simply an interface to @code{enlarge-window}.
@end deffn

@deffn Command shrink-window size &optional horizontal
  This function is the exact analog to @code{enlarge-window}, making the
selected window smaller by giving lines (or columns) to the other
windows.  If the window shrinks below @code{window-min-height}, then it
disappears. 
If @var{size} is negative, it enlarges instead by @minus{}@var{size}.
@end deffn

@deffn Command shrink-window-horizontally columns
  This function makes the selected window @var{columns} narrower.

  This function is simply an interface to @code{shrink-window}.
@end deffn

  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 the entire screen, this is one
less than what @code{(screen-height)} would return (since the last
line is always reserved for the minibuffer).

  If @var{window} is @code{nil}, the function uses the selected window.

@example
(window-height)
     @result{} 49
@end example
@end defun

@defun window-width &optional window
  This function returns the number of columns in @var{window}.  If
@var{window} fills the entire screen, this is what @code{(screen-width)}
would return.

  If @var{window} is @code{nil}, the function uses the selected window.

@example
(window-width)
     @result{} 80
@end example
@end defun

@defun window-edges &optional window
  This function returns a list of the edge coordinates of @var{window}.
The order of the list is: @code{(@var{left} @var{top} @var{right}
@var{bottom})}, all relative to 0, 0 at the top left corner of the screen.

  @var{right} is one more than the rightmost column used by @var{window}, and
@var{bottom} is one more than the bottommost row used by @var{window} and
its mode-line.

  For example, the edges of the following window are 
@w{@samp{0 0 5 8}}.  (The mode line is shown with
@w{@samp{xxxxxxxxx}}.)

@group
@example
           0    
           _______
        0 |       | 
          |       |   
          |       | 
          xxxxxxxxx  5

                  8     
@end example
@end group

  If @var{window} fills the entire screen, then @var{right} and
@var{bottom} are the same as the values returned by
@code{(window-width)} and @code{(window-height)} respectively.

  When the screen is split, and the window's right side is a separator,
the value of @var{right} is the column number of the separator;
conversely, if the window's left side is a separator, the value of
@var{left} is the column number of the separator;

  In the following example, the edges of the left window are
@w{@samp{0 0 4 5}} and the edges of the right window are @w{@samp{4 0
8 5}}.

@group
@example
           ___ ___
          |   |   |    
          |   |   |    
          |123|567|    
          xxxxxxxxx 
@end example
@end group

  If @var{window} is @code{nil}, the function uses the selected window.

@example
(window-edges (selected-window))
     @result{} (0 0 80 49)

(list 0 0 (window-width) (window-height))
     @result{} (0 0 80 49)
@end example
@end defun

  The following two variables constrain resizing functions to a minimum
height and width.

@defopt window-min-height
  The value of this variable determines how short a window may become
before it disappears.  When other windows are being enlarged, the
window disappears when it becomes smaller than this.  No window may be
created that is smaller than this.  The absolute minimum height is 2
(allowing one line for the mode line, and one line for the buffer
display); actions which change window sizes reset this variable to 2
if it is less than 2.
@end defopt

@defopt window-min-width
  The value of this variable determines how narrow a window may become
before it disappears.  When other windows are bing enlarged, the window
disappears when it becomes narrower than this.  No window may be created
that is narrower than this.  The absolute minimum width is 1; any value
below that is ignored.
@end defopt

@node Window Configurations,  , Window Size, Windows
@section Window Configurations
@cindex window configurations
@cindex saving window information

  Window configurations record entire screen layouts---all windows,
their sizes, which buffers they contain, what part of each buffer is
displayed, and the values of point and mark.

  Sometimes you want Emacs to restore the window configuration to some
saved past pattern.  This can be done with the following functions and
special forms.

  No one has implemented primitives to look inside of window
configurations.

@defun current-window-configuration
  This function returns a new object representing Emacs's selected window
configuration, namely the number of windows, their sizes and current
buffers, which window is the selected window, and for each displayed buffer,
where display starts, and the positions of the point and the mark.  An
exception is made for the point in the current buffer, whose value is not
saved.  An example of how it could be used with @code{set-window-configuration}
to emulate @code{save-window-excursion} appears below with @code{save-window-excursion}.
@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}.
@var{configuration} must be a value that
@code{current-window-configuration} returned previously.
@end defun

@defspec save-window-excursion forms@dots{}
  This function executes @var{forms} in sequence, preserving window sizes
and contents.  It restores each window with the same start of display of
its buffer.  It does not restore the value of point in the current buffer
(use @code{save-excursion} for that).

  This function returns the value of the final form in @var{forms}.

@example
(split-window)
     @result{} #<window 25 on control-structure.texinfo>
(setq w (selected-window))
     @result{} #<window 19 on control-structure.texinfo>
(save-window-excursion
   (delete-other-windows w)
   (switch-to-buffer "foo")
   'do-something)
     @result{} do-something
@end example
@end defspec