Next: , Previous: , Up: Windows   [Contents][Index]


38.15 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. SXEmacs does not permit overlapping windows or gaps between windows, so resizing one window affects other windows.

Command: enlarge-window count &optional horizontal window

This function makes the selected window count 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 count 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 count is negative, this function shrinks the window by -count 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.

If window is non-nil, it specifies a window to change instead of the selected 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: enlarge-window-pixels count &optional side window

This function makes the selected window count pixels larger. When called from Lisp, optional second argument side non-nil means to grow sideways count pixels, and optional third argument window specifies the window to change instead of the selected window.

Command: shrink-window count &optional horizontal window

This function is like enlarge-window but negates the argument count, 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 count is negative, the window is enlarged by -count lines or columns.

If window is non-nil, it specifies a window to change instead of the selected window.

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-pixels count &optional side window

This function makes the selected window count pixels smaller. When called from Lisp, optional second argument side non-nil means to shrink sideways count pixels, and optional third argument window specifies the window to change instead of the selected window.

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 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.

Variable: window-size-change-functions

This variable holds a list of functions to be called if the size of any window changes for any reason. The functions are called just once per redisplay, and just once for each frame on which size changes have occurred.

Each function receives the frame as its sole argument. There is no direct way to find out which windows changed size, or precisely how; however, if your size-change function keeps track, after each change, of the windows that interest you, you can figure out what has changed by comparing the old size data with the new.

Creating or deleting windows counts as a size change, and therefore causes these functions to be called. Changing the frame size also counts, because it changes the sizes of the existing windows.

It is not a good idea to use save-window-excursion in these functions, because that always counts as a size change, and it would cause these functions to be called over and over. In most cases, save-selected-window is what you need here.


Next: , Previous: , Up: Windows   [Contents][Index]