Next: Coordinates and Windows, Previous: Size of Window, Up: Windows
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.
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-heightlines, 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 belowwindow-min-widthcolumns, 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-windowgets 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-heightandwindow-min-width),enlarge-windowdeletes the window.
enlarge-windowreturnsnil.
This function makes the selected window columns wider. It could be defined as follows:
(defun enlarge-window-horizontally (columns) (interactive "p") (enlarge-window columns t))
This function is like
enlarge-windowbut negates the argument size, making the selected window smaller by giving lines (or columns) to the other windows. If the window shrinks belowwindow-min-heightorwindow-min-width, then it disappears.If size is negative, the window is enlarged by −size lines or columns.
This function makes the selected window columns narrower. It could be defined as follows:
(defun shrink-window-horizontally (columns) (interactive "p") (shrink-window columns t))
This function makes the selected window delta lines taller or delta columns wider, by moving the bottom or right edge. This function does not delete other windows; if it cannot make the requested size adjustment, it signals an error. On success, this function returns
nil.
This function makes window the right height to display its contents exactly. If window is omitted or
nil, it uses the selected window.The argument max-height specifies the maximum height the window is allowed to be;
nilmeans use the frame height. The argument min-height specifies the minimum height for the window;nilmeans usewindow-min-height. All these height values include the mode-line and/or header-line.
This command shrinks window vertically to be as small as possible while still showing the full contents of its buffer—but not less than
window-min-heightlines. 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.
This command returns non-
nilif it actually shrank the window andnilotherwise.
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.If the value is
height, then only the window's height is fixed; if the value iswidth, then only the window's width is fixed. Any other non-nilvalue fixes both the width and the height.This variable automatically becomes buffer-local when set.
Explicit size-change functions such as
enlarge-windowget 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 bindwindow-size-fixedtonil, 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-structure-changing functions to a minimum height and width.
The value of this variable determines how short a window may become before it is automatically deleted. Making a window smaller than
window-min-heightautomatically deletes it, and no window may be created shorter than this. The default value is 4.The absolute minimum window height is one; actions that change window sizes reset this variable to one if it is less than one.
The value of this variable determines how narrow a window may become before it is automatically deleted. Making a window smaller than
window-min-widthautomatically deletes it, and no window may be created narrower than this. The default value is 10.The absolute minimum window width is two; actions that change window sizes reset this variable to two if it is less than two.