GNU Info

Info Node: (elisp)Resizing Windows

(elisp)Resizing Windows


Next: Coordinates and Windows Prev: Size of Window Up: Windows
Enter node , (file) or (file)node

Changing the Size of a Window
=============================

   The window size functions fall 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 between
windows, so resizing one window affects other windows.

 - Command: enlarge-window size &optional horizontal
     This function makes the selected window SIZE lines taller,
     stealing lines from neighboring windows.  It takes the lines from
     one window at a time until that window is used up, then takes from
     another.  If a window from which lines are stolen shrinks below
     `window-min-height' lines, that window disappears.

     If HORIZONTAL is non-`nil', this function makes WINDOW wider by
     SIZE columns, stealing columns instead of lines.  If a window from
     which columns are stolen shrinks below `window-min-width' columns,
     that window disappears.

     If the requested size would exceed that of the window's frame,
     then the function makes the window occupy the entire height (or
     width) of the frame.

     If there are various other windows from which lines or columns can
     be stolen, and some of them specify fixed size (using
     `window-size-fixed', see below), they are left untouched while
     other windows are "robbed."  If it would be necessary to alter the
     size of a fixed-size window, `enlarge-window' gets an error
     instead.

     If SIZE is negative, this function shrinks the window by -SIZE
     lines or columns.  If that makes the window smaller than the
     minimum size (`window-min-height' and `window-min-width'),
     `enlarge-window' deletes the window.

     `enlarge-window' returns `nil'.

 - Command: enlarge-window-horizontally columns
     This function makes the selected window COLUMNS wider.  It could
     be defined as follows:

          (defun enlarge-window-horizontally (columns)
            (enlarge-window columns t))

 - Command: shrink-window size &optional horizontal
     This function is like `enlarge-window' but negates the argument
     SIZE, making the selected window smaller by giving lines (or
     columns) to the other windows.  If the window shrinks below
     `window-min-height' or `window-min-width', then it disappears.

     If SIZE is negative, the window is enlarged by -SIZE lines or
     columns.

 - Command: shrink-window-horizontally columns
     This function makes the selected window COLUMNS narrower.  It
     could be defined as follows:

          (defun shrink-window-horizontally (columns)
            (shrink-window columns t))

 - Command: shrink-window-if-larger-than-buffer &optional window
     This command shrinks WINDOW to be as small as possible while still
     showing the full contents of its buffer--but not less than
     `window-min-height' lines.  If WINDOW is not given, it defaults to
     the selected window.

     However, the command does nothing if the window is already too
     small to display the whole text of the buffer, or if part of the
     contents are currently scrolled off screen, or if the window is
     not the full width of its frame, or if the window is the only
     window in its frame.

 - Variable: window-size-fixed
     If this variable is non-`nil', in any given buffer, then the size
     of any window displaying the buffer remains fixed unless you
     explicitly change it or Emacs has no other choice.  (This feature
     is new in Emacs 21.)

     If the value is `height', then only the window's height is fixed;
     if the value is `width', then only the window's width is fixed.
     Any other non-`nil' value fixes both the width and the height.

     The usual way to use this variable is to give it a buffer-local
     value in a particular buffer.  That way, the windows (but usually
     there is only one) displaying that buffer have fixed size.

     Explicit size-change functions such as `enlarge-window' get an
     error if they would have to change a window size which is fixed.
     Therefore, when you want to change the size of such a window, you
     should bind `window-size-fixed' to `nil', like this:

          (let ((window-size-fixed nil))
             (enlarge-window 10))

     Note that changing the frame size will change the size of a
     fixed-size window, if there is no other alternative.

   The following two variables constrain the window-size-changing
functions to a minimum height and width.

 - User Option: window-min-height
     The value of this variable determines how short a window may become
     before it is automatically deleted.  Making a window smaller than
     `window-min-height' automatically deletes it, and no window may be
     created shorter than this.  The absolute minimum height is two
     (allowing one line for the mode line, and one line for the buffer
     display).  Actions that change window sizes reset this variable to
     two if it is less than two.  The default value is 4.

 - User Option: window-min-width
     The value of this variable determines how narrow a window may
     become before it is automatically deleted.  Making a window
     smaller than `window-min-width' automatically deletes it, and no
     window may be created narrower than this.  The absolute minimum
     width is one; any value below that is ignored.  The default value
     is 10.


automatically generated by info2www version 1.2.2.9