diff options
| author | Martin Rudalics | 2011-09-23 11:12:53 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2011-09-23 11:12:53 +0200 |
| commit | b33b68a32cc0d0b7f60a1de9a17e59e38e72a3d1 (patch) | |
| tree | 73a407c9e44f76dd3a5b02f208e301daa475b119 | |
| parent | 71146d7b6e7524c91b4eee124cfdaaf86aa21643 (diff) | |
| download | emacs-b33b68a32cc0d0b7f60a1de9a17e59e38e72a3d1.tar.gz emacs-b33b68a32cc0d0b7f60a1de9a17e59e38e72a3d1.zip | |
Document changes to windows code.
* frames.texi (Frames and Windows): Move section and rename to
Windows and Frames in windows.texi.
* windows.texi (Windows): Restructure.
(Basic Windows): Rewrite. Explain live and internal windows and
normalization functions.
(Windows and Frames): Move section here from frames.texi.
Describe subwindows, window combinations, window tree, and
corresponding functions including window-list here.
(Window Sizes): Rename section from Size of Window and move it
up in chapter. Describe total and body sizes and the
corresponding functions. Explain new semantics of
window-min-height/-width.
(Resizing Windows): Move section up in chapter. Describe new
resize functions.
(Splitting Windows): Describe new behavior of split-window,
split-window-above-each-other and split-window-side-by-side.
Provide examples. Describe window-nest and window-splits
options.
(Deleting Windows): Minor rewrite.
(Selecting Windows): Minor rewrite. Describe
frame-selected-window and set-frame-selected-window here.
(Cyclic Window Ordering): Minor rewrite. Describe
window-list-1.
(Buffers and Windows): Rewrite. Explain a window's previous and
next buffers and the corresponding functions.
* elisp.texi (Top): Update node listings for frames and windows
sections.
| -rw-r--r-- | doc/lispref/ChangeLog | 30 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 10 | ||||
| -rw-r--r-- | doc/lispref/frames.texi | 49 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 2659 |
4 files changed, 1895 insertions, 853 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 70f6c9b7f22..90d346c0bf7 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,33 @@ | |||
| 1 | 2011-09-23 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * frames.texi (Frames and Windows): Move section and rename to | ||
| 4 | Windows and Frames in windows.texi. | ||
| 5 | * windows.texi (Windows): Restructure. | ||
| 6 | (Basic Windows): Rewrite. Explain live and internal windows and | ||
| 7 | normalization functions. | ||
| 8 | (Windows and Frames): Move section here from frames.texi. | ||
| 9 | Describe subwindows, window combinations, window tree, and | ||
| 10 | corresponding functions including window-list here. | ||
| 11 | (Window Sizes): Rename section from Size of Window and move it | ||
| 12 | up in chapter. Describe total and body sizes and the | ||
| 13 | corresponding functions. Explain new semantics of | ||
| 14 | window-min-height/-width. | ||
| 15 | (Resizing Windows): Move section up in chapter. Describe new | ||
| 16 | resize functions. | ||
| 17 | (Splitting Windows): Describe new behavior of split-window, | ||
| 18 | split-window-above-each-other and split-window-side-by-side. | ||
| 19 | Provide examples. Describe window-nest and window-splits | ||
| 20 | options. | ||
| 21 | (Deleting Windows): Minor rewrite. | ||
| 22 | (Selecting Windows): Minor rewrite. Describe | ||
| 23 | frame-selected-window and set-frame-selected-window here. | ||
| 24 | (Cyclic Window Ordering): Minor rewrite. Describe | ||
| 25 | window-list-1. | ||
| 26 | (Buffers and Windows): Rewrite. Explain a window's previous and | ||
| 27 | next buffers and the corresponding functions. | ||
| 28 | * elisp.texi (Top): Update node listings for frames and windows | ||
| 29 | sections. | ||
| 30 | |||
| 1 | 2011-09-21 Stefan Monnier <monnier@iro.umontreal.ca> | 31 | 2011-09-21 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 32 | ||
| 3 | * display.texi (Face Functions): `face-list' returns faces (bug#9564). | 33 | * display.texi (Face Functions): `face-list' returns faces (bug#9564). |
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index bcf6d3318ef..d3b96a0eb81 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -927,6 +927,9 @@ Buffers | |||
| 927 | Windows | 927 | Windows |
| 928 | 928 | ||
| 929 | * Basic Windows:: Basic information on using windows. | 929 | * Basic Windows:: Basic information on using windows. |
| 930 | * Windows and Frames:: Relating windows to the frame they appear on. | ||
| 931 | * Window Sizes:: Accessing a window's size. | ||
| 932 | * Resizing Windows:: Changing the sizes of windows. | ||
| 930 | * Splitting Windows:: Splitting one window into two windows. | 933 | * Splitting Windows:: Splitting one window into two windows. |
| 931 | * Deleting Windows:: Deleting a window gives its space to other windows. | 934 | * Deleting Windows:: Deleting a window gives its space to other windows. |
| 932 | * Selecting Windows:: The selected window is the one that you edit in. | 935 | * Selecting Windows:: The selected window is the one that you edit in. |
| @@ -936,17 +939,14 @@ Windows | |||
| 936 | and choosing a window for it. | 939 | and choosing a window for it. |
| 937 | * Choosing Window:: How to choose a window for displaying a buffer. | 940 | * Choosing Window:: How to choose a window for displaying a buffer. |
| 938 | * Dedicated Windows:: How to avoid displaying another buffer in | 941 | * Dedicated Windows:: How to avoid displaying another buffer in |
| 939 | a specific window. | 942 | a specific window. |
| 940 | * Window Point:: Each window has its own location of point. | 943 | * Window Point:: Each window has its own location of point. |
| 941 | * Window Start and End:: Buffer positions indicating which text is | 944 | * Window Start and End:: Buffer positions indicating which text is |
| 942 | on-screen in a window. | 945 | on-screen in a window. |
| 943 | * Textual Scrolling:: Moving text up and down through the window. | 946 | * Textual Scrolling:: Moving text up and down through the window. |
| 944 | * Vertical Scrolling:: Moving the contents up and down on the window. | 947 | * Vertical Scrolling:: Moving the contents up and down on the window. |
| 945 | * Horizontal Scrolling:: Moving the contents sideways on the window. | 948 | * Horizontal Scrolling:: Moving the contents sideways on the window. |
| 946 | * Size of Window:: Accessing the size of a window. | ||
| 947 | * Resizing Windows:: Changing the size of a window. | ||
| 948 | * Coordinates and Windows:: Converting coordinates to windows. | 949 | * Coordinates and Windows:: Converting coordinates to windows. |
| 949 | * Window Tree:: The layout and sizes of all windows in a frame. | ||
| 950 | * Window Configurations:: Saving and restoring the state of the screen. | 950 | * Window Configurations:: Saving and restoring the state of the screen. |
| 951 | * Window Parameters:: Associating additional information with windows. | 951 | * Window Parameters:: Associating additional information with windows. |
| 952 | * Window Hooks:: Hooks for scrolling, window size changes, | 952 | * Window Hooks:: Hooks for scrolling, window size changes, |
| @@ -962,8 +962,6 @@ Frames | |||
| 962 | * Frame Titles:: Automatic updating of frame titles. | 962 | * Frame Titles:: Automatic updating of frame titles. |
| 963 | * Deleting Frames:: Frames last until explicitly deleted. | 963 | * Deleting Frames:: Frames last until explicitly deleted. |
| 964 | * Finding All Frames:: How to examine all existing frames. | 964 | * Finding All Frames:: How to examine all existing frames. |
| 965 | * Frames and Windows:: A frame contains windows; | ||
| 966 | display of text always works through windows. | ||
| 967 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. | 965 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. |
| 968 | * Input Focus:: Specifying the selected frame. | 966 | * Input Focus:: Specifying the selected frame. |
| 969 | * Visibility of Frames:: Frames may be visible or invisible, or icons. | 967 | * Visibility of Frames:: Frames may be visible or invisible, or icons. |
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index d619b92e4d3..d9399e98a69 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -86,8 +86,6 @@ is the same as for @code{framep} above. | |||
| 86 | * Frame Titles:: Automatic updating of frame titles. | 86 | * Frame Titles:: Automatic updating of frame titles. |
| 87 | * Deleting Frames:: Frames last until explicitly deleted. | 87 | * Deleting Frames:: Frames last until explicitly deleted. |
| 88 | * Finding All Frames:: How to examine all existing frames. | 88 | * Finding All Frames:: How to examine all existing frames. |
| 89 | * Frames and Windows:: A frame contains windows; | ||
| 90 | display of text always works through windows. | ||
| 91 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. | 89 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. |
| 92 | * Input Focus:: Specifying the selected frame. | 90 | * Input Focus:: Specifying the selected frame. |
| 93 | * Visibility of Frames:: Frames may be visible or invisible, or icons. | 91 | * Visibility of Frames:: Frames may be visible or invisible, or icons. |
| @@ -1309,53 +1307,6 @@ direction. | |||
| 1309 | See also @code{next-window} and @code{previous-window}, in @ref{Cyclic | 1307 | See also @code{next-window} and @code{previous-window}, in @ref{Cyclic |
| 1310 | Window Ordering}. | 1308 | Window Ordering}. |
| 1311 | 1309 | ||
| 1312 | @node Frames and Windows | ||
| 1313 | @section Frames and Windows | ||
| 1314 | |||
| 1315 | Each window is part of one and only one frame; you can get that frame | ||
| 1316 | with @code{window-frame}. | ||
| 1317 | |||
| 1318 | @defun window-frame window | ||
| 1319 | This function returns the frame that @var{window} is on. | ||
| 1320 | @end defun | ||
| 1321 | |||
| 1322 | All the non-minibuffer windows in a frame are arranged in a cyclic | ||
| 1323 | order. The order runs from the frame's top window, which is at the | ||
| 1324 | upper left corner, down and to the right, until it reaches the window at | ||
| 1325 | the lower right corner (always the minibuffer window, if the frame has | ||
| 1326 | one), and then it moves back to the top. @xref{Cyclic Window Ordering}. | ||
| 1327 | |||
| 1328 | @defun frame-first-window &optional frame | ||
| 1329 | This returns the topmost, leftmost window of frame @var{frame}. | ||
| 1330 | If omitted or @code{nil}, @var{frame} defaults to the selected frame. | ||
| 1331 | @end defun | ||
| 1332 | |||
| 1333 | At any time, exactly one window on any frame is @dfn{selected within the | ||
| 1334 | frame}. The significance of this designation is that selecting the | ||
| 1335 | frame also selects this window. Conversely, selecting a window for | ||
| 1336 | Emacs with @code{select-window} also makes that window selected within | ||
| 1337 | its frame. @xref{Selecting Windows}. | ||
| 1338 | |||
| 1339 | @defun frame-selected-window &optional frame | ||
| 1340 | This function returns the window on @var{frame} that is selected | ||
| 1341 | within @var{frame}. If omitted or @code{nil}, @var{frame} defaults to | ||
| 1342 | the selected frame. | ||
| 1343 | @end defun | ||
| 1344 | |||
| 1345 | @defun set-frame-selected-window frame window &optional norecord | ||
| 1346 | This sets the selected window of frame @var{frame} to @var{window}. | ||
| 1347 | If @var{frame} is @code{nil}, it operates on the selected frame. If | ||
| 1348 | @var{frame} is the selected frame, this makes @var{window} the | ||
| 1349 | selected window. This function returns @var{window}. | ||
| 1350 | |||
| 1351 | Optional argument @var{norecord} non-@code{nil} means to neither change | ||
| 1352 | the order of recently selected windows nor the buffer list (@pxref{The | ||
| 1353 | Buffer List}). | ||
| 1354 | @end defun | ||
| 1355 | |||
| 1356 | Another function that (usually) returns one of the windows in a given | ||
| 1357 | frame is @code{minibuffer-window}. @xref{Definition of minibuffer-window}. | ||
| 1358 | |||
| 1359 | @node Minibuffers and Frames | 1310 | @node Minibuffers and Frames |
| 1360 | @section Minibuffers and Frames | 1311 | @section Minibuffers and Frames |
| 1361 | 1312 | ||
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 2cf4a8152c7..b80fe02b0ff 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -7,13 +7,16 @@ | |||
| 7 | @node Windows, Frames, Buffers, Top | 7 | @node Windows, Frames, Buffers, Top |
| 8 | @chapter Windows | 8 | @chapter Windows |
| 9 | 9 | ||
| 10 | This chapter describes most of the functions and variables related to | 10 | This chapter describes the functions and variables related to Emacs |
| 11 | Emacs windows. @xref{Frames and Windows}, for how windows relate to | 11 | windows. @xref{Frames}, for how windows are assigned an area of screen |
| 12 | frames. @xref{Display}, for information on how text is displayed in | 12 | available for Emacs to use. @xref{Display}, for information on how text |
| 13 | windows. | 13 | is displayed in windows. |
| 14 | 14 | ||
| 15 | @menu | 15 | @menu |
| 16 | * Basic Windows:: Basic information on using windows. | 16 | * Basic Windows:: Basic information on using windows. |
| 17 | * Windows and Frames:: Relating windows to the frame they appear on. | ||
| 18 | * Window Sizes:: Accessing a window's size. | ||
| 19 | * Resizing Windows:: Changing the sizes of windows. | ||
| 17 | * Splitting Windows:: Splitting one window into two windows. | 20 | * Splitting Windows:: Splitting one window into two windows. |
| 18 | * Deleting Windows:: Deleting a window gives its space to other windows. | 21 | * Deleting Windows:: Deleting a window gives its space to other windows. |
| 19 | * Selecting Windows:: The selected window is the one that you edit in. | 22 | * Selecting Windows:: The selected window is the one that you edit in. |
| @@ -30,10 +33,7 @@ windows. | |||
| 30 | * Textual Scrolling:: Moving text up and down through the window. | 33 | * Textual Scrolling:: Moving text up and down through the window. |
| 31 | * Vertical Scrolling:: Moving the contents up and down on the window. | 34 | * Vertical Scrolling:: Moving the contents up and down on the window. |
| 32 | * Horizontal Scrolling:: Moving the contents sideways on the window. | 35 | * Horizontal Scrolling:: Moving the contents sideways on the window. |
| 33 | * Size of Window:: Accessing the size of a window. | ||
| 34 | * Resizing Windows:: Changing the size of a window. | ||
| 35 | * Coordinates and Windows:: Converting coordinates to windows. | 36 | * Coordinates and Windows:: Converting coordinates to windows. |
| 36 | * Window Tree:: The layout and sizes of all windows in a frame. | ||
| 37 | * Window Configurations:: Saving and restoring the state of the screen. | 37 | * Window Configurations:: Saving and restoring the state of the screen. |
| 38 | * Window Parameters:: Associating additional information with windows. | 38 | * Window Parameters:: Associating additional information with windows. |
| 39 | * Window Hooks:: Hooks for scrolling, window size changes, | 39 | * Window Hooks:: Hooks for scrolling, window size changes, |
| @@ -41,54 +41,35 @@ windows. | |||
| 41 | or window configuration changes. | 41 | or window configuration changes. |
| 42 | @end menu | 42 | @end menu |
| 43 | 43 | ||
| 44 | |||
| 44 | @node Basic Windows | 45 | @node Basic Windows |
| 45 | @section Basic Concepts of Emacs Windows | 46 | @section Basic Concepts of Emacs Windows |
| 46 | @cindex window | 47 | @cindex window |
| 47 | @cindex selected window | ||
| 48 | |||
| 49 | A @dfn{window} in Emacs is the physical area of the screen in which a | ||
| 50 | buffer is displayed. The term is also used to refer to a Lisp object that | ||
| 51 | represents that screen area in Emacs Lisp. It should be | ||
| 52 | clear from the context which is meant. | ||
| 53 | |||
| 54 | Emacs groups windows into frames; see @ref{Frames}. A frame | ||
| 55 | represents an area of screen available for Emacs to use. Each frame | ||
| 56 | always contains at least one window, but you can subdivide it | ||
| 57 | vertically or horizontally into multiple, nonoverlapping Emacs | ||
| 58 | windows. | ||
| 59 | 48 | ||
| 60 | In each frame, at any time, one and only one window is designated as | 49 | A @dfn{window} in Emacs is the physical area of the screen in which a |
| 61 | @dfn{selected within the frame}. The frame's cursor appears in that | 50 | buffer is displayed, see @ref{Buffers}. The term is also used to refer |
| 62 | window, but the other windows have ``non-selected'' cursors, normally | 51 | to a Lisp object that represents that screen area in Emacs Lisp. It |
| 63 | less visible. (@xref{Cursor Parameters}, for customizing this.) At | 52 | should be clear from the context which is meant. |
| 64 | any time, one frame is the selected frame; and the window selected | ||
| 65 | within that frame is @dfn{the selected window}. The selected window's | ||
| 66 | buffer is usually the current buffer (except when @code{set-buffer} has | ||
| 67 | been used); see @ref{Current Buffer}. | ||
| 68 | |||
| 69 | For practical purposes, a window exists only while it is displayed in | ||
| 70 | a frame. Once removed from the frame, the window is effectively deleted | ||
| 71 | and should not be used, @emph{even though there may still be references | ||
| 72 | to it} from other Lisp objects; see @ref{Deleting Windows}. Restoring a | ||
| 73 | saved window configuration is the only way for a window no longer on the | ||
| 74 | screen to come back to life; see @ref{Window Configurations}. | ||
| 75 | 53 | ||
| 76 | @cindex multiple windows | 54 | @cindex multiple windows |
| 77 | Users create multiple windows so they can look at several buffers at | 55 | Emacs groups windows into frames; see @ref{Frames}. Each frame always |
| 78 | once. Lisp libraries use multiple windows for a variety of reasons, but | 56 | contains at least one window, but you can subdivide it into multiple, |
| 79 | most often to display related information. In Rmail, for example, you | 57 | non-overlapping Emacs windows. Users create multiple windows so they |
| 80 | can move through a summary buffer in one window while the other window | 58 | can look at several buffers at once. Lisp libraries use multiple |
| 81 | shows messages one at a time as they are reached. | 59 | windows for a variety of reasons, but most often to display related |
| 60 | information. In Rmail, for example, you can move through a summary | ||
| 61 | buffer in one window while the other window shows messages one at a time | ||
| 62 | as they are reached. | ||
| 82 | 63 | ||
| 64 | @cindex terminal screen | ||
| 65 | @cindex screen of terminal | ||
| 83 | The meaning of ``window'' in Emacs is similar to what it means in the | 66 | The meaning of ``window'' in Emacs is similar to what it means in the |
| 84 | context of general-purpose window systems such as X, but not identical. | 67 | context of general-purpose window systems such as X, but not identical. |
| 85 | The X Window System places X windows on the screen; Emacs uses one or | 68 | The X Window System places X windows on the screen; Emacs uses one or |
| 86 | more X windows as frames, and subdivides them into | 69 | more X windows as frames, and subdivides them into Emacs windows. When |
| 87 | Emacs windows. When you use Emacs on a character-only terminal, Emacs | 70 | you use Emacs on a character-only terminal, Emacs treats the whole |
| 88 | treats the whole terminal screen as one frame. | 71 | terminal screen as one frame. |
| 89 | 72 | ||
| 90 | @cindex terminal screen | ||
| 91 | @cindex screen of terminal | ||
| 92 | @cindex tiled windows | 73 | @cindex tiled windows |
| 93 | Most window systems support arbitrarily located overlapping windows. | 74 | Most window systems support arbitrarily located overlapping windows. |
| 94 | In contrast, Emacs windows are @dfn{tiled}; they never overlap, and | 75 | In contrast, Emacs windows are @dfn{tiled}; they never overlap, and |
| @@ -97,68 +78,937 @@ which Emacs creates new windows (@pxref{Splitting Windows}) and resizes | |||
| 97 | them (@pxref{Resizing Windows}), not all conceivable tilings of windows | 78 | them (@pxref{Resizing Windows}), not all conceivable tilings of windows |
| 98 | on an Emacs frame are actually possible. | 79 | on an Emacs frame are actually possible. |
| 99 | 80 | ||
| 81 | For practical purposes, a window exists only while it is displayed in | ||
| 82 | a frame. Once removed from the frame, the window is effectively deleted | ||
| 83 | and should not be used, even though the Lisp object representing it | ||
| 84 | might be still referenced from other Lisp objects; see @ref{Deleting | ||
| 85 | Windows}. Restoring a saved window configuration is the only way for a | ||
| 86 | window no longer on the screen to come back to life; see @ref{Window | ||
| 87 | Configurations}. | ||
| 88 | |||
| 100 | @defun windowp object | 89 | @defun windowp object |
| 101 | This function returns @code{t} if @var{object} is a window. | 90 | This function returns @code{t} if @var{object} is a window, @code{nil} |
| 91 | otherwise. It can return @code{t} if @var{object} denotes a window that | ||
| 92 | has been deleted. | ||
| 93 | @end defun | ||
| 94 | |||
| 95 | @cindex live windows | ||
| 96 | @cindex internal windows | ||
| 97 | For historical reasons a window is considered @dfn{live} if and only | ||
| 98 | if it currently displays a buffer; see @ref{Buffers and Windows}. In | ||
| 99 | order to show multiple windows within one and the same frame, Emacs | ||
| 100 | organizes them in form of a tree called window tree; see @ref{Windows | ||
| 101 | and Frames}. The internal nodes of a window tree are called internal | ||
| 102 | windows and are not considered live. The leaf nodes of a window tree | ||
| 103 | constitute the windows displaying buffers and only they will be called | ||
| 104 | live here. | ||
| 105 | |||
| 106 | @defun window-live-p object | ||
| 107 | This function returns @code{t} if @var{object} is a live window and | ||
| 108 | @code{nil} otherwise. A live window is a window that displays a buffer. | ||
| 109 | @end defun | ||
| 110 | |||
| 111 | @defun window-any-p object | ||
| 112 | This function returns @code{t} if @var{object} denotes a live or an | ||
| 113 | internal window and @code{nil} otherwise. In particular, this function | ||
| 114 | returns @code{nil} if @var{object} is a window that has been | ||
| 115 | deleted. | ||
| 116 | @end defun | ||
| 117 | |||
| 118 | @cindex selected window | ||
| 119 | In each frame, at any time, one and only one window is designated as | ||
| 120 | @dfn{selected within the frame}. Also, at any time, one frame is the | ||
| 121 | selected frame (@pxref{Input Focus}). The window selected within the | ||
| 122 | selected frame is the @dfn{selected window}. | ||
| 123 | |||
| 124 | The selected window is always a live window. Its buffer is usually | ||
| 125 | the current buffer (except when @code{set-buffer} has been used); see | ||
| 126 | @ref{Current Buffer}. | ||
| 127 | |||
| 128 | @defun selected-window | ||
| 129 | This function returns the selected window. This is the window in which | ||
| 130 | the cursor for selected windows (@pxref{Cursor Parameters}) appears and | ||
| 131 | to which many commands apply. | ||
| 132 | @end defun | ||
| 133 | |||
| 134 | The window handling functions can be roughly grouped into functions | ||
| 135 | operating on live windows only and functions that accept any window as | ||
| 136 | argument. Many of these functions accept as argument the value | ||
| 137 | @code{nil} to specify the selected window. The two functions below can | ||
| 138 | be used to ``normalize'' arguments specifying windows in a uniform | ||
| 139 | manner. | ||
| 140 | |||
| 141 | @defun window-normalize-any-window window | ||
| 142 | This function returns the normalized value for @var{window} which can be | ||
| 143 | any window that has not been deleted. More precisely, if @var{window} | ||
| 144 | is @code{nil}, it returns the selected window. If @var{window} denotes | ||
| 145 | a live or internal window, it returns that window. Otherwise, this | ||
| 146 | function signals an error. | ||
| 147 | @end defun | ||
| 148 | |||
| 149 | @defun window-normalize-live-window window | ||
| 150 | This functions returns the normalized value for a live window | ||
| 151 | @var{window}. More precisely, if @var{window} is @code{nil}, it returns | ||
| 152 | the selected window. If @var{window} is a live window, it returns that | ||
| 153 | window. Otherwise, this function signals an error. | ||
| 154 | @end defun | ||
| 155 | |||
| 156 | |||
| 157 | @node Windows and Frames | ||
| 158 | @section Windows and Frames | ||
| 159 | |||
| 160 | Each window is part of one and only one frame (@pxref{Frames}); you can | ||
| 161 | get that frame with the function described next. | ||
| 162 | |||
| 163 | @defun window-frame window | ||
| 164 | This function returns the frame that @var{window} is on. The argument | ||
| 165 | @var{window} can be any window and defaults to the selected one. | ||
| 166 | @end defun | ||
| 167 | |||
| 168 | The following function returns a list of all live windows on a specific | ||
| 169 | frame. | ||
| 170 | |||
| 171 | @defun window-list &optional frame minibuf window | ||
| 172 | This function returns a list of @var{frame}'s live windows, starting | ||
| 173 | with @var{window}. The optional argument @var{frame} has to denote a | ||
| 174 | live frame and defaults to the selected frame. The optional argument | ||
| 175 | @var{window} has to denote a live window on the frame specified by | ||
| 176 | @var{frame} and defaults to the selected one. | ||
| 177 | |||
| 178 | The argument @var{minibuf} specifies if the minibuffer window shall be | ||
| 179 | included in the return value. If @var{minibuf} is @code{t}, the result | ||
| 180 | always includes the minibuffer window. If @var{minibuf} is @code{nil} | ||
| 181 | or omitted, that includes the minibuffer window only if it is active. | ||
| 182 | If @var{minibuf} is neither @code{nil} nor @code{t}, the result never | ||
| 183 | includes the minibuffer window. | ||
| 184 | @end defun | ||
| 185 | |||
| 186 | @cindex window tree | ||
| 187 | Windows within one and the same frame are organized in form of a tree | ||
| 188 | called @dfn{window tree}. The leaf nodes of a window tree constitute | ||
| 189 | the windows visible to the user. These are the windows associated with | ||
| 190 | buffers and are usually called live windows. The internal nodes of a | ||
| 191 | window tree are needed for finding, traversing and displaying the live | ||
| 192 | windows. | ||
| 193 | |||
| 194 | A minibuffer window (@pxref{Minibuffer Windows}) is not considered | ||
| 195 | part of its frame's window tree unless the frame is a minibuffer-only | ||
| 196 | frame. Most functions covered in this section accept, however, the | ||
| 197 | minibuffer window as argument. Also, the minibuffer window is listed by | ||
| 198 | the function @code{window-tree} described at the end of this section. | ||
| 199 | |||
| 200 | A window tree is rooted at the root window of its frame. | ||
| 201 | |||
| 202 | @defun frame-root-window &optional frame-or-window | ||
| 203 | This function returns the root window of @var{frame-or-window}. The | ||
| 204 | argument @var{frame-or-window} has to denote either a window or a frame | ||
| 205 | and defaults to the selected frame. If @var{frame-or-window} denotes a | ||
| 206 | window, the return value is the root window of that window's frame. | ||
| 207 | This function always returns a window; a live window if the frame | ||
| 208 | specified by @var{frame-or-window} contains no other live windows and an | ||
| 209 | internal window otherwise. | ||
| 210 | @end defun | ||
| 211 | |||
| 212 | @cindex subwindow | ||
| 213 | All other windows of a frame with the exception of the minibuffer window | ||
| 214 | are subwindows of the frame's root window. A window is considered a | ||
| 215 | @dfn{subwindow} of another window if it occupies a part of that other | ||
| 216 | window's screen area. | ||
| 217 | |||
| 218 | The functions described next allow to access the members of a window | ||
| 219 | tree and take an arbitrary window as argument. | ||
| 220 | |||
| 221 | @cindex parent window | ||
| 222 | @defun window-parent &optional window | ||
| 223 | Return @var{window}'s parent in the window tree. The optional argument | ||
| 224 | @var{window} can denote an arbitrary window and defaults to the selected | ||
| 225 | one. The return value is @code{nil} if @var{window} is a minibuffer | ||
| 226 | window or the root window of its frame and an internal window otherwise. | ||
| 227 | @end defun | ||
| 228 | |||
| 229 | @cindex child window | ||
| 230 | Parent windows do not appear on the screen. The screen area of a | ||
| 231 | parent window is the rectangular part of the window's frame occupied by | ||
| 232 | the window's @dfn{child windows}, that is, the set of windows having | ||
| 233 | that window as their parent. Each parent window has at least two child | ||
| 234 | windows, so there are no ``Matryoshka'' windows. Minibuffer windows do | ||
| 235 | not have child windows. | ||
| 236 | |||
| 237 | @cindex window combination | ||
| 238 | @cindex vertical combination | ||
| 239 | @cindex horizontal combination | ||
| 240 | The children of any parent window form either a vertical or a horizontal | ||
| 241 | combination of windows. A @dfn{vertical combination} is a set of | ||
| 242 | windows arranged one above each other. A @dfn{horizontal combination} | ||
| 243 | is a set of windows arranged side by side. Consider the frame shown | ||
| 244 | below (for simplicity we assume that the frame does not contain a | ||
| 245 | minibuffer window): | ||
| 246 | |||
| 247 | @smallexample | ||
| 248 | @group | ||
| 249 | ______________________________________ | ||
| 250 | | ______ ____________________________ | | ||
| 251 | || || __________________________ || | ||
| 252 | || ||| ___________ ___________ ||| | ||
| 253 | || |||| || |||| | ||
| 254 | || |||| || |||| | ||
| 255 | || ||||_____W6____||_____W7____|||| | ||
| 256 | || |||____________W4____________||| | ||
| 257 | || || __________________________ || | ||
| 258 | || ||| ||| | ||
| 259 | || |||____________W5____________||| | ||
| 260 | ||__W2__||_____________W3_____________ | | ||
| 261 | |__________________W1__________________| | ||
| 262 | |||
| 263 | @end group | ||
| 264 | @end smallexample | ||
| 265 | |||
| 266 | The root window of the frame is @code{W1}---a horizontal combination of | ||
| 267 | the live window @code{W2} and the internal window @code{W3}. Hence | ||
| 268 | @code{(window-parent W1)} is @code{nil} while @code{(window-parent W2)} | ||
| 269 | and @code{(window-parent W3)} are both @code{W1}. | ||
| 270 | |||
| 271 | The internal window @code{W3} is a vertical combination of @code{W4} | ||
| 272 | and the live window @code{W5}. The internal window @code{W4} is a | ||
| 273 | horizontal combination of the live windows @code{W6} and @code{W7}. The | ||
| 274 | windows you can actually see on the screen are @code{W2}, @code{W5}, | ||
| 275 | @code{W6} and @code{W7}. | ||
| 276 | |||
| 277 | For any parent window, the first child window can be retrieved by the | ||
| 278 | functions given next. | ||
| 279 | |||
| 280 | @defun window-top-child &optional window | ||
| 281 | This function returns @var{window}'s first vertical child window. The | ||
| 282 | optional argument @var{window} can be an arbitrary window and defaults | ||
| 283 | to the selected one. The return value is @code{nil} if @var{window} is | ||
| 284 | a live window or its children form a horizontal combination. In the | ||
| 285 | example above @code{(window-top-child W3)} is @code{W4} while | ||
| 286 | @code{(window-top-child W4)} is @code{nil}. | ||
| 287 | @end defun | ||
| 288 | |||
| 289 | @defun window-left-child &optional window | ||
| 290 | This function returns @var{window}'s first horizontal child window. The | ||
| 291 | optional argument @var{window} can be an arbitrary window and defaults | ||
| 292 | to the selected one. The return value is @code{nil} if @var{window} is | ||
| 293 | a live window or its children form a vertical combination. In the | ||
| 294 | example above @code{(window-left-child W4)} is @code{W6} while | ||
| 295 | @code{(window-top-child W3)} is @code{nil}. | ||
| 296 | @end defun | ||
| 297 | |||
| 298 | @defun window-child window | ||
| 299 | This function return @var{window}'s first child window. The return | ||
| 300 | value is @code{nil} if @var{window} is a live window. In the example | ||
| 301 | above @code{(window-child W3)} is @code{W4} while @code{(window-child | ||
| 302 | W4)} is @code{W6}. | ||
| 303 | @end defun | ||
| 304 | |||
| 305 | The following function is useful to determine whether a window is part | ||
| 306 | of a vertical or horizontal combination. | ||
| 307 | |||
| 308 | @defun window-iso-combined-p &optional window horizontal | ||
| 309 | This function returns non-@code{nil} if and only if @var{window} is | ||
| 310 | vertically combined. The argument @var{window} can specify any window | ||
| 311 | and defaults to the selected one. The actual return value is the first | ||
| 312 | vertical child of window. | ||
| 313 | |||
| 314 | If the optional argument @var{horizontal} is non-@code{nil}, this means | ||
| 315 | to return non-@code{nil} if and only if @var{window} is horizontally | ||
| 316 | combined. In this case, the return value is the first horizontal child | ||
| 317 | of window. | ||
| 318 | @end defun | ||
| 319 | |||
| 320 | @cindex sibling window | ||
| 321 | For any window that is part of a combination, the other windows in that | ||
| 322 | combination are called the window's @dfn{siblings}. The only windows | ||
| 323 | that do not have siblings are root windows of frames and minibuffer | ||
| 324 | windows. A window's siblings can be retrieved with the following two | ||
| 325 | functions. | ||
| 326 | |||
| 327 | @defun window-next-sibling &optional window | ||
| 328 | This function returns @var{window}'s next sibling. The optional | ||
| 329 | argument @var{window} can be an arbitrary window and defaults to the | ||
| 330 | selected window. It returns @code{nil} if @var{window} is the last | ||
| 331 | child of its parent. In our example @code{(window-next-sibling W2)} is | ||
| 332 | @code{W3} while @code{(window-next-sibling W3)} is @code{nil}. | ||
| 333 | @end defun | ||
| 334 | |||
| 335 | @defun window-prev-sibling &optional window | ||
| 336 | This function returns @var{window}'s previous sibling. The optional | ||
| 337 | argument @var{window} can be an arbitrary window and defaults to the | ||
| 338 | selected window. It returns @code{nil} if @var{window} is the first | ||
| 339 | child of its parent. In our example @code{(window-prev-sibling W3)} is | ||
| 340 | @code{W2} and @code{(window-prev-sibling W2)} is @code{nil}. | ||
| 341 | @end defun | ||
| 342 | |||
| 343 | The functions @code{window-next-sibling} and @code{window-prev-sibling} | ||
| 344 | should not be confused with the functions @code{next-window} and | ||
| 345 | @code{previous-window} which respectively return the next and previous | ||
| 346 | window in the cyclic ordering of windows, see @ref{Cyclic Window | ||
| 347 | Ordering}. | ||
| 348 | |||
| 349 | In order to find the first live window on a frame, the following | ||
| 350 | function can be used. | ||
| 351 | |||
| 352 | @defun frame-first-window &optional frame-or-window | ||
| 353 | This function returns the live window at the upper left corner of the | ||
| 354 | frame specified by @var{frame-or-window}. The argument | ||
| 355 | @var{frame-or-window} must denote a window or a live frame and defaults | ||
| 356 | to the selected frame. If @var{frame-or-window} specifies a window, | ||
| 357 | this function returns the first window on that window's frame. Under | ||
| 358 | the assumption that the frame from our canonical example is selected | ||
| 359 | @code{(frame-first-window)} returns @code{W2}. | ||
| 360 | @end defun | ||
| 361 | |||
| 362 | You can get the window tree of a frame with the following function. | ||
| 363 | |||
| 364 | @cindex window tree | ||
| 365 | @defun window-tree &optional frame | ||
| 366 | This function returns the window tree for frame @var{frame}. The | ||
| 367 | optional argument @var{frame} must be a live frame and defaults to the | ||
| 368 | selected one. | ||
| 369 | |||
| 370 | The return value is a list of the form @code{(@var{root} @var{mini})}, | ||
| 371 | where @var{root} represents the window tree of the frame's | ||
| 372 | root window, and @var{mini} is the frame's minibuffer window. | ||
| 373 | |||
| 374 | If the root window is live, @var{root} specifies the root window and | ||
| 375 | nothing else. Otherwise, @var{root} is a list @code{(@var{dir} | ||
| 376 | @var{edges} @var{w1} @var{w2} ...)} where @var{dir} is @code{nil} for a | ||
| 377 | horizontal combination, and @code{t} for a vertical combination, | ||
| 378 | @var{edges} gives the size and position of the combination, and the | ||
| 379 | remaining elements are the child windows. Each child window may again | ||
| 380 | be a live window or a list representing a window combination, and so on. | ||
| 381 | The @var{edges} element is a list @code{(@var{left}@var{ top}@var{ | ||
| 382 | right}@var{ bottom})} similar to the value returned by | ||
| 383 | @code{window-edges}, see @ref{Coordinates and Windows}. | ||
| 384 | @end defun | ||
| 385 | |||
| 386 | |||
| 387 | @node Window Sizes | ||
| 388 | @section Window Sizes | ||
| 389 | @cindex window size | ||
| 390 | @cindex size of window | ||
| 391 | |||
| 392 | Emacs windows are rectangular. The structure of a live window can be | ||
| 393 | roughly sketched as follows: | ||
| 394 | |||
| 395 | @smallexample | ||
| 396 | @group | ||
| 397 | _________________________________________ | ||
| 398 | ^ |______________ Header Line_______________| | ||
| 399 | | |LS|LF|LM| |RM|RF|RS| ^ | ||
| 400 | | | | | | | | | | | | ||
| 401 | Window | | | | Text Area | | | | Window | ||
| 402 | Total | | | | (Window Body) | | | | Body | ||
| 403 | Height | | | | | | | | Height | ||
| 404 | | | | | |<- Window Body Width ->| | | | | | ||
| 405 | | |__|__|__|_______________________|__|__|__| v | ||
| 406 | v |_______________ Mode Line _______________| | ||
| 407 | |||
| 408 | <----------- Window Total Width --------> | ||
| 409 | |||
| 410 | @end group | ||
| 411 | @end smallexample | ||
| 412 | |||
| 413 | @cindex window body | ||
| 414 | @cindex body of a window | ||
| 415 | The text area constitutes the body of the window. In its most simple | ||
| 416 | form, a window consists of its body alone. LS and RS stand for the left | ||
| 417 | and right scroll bar (@pxref{Scroll Bars}) respectively. Only one of | ||
| 418 | them can be present at any time. LF and RF denote the left and right | ||
| 419 | fringe, see @ref{Fringes}. LM and RM, finally, stand for the left and | ||
| 420 | right display margin, see @ref{Display Margins}. The header line, if | ||
| 421 | present, is located above theses areas, the mode line below, see | ||
| 422 | @ref{Mode Line Format}. | ||
| 423 | |||
| 424 | @cindex window height | ||
| 425 | @cindex total window height | ||
| 426 | @cindex height of a window | ||
| 427 | @cindex total height of a window | ||
| 428 | The @dfn{total height of a window} is specified as the total number of | ||
| 429 | lines occupied by the window. Any mode or header line is included in a | ||
| 430 | window's total height. For an internal window, the total height is | ||
| 431 | calculated recursively from the total heights of its child windows. | ||
| 432 | |||
| 433 | @cindex window width | ||
| 434 | @cindex total window width | ||
| 435 | @cindex width of a window | ||
| 436 | @cindex total width of a window | ||
| 437 | The @dfn{total width of a window} denotes the total number of columns of | ||
| 438 | the window. Any scroll bar and the column of @samp{|} characters that | ||
| 439 | separate the window from its right sibling are included in a window's | ||
| 440 | total width. On a window-system, fringes and display margins are | ||
| 441 | included in a window's total width too. For an internal window, the | ||
| 442 | total width is calculated recursively from the total widths of its child | ||
| 443 | windows. | ||
| 444 | |||
| 445 | @cindex total size of a window | ||
| 446 | @cindex total window size | ||
| 447 | The following function is the standard interface for getting the total | ||
| 448 | size of any window: | ||
| 449 | |||
| 450 | @defun window-total-size &optional window &optional horizontal | ||
| 451 | This function returns the total number of lines of @var{window}. The | ||
| 452 | argument @var{window} can denote any window and defaults to the selected | ||
| 453 | one. If @var{window} is live, the return value includes any header or | ||
| 454 | mode lines of @var{window}. If @var{window} is internal, the return | ||
| 455 | value is the sum of the total heights of @var{window}'s child windows | ||
| 456 | provided these are vertically combined and the height of @var{window}'s | ||
| 457 | first child if they are horizontally combined. | ||
| 458 | |||
| 459 | If the optional argument @var{horizontal} is non-@code{nil}, this | ||
| 460 | function returns the total number of columns of @var{window}. If | ||
| 461 | @var{window} is live, the return value includes any vertical divider | ||
| 462 | column or scroll bars of @var{window}. On a window-system, the return | ||
| 463 | value includes the space occupied by any margins and fringes of | ||
| 464 | @var{window} too. If @var{window} is internal, the return value is the | ||
| 465 | sum of the total widths of @var{window}'s child windows provided these | ||
| 466 | are horizontally combined and the width of @var{window}'s first child | ||
| 467 | otherwise. | ||
| 468 | @end defun | ||
| 469 | |||
| 470 | Alternatively, the following two functions can be used to retrieve | ||
| 471 | either the total height or the total width of a window: | ||
| 472 | |||
| 473 | @defun window-total-height &optional window | ||
| 474 | This function returns the total number of lines of @var{window}. | ||
| 475 | @var{window} can be any window and defaults to the selected one. The | ||
| 476 | return value includes @var{window}'s mode line and header line, if any. | ||
| 477 | If @var{window} is internal the return value is the sum of heights of | ||
| 478 | @var{window}'s child windows for a vertical combination and the height | ||
| 479 | of @var{window}'s first child otherwise. | ||
| 480 | @end defun | ||
| 481 | |||
| 482 | @defun window-total-width &optional window | ||
| 483 | This function returns the total number of columns of @var{window}. | ||
| 484 | @var{window} can be any window and defaults to the selected one. The | ||
| 485 | return value includes any vertical dividers or scrollbars of | ||
| 486 | @var{window}. On a window-system the return value also includes the | ||
| 487 | space occupied by any margins and fringes of @var{window}. If | ||
| 488 | @var{window} is internal, the return value is the sum of the widths of | ||
| 489 | @var{window}'s child windows for a horizontal combination and the width | ||
| 490 | of @var{window}'s first child otherwise. | ||
| 491 | @end defun | ||
| 492 | |||
| 493 | The total height of any window is usually less than the height of the | ||
| 494 | window's frame, because the latter may also include the minibuffer | ||
| 495 | window. Depending on the toolkit in use, the frame height can also | ||
| 496 | include the menu bar and the tool bar (@pxref{Size and Position}). | ||
| 497 | Therefore, in general it is not straightforward to compare window and | ||
| 498 | frame heights. The following function is useful to determine whether | ||
| 499 | there are no other windows above or below a specified window. | ||
| 500 | |||
| 501 | @cindex full-height window | ||
| 502 | @defun window-full-height-p &optional window | ||
| 503 | This function returns non-@code{nil} if there is no other window above | ||
| 504 | or below @var{window} on the containing frame. More precisely, this | ||
| 505 | function returns @code{t} if and only if the total height of | ||
| 506 | @var{window} equals the total height of the root window (@pxref{Windows | ||
| 507 | and Frames}) of @var{window}'s frame. The @var{window} argument may | ||
| 508 | denote any window and defaults to the selected one. | ||
| 509 | @end defun | ||
| 510 | |||
| 511 | @cindex full-width window | ||
| 512 | The following function can be used to determine whether there are no | ||
| 513 | other windows on the left or right of a specified window. | ||
| 514 | |||
| 515 | @defun window-full-width-p &optional window | ||
| 516 | This function returns non-@code{nil} if there are no other windows on | ||
| 517 | the left or right of @var{window}; @code{nil} otherwise. More | ||
| 518 | precisely, this function returns @code{t} if and only if the total width | ||
| 519 | of @var{window} equals the total width of the root window | ||
| 520 | (@pxref{Windows and Frames}) of @var{window}'s frame. The @var{window} | ||
| 521 | argument may denote any window and defaults to the selected one. | ||
| 522 | @end defun | ||
| 523 | |||
| 524 | @cindex top line of window | ||
| 525 | @cindex left column of window | ||
| 526 | The windows of a frame are unambiguously characterized by the | ||
| 527 | combination of their top line and left column within that frame. | ||
| 528 | |||
| 529 | @defun window-top-line &optional window | ||
| 530 | This function returns the top line of @var{window}. The argument | ||
| 531 | @var{window} can denote any window and defaults to the selected one. | ||
| 532 | @end defun | ||
| 533 | |||
| 534 | @defun window-left-column &optional window | ||
| 535 | This function returns the left column of @var{window}. The argument | ||
| 536 | @var{window} can denote any window and defaults to the selected one. | ||
| 537 | @end defun | ||
| 538 | |||
| 539 | For a frame displaying one window only, that window's top line and left | ||
| 540 | column are both zero. When a frame displays a window @var{WB} below a | ||
| 541 | window @var{WA}, the top line of @var{WB} can be calculated by adding | ||
| 542 | the total height of @var{WA} to the top line of @var{WA}. When a frame | ||
| 543 | displays a window @var{WR} on the right of a window @var{WL}, the left | ||
| 544 | column of @var{WR} can be calculated by adding the total width of | ||
| 545 | @var{WL} to the left column of @var{WL}. | ||
| 546 | |||
| 547 | @cindex window body height | ||
| 548 | @cindex body height of a window | ||
| 549 | The @dfn{body height of a window} is specified as the total number of | ||
| 550 | lines occupied by the window's text area. Mode or header lines are not | ||
| 551 | included in a window's body height. | ||
| 552 | |||
| 553 | @cindex window body width | ||
| 554 | @cindex body width of a window | ||
| 555 | The @dfn{body width of a window} denotes the total number of columns | ||
| 556 | occupied by the window's text area. Scroll bars or columns of @samp{|} | ||
| 557 | characters that separate side-by-side windows are not included in a | ||
| 558 | window's body width. | ||
| 559 | |||
| 560 | @cindex body size of a window | ||
| 561 | @cindex window body size | ||
| 562 | The following functions retrieve height and width of the body of a live | ||
| 563 | window: | ||
| 564 | |||
| 565 | @defun window-body-size &optional window horizontal | ||
| 566 | This function returns the number of lines of @var{window}'s text area. | ||
| 567 | @var{window} must be a live window and defaults to the selected one. | ||
| 568 | The return value does not count any mode or header line of @var{window}. | ||
| 569 | |||
| 570 | Optional argument @var{horizontal} non-@code{nil} means to return the | ||
| 571 | number of columns of @var{window}'s text area. In this case the return | ||
| 572 | value does not include any vertical divider or scroll bar owned by | ||
| 573 | @var{window}. On a window-system the return value does not include the | ||
| 574 | number of columns used for @var{window}'s fringes or display margins | ||
| 575 | either. | ||
| 576 | @end defun | ||
| 577 | |||
| 578 | @defun window-body-height &optional window | ||
| 579 | This function returns the number of lines of @var{window}'s body. | ||
| 580 | @var{window} must be a live window and defaults to the selected one. | ||
| 581 | |||
| 582 | The return value does not include @var{window}'s mode line and header | ||
| 583 | line, if any. If a line at the bottom of the window is only partially | ||
| 584 | visible, that line is included in the return value. If you do not | ||
| 585 | want to include a partially visible bottom line in the return value, | ||
| 586 | use @code{window-text-height} instead. | ||
| 587 | @end defun | ||
| 588 | |||
| 589 | @defun window-body-width &optional window | ||
| 590 | This function returns the number of columns of @var{window}'s body. | ||
| 591 | @var{window} must be a live window and defaults to the selected one. | ||
| 592 | |||
| 593 | The return value does not include any vertical dividers or scroll bars | ||
| 594 | owned by @var{window}. On a window-system the return value does not | ||
| 595 | include the number of columns used for @var{window}'s fringes or | ||
| 596 | display margins either. | ||
| 597 | @end defun | ||
| 598 | |||
| 599 | The following functions have been used in earlier versions of Emacs. | ||
| 600 | They are still supported but due to the confusing nomenclature they | ||
| 601 | should not be used any more in future code. | ||
| 602 | |||
| 603 | @defun window-height &optional window | ||
| 604 | This function is an alias for `window-total-height', see above. | ||
| 605 | @end defun | ||
| 606 | |||
| 607 | @defun window-width &optional window | ||
| 608 | This function is an alias for `window-body-width', see above. | ||
| 609 | @end defun | ||
| 610 | |||
| 611 | @cindex minimum window size | ||
| 612 | The following two options constrain the sizes of windows to a minimum | ||
| 613 | height and width. Their values are honored when windows are split | ||
| 614 | (@pxref{Splitting Windows}) or resized (@pxref{Resizing Windows}). Any | ||
| 615 | request to make a window smaller than specified here will usually result | ||
| 616 | in an error. | ||
| 617 | |||
| 618 | @defopt window-min-height | ||
| 619 | The value of this variable specifies how short a window may be. The | ||
| 620 | value is measured in line units and has to account for any header or | ||
| 621 | mode line. The default value for this option is @code{4}. Values less | ||
| 622 | than @code{1} are ignored. | ||
| 623 | @end defopt | ||
| 624 | |||
| 625 | @defopt window-min-width | ||
| 626 | The value of this variable specifies how narrow a window may be. The | ||
| 627 | value is measured in characters and includes any margins, fringes, | ||
| 628 | scroll bar and vertical divider column. The default value for this | ||
| 629 | option is @code{10}. A value less than @code{2} is ignored. | ||
| 630 | @end defopt | ||
| 631 | |||
| 632 | Applications should not rebind these variables. To shrink a specific | ||
| 633 | window to a height or width less than the one specified here, they | ||
| 634 | should rather invoke @code{window-resize} (@pxref{Resizing Windows}) | ||
| 635 | with a non-@code{nil} @var{ignore} argument. The function | ||
| 636 | @code{split-window} (@pxref{Splitting Windows}) can make a window | ||
| 637 | smaller than specified here by calling it with a non-@code{nil} | ||
| 638 | @var{size} argument. Interactively, the values specified here cannot be | ||
| 639 | overridden. | ||
| 640 | |||
| 641 | Earlier versions of Emacs could delete a window when its size dropped | ||
| 642 | below @code{window-min-height} or @code{window-min-width}. As a rule, | ||
| 643 | the current version of Emacs does no more delete windows by side-effect. | ||
| 644 | The only exception to this rule are requests to resize a frame which may | ||
| 645 | implicitly delete windows when they do not fit on the frame any more, | ||
| 646 | see @ref{Size and Position}. | ||
| 647 | |||
| 648 | The size of a window can be fixed which means that it cannot be split | ||
| 649 | (@pxref{Splitting Windows}) or resized (@pxref{Resizing Windows}). | ||
| 650 | |||
| 651 | @cindex fixed-size window | ||
| 652 | @defvar window-size-fixed | ||
| 653 | If this variable is non-@code{nil}, in a given buffer, then the size of | ||
| 654 | any window displaying that buffer remains fixed unless you either | ||
| 655 | explicitly change it or Emacs has no other choice. | ||
| 656 | |||
| 657 | If the value is @code{height}, then only the window's height is fixed; | ||
| 658 | if the value is @code{width}, then only the window's width is fixed. | ||
| 659 | Any other non-@code{nil} value fixes both the width and the height. | ||
| 660 | |||
| 661 | This variable automatically becomes buffer-local when set. | ||
| 662 | @end defvar | ||
| 663 | |||
| 664 | Commands supposed to explicitly change the size of windows such as | ||
| 665 | @code{enlarge-window} (@pxref{Resizing Windows}) get an error if they | ||
| 666 | had to change a window size which is fixed. Other functions like | ||
| 667 | @code{window-resize} (@pxref{Resizing Windows}) have an optional | ||
| 668 | @var{ignore} argument which allows to change the size of fixed-size | ||
| 669 | windows. | ||
| 670 | |||
| 671 | Deleting a window or changing a frame's size may change the size of a | ||
| 672 | fixed-size window, if there is no other alternative. | ||
| 673 | |||
| 674 | The height of a vertical combination of windows cannot be changed | ||
| 675 | when the height of all these windows is fixed. Its width cannot be | ||
| 676 | changed if the width of at least one of these windows is fixed. | ||
| 677 | Similarly, the width of a horizontal combination of windows cannot be | ||
| 678 | changed when the width of all these windows is fixed. Its height cannot | ||
| 679 | be changed if the height of at least one of these windows is fixed. | ||
| 680 | |||
| 681 | The next function allows to check whether the size of an arbitrary | ||
| 682 | window is fixed. | ||
| 683 | |||
| 684 | @defun window-size-fixed-p &optional window horizontal | ||
| 685 | This function returns non-@code{nil} if @var{window}'s height is fixed. | ||
| 686 | The argument @var{window} can be an arbitrary window and defaults to the | ||
| 687 | selected one. Optional argument @var{horizontal} non-@code{nil} means | ||
| 688 | return non-@code{nil} if @var{window}'s width is fixed. | ||
| 689 | |||
| 690 | If this function returns @code{nil}, this does not necessarily mean that | ||
| 691 | @var{window} can be resized in the desired direction. The function | ||
| 692 | @code{window-resizable} (@pxref{Resizing Windows}) can tell that. | ||
| 693 | @end defun | ||
| 694 | |||
| 695 | |||
| 696 | @node Resizing Windows | ||
| 697 | @section Resizing Windows | ||
| 698 | @cindex window resizing | ||
| 699 | @cindex resize window | ||
| 700 | @cindex changing window size | ||
| 701 | @cindex window size, changing | ||
| 702 | |||
| 703 | Emacs does not permit overlapping windows or gaps between windows, so | ||
| 704 | changing the size of a window always affects at least one other window. | ||
| 705 | When a frame contains just one window, that window can be resized only | ||
| 706 | by resizing the window's frame. The functions described below are | ||
| 707 | therefore meaningful only in the context of a frame containing at least | ||
| 708 | two windows. The size of the corresponding frame never changes when | ||
| 709 | invoking a function described in this section. | ||
| 710 | |||
| 711 | The routines changing window sizes always operate in one dimension at | ||
| 712 | a time. This means that windows can be resized only either vertically | ||
| 713 | or horizontally. If a window shall be resized in both dimensions, it | ||
| 714 | must be resized in one dimension first and in the other dimension | ||
| 715 | afterwards. If the second resize operation fails, the frame might end | ||
| 716 | up in an unsatisfactory state. To avoid such states, it might be useful | ||
| 717 | to save the current window configuration (@pxref{Window Configurations}) | ||
| 718 | before attempting the first resize operation and restore the saved | ||
| 719 | configuration in case the second resize operation fails. | ||
| 720 | |||
| 721 | Functions that resize windows are supposed to obey restrictions | ||
| 722 | imposed by window minimum sizes and fixed-size windows, see @ref{Window | ||
| 723 | Sizes}. In order to determine whether resizing a specific window is | ||
| 724 | possible in the first place, the following function can be used: | ||
| 725 | |||
| 726 | @defun window-resizable window delta &optional horizontal ignore side noup nodown | ||
| 727 | This function returns @var{delta} if the size of @var{window} can be | ||
| 728 | changed vertically by @var{delta} lines. Optional argument | ||
| 729 | @var{horizontal} non-@code{nil} means to return @var{delta} if | ||
| 730 | @var{window} can be resized horizontally by @var{delta} columns. A | ||
| 731 | return value of zero means that @var{window} is not resizable. | ||
| 732 | |||
| 733 | If @var{delta} is a positive number, this means that @var{window} shall | ||
| 734 | be enlarged by @var{delta} lines or columns. If @var{window} cannot be | ||
| 735 | enlarged by @var{delta} lines or columns, this function returns the | ||
| 736 | maximum value in the range from 0 to @var{delta} by which @var{window} | ||
| 737 | can be enlarged. | ||
| 738 | |||
| 739 | If @var{delta} is a negative number, this means that @var{window} shall | ||
| 740 | be shrunk by -@var{delta} lines or columns. If @var{window} cannot be | ||
| 741 | shrunk by -@var{delta} lines or columns, this function returns the | ||
| 742 | minimum value in the range from @var{delta} to 0 that can be used for | ||
| 743 | shrinking @var{window}. | ||
| 744 | |||
| 745 | Optional argument @var{ignore} non-@code{nil} means ignore any | ||
| 746 | restrictions imposed by the variables @code{window-min-height} or | ||
| 747 | @code{window-min-width} and @code{window-size-fixed}. In this case the | ||
| 748 | minimum height of a window is specified as the minimum number of lines | ||
| 749 | that allow viewing any header or mode line and at least one line of the | ||
| 750 | text area of window. The minimum width of a window includes any | ||
| 751 | fringes, margins and the scroll bar as well as two text columns. | ||
| 752 | |||
| 753 | If @var{ignore} denotes a window, this means to ignore restrictions for | ||
| 754 | that window only. If @var{ignore} equals the constant @code{safe}, this | ||
| 755 | means a live window may get as small as one line or two columns. | ||
| 756 | |||
| 757 | Optional argument @var{noup} non-@code{nil} means don't go up in the | ||
| 758 | window tree but try to steal or distribute the space needed for the | ||
| 759 | resize operation among the other windows within @var{window}'s | ||
| 760 | combination. Optional argument @var{nodown} non-@code{nil} means don't | ||
| 761 | check whether @var{window} itself and its subwindows can be resized. | ||
| 762 | @end defun | ||
| 763 | |||
| 764 | The function @code{window-resizable} does not change any window sizes. | ||
| 765 | The following function does: | ||
| 766 | |||
| 767 | @defun window-resize window delta &optional horizontal ignore | ||
| 768 | This function resizes @var{window} vertically by @var{delta} lines. The | ||
| 769 | argument @var{window} can denote an arbitrary window and defaults to the | ||
| 770 | selected one. An attempt to resize the root window of a frame will | ||
| 771 | raise an error. | ||
| 772 | |||
| 773 | Second argument @var{delta} a positive number means @var{window} shall | ||
| 774 | be enlarged by @var{delta} lines. If @var{delta} is negative, that | ||
| 775 | means @var{window} shall be shrunk by -@var{delta} lines. | ||
| 776 | |||
| 777 | Optional argument @var{horizontal} non-@code{nil} means to resize | ||
| 778 | @var{window} horizontally by @var{delta} columns. In this case a | ||
| 779 | positive @var{delta} means enlarge @var{window} by @var{delta} columns. | ||
| 780 | A negative @var{delta} means @var{window} shall be shrunk by | ||
| 781 | -@var{delta} columns. | ||
| 782 | |||
| 783 | Optional argument @var{ignore} has the same meaning as for the function | ||
| 784 | @code{window-resizable} above. | ||
| 785 | |||
| 786 | This function can simultaneously move two edges of WINDOW. Exactly | ||
| 787 | which edges of @var{window} are moved and which other windows are | ||
| 788 | resized along with @var{window} is determined by the splits and nest | ||
| 789 | status of the involved windows (@pxref{Splitting Windows}). If only the | ||
| 790 | low (right) edge of @var{window} shall be moved, the function | ||
| 791 | @code{adjust-window-trailing-edge} described below should be used. | ||
| 792 | @end defun | ||
| 793 | |||
| 794 | The next four commands are simple interfaces to @code{window-resize}. | ||
| 795 | They always operate on the selected window, never delete any window, and | ||
| 796 | always raise an error when resizing would violate a restriction imposed | ||
| 797 | by @code{window-min-height}, @code{window-min-width}, or | ||
| 798 | @code{window-size-fixed}. | ||
| 799 | |||
| 800 | @deffn Command enlarge-window delta &optional horizontal | ||
| 801 | This function makes the selected window @var{delta} lines taller. | ||
| 802 | Interactively, if no argument is given, it makes the selected window one | ||
| 803 | line taller. If optional argument @var{horizontal} is non-@code{nil}, | ||
| 804 | it makes the selected window wider by @var{delta} columns. If | ||
| 805 | @var{delta} is negative, it shrinks the selected window by -@var{delta} | ||
| 806 | lines or columns. The return value is @code{nil}. | ||
| 807 | @end deffn | ||
| 808 | |||
| 809 | @deffn Command enlarge-window-horizontally delta | ||
| 810 | This function makes the selected window @var{delta} columns wider. | ||
| 811 | Interactively, if no argument is given, it makes the selected window one | ||
| 812 | column wider. | ||
| 813 | @end deffn | ||
| 814 | |||
| 815 | @deffn Command shrink-window delta &optional horizontal | ||
| 816 | This function makes the selected window @var{delta} lines smaller. | ||
| 817 | Interactively, if no argument is given, it makes the selected window one | ||
| 818 | line smaller. If optional argument @var{horizontal} is non-@code{nil}, | ||
| 819 | it makes the selected window narrower by @var{delta} columns. If | ||
| 820 | @var{delta} is negative, it enlarges the selected window by -@var{delta} | ||
| 821 | lines or columns. The return value is @code{nil}. | ||
| 822 | @end deffn | ||
| 823 | |||
| 824 | @deffn Command shrink-window-horizontally delta | ||
| 825 | This function makes the selected window @var{delta} columns narrower. | ||
| 826 | Interactively, if no argument is given, it makes the selected window one | ||
| 827 | column narrower. | ||
| 828 | @end deffn | ||
| 829 | |||
| 830 | The following function is useful for moving the line dividing two | ||
| 831 | windows. | ||
| 832 | |||
| 833 | @defun adjust-window-trailing-edge window delta &optional horizontal | ||
| 834 | This function moves @var{window}'s bottom edge by @var{delta} lines. | ||
| 835 | Optional argument @var{horizontal} non-@code{nil} means to move | ||
| 836 | @var{window}'s right edge by @var{delta} columns. The argument | ||
| 837 | @var{window} defaults to the selected window. | ||
| 838 | |||
| 839 | If @var{delta} is greater zero, this moves the edge downwards or to the | ||
| 840 | right. If @var{delta} is less than zero, this moves the edge upwards or | ||
| 841 | to the left. If the edge can't be moved by @var{delta} lines or columns, | ||
| 842 | it is moved as far as possible in the desired direction but no error is | ||
| 843 | signalled. | ||
| 844 | |||
| 845 | This function tries to resize windows adjacent to the edge that is | ||
| 846 | moved. Only if this is insufficient, it will also resize windows not | ||
| 847 | adjacent to that edge. As a consequence, if you move an edge in one | ||
| 848 | direction and back in the other direction by the same amount, the | ||
| 849 | resulting window configuration will not be necessarily identical to the | ||
| 850 | one before the first move. So if your intend to just resize | ||
| 851 | @var{window}, you should not use this function but call | ||
| 852 | @code{window-resize} (see above) instead. | ||
| 102 | @end defun | 853 | @end defun |
| 103 | 854 | ||
| 855 | @deffn Command fit-window-to-buffer &optional window max-height min-height override | ||
| 856 | This command makes @var{window} the right height to display its | ||
| 857 | contents exactly. The default for @var{window} is the selected window. | ||
| 858 | |||
| 859 | The optional argument @var{max-height} specifies the maximum total | ||
| 860 | height the window is allowed to be; @code{nil} means use the maximum | ||
| 861 | permissible height of a window on @var{window}'s frame. The optional | ||
| 862 | argument @var{min-height} specifies the minimum toatl height for the | ||
| 863 | window; @code{nil} means use @code{window-min-height}. All these height | ||
| 864 | values include the mode line and/or header line. | ||
| 865 | |||
| 866 | If the optional argument @var{override} is non-@code{nil}, this means to | ||
| 867 | ignore any restrictions imposed by @code{window-min-height} and | ||
| 868 | @code{window-min-width} on the size of @var{window}. | ||
| 869 | |||
| 870 | This function returns non-@code{nil} if it orderly resized @var{window}, | ||
| 871 | and @code{nil} otherwise. | ||
| 872 | @end deffn | ||
| 873 | |||
| 874 | @deffn Command shrink-window-if-larger-than-buffer &optional window | ||
| 875 | This command shrinks @var{window} vertically to be as small as possible | ||
| 876 | while still showing the full contents of its buffer---but not less than | ||
| 877 | @code{window-min-height} lines. The argument @var{window} must denote | ||
| 878 | a live window and defaults to the selected one. | ||
| 879 | |||
| 880 | However, this command does nothing if the window is already too small to | ||
| 881 | display the whole text of the buffer, or if part of the contents are | ||
| 882 | currently scrolled off screen, or if the window is not the full width of | ||
| 883 | its frame, or if the window is the only window in its frame. | ||
| 884 | |||
| 885 | This command returns non-@code{nil} if it actually shrank the window | ||
| 886 | and @code{nil} otherwise. | ||
| 887 | @end deffn | ||
| 888 | |||
| 889 | @cindex balancing window sizes | ||
| 890 | Emacs provides two functions to balance windows, that is, to even out | ||
| 891 | the sizes of all windows on the same frame. The minibuffer window and | ||
| 892 | fixed-size windows are not resized by these functions. | ||
| 893 | |||
| 894 | @deffn Command balance-windows &optional window-or-frame | ||
| 895 | This function balances windows in a way that gives more space to | ||
| 896 | full-width and/or full-height windows. If @var{window-or-frame} | ||
| 897 | specifies a frame, it balances all windows on that frame. If | ||
| 898 | @var{window-or-frame} specifies a window, it balances that window and | ||
| 899 | its siblings (@pxref{Windows and Frames}) only. | ||
| 900 | @end deffn | ||
| 901 | |||
| 902 | @deffn Command balance-windows-area | ||
| 903 | This function attempts to give all windows on the selected frame | ||
| 904 | approximately the same share of the screen area. This means that | ||
| 905 | full-width or full-height windows are not given more space than other | ||
| 906 | windows. | ||
| 907 | @end deffn | ||
| 908 | |||
| 909 | @cindex maximizing windows | ||
| 910 | The following function can be used to give a window the maximum possible | ||
| 911 | size without deleting other ones. | ||
| 912 | |||
| 913 | @deffn Command maximize-window &optional window | ||
| 914 | This function maximizes @var{window}. More precisely, this makes | ||
| 915 | @var{window} as large as possible without resizing its frame or deleting | ||
| 916 | other windows. @var{window} can be any window and defaults to the | ||
| 917 | selected one. | ||
| 918 | @end deffn | ||
| 919 | |||
| 920 | @cindex minimizing windows | ||
| 921 | To make a window as small as possible without deleting it the | ||
| 922 | following function can be used. | ||
| 923 | |||
| 924 | @deffn Command minimize-window &optional window | ||
| 925 | This function minimizes @var{window}. More precisely, this makes | ||
| 926 | @var{window} as small as possible without deleting it or resizing its | ||
| 927 | frame. @var{window} can be any window and defaults to the selected one. | ||
| 928 | @end deffn | ||
| 929 | |||
| 930 | |||
| 104 | @node Splitting Windows | 931 | @node Splitting Windows |
| 105 | @section Splitting Windows | 932 | @section Splitting Windows |
| 106 | @cindex splitting windows | 933 | @cindex splitting windows |
| 107 | @cindex window splitting | 934 | @cindex window splitting |
| 108 | 935 | ||
| 109 | The functions described below are the primitives used to split a window | 936 | The functions described below are the primitives needed for creating a |
| 110 | into two windows. They do not accept a buffer as an argument. Rather, | 937 | new window. They do not accept a buffer as an argument. Rather, they |
| 111 | the two ``halves'' of the split window initially display the same buffer | 938 | ``split'' an existing window into two halves, both displaying the buffer |
| 112 | previously visible in the window that was split. | 939 | previously visible in the window that was split. |
| 113 | 940 | ||
| 114 | @deffn Command split-window &optional window size horizontal | 941 | @deffn Command split-window &optional window size side |
| 115 | This function splits a new window out of @var{window}'s screen area. It | 942 | This function creates a new window adjacent to @var{window}. It returns |
| 116 | returns the new window. The default for @var{window} is the selected | 943 | the new window which is always a live window. The argument @var{window} |
| 117 | window. When you split the selected window, it remains selected. | 944 | can denote any window and defaults to the selected one. This function |
| 118 | 945 | does not change the selected window. | |
| 119 | If @var{horizontal} is non-@code{nil}, then @var{window} splits into two | 946 | |
| 120 | side by side windows. The original window keeps the leftmost @var{size} | 947 | Optional second argument @var{size} a positive number means make |
| 121 | columns, and gives the rest of the columns to the new window. | 948 | @var{window} @var{size} lines (or columns) tall. If @var{size} is |
| 122 | Otherwise, @var{window} splits into windows one above the other, the | 949 | negative, make the new window @minus{}@var{size} lines (or columns) |
| 123 | original window keeps the upper @var{size} lines and gives the rest of | 950 | tall. If @var{size} is omitted or @code{nil}, then @var{window} is |
| 124 | the lines to the new window. The original window @var{window} is | 951 | divided evenly into two parts. (If there is an odd line, it is |
| 125 | therefore the left-hand or upper of the two, and the new window is the | 952 | allocated to the new window.) |
| 126 | right-hand or lower. | 953 | |
| 127 | 954 | If splitting would result in making a window smaller than | |
| 128 | If @var{size} is omitted or @code{nil}, then @var{window} is divided | 955 | @code{window-min-height} or @code{window-min-width} (@pxref{Window |
| 129 | evenly into two parts. (If there is an odd line, it is allocated to | 956 | Sizes}), this function usually signals an error. However, if @var{size} |
| 130 | the new window.) When @code{split-window} is called interactively, | 957 | is non-@code{nil} and valid, a new window of the requested size is |
| 131 | all its arguments are @code{nil}. | 958 | created. (A size value would be invalid if it assigned less than one |
| 132 | 959 | line or less than two columns to the new window.) | |
| 133 | If splitting would result in making a window that is smaller than | 960 | |
| 134 | @code{window-min-height} or @code{window-min-width} (@pxref{Resizing | 961 | Optional third argument @var{side} @code{nil} (or @code{below}) |
| 135 | Windows}), @code{split-window} signals an error and does not split the | 962 | specifies that the new window shall be located below @var{window}. The |
| 136 | window at all. | 963 | value @code{above} means the new window will be located above |
| 964 | @var{window}. In both cases @var{size} specifies the new number of | ||
| 965 | lines for @var{window} (or the new window if @var{size} is negative) | ||
| 966 | including space reserved for the mode and/or header line. | ||
| 967 | |||
| 968 | If @var{side} is @code{t} or @code{right} the new window will be | ||
| 969 | positioned on the right side of @var{window}. The value @code{left} | ||
| 970 | means the new window will be located on the left side of @var{window}. | ||
| 971 | In both cases @var{size} specifies the new number of columns for | ||
| 972 | @var{window} (or the new window provided @var{size} is negative) | ||
| 973 | including space reserved for margins, fringes and the scroll bar or a | ||
| 974 | divider column. | ||
| 975 | |||
| 976 | Any other non-@code{nil} value for @var{side} is currently handled like | ||
| 977 | @code{t} (or @code{right}). Since this might change in the future, | ||
| 978 | application programs should refrain from using other values. | ||
| 979 | |||
| 980 | If @var{window} is live, properties of the new window like margins and | ||
| 981 | scroll bars are inherited from @var{window}. If @var{window} is an | ||
| 982 | internal window, these properties, as well as the buffer shown in the | ||
| 983 | new window, are inherited from the window selected on @var{window}'s | ||
| 984 | frame. | ||
| 985 | |||
| 986 | If @code{ignore-window-parameters} is non-@code{nil}, this function | ||
| 987 | ignores window parameters (@pxref{Window Parameters}). Otherwise, if | ||
| 988 | the @code{split-window} parameter of @var{window} is @code{t}, it splits | ||
| 989 | the window disregarding any other window parameters. If the | ||
| 990 | @code{split-window} parameter specifies a function, that function is | ||
| 991 | called with the arguments @var{window}, @var{size}, and @var{side} to | ||
| 992 | split @var{window}. If that function is @code{ignore}, nothing is done. | ||
| 993 | @end deffn | ||
| 137 | 994 | ||
| 138 | The following example starts with one window on a screen that is 50 | 995 | The following example starts with one window on a screen that is 50 |
| 139 | lines high by 80 columns wide; then it splits the window. | 996 | lines high by 80 columns wide; then it splits the window. |
| 140 | 997 | ||
| 141 | @smallexample | 998 | @smallexample |
| 142 | @group | 999 | @group |
| 143 | (setq w (selected-window)) | 1000 | (setq W1 (selected-window)) |
| 144 | @result{} #<window 8 on windows.texi> | 1001 | @result{} #<window 8 on windows.texi> |
| 145 | (window-edges) ; @r{Edges in order:} | 1002 | (setq W2 (split-window W1 15)) |
| 146 | @result{} (0 0 80 50) ; @r{left--top--right--bottom} | ||
| 147 | @end group | ||
| 148 | |||
| 149 | @group | ||
| 150 | ;; @r{Returns window created} | ||
| 151 | (setq w2 (split-window w 15)) | ||
| 152 | @result{} #<window 28 on windows.texi> | 1003 | @result{} #<window 28 on windows.texi> |
| 153 | @end group | 1004 | @end group |
| 154 | @group | 1005 | @group |
| 155 | (window-edges w2) | 1006 | (window-top-line W1) |
| 156 | @result{} (0 15 80 50) ; @r{Bottom window;} | 1007 | @result{} 0 |
| 157 | ; @r{top is line 15} | 1008 | (window-total-size W1) |
| 158 | @end group | 1009 | @result{} 15 |
| 159 | @group | 1010 | (window-top-line W2) |
| 160 | (window-edges w) | 1011 | @result{} 15 |
| 161 | @result{} (0 0 80 15) ; @r{Top window} | ||
| 162 | @end group | 1012 | @end group |
| 163 | @end smallexample | 1013 | @end smallexample |
| 164 | 1014 | ||
| @@ -168,34 +1018,30 @@ The screen looks like this: | |||
| 168 | @group | 1018 | @group |
| 169 | __________ | 1019 | __________ |
| 170 | | | line 0 | 1020 | | | line 0 |
| 171 | | w | | 1021 | | W1 | |
| 172 | |__________| | 1022 | |__________| |
| 173 | | | line 15 | 1023 | | | line 15 |
| 174 | | w2 | | 1024 | | W2 | |
| 175 | |__________| | 1025 | |__________| |
| 176 | line 50 | 1026 | line 50 |
| 177 | column 0 column 80 | 1027 | column 0 column 80 |
| 178 | @end group | 1028 | @end group |
| 179 | @end smallexample | 1029 | @end smallexample |
| 180 | 1030 | ||
| 181 | Next, split the top window horizontally: | 1031 | Next, split the top window into two side-by-side windows: |
| 182 | 1032 | ||
| 183 | @smallexample | 1033 | @smallexample |
| 184 | @group | 1034 | @group |
| 185 | (setq w3 (split-window w 35 t)) | 1035 | (setq W3 (split-window W1 35 t)) |
| 186 | @result{} #<window 32 on windows.texi> | 1036 | @result{} #<window 32 on windows.texi> |
| 187 | @end group | 1037 | @end group |
| 188 | @group | 1038 | @group |
| 189 | (window-edges w3) | 1039 | (window-left-column W1) |
| 190 | @result{} (35 0 80 15) ; @r{Left edge at column 35} | 1040 | @result{} 0 |
| 191 | @end group | 1041 | (window-total-size W1 t) |
| 192 | @group | 1042 | @result{} 35 |
| 193 | (window-edges w) | 1043 | (window-left-column W3) |
| 194 | @result{} (0 0 35 15) ; @r{Right edge at column 35} | 1044 | @result{} 35 |
| 195 | @end group | ||
| 196 | @group | ||
| 197 | (window-edges w2) | ||
| 198 | @result{} (0 15 80 50) ; @r{Bottom window unchanged} | ||
| 199 | @end group | 1045 | @end group |
| 200 | @end smallexample | 1046 | @end smallexample |
| 201 | 1047 | ||
| @@ -206,11 +1052,11 @@ Now the screen looks like this: | |||
| 206 | @group | 1052 | @group |
| 207 | column 35 | 1053 | column 35 |
| 208 | __________ | 1054 | __________ |
| 209 | | | | line 0 | 1055 | | | | line 0 |
| 210 | | w | w3 | | 1056 | | W1 | W3 | |
| 211 | |___|______| | 1057 | |____|_____| |
| 212 | | | line 15 | 1058 | | | line 15 |
| 213 | | w2 | | 1059 | | W2 | |
| 214 | |__________| | 1060 | |__________| |
| 215 | line 50 | 1061 | line 50 |
| 216 | column 0 column 80 | 1062 | column 0 column 80 |
| @@ -221,9 +1067,492 @@ Normally, Emacs indicates the border between two side-by-side windows | |||
| 221 | with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The | 1067 | with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The |
| 222 | display table can specify alternative border characters; see @ref{Display | 1068 | display table can specify alternative border characters; see @ref{Display |
| 223 | Tables}. | 1069 | Tables}. |
| 224 | @end deffn | ||
| 225 | 1070 | ||
| 226 | @deffn Command split-window-vertically &optional size | 1071 | Below we describe how @code{split-window} can be used to create the |
| 1072 | window configuration from our earlier example (@pxref{Windows and | ||
| 1073 | Frames}) and how internal windows are created for this purpose. We | ||
| 1074 | start with a frame containing one live window @code{W2} (in the | ||
| 1075 | following scenarios window names are assigned in an arbitrary manner in | ||
| 1076 | order to match the names of the example). Evaluating the form | ||
| 1077 | @code{(split-window W2 8 t)} creates a new internal window @code{W1} | ||
| 1078 | with two children---@code{W2} (the window we've split) and a new leaf | ||
| 1079 | window @code{W6}: | ||
| 1080 | @smallexample | ||
| 1081 | @group | ||
| 1082 | ______________________________________ | ||
| 1083 | | ______ ____________________________ | | ||
| 1084 | || || || | ||
| 1085 | || || || | ||
| 1086 | || || || | ||
| 1087 | || || || | ||
| 1088 | || || || | ||
| 1089 | || || || | ||
| 1090 | || || || | ||
| 1091 | || || || | ||
| 1092 | || || || | ||
| 1093 | || || || | ||
| 1094 | ||__W2__||_____________W6_____________ | | ||
| 1095 | |__________________W1__________________| | ||
| 1096 | |||
| 1097 | @end group | ||
| 1098 | @end smallexample | ||
| 1099 | |||
| 1100 | Evaluating now @code{(split-window W6 -3)} creates another internal | ||
| 1101 | window @code{W3} with two children---@code{W6} and a new live window | ||
| 1102 | @code{W5}. This leaves us with a vertically combined window @code{W3} | ||
| 1103 | embedded in the horizontally combined window @code{W1}: | ||
| 1104 | @smallexample | ||
| 1105 | @group | ||
| 1106 | ______________________________________ | ||
| 1107 | | ______ ____________________________ | | ||
| 1108 | || || __________________________ || | ||
| 1109 | || ||| ||| | ||
| 1110 | || ||| ||| | ||
| 1111 | || ||| ||| | ||
| 1112 | || ||| ||| | ||
| 1113 | || ||| ||| | ||
| 1114 | || |||____________W6____________||| | ||
| 1115 | || || __________________________ || | ||
| 1116 | || ||| ||| | ||
| 1117 | || |||____________W5____________||| | ||
| 1118 | ||__W2__||_____________W3_____________ | | ||
| 1119 | |__________________W1__________________| | ||
| 1120 | |||
| 1121 | @end group | ||
| 1122 | @end smallexample | ||
| 1123 | |||
| 1124 | Finally, evaluating @code{(split-window W6 nil t)} should get us the | ||
| 1125 | desired configuration as depicted below. | ||
| 1126 | @smallexample | ||
| 1127 | @group | ||
| 1128 | ______________________________________ | ||
| 1129 | | ______ ____________________________ | | ||
| 1130 | || || __________________________ || | ||
| 1131 | || ||| ___________ ___________ ||| | ||
| 1132 | || |||| || |||| | ||
| 1133 | || |||| || |||| | ||
| 1134 | || ||||_____W6____||_____W7____|||| | ||
| 1135 | || |||____________W4____________||| | ||
| 1136 | || || __________________________ || | ||
| 1137 | || ||| ||| | ||
| 1138 | || |||____________W5____________||| | ||
| 1139 | ||__W2__||_____________W3_____________ | | ||
| 1140 | |__________________W1__________________| | ||
| 1141 | |||
| 1142 | @end group | ||
| 1143 | @end smallexample | ||
| 1144 | |||
| 1145 | The scenario sketched above is the standard way to obtain the desired | ||
| 1146 | configuration. In Emacs 23 it was also the only way to do that since | ||
| 1147 | Emacs 23 did't allow splitting internal windows. | ||
| 1148 | |||
| 1149 | With Emacs 24 you can also proceed as follows: Split an initial window | ||
| 1150 | @code{W6} by evaluating @code{(split-window W6 -3)} to produce the | ||
| 1151 | following vertical combination: | ||
| 1152 | @smallexample | ||
| 1153 | @group | ||
| 1154 | ______________________________________ | ||
| 1155 | | ____________________________________ | | ||
| 1156 | || || | ||
| 1157 | || || | ||
| 1158 | || || | ||
| 1159 | || || | ||
| 1160 | || || | ||
| 1161 | || || | ||
| 1162 | || || | ||
| 1163 | ||_________________W6_________________|| | ||
| 1164 | | ____________________________________ | | ||
| 1165 | || || | ||
| 1166 | ||_________________W5_________________|| | ||
| 1167 | |__________________W3__________________| | ||
| 1168 | |||
| 1169 | @end group | ||
| 1170 | @end smallexample | ||
| 1171 | |||
| 1172 | Evaluating now @code{(split-window (window-parent W6) -8 'left)} or, | ||
| 1173 | equivalently, @code{(split-window W3 -8 'left)} should now produce the | ||
| 1174 | penultimate configuration from the previous scenario from where we can | ||
| 1175 | continue as described before. | ||
| 1176 | |||
| 1177 | Another strategy starts with splitting an inital window @code{W6} by | ||
| 1178 | evaluating @code{(split-window W6 nil nil t)} with the following result: | ||
| 1179 | @smallexample | ||
| 1180 | @group | ||
| 1181 | ______________________________________ | ||
| 1182 | | _________________ _________________ | | ||
| 1183 | || || || | ||
| 1184 | || || || | ||
| 1185 | || || || | ||
| 1186 | || || || | ||
| 1187 | || || || | ||
| 1188 | || || || | ||
| 1189 | || || || | ||
| 1190 | || || || | ||
| 1191 | || || || | ||
| 1192 | || || || | ||
| 1193 | ||________W6_______||________W7_______|| | ||
| 1194 | |__________________W4__________________| | ||
| 1195 | |||
| 1196 | @end group | ||
| 1197 | @end smallexample | ||
| 1198 | |||
| 1199 | Evaluating now @code{(split-window W4 -3)} or @code{(split-window | ||
| 1200 | (window-parent W6) -3)} should get us a configuration as shown next. | ||
| 1201 | @smallexample | ||
| 1202 | @group | ||
| 1203 | ______________________________________ | ||
| 1204 | | ____________________________________ | | ||
| 1205 | || ________________ ________________ || | ||
| 1206 | ||| || ||| | ||
| 1207 | ||| || ||| | ||
| 1208 | ||| || ||| | ||
| 1209 | ||| || ||| | ||
| 1210 | ||| || ||| | ||
| 1211 | |||_______W6_______||________W7______||| | ||
| 1212 | ||_________________W4_________________|| | ||
| 1213 | | ____________________________________ | | ||
| 1214 | || || | ||
| 1215 | ||_________________W5_________________|| | ||
| 1216 | |__________________W3__________________| | ||
| 1217 | |||
| 1218 | @end group | ||
| 1219 | @end smallexample | ||
| 1220 | |||
| 1221 | The desired configuration can be now obtained by evaluating | ||
| 1222 | @code{(split-window W3 -8 'left)} or, equivalently, @code{(split-window | ||
| 1223 | (window-parent W5) -8 'left)}. | ||
| 1224 | |||
| 1225 | For a final approach let's start with the configuration of two live | ||
| 1226 | windows @code{W6} and @code{W7} shown above. If we now evaluate | ||
| 1227 | @code{(split-window W4 -8 'left)} or @code{(split-window (window-parent | ||
| 1228 | W6) -8 'left)} we get the following configuration. | ||
| 1229 | @smallexample | ||
| 1230 | @group | ||
| 1231 | ______________________________________ | ||
| 1232 | | ______ ____________________________ | | ||
| 1233 | || || ____________ ____________ || | ||
| 1234 | || ||| || ||| | ||
| 1235 | || ||| || ||| | ||
| 1236 | || ||| || ||| | ||
| 1237 | || ||| || ||| | ||
| 1238 | || ||| || ||| | ||
| 1239 | || ||| || ||| | ||
| 1240 | || ||| || ||| | ||
| 1241 | || |||______W6____||______W7____||| | ||
| 1242 | ||__W2__||_____________W4_____________|| | ||
| 1243 | |__________________W1__________________| | ||
| 1244 | |||
| 1245 | @end group | ||
| 1246 | @end smallexample | ||
| 1247 | |||
| 1248 | Evaluating now @code{(split-window W4 -3)} or, for example, | ||
| 1249 | @code{(split-window (window-parent W6) -3)} should produce the desired | ||
| 1250 | configuration. | ||
| 1251 | |||
| 1252 | The two options described next can be used to tune the operation of | ||
| 1253 | @code{split-window}. | ||
| 1254 | |||
| 1255 | @defopt window-splits | ||
| 1256 | If this variable is nil, the function @code{split-window} can split a | ||
| 1257 | window if and only if that window's screen estate is sufficiently large | ||
| 1258 | to accomodate both--itself and the new window. | ||
| 1259 | |||
| 1260 | If this variable is non-@code{nil}, @code{split-window} tries to resize | ||
| 1261 | all windows that are part of the same combination as the old window to | ||
| 1262 | accomodate the new window. Hence, the new window can be also created if | ||
| 1263 | the old window is of fixed size or too small to split (@pxref{Window | ||
| 1264 | Sizes}). | ||
| 1265 | |||
| 1266 | In any case, the value of this variable is assigned to the splits status | ||
| 1267 | of the new window and, provided old and new window form a new | ||
| 1268 | combination, of the old window as well. The splits status of a window | ||
| 1269 | can be retrieved by invoking the function @code{window-splits} and | ||
| 1270 | altered by the function @code{set-window-splits} described next. | ||
| 1271 | |||
| 1272 | If @code{window-nest} (see below) is non-@code{nil}, the space for the | ||
| 1273 | new window is exclusively taken from the old window, but the splits | ||
| 1274 | status of the involved windows is nevertheless set as described here. | ||
| 1275 | @end defopt | ||
| 1276 | |||
| 1277 | @defun window-splits &optional window | ||
| 1278 | This function returns the splits status of @var{window}. The argument | ||
| 1279 | @var{window} can be any window and defaults to the selected one. | ||
| 1280 | |||
| 1281 | @cindex splits status | ||
| 1282 | The @dfn{splits status} of a window specifies how resizing and deleting | ||
| 1283 | that window may affect the size of other windows in the same window | ||
| 1284 | combination. More precisely, if @var{window}'s splits status is | ||
| 1285 | @code{nil} and @var{window} is resized, the corresponding space is | ||
| 1286 | preferably taken from (or given to) @var{window}'s right sibling. When | ||
| 1287 | @var{window} is deleted, its space is given to its left sibling. If | ||
| 1288 | @var{window}'s splits status is non-@code{nil}, resizing and deleting | ||
| 1289 | @var{window} may resize @emph{all} windows in @var{window}'s | ||
| 1290 | combination. | ||
| 1291 | |||
| 1292 | The splits status is initially set by @code{split-window} | ||
| 1293 | from the current value of the variable @code{window-splits} (see above) | ||
| 1294 | and can be reset by the function @code{set-window-splits} (see below). | ||
| 1295 | @end defun | ||
| 1296 | |||
| 1297 | @defun set-window-splits window &optional status | ||
| 1298 | This function sets the splits status (see above) of @var{window} to | ||
| 1299 | @var{status}. The argument @var{window} can be any window and defaults | ||
| 1300 | to the selected one. The return value is @var{status}. | ||
| 1301 | @end defun | ||
| 1302 | |||
| 1303 | To illustrate the use of @code{window-splits} consider the following | ||
| 1304 | window configuration: | ||
| 1305 | @smallexample | ||
| 1306 | @group | ||
| 1307 | ______________________________________ | ||
| 1308 | | ____________________________________ | | ||
| 1309 | || || | ||
| 1310 | || || | ||
| 1311 | || || | ||
| 1312 | || || | ||
| 1313 | ||_________________W2_________________|| | ||
| 1314 | | ____________________________________ | | ||
| 1315 | || || | ||
| 1316 | || || | ||
| 1317 | || || | ||
| 1318 | || || | ||
| 1319 | ||_________________W3_________________|| | ||
| 1320 | |__________________W1__________________| | ||
| 1321 | |||
| 1322 | @end group | ||
| 1323 | @end smallexample | ||
| 1324 | |||
| 1325 | Splitting window @code{W3} with @code{window-splits} @code{nil} | ||
| 1326 | produces a configuration where the size of @code{W2} remains unchanged: | ||
| 1327 | @smallexample | ||
| 1328 | @group | ||
| 1329 | ______________________________________ | ||
| 1330 | | ____________________________________ | | ||
| 1331 | || || | ||
| 1332 | || || | ||
| 1333 | || || | ||
| 1334 | || || | ||
| 1335 | ||_________________W2_________________|| | ||
| 1336 | | ____________________________________ | | ||
| 1337 | || || | ||
| 1338 | ||_________________W3_________________|| | ||
| 1339 | | ____________________________________ | | ||
| 1340 | || || | ||
| 1341 | ||_________________W4_________________|| | ||
| 1342 | |__________________W1__________________| | ||
| 1343 | |||
| 1344 | @end group | ||
| 1345 | @end smallexample | ||
| 1346 | |||
| 1347 | Splitting @code{W3} with @code{window-splits} non-@code{nil} instead | ||
| 1348 | produces a configuration where all windows have approximately the same | ||
| 1349 | height: | ||
| 1350 | |||
| 1351 | @smallexample | ||
| 1352 | @group | ||
| 1353 | ______________________________________ | ||
| 1354 | | ____________________________________ | | ||
| 1355 | || || | ||
| 1356 | || || | ||
| 1357 | ||_________________W2_________________|| | ||
| 1358 | | ____________________________________ | | ||
| 1359 | || || | ||
| 1360 | || || | ||
| 1361 | ||_________________W3_________________|| | ||
| 1362 | | ____________________________________ | | ||
| 1363 | || || | ||
| 1364 | || || | ||
| 1365 | ||_________________W4_________________|| | ||
| 1366 | |__________________W1__________________| | ||
| 1367 | |||
| 1368 | @end group | ||
| 1369 | @end smallexample | ||
| 1370 | |||
| 1371 | @defopt window-nest | ||
| 1372 | If this variable is @code{nil}, @code{split-window} creates a new parent | ||
| 1373 | window if and only if the old window has no parent window or shall be | ||
| 1374 | split orthogonally to the combination it is part of. If this variable | ||
| 1375 | is non-@code{nil}, @code{split-window} always creates a new parent | ||
| 1376 | window. If this variable is always non-@code{nil}, a frame's window | ||
| 1377 | tree is a binary tree so every window but the frame's root window has | ||
| 1378 | exactly one sibling. | ||
| 1379 | |||
| 1380 | The value of this variable is also assigned to the nest status of the | ||
| 1381 | new parent window. The nest status of any window can be retrieved via | ||
| 1382 | the function @code{window-nest} and altered by the function | ||
| 1383 | @code{set-window-nest}, see below. | ||
| 1384 | @end defopt | ||
| 1385 | |||
| 1386 | @defun window-nest &optional window | ||
| 1387 | This function returns the nest status of @var{window}. The argument | ||
| 1388 | @var{window} can be any window and defaults to the selected one. Note, | ||
| 1389 | however, that the nest status is currently meaningful for internal | ||
| 1390 | windows only. | ||
| 1391 | |||
| 1392 | @cindex nest status | ||
| 1393 | The @dfn{nest status} of a window specifies whether that window may be | ||
| 1394 | removed and its subwindows recombined with that window's siblings when | ||
| 1395 | such a sibling's subwindow is deleted. The nest status is initially | ||
| 1396 | assigned by @code{split-window} from the current value of the variable | ||
| 1397 | @code{window-nest} (see above) and can be reset by the function | ||
| 1398 | @code{set-window-nest} (see below). | ||
| 1399 | |||
| 1400 | If the return value is @code{nil}, subwindows of @var{window} may be | ||
| 1401 | recombined with @var{window}'s siblings when a window gets deleted. A | ||
| 1402 | return value of @code{nil} means that subwindows of @var{window} are | ||
| 1403 | never (re-)combined with @var{window}'s siblings in such a case. | ||
| 1404 | @end defun | ||
| 1405 | |||
| 1406 | @defun set-window-nest window &optional status | ||
| 1407 | This functions sets the nest status (see above) of @var{window} to | ||
| 1408 | @var{status}. The argument @var{window} can be any window and defaults | ||
| 1409 | to the selected one. Note that setting the nest status is meaningful | ||
| 1410 | for internal windows only. The return value is @var{status}. | ||
| 1411 | @end defun | ||
| 1412 | |||
| 1413 | To illustrate the use of @code{window-nest} consider the following | ||
| 1414 | configuration (throughout the following examples we shall assume that | ||
| 1415 | @code{window-splits} invariantly is @code{nil}). | ||
| 1416 | @smallexample | ||
| 1417 | @group | ||
| 1418 | ______________________________________ | ||
| 1419 | | ____________________________________ | | ||
| 1420 | || || | ||
| 1421 | || || | ||
| 1422 | || || | ||
| 1423 | || || | ||
| 1424 | || || | ||
| 1425 | || || | ||
| 1426 | ||_________________W2_________________|| | ||
| 1427 | | ____________________________________ | | ||
| 1428 | || || | ||
| 1429 | || || | ||
| 1430 | ||_________________W3_________________|| | ||
| 1431 | |__________________W1__________________| | ||
| 1432 | |||
| 1433 | @end group | ||
| 1434 | @end smallexample | ||
| 1435 | |||
| 1436 | Splitting @code{W2} into two windows above each other with | ||
| 1437 | @code{window-nest} equal @code{nil} will get you a configuration like: | ||
| 1438 | @smallexample | ||
| 1439 | @group | ||
| 1440 | ______________________________________ | ||
| 1441 | | ____________________________________ | | ||
| 1442 | || || | ||
| 1443 | || || | ||
| 1444 | ||_________________W2_________________|| | ||
| 1445 | | ____________________________________ | | ||
| 1446 | || || | ||
| 1447 | || || | ||
| 1448 | ||_________________W4_________________|| | ||
| 1449 | | ____________________________________ | | ||
| 1450 | || || | ||
| 1451 | || || | ||
| 1452 | ||_________________W3_________________|| | ||
| 1453 | |__________________W1__________________| | ||
| 1454 | |||
| 1455 | @end group | ||
| 1456 | @end smallexample | ||
| 1457 | |||
| 1458 | If you now enlarge window @code{W4}, Emacs steals the necessary space | ||
| 1459 | from window @code{W3} resulting in a configuration like: | ||
| 1460 | @smallexample | ||
| 1461 | @group | ||
| 1462 | ______________________________________ | ||
| 1463 | | ____________________________________ | | ||
| 1464 | || || | ||
| 1465 | || || | ||
| 1466 | ||_________________W2_________________|| | ||
| 1467 | | ____________________________________ | | ||
| 1468 | || || | ||
| 1469 | || || | ||
| 1470 | || || | ||
| 1471 | ||_________________W4_________________|| | ||
| 1472 | | ____________________________________ | | ||
| 1473 | || || | ||
| 1474 | ||_________________W3_________________|| | ||
| 1475 | |__________________W1__________________| | ||
| 1476 | |||
| 1477 | @end group | ||
| 1478 | @end smallexample | ||
| 1479 | |||
| 1480 | Deleting window @code{W4}, will return its space to @code{W2} as | ||
| 1481 | follows: | ||
| 1482 | @smallexample | ||
| 1483 | @group | ||
| 1484 | ______________________________________ | ||
| 1485 | | ____________________________________ | | ||
| 1486 | || || | ||
| 1487 | || || | ||
| 1488 | || || | ||
| 1489 | || || | ||
| 1490 | || || | ||
| 1491 | || || | ||
| 1492 | || || | ||
| 1493 | ||_________________W2_________________|| | ||
| 1494 | | ____________________________________ | | ||
| 1495 | || || | ||
| 1496 | ||_________________W3_________________|| | ||
| 1497 | |__________________W1__________________| | ||
| 1498 | |||
| 1499 | @end group | ||
| 1500 | @end smallexample | ||
| 1501 | |||
| 1502 | Hence, with respect to the initial configuration, window @code{W2} has | ||
| 1503 | grown at the expense of window @code{W3}. If, however, in the initial | ||
| 1504 | configuration you had split @code{W2} with @code{window-nest} bound to | ||
| 1505 | @code{t}, a new internal window @code{W5} would have been created as | ||
| 1506 | depicted below. | ||
| 1507 | @smallexample | ||
| 1508 | @group | ||
| 1509 | ______________________________________ | ||
| 1510 | | ____________________________________ | | ||
| 1511 | || __________________________________ || | ||
| 1512 | ||| ||| | ||
| 1513 | |||________________W2________________||| | ||
| 1514 | || __________________________________ || | ||
| 1515 | ||| ||| | ||
| 1516 | |||________________W4________________||| | ||
| 1517 | ||_________________W5_________________|| | ||
| 1518 | | ____________________________________ | | ||
| 1519 | || || | ||
| 1520 | || || | ||
| 1521 | ||_________________W3_________________|| | ||
| 1522 | |__________________W1__________________| | ||
| 1523 | |||
| 1524 | @end group | ||
| 1525 | @end smallexample | ||
| 1526 | |||
| 1527 | Enlarging @code{W4} would now have stolen the necessary space from | ||
| 1528 | @code{W2} instead of @code{W3} as | ||
| 1529 | @smallexample | ||
| 1530 | @group | ||
| 1531 | ______________________________________ | ||
| 1532 | | ____________________________________ | | ||
| 1533 | || __________________________________ || | ||
| 1534 | |||________________W2________________||| | ||
| 1535 | || __________________________________ || | ||
| 1536 | ||| ||| | ||
| 1537 | ||| ||| | ||
| 1538 | |||________________W4________________||| | ||
| 1539 | ||_________________W5_________________|| | ||
| 1540 | | ____________________________________ | | ||
| 1541 | || || | ||
| 1542 | || || | ||
| 1543 | ||_________________W3_________________|| | ||
| 1544 | |__________________W1__________________| | ||
| 1545 | |||
| 1546 | @end group | ||
| 1547 | @end smallexample | ||
| 1548 | |||
| 1549 | and the subsequent deletion of @code{W4} would have restored the initial | ||
| 1550 | configuration. | ||
| 1551 | |||
| 1552 | For interactive use, Emacs provides two commands which always split the | ||
| 1553 | selected window. | ||
| 1554 | |||
| 1555 | @deffn Command split-window-above-each-other &optional size | ||
| 227 | This function splits the selected window into two windows, one above the | 1556 | This function splits the selected window into two windows, one above the |
| 228 | other, leaving the upper of the two windows selected, with @var{size} | 1557 | other, leaving the upper of the two windows selected, with @var{size} |
| 229 | lines. (If @var{size} is negative, then the lower of the two windows | 1558 | lines. (If @var{size} is negative, then the lower of the two windows |
| @@ -232,76 +1561,30 @@ the upper window is still the one selected.) However, if | |||
| 232 | @code{split-window-keep-point} (see below) is @code{nil}, then either | 1561 | @code{split-window-keep-point} (see below) is @code{nil}, then either |
| 233 | window can be selected. | 1562 | window can be selected. |
| 234 | 1563 | ||
| 235 | In other respects, this function is similar to @code{split-window}. | 1564 | In other respects, this function is similar to @code{split-window}. |
| 236 | In particular, the upper window is the original one and the return | 1565 | In particular, the upper window is the original one and the return value |
| 237 | value is the new, lower window. | 1566 | is the new, lower window. |
| 238 | @end deffn | 1567 | @end deffn |
| 239 | 1568 | ||
| 240 | @defopt split-window-keep-point | 1569 | @defopt split-window-keep-point |
| 241 | If this variable is non-@code{nil} (the default), then | 1570 | If this variable is non-@code{nil} (the default), then |
| 242 | @code{split-window-vertically} behaves as described above. | 1571 | @code{split-window-above-each-other} behaves as described above. |
| 243 | |||
| 244 | If it is @code{nil}, then @code{split-window-vertically} adjusts point | ||
| 245 | in each of the two windows to avoid scrolling. (This is useful on | ||
| 246 | slow terminals.) It selects whichever window contains the screen line | ||
| 247 | that point was previously on. | ||
| 248 | 1572 | ||
| 249 | This variable affects the behavior of @code{split-window-vertically} | 1573 | If it is @code{nil}, then @code{split-window-above-each-other} |
| 250 | only. It has no effect on the other functions described here. | 1574 | adjusts point in each of the two windows to avoid scrolling. (This is |
| 1575 | useful on slow terminals.) It selects whichever window contains the | ||
| 1576 | screen line that point was previously on. Other functions are not | ||
| 1577 | affected by this variable. | ||
| 251 | @end defopt | 1578 | @end defopt |
| 252 | 1579 | ||
| 253 | @deffn Command split-window-horizontally &optional size | 1580 | @deffn Command split-window-side-by-side &optional size |
| 254 | This function splits the selected window into two windows | 1581 | This function splits the selected window into two windows |
| 255 | side-by-side, leaving the selected window on the left with @var{size} | 1582 | side-by-side, leaving the selected window on the left with @var{size} |
| 256 | columns. If @var{size} is negative, the rightmost window gets | 1583 | columns. If @var{size} is negative, the rightmost window gets |
| 257 | @minus{}@var{size} columns, but the leftmost window still remains | 1584 | @minus{}@var{size} columns, but the leftmost window still remains |
| 258 | selected. | 1585 | selected. |
| 259 | |||
| 260 | This function is basically an interface to @code{split-window}. | ||
| 261 | You could define a simplified version of the function like this: | ||
| 262 | |||
| 263 | @smallexample | ||
| 264 | @group | ||
| 265 | (defun split-window-horizontally (&optional arg) | ||
| 266 | "Split selected window into two windows, side by side..." | ||
| 267 | (interactive "P") | ||
| 268 | @end group | ||
| 269 | @group | ||
| 270 | (let ((size (and arg (prefix-numeric-value arg)))) | ||
| 271 | (and size (< size 0) | ||
| 272 | (setq size (+ (window-width) size))) | ||
| 273 | (split-window nil size t))) | ||
| 274 | @end group | ||
| 275 | @end smallexample | ||
| 276 | @end deffn | 1586 | @end deffn |
| 277 | 1587 | ||
| 278 | @defun one-window-p &optional no-mini all-frames | ||
| 279 | This function returns non-@code{nil} if there is only one window. The | ||
| 280 | argument @var{no-mini}, if non-@code{nil}, means don't count the | ||
| 281 | minibuffer even if it is active; otherwise, the minibuffer window is | ||
| 282 | counted when it is active. | ||
| 283 | |||
| 284 | The argument @var{all-frames} specifies which frames to consider. Here | ||
| 285 | are the possible values and their meanings: | ||
| 286 | |||
| 287 | @table @asis | ||
| 288 | @item @code{nil} | ||
| 289 | Count the windows in the selected frame, plus the minibuffer used | ||
| 290 | by that frame even if it lies in some other frame. | ||
| 291 | |||
| 292 | @item @code{t} | ||
| 293 | Count all windows in all existing frames. | ||
| 294 | |||
| 295 | @item @code{visible} | ||
| 296 | Count all windows in all visible frames. | ||
| 297 | |||
| 298 | @item 0 | ||
| 299 | Count all windows in all visible or iconified frames. | ||
| 300 | |||
| 301 | @item anything else | ||
| 302 | Count precisely the windows in the selected frame, and no others. | ||
| 303 | @end table | ||
| 304 | @end defun | ||
| 305 | 1588 | ||
| 306 | @node Deleting Windows | 1589 | @node Deleting Windows |
| 307 | @section Deleting Windows | 1590 | @section Deleting Windows |
| @@ -313,105 +1596,110 @@ appear on the screen, but continues to exist as a Lisp object until | |||
| 313 | there are no references to it. There is no way to cancel the deletion | 1596 | there are no references to it. There is no way to cancel the deletion |
| 314 | of a window aside from restoring a saved window configuration | 1597 | of a window aside from restoring a saved window configuration |
| 315 | (@pxref{Window Configurations}). Restoring a window configuration also | 1598 | (@pxref{Window Configurations}). Restoring a window configuration also |
| 316 | deletes any windows that aren't part of that configuration. | 1599 | deletes any windows that aren't part of that configuration. Erroneous |
| 317 | 1600 | information may result from using a deleted window as if it were live. | |
| 318 | When you delete a window, the space it took up is given to one of | ||
| 319 | its sibling windows adjacent to it. | ||
| 320 | |||
| 321 | @c Emacs 19 feature | ||
| 322 | @defun window-live-p window | ||
| 323 | This function returns @code{nil} if @var{window} is deleted, and | ||
| 324 | @code{t} otherwise. | ||
| 325 | |||
| 326 | @strong{Warning:} Erroneous information or fatal errors may result from | ||
| 327 | using a deleted window as if it were live. | ||
| 328 | @end defun | ||
| 329 | 1601 | ||
| 330 | @deffn Command delete-window &optional window | 1602 | @deffn Command delete-window &optional window |
| 331 | This function removes @var{window} from display and returns @code{nil}. | 1603 | This function removes @var{window} from display and returns @code{nil}. |
| 332 | The default for @var{window} is the selected window. An error is | 1604 | The argument @var{window} can denote any window and defaults to the |
| 333 | signaled if @var{window} is the only window on its frame. | 1605 | selected one. An error is signaled if @var{window} is the only window |
| 1606 | on its frame. Hence @var{window} must have at least one sibling window | ||
| 1607 | (@pxref{Windows and Frames}) in order to get deleted. | ||
| 1608 | |||
| 1609 | If the variable @code{ignore-window-parameters} (@pxref{Window | ||
| 1610 | Parameters}) is non-@code{nil}, this function ignores all parameters of | ||
| 1611 | @var{window}. Otherwise, if the @code{delete-window} parameter of | ||
| 1612 | @var{window} is @code{t}, it deletes the window disregarding other | ||
| 1613 | window parameters. If the @code{delete-window} parameter specifies a | ||
| 1614 | function, that function is called with @var{window} as its sole | ||
| 1615 | argument. | ||
| 1616 | |||
| 1617 | If the splits status of @var{window} (@pxref{Splitting Windows}) is | ||
| 1618 | @code{nil}, the space @var{window} took up is given to its left sibling | ||
| 1619 | if such a window exists and to its right sibling otherwise. If the | ||
| 1620 | splits status of @var{window} is non-@code{nil}, its space is | ||
| 1621 | proportionally distributed among the remaining windows in the same | ||
| 1622 | combination. | ||
| 334 | @end deffn | 1623 | @end deffn |
| 335 | 1624 | ||
| 336 | @deffn Command delete-other-windows &optional window | 1625 | @deffn Command delete-other-windows &optional window |
| 337 | This function makes @var{window} the only window on its frame, by | 1626 | This function makes @var{window} fill its frame and returns @code{nil}. |
| 338 | deleting the other windows in that frame. The default for @var{window} | 1627 | The argument @var{window} can denote an arbitrary window and defaults to |
| 339 | is the selected window. The return value is @code{nil}. | 1628 | the selected one. |
| 1629 | |||
| 1630 | If the variable @code{ignore-window-parameters} (@pxref{Window | ||
| 1631 | Parameters}) is non-@code{nil}, this function ignores all parameters of | ||
| 1632 | @var{window}. Otherwise, if the @code{delete-other-windows} parameter | ||
| 1633 | of @var{window} equals @code{t}, it deletes all other windows | ||
| 1634 | disregarding any remaining window parameters. If the | ||
| 1635 | @code{delete-other-windows} parameter of @var{window} specifies a | ||
| 1636 | function, it calls that function with @var{window} as its sole argument. | ||
| 340 | @end deffn | 1637 | @end deffn |
| 341 | 1638 | ||
| 342 | @deffn Command delete-windows-on &optional buffer-or-name frame | 1639 | @deffn Command delete-windows-on &optional buffer-or-name frame |
| 343 | This function deletes all windows showing @var{buffer-or-name}. If | 1640 | This function deletes all windows showing @var{buffer-or-name} and |
| 344 | there are no windows showing @var{buffer-or-name}, it does nothing. The | 1641 | returns nil. If there are no windows showing @var{buffer-or-name}, it |
| 345 | optional argument @var{buffer-or-name} may be a buffer or the name of an | 1642 | does nothing. The optional argument @var{buffer-or-name} may be a |
| 346 | existing buffer and defaults to the current buffer. | 1643 | buffer or the name of an existing buffer and defaults to the current |
| 347 | 1644 | buffer. Invoking this command on a minibuffer signals an error. | |
| 348 | @code{delete-windows-on} operates frame by frame. If a frame has | 1645 | |
| 349 | several windows showing different buffers, then those showing | 1646 | The function @code{delete-windows-on} operates by calling |
| 350 | @var{buffer-or-name} are removed, and the others expand to fill the | 1647 | @code{delete-window} for each window showing @var{buffer-or-name}. If a |
| 351 | space. If all windows in some frame are showing @var{buffer-or-name} | 1648 | frame has several windows showing different buffers, then those showing |
| 352 | (including the case where there is only one window), then the frame | 1649 | @var{buffer-or-name} are removed, and the other windows expand to fill |
| 353 | winds up with a single window showing another buffer chosen with | 1650 | the space. |
| 354 | @code{other-buffer} (@pxref{The Buffer List}). If, however, the window | 1651 | |
| 355 | showing @var{buffer-or-name} is dedicated to its buffer | 1652 | If all windows in some frame are showing @var{buffer-or-name} (including |
| 356 | (@pxref{Dedicated Windows}), and there are other frames left, that | 1653 | the case where there is only one window), then that frame is deleted |
| 357 | window's frame is deleted. | 1654 | provided there are other frames left. |
| 358 | 1655 | ||
| 359 | The optional argument @var{frame} specifies which frames to operate on. | 1656 | The optional argument @var{frame} specifies which frames to operate on. |
| 360 | This function does not use it in quite the same way as the other | 1657 | This function does not use it in quite the same way as the other |
| 361 | functions which scan all windows; specifically, the values @code{t} and | 1658 | functions which scan all live windows (@pxref{Cyclic Window Ordering}); |
| 362 | @code{nil} have the opposite of their meanings in other functions. Here | 1659 | specifically, the values @code{t} and @code{nil} have the opposite of |
| 363 | are the full details: | 1660 | their meanings in the other functions. Here are the full details: |
| 364 | 1661 | ||
| 365 | @itemize @bullet | 1662 | @itemize @bullet |
| 366 | @item | 1663 | @item @code{nil} |
| 367 | If it is @code{nil}, operate on all frames. | 1664 | means operate on all frames. |
| 368 | @item | 1665 | @item @code{t} |
| 369 | If it is @code{t}, operate on the selected frame. | 1666 | means operate on the selected frame. |
| 370 | @item | 1667 | @item @code{visible} |
| 371 | If it is @code{visible}, operate on all visible frames. | 1668 | means operate on all visible frames. |
| 372 | @item | 1669 | @item @code{0} |
| 373 | If it is 0, operate on all visible or iconified frames. | 1670 | means operate on all visible or iconified frames. |
| 374 | @item | 1671 | @item A frame |
| 375 | If it is a frame, operate on that frame. | 1672 | means operate on that frame. |
| 376 | @end itemize | 1673 | @end itemize |
| 377 | |||
| 378 | This function always returns @code{nil}. | ||
| 379 | @end deffn | 1674 | @end deffn |
| 380 | 1675 | ||
| 1676 | |||
| 381 | @node Selecting Windows | 1677 | @node Selecting Windows |
| 382 | @section Selecting Windows | 1678 | @section Selecting Windows |
| 383 | @cindex selecting a window | 1679 | @cindex selecting a window |
| 384 | 1680 | ||
| 385 | When a window is selected, the buffer in the window becomes the current | ||
| 386 | buffer, and the cursor will appear in it. | ||
| 387 | |||
| 388 | @defun selected-window | ||
| 389 | This function returns the selected window. This is the window in | ||
| 390 | which the cursor appears and to which many commands apply. | ||
| 391 | @end defun | ||
| 392 | |||
| 393 | @defun select-window window &optional norecord | 1681 | @defun select-window window &optional norecord |
| 394 | This function makes @var{window} the selected window. The cursor then | 1682 | This function makes @var{window} the selected window, see @ref{Basic |
| 395 | appears in @var{window} (after redisplay). Unless @var{window} was | 1683 | Windows}. Unless @var{window} already is the selected window, this also |
| 396 | already selected, @code{select-window} makes @var{window}'s buffer the | 1684 | makes @var{window}'s buffer (@pxref{Buffers and Windows}) the current |
| 397 | current buffer. The return value is @var{window}. | 1685 | buffer. Moreover, the cursor for selected windows will be displayed in |
| 1686 | @var{window} after the next redisplay. This function returns | ||
| 1687 | @var{window}. | ||
| 398 | 1688 | ||
| 399 | Normally, @var{window}'s selected buffer is moved to the front of the | 1689 | Normally, @var{window}'s selected buffer is moved to the front of the |
| 400 | buffer list (@pxref{The Buffer List}) and @var{window} becomes the most | 1690 | buffer list (@pxref{The Buffer List}) and @var{window} becomes the most |
| 401 | recently selected window. But if @var{norecord} is non-@code{nil}, the | 1691 | recently selected window. But if the optional argument @var{norecord} |
| 402 | buffer list remains unchanged and @var{window} does not become the most | 1692 | is non-@code{nil}, the buffer list remains unchanged and @var{window} |
| 403 | recently selected one. | 1693 | does not become the most recently selected one. |
| 404 | |||
| 405 | |||
| 406 | @example | ||
| 407 | @group | ||
| 408 | (setq w (next-window)) | ||
| 409 | (select-window w) | ||
| 410 | @result{} #<window 65 on windows.texi> | ||
| 411 | @end group | ||
| 412 | @end example | ||
| 413 | @end defun | 1694 | @end defun |
| 414 | 1695 | ||
| 1696 | @cindex most recently selected windows | ||
| 1697 | The sequence of calls to @code{select-window} with a non-@code{nil} | ||
| 1698 | @var{norecord} argument determines an ordering of windows by their | ||
| 1699 | selection time. The function @code{get-lru-window} can be used to | ||
| 1700 | retrieve the least recently selected live window in this ordering, see | ||
| 1701 | @ref{Cyclic Window Ordering}. | ||
| 1702 | |||
| 415 | @defmac save-selected-window forms@dots{} | 1703 | @defmac save-selected-window forms@dots{} |
| 416 | This macro records the selected frame, as well as the selected window | 1704 | This macro records the selected frame, as well as the selected window |
| 417 | of each frame, executes @var{forms} in sequence, then restores the | 1705 | of each frame, executes @var{forms} in sequence, then restores the |
| @@ -437,138 +1725,105 @@ restores the previously selected window and current buffer. The ordering | |||
| 437 | of recently selected windows and the buffer list remain unchanged unless | 1725 | of recently selected windows and the buffer list remain unchanged unless |
| 438 | you deliberately change them within @var{forms}, for example, by calling | 1726 | you deliberately change them within @var{forms}, for example, by calling |
| 439 | @code{select-window} with argument @var{norecord} @code{nil}. | 1727 | @code{select-window} with argument @var{norecord} @code{nil}. |
| 440 | @end defmac | ||
| 441 | |||
| 442 | @cindex finding windows | ||
| 443 | The following functions choose one of the windows on the screen, | ||
| 444 | offering various criteria for the choice. | ||
| 445 | |||
| 446 | @defun get-lru-window &optional frame dedicated | ||
| 447 | This function returns the window least recently ``used'' (that is, | ||
| 448 | selected) among a set of candidate windows. If any full-width windows | ||
| 449 | are present, it only considers these. | ||
| 450 | |||
| 451 | The selected window is returned if it is the only candidate. A | ||
| 452 | minibuffer window is never a candidate. A dedicated window | ||
| 453 | (@pxref{Dedicated Windows}) is never a candidate unless the optional | ||
| 454 | argument @var{dedicated} is non-@code{nil}. | ||
| 455 | 1728 | ||
| 456 | The optional argument @var{frame} specifies which windows are | 1729 | The order of recently selected windows and the buffer list are not |
| 457 | considered. | 1730 | changed by this macro. |
| 1731 | @end defmac | ||
| 458 | 1732 | ||
| 459 | @itemize @bullet | 1733 | @cindex frame selected window |
| 460 | @item | 1734 | @cindex window selected within frame |
| 461 | If it is @code{nil}, consider windows on the selected frame. | 1735 | Earlier (@pxref{Basic Windows}) we mentioned that at any time, exactly |
| 462 | @item | 1736 | one window on any frame is selected within the frame. The significance |
| 463 | If it is @code{t}, consider windows on all frames. | 1737 | of this designation is that selecting the frame also selects this |
| 464 | @item | 1738 | window. Conversely, selecting a window for Emacs with |
| 465 | If it is @code{visible}, consider windows on all visible frames. | 1739 | @code{select-window} also makes that window selected within its frame. |
| 466 | @item | 1740 | |
| 467 | If it is 0, consider windows on all visible or iconified frames. | 1741 | @defun frame-selected-window &optional frame |
| 468 | @item | 1742 | This function returns the window on @var{frame} that is selected within |
| 469 | If it is a frame, consider windows on that frame. | 1743 | @var{frame}. The optional argument @var{frame} must denote a live frame |
| 470 | @end itemize | 1744 | and defaults to the selected one. |
| 471 | @end defun | 1745 | @end defun |
| 472 | 1746 | ||
| 473 | @defun get-largest-window &optional frame dedicated | 1747 | @defun set-frame-selected-window frame window &optional norecord |
| 474 | This function returns the window with the largest area (height times | 1748 | This function sets the selected window of frame @var{frame} to |
| 475 | width). If there are no side-by-side windows, then this is the window | 1749 | @var{window}. The argument @var{frame} must denote a live frame and |
| 476 | with the most lines. A minibuffer window is never a candidate. A | 1750 | defaults to the selected one. If @var{frame} is the selected frame, |
| 477 | dedicated window (@pxref{Dedicated Windows}) is never a candidate unless | 1751 | this also makes @var{window} the selected window. The argument |
| 478 | the optional argument @var{dedicated} is non-@code{nil}. | 1752 | @var{window} must denote a live window. This function returns |
| 479 | 1753 | @var{window}. | |
| 480 | If there are two candidate windows of the same size, this function | 1754 | |
| 481 | prefers the one that comes first in the cyclic ordering of windows, | 1755 | Optional argument @var{norecord} non-@code{nil} means to neither change |
| 482 | starting from the selected window (@pxref{Cyclic Window Ordering}). | 1756 | the list of most recently selected windows (@pxref{Selecting Windows}) |
| 483 | 1757 | nor the buffer list (@pxref{The Buffer List}). | |
| 484 | The optional argument @var{frame} specifies which set of windows to | ||
| 485 | consider, see @code{get-lru-window} above. | ||
| 486 | @end defun | 1758 | @end defun |
| 487 | 1759 | ||
| 488 | @cindex window that satisfies a predicate | ||
| 489 | @cindex conditional selection of windows | ||
| 490 | @defun get-window-with-predicate predicate &optional minibuf all-frames default | ||
| 491 | This function returns a window satisfying @var{predicate}. It cycles | ||
| 492 | through all visible windows using @code{walk-windows} (@pxref{Cyclic | ||
| 493 | Window Ordering}), calling @var{predicate} on each one of them with that | ||
| 494 | window as its argument. The function returns the first window for which | ||
| 495 | @var{predicate} returns a non-@code{nil} value; if that never happens, | ||
| 496 | it returns @var{default} (which defaults to @code{nil}). | ||
| 497 | |||
| 498 | The optional arguments @var{minibuf} and @var{all-frames} specify the | ||
| 499 | set of windows to include in the scan. See the description of | ||
| 500 | @code{next-window} in @ref{Cyclic Window Ordering}, for details. | ||
| 501 | @end defun | ||
| 502 | 1760 | ||
| 503 | @node Cyclic Window Ordering | 1761 | @node Cyclic Window Ordering |
| 504 | @comment node-name, next, previous, up | ||
| 505 | @section Cyclic Ordering of Windows | 1762 | @section Cyclic Ordering of Windows |
| 506 | @cindex cyclic ordering of windows | 1763 | @cindex cyclic ordering of windows |
| 507 | @cindex ordering of windows, cyclic | 1764 | @cindex ordering of windows, cyclic |
| 508 | @cindex window ordering, cyclic | 1765 | @cindex window ordering, cyclic |
| 509 | 1766 | ||
| 510 | When you use the command @kbd{C-x o} (@code{other-window}) to select | 1767 | When you use the command @kbd{C-x o} (@code{other-window}) to select |
| 511 | some other window, it moves through the windows on the screen in a | 1768 | some other window, it moves through live windows in a specific order. |
| 512 | specific order. For any given configuration of windows, this order | 1769 | For any given configuration of windows, this order never varies. It is |
| 513 | never varies. It is called the @dfn{cyclic ordering of windows}. | 1770 | called the @dfn{cyclic ordering of windows}. |
| 514 | 1771 | ||
| 515 | For a particular frame, this ordering generally goes from top to | 1772 | For a particular frame, this ordering is determined by the window |
| 516 | bottom, and from left to right. But it may go down first or go right | 1773 | tree of that frame, see @ref{Windows and Frames}. More precisely, the |
| 517 | first, depending on the order in which windows were split. | 1774 | ordering is obtained by a depth-first traversal of the frame's window |
| 1775 | tree supplemented, if requested, by the frame's minibuffer window. | ||
| 518 | 1776 | ||
| 519 | If the first split was vertical (into windows one above each other), | 1777 | If there's just one live frame, the cyclic ordering is the ordering |
| 520 | and then the subwindows were split horizontally, then the ordering is | 1778 | for that frame. Otherwise, the cyclic ordering is obtained by appending |
| 521 | left to right in the top of the frame, and then left to right in the | 1779 | the orderings for individual frames in order of the list of all live |
| 522 | next lower part of the frame, and so on. If the first split was | 1780 | frames, @ref{Finding All Frames}. In any case, the ordering is made |
| 523 | horizontal, the ordering is top to bottom in the left part, and so on. | 1781 | ``cyclic'' by having the last window precede the first window in the |
| 524 | In general, within each set of siblings at any level in the window tree | 1782 | ordering. |
| 525 | (@pxref{Window Tree}), the order is left to right, or top to bottom. | ||
| 526 | 1783 | ||
| 527 | @defun next-window &optional window minibuf all-frames | 1784 | @defun next-window &optional window minibuf all-frames |
| 528 | @cindex minibuffer window, and @code{next-window} | 1785 | @cindex minibuffer window, and @code{next-window} |
| 529 | This function returns the window following @var{window} in the cyclic | 1786 | This function returns the window following @var{window} in the cyclic |
| 530 | ordering of windows. This is the window @kbd{C-x o} selects if typed | 1787 | ordering of windows. The argument @var{window} must specify a live |
| 531 | when @var{window} is selected. The default for @var{window} is the | 1788 | window and defaults to the selected one. |
| 532 | selected window. | ||
| 533 | 1789 | ||
| 534 | The value of the optional argument @var{minibuf} specifies whether the | 1790 | The optional argument @var{minibuf} specifies whether minibuffer windows |
| 535 | minibuffer is included in the window order. Normally, when | 1791 | shall be included in the cyclic ordering. Normally, when @var{minibuf} |
| 536 | @var{minibuf} is @code{nil}, the minibuffer is included only if it is | 1792 | is @code{nil}, a minibuffer window is included only if it is currently |
| 537 | currently ``active''; this matches the behavior of @kbd{C-x o}. (The | 1793 | ``active''; this matches the behavior of @kbd{C-x o}. (Note that a |
| 538 | minibuffer window is active while the minibuffer is in use; see | 1794 | minibuffer window is active as long as its minibuffer is in use; see |
| 539 | @ref{Minibuffers}.) | 1795 | @ref{Minibuffers}). |
| 540 | 1796 | ||
| 541 | If @var{minibuf} is @code{t}, the cyclic ordering includes the | 1797 | If @var{minibuf} is @code{t}, the cyclic ordering includes all |
| 542 | minibuffer window even if it is not active. If @var{minibuf} is neither | 1798 | minibuffer windows. If @var{minibuf} is neither @code{t} nor |
| 543 | @code{t} nor @code{nil}, the minibuffer window is not included even if | 1799 | @code{nil}, minibuffer windows are not included even if they are active. |
| 544 | it is active. | ||
| 545 | 1800 | ||
| 546 | The optional argument @var{all-frames} specifies which frames to | 1801 | The optional argument @var{all-frames} specifies which frames to |
| 547 | consider. Here are the possible values and their meanings: | 1802 | consider. Here are the possible values and their meanings: |
| 548 | 1803 | ||
| 549 | @table @asis | 1804 | @itemize @bullet |
| 550 | @item @code{nil} | 1805 | @item @code{nil} |
| 551 | Consider all the windows in @var{window}'s frame, plus the minibuffer | 1806 | means consider all windows on @var{window}'s frame, plus the minibuffer |
| 552 | used by that frame even if it lies in some other frame. If the | 1807 | window used by that frame even if it lies in some other frame. If the |
| 553 | minibuffer counts (as determined by @var{minibuf}), then all windows on | 1808 | minibuffer counts (as determined by @var{minibuf}), then all windows on |
| 554 | all frames that share that minibuffer count too. | 1809 | all frames that share that minibuffer count too. |
| 555 | 1810 | ||
| 556 | @item @code{t} | 1811 | @item @code{t} |
| 557 | Consider all windows in all existing frames. | 1812 | means consider all windows on all existing frames. |
| 558 | 1813 | ||
| 559 | @item @code{visible} | 1814 | @item @code{visible} |
| 560 | Consider all windows in all visible frames. (To get useful results, you | 1815 | means consider all windows on all visible frames. (To get useful |
| 561 | must ensure @var{window} is in a visible frame.) | 1816 | results, ensure that @var{window} is on a visible frame.) |
| 562 | 1817 | ||
| 563 | @item 0 | 1818 | @item 0 |
| 564 | Consider all windows in all visible or iconified frames. | 1819 | means consider all windows on all visible or iconified frames. |
| 565 | 1820 | ||
| 566 | @item a frame | 1821 | @item A frame |
| 567 | Consider all windows on that frame. | 1822 | means consider all windows on that frame. |
| 568 | 1823 | ||
| 569 | @item anything else | 1824 | @item Anything else |
| 570 | Consider precisely the windows in @var{window}'s frame, and no others. | 1825 | means consider the windows on @var{window}'s frame, and no others. |
| 571 | @end table | 1826 | @end itemize |
| 572 | 1827 | ||
| 573 | This example assumes there are two windows, both displaying the | 1828 | This example assumes there are two windows, both displaying the |
| 574 | buffer @samp{windows.texi}: | 1829 | buffer @samp{windows.texi}: |
| @@ -592,7 +1847,7 @@ buffer @samp{windows.texi}: | |||
| 592 | @defun previous-window &optional window minibuf all-frames | 1847 | @defun previous-window &optional window minibuf all-frames |
| 593 | This function returns the window preceding @var{window} in the cyclic | 1848 | This function returns the window preceding @var{window} in the cyclic |
| 594 | ordering of windows. The other arguments specify which windows to | 1849 | ordering of windows. The other arguments specify which windows to |
| 595 | include in the cycle, as in @code{next-window}. | 1850 | consider as in @code{next-window}. |
| 596 | @end defun | 1851 | @end defun |
| 597 | 1852 | ||
| 598 | @deffn Command other-window count &optional all-frames | 1853 | @deffn Command other-window count &optional all-frames |
| @@ -608,80 +1863,153 @@ prefix argument. | |||
| 608 | The optional argument @var{all-frames} has the same meaning as in | 1863 | The optional argument @var{all-frames} has the same meaning as in |
| 609 | @code{next-window}, but the @var{minibuf} argument of @code{next-window} | 1864 | @code{next-window}, but the @var{minibuf} argument of @code{next-window} |
| 610 | is always effectively @code{nil}. This function returns @code{nil}. | 1865 | is always effectively @code{nil}. This function returns @code{nil}. |
| 1866 | |||
| 1867 | This function does not select a window that has a non-@code{nil} | ||
| 1868 | @code{no-other-window} window parameter (@pxref{Window Parameters}). | ||
| 611 | @end deffn | 1869 | @end deffn |
| 612 | 1870 | ||
| 613 | @c Emacs 19 feature | 1871 | The following function returns a copy of the list of windows in the |
| 1872 | cyclic odering. | ||
| 1873 | |||
| 1874 | @defun window-list-1 &optional window &optional minibuf &optional all_frames | ||
| 1875 | This function returns a list of live windows. The optional arguments | ||
| 1876 | @var{minibuf} and @var{all-frames} specify the set of windows to include | ||
| 1877 | in the list. See the description of @code{next-window} for details. | ||
| 1878 | |||
| 1879 | The optional argument @var{window} specifies the first window to list | ||
| 1880 | and defaults to the selected window. If @var{window} is not on the list | ||
| 1881 | of windows returned, some other window will be listed first but no error | ||
| 1882 | is signalled. | ||
| 1883 | @end defun | ||
| 1884 | |||
| 1885 | The functions described below use @code{window-list-1} for generating a | ||
| 1886 | copy of the list of all relevant windows. Hence, any change of the | ||
| 1887 | window configuration that occurs while one of these functions is | ||
| 1888 | executed is @emph{not} reflected in the list of windows investigated. | ||
| 1889 | |||
| 614 | @defun walk-windows proc &optional minibuf all-frames | 1890 | @defun walk-windows proc &optional minibuf all-frames |
| 615 | This function cycles through all windows. It calls the function | 1891 | This function cycles through live windows. It calls the function |
| 616 | @code{proc} once for each window, with the window as its sole | 1892 | @var{proc} once for each window, with the window as its sole argument. |
| 617 | argument. | ||
| 618 | 1893 | ||
| 619 | The optional arguments @var{minibuf} and @var{all-frames} specify the | 1894 | The optional arguments @var{minibuf} and @var{all-frames} specify the |
| 620 | set of windows to include in the walk. See @code{next-window}, above, | 1895 | set of windows to include in the walk, see @code{next-window} above. If |
| 621 | for details. | 1896 | @var{all-frames} specifies a frame, the first window walked is the first |
| 1897 | window on that frame as returned by @code{frame-first-window} and not | ||
| 1898 | necessarily the selected window. | ||
| 1899 | |||
| 1900 | If @var{proc} changes the window configuration by splitting or deleting | ||
| 1901 | windows, that change is not reflected in the set of windows walked. | ||
| 1902 | That set is determined entirely by the set of live windows at the time | ||
| 1903 | this function was invoked. | ||
| 622 | @end defun | 1904 | @end defun |
| 623 | 1905 | ||
| 624 | @defun window-list &optional frame minibuf window | 1906 | The following function allows to determine whether a specific window is |
| 625 | This function returns a list of all windows on @var{frame}, starting | 1907 | the only live window. |
| 626 | with @var{window}. The default for @var{frame} is the selected frame; | ||
| 627 | the default for @var{window} is the selected window. | ||
| 628 | 1908 | ||
| 629 | The value of @var{minibuf} specifies if the minibuffer window shall be | 1909 | @defun one-window-p &optional no-mini all-frames |
| 630 | included in the result list. If @var{minibuf} is @code{t}, the result | 1910 | This function returns non-@code{nil} if the selected window is the only |
| 631 | always includes the minibuffer window. If @var{minibuf} is @code{nil} | 1911 | window. |
| 632 | or omitted, that includes the minibuffer window if it is active. If | 1912 | |
| 633 | @var{minibuf} is neither @code{nil} nor @code{t}, the result never | 1913 | The optional argument @var{no-mini}, if non-@code{nil}, means don't |
| 634 | includes the minibuffer window. | 1914 | count the minibuffer even if it is active; otherwise, the minibuffer |
| 1915 | window is counted when it is active. The optional argument | ||
| 1916 | @var{all-frames} has the same meaning as for @code{next-window}, see | ||
| 1917 | above. | ||
| 1918 | @end defun | ||
| 1919 | |||
| 1920 | @cindex finding windows | ||
| 1921 | The following functions choose (but do not select) one of the windows | ||
| 1922 | on the screen, offering various criteria for the choice. | ||
| 1923 | |||
| 1924 | @cindex least recently used window | ||
| 1925 | @defun get-lru-window &optional all-frames dedicated | ||
| 1926 | This function returns the window least recently ``used'' (that is, | ||
| 1927 | selected). If any full-width windows are present, it only considers | ||
| 1928 | these. The optional argument @var{all-frames} has the same meaning as | ||
| 1929 | in @code{next-window}. | ||
| 1930 | |||
| 1931 | The selected window is returned if it is the only candidate. A | ||
| 1932 | minibuffer window is never a candidate. A dedicated window | ||
| 1933 | (@pxref{Dedicated Windows}) is never a candidate unless the optional | ||
| 1934 | argument @var{dedicated} is non-@code{nil}. | ||
| 1935 | @end defun | ||
| 1936 | |||
| 1937 | @cindex largest window | ||
| 1938 | @defun get-largest-window &optional all-frames dedicated | ||
| 1939 | This function returns the window with the largest area (height times | ||
| 1940 | width). A minibuffer window is never a candidate. A dedicated window | ||
| 1941 | (@pxref{Dedicated Windows}) is never a candidate unless the optional | ||
| 1942 | argument @var{dedicated} is non-@code{nil}. | ||
| 1943 | |||
| 1944 | If there are two candidate windows of the same size, this function | ||
| 1945 | prefers the one that comes first in the cyclic ordering of windows, | ||
| 1946 | starting from the selected window. | ||
| 1947 | |||
| 1948 | The optional argument @var{all-frames} specifies which set of windows to | ||
| 1949 | consider as with @code{next-window}, see above. | ||
| 1950 | @end defun | ||
| 1951 | |||
| 1952 | @cindex window that satisfies a predicate | ||
| 1953 | @cindex conditional selection of windows | ||
| 1954 | @defun get-window-with-predicate predicate &optional minibuf all-frames default | ||
| 1955 | This function returns a window satisfying @var{predicate}. It cycles | ||
| 1956 | through all visible windows calling @var{predicate} on each one of them | ||
| 1957 | with that window as its argument. The function returns the first window | ||
| 1958 | for which @var{predicate} returns a non-@code{nil} value; if that never | ||
| 1959 | happens, it returns @var{default} (which defaults to @code{nil}). | ||
| 1960 | |||
| 1961 | The optional arguments @var{minibuf} and @var{all-frames} specify the | ||
| 1962 | set of windows to investigate. See the description of | ||
| 1963 | @code{next-window} for details. | ||
| 635 | @end defun | 1964 | @end defun |
| 636 | 1965 | ||
| 1966 | |||
| 637 | @node Buffers and Windows | 1967 | @node Buffers and Windows |
| 638 | @section Buffers and Windows | 1968 | @section Buffers and Windows |
| 639 | @cindex examining windows | 1969 | @cindex examining windows |
| 640 | @cindex windows, controlling precisely | 1970 | @cindex windows, controlling precisely |
| 641 | @cindex buffers, controlled in windows | 1971 | @cindex buffers, controlled in windows |
| 642 | 1972 | ||
| 643 | This section describes low-level functions to examine windows or to | 1973 | To find out which buffer is displayed in a given window the following |
| 644 | display buffers in windows in a precisely controlled fashion. | 1974 | function is used. |
| 645 | @iftex | ||
| 646 | See the following section for | ||
| 647 | @end iftex | ||
| 648 | @ifnottex | ||
| 649 | @xref{Displaying Buffers}, for | ||
| 650 | @end ifnottex | ||
| 651 | related functions that find a window to use and specify a buffer for it. | ||
| 652 | The functions described there are easier to use, but they employ | ||
| 653 | heuristics in choosing or creating a window; use the functions described | ||
| 654 | here when you need complete control. | ||
| 655 | 1975 | ||
| 656 | @defun set-window-buffer window buffer-or-name &optional keep-margins | 1976 | @defun window-buffer &optional window |
| 657 | This function makes @var{window} display @var{buffer-or-name} as its | 1977 | This function returns the buffer that @var{window} is displaying. The |
| 658 | contents. It returns @code{nil}. The default for @var{window} is the | 1978 | argument @var{window} can be any window and defaults to the selected |
| 659 | selected window. The argument @var{buffer-or-name} must specify a | 1979 | one. If @var{window} is an internal window, this function returns |
| 660 | buffer or the name of an existing buffer. | 1980 | @code{nil}. |
| 1981 | @end defun | ||
| 661 | 1982 | ||
| 662 | @code{set-window-buffer} is the fundamental primitive for changing which | 1983 | The basic, low-level function to associate a window with a buffer is |
| 663 | buffer is displayed in a window, and all ways of doing that call this | 1984 | @code{set-window-buffer}. Higher-level functions like |
| 664 | function. | 1985 | @code{display-buffer} try to obey a number of user customizations |
| 1986 | regulating which windows are supposed to display which buffers. When | ||
| 1987 | writing an application, programmers should therefore carefully evaluate | ||
| 1988 | whether they really need the power of @code{set-window-buffer}. | ||
| 665 | 1989 | ||
| 666 | @example | 1990 | @defun set-window-buffer window buffer-or-name &optional keep-margins |
| 667 | @group | 1991 | This function makes @var{window} display @var{buffer-or-name} and |
| 668 | (set-window-buffer (selected-window) "foo") | 1992 | returns @code{nil}. The argument @var{window} has to denote a live |
| 669 | @result{} nil | 1993 | window and defaults to the selected one. The argument |
| 670 | @end group | 1994 | @var{buffer-or-name} must specify a buffer or the name of an existing |
| 671 | @end example | 1995 | buffer. An error is signalled when @var{window} is @dfn{strongly} |
| 1996 | dedicated to its buffer (@pxref{Dedicated Windows}) and does not already | ||
| 1997 | display @var{buffer-or-name}. | ||
| 672 | 1998 | ||
| 673 | Normally, displaying @var{buffer-or-name} in @var{window} resets the | 1999 | Normally, displaying @var{buffer-or-name} in @var{window} resets the |
| 674 | window's position, display margins, fringe widths, and scroll bar | 2000 | window's position, display margins, fringe widths, and scroll bar |
| 675 | settings based on the local variables of that buffer. | 2001 | settings based on the local variables of the specified buffer. However, |
| 676 | However, if @var{keep-margins} is non-@code{nil}, display margins and | 2002 | if the optional argument @var{keep-margins} is non-@code{nil}, display |
| 677 | fringe widths of @var{window} remain unchanged. @xref{Fringes}. | 2003 | margins and fringe widths of @var{window} remain unchanged. |
| 678 | 2004 | @xref{Fringes}. | |
| 679 | @code{set-window-buffer} signals an error when @var{window} is | 2005 | |
| 680 | @dfn{strongly} dedicated to its buffer (@pxref{Dedicated Windows}) and | 2006 | This function is the fundamental primitive for changing which buffer is |
| 681 | does not already display @var{buffer-or-name}. | 2007 | displayed in a window, and all ways of doing that call this function. |
| 2008 | Neither the selected window nor the current buffer are changed by this | ||
| 2009 | function. | ||
| 682 | 2010 | ||
| 683 | Note that this function runs @code{window-scroll-functions} before | 2011 | This function runs @code{window-scroll-functions} before running |
| 684 | running @code{window-configuration-change-hook}. | 2012 | @code{window-configuration-change-hook}, see @ref{Window Hooks}. |
| 685 | @end defun | 2013 | @end defun |
| 686 | 2014 | ||
| 687 | @defvar buffer-display-count | 2015 | @defvar buffer-display-count |
| @@ -690,26 +2018,22 @@ displayed in a window. It is incremented each time | |||
| 690 | @code{set-window-buffer} is called for the buffer. | 2018 | @code{set-window-buffer} is called for the buffer. |
| 691 | @end defvar | 2019 | @end defvar |
| 692 | 2020 | ||
| 693 | @defun window-buffer &optional window | 2021 | @defvar buffer-display-time |
| 694 | This function returns the buffer that @var{window} is displaying. The | 2022 | This variable records the time at which a buffer was last made visible |
| 695 | default for @var{window} is the selected window. | 2023 | in a window. It is always local in each buffer; each time |
| 696 | 2024 | @code{set-window-buffer} is called, it sets this variable to | |
| 697 | @example | 2025 | @code{(current-time)} in the specified buffer (@pxref{Time of Day}). |
| 698 | @group | 2026 | When a buffer is first created, @code{buffer-display-time} starts out |
| 699 | (window-buffer) | 2027 | with the value @code{nil}. |
| 700 | @result{} #<buffer windows.texi> | 2028 | @end defvar |
| 701 | @end group | ||
| 702 | @end example | ||
| 703 | @end defun | ||
| 704 | 2029 | ||
| 705 | @defun get-buffer-window &optional buffer-or-name all-frames | 2030 | @defun get-buffer-window &optional buffer-or-name all-frames |
| 706 | This function returns a window currently displaying | 2031 | This function returns a window displaying @var{buffer-or-name}, or |
| 707 | @var{buffer-or-name}, or @code{nil} if there is none. If there are | 2032 | @code{nil} if there is none. If there are several such windows, then |
| 708 | several such windows, then the function returns the first one in the | 2033 | the function returns the first one in the cyclic ordering of windows, |
| 709 | cyclic ordering of windows, starting from the selected window. | 2034 | starting from the selected window, @xref{Cyclic Window Ordering}. |
| 710 | @xref{Cyclic Window Ordering}. | ||
| 711 | 2035 | ||
| 712 | The argument @var{BUFFER-OR-NAME} may be a buffer or a buffer name and | 2036 | The argument @var{buffer-or-name} may be a buffer or a buffer name and |
| 713 | defaults to the current buffer. The optional argument @var{all-frames} | 2037 | defaults to the current buffer. The optional argument @var{all-frames} |
| 714 | specifies which windows to consider: | 2038 | specifies which windows to consider: |
| 715 | 2039 | ||
| @@ -739,18 +2063,146 @@ This function returns a list of all windows currently displaying | |||
| 739 | or the name of an existing buffer and defaults to the current buffer. | 2063 | or the name of an existing buffer and defaults to the current buffer. |
| 740 | 2064 | ||
| 741 | The two remaining arguments work like the same-named arguments of | 2065 | The two remaining arguments work like the same-named arguments of |
| 742 | @code{next-window}; they are @emph{not} like the optional arguments of | 2066 | @code{next-window} (@pxref{Cyclic Window Ordering}); they are @emph{not} |
| 743 | @code{get-buffer-window}. | 2067 | like the optional arguments of @code{get-buffer-window}. |
| 744 | @end defun | 2068 | @end defun |
| 745 | 2069 | ||
| 746 | @defvar buffer-display-time | 2070 | The following command removes a buffer from all windows showing it. |
| 747 | This variable records the time at which a buffer was last made visible | 2071 | |
| 748 | in a window. It is always local in each buffer; each time | 2072 | @deffn Command replace-buffer-in-windows &optional buffer-or-name |
| 749 | @code{set-window-buffer} is called, it sets this variable to | 2073 | This function replaces @var{buffer-or-name} in all windows displaying it |
| 750 | @code{(current-time)} in the specified buffer (@pxref{Time of Day}). | 2074 | with some other buffer. It uses @code{switch-to-prev-buffer}, see |
| 751 | When a buffer is first created, @code{buffer-display-time} starts out | 2075 | below, to choose that other buffer which is usually the last buffer |
| 752 | with the value @code{nil}. | 2076 | displayed before @var{buffer-or-name} in the respective window. |
| 753 | @end defvar | 2077 | |
| 2078 | The argument @var{buffer-or-name} may be a buffer or the name of an | ||
| 2079 | existing buffer and defaults to the current buffer. | ||
| 2080 | |||
| 2081 | If a window displaying @var{buffer-or-name} is dedicated | ||
| 2082 | (@pxref{Dedicated Windows}) has never displayed any other buffers and is | ||
| 2083 | not the only window on its frame, that window is deleted. If that | ||
| 2084 | window is the only window on its frame and there are other frames left, | ||
| 2085 | the window's frame is deleted too. If there are no other frames left, | ||
| 2086 | some other buffer is displayed in that window as explained above. You | ||
| 2087 | can prevent the deletion of windows and/or frames by customizing the | ||
| 2088 | option @var{window-auto-delete}. | ||
| 2089 | |||
| 2090 | This function returns @code{nil}. | ||
| 2091 | @end deffn | ||
| 2092 | |||
| 2093 | When @code{replace-buffer-in-windows} has to show another buffer in a | ||
| 2094 | window, it tries to pick the buffer shown there before. For this | ||
| 2095 | purpose each window remembers the buffers it has displayed earlier and | ||
| 2096 | the order in which these buffers have been removed from it. | ||
| 2097 | |||
| 2098 | The list of @dfn{previous buffers} of a window is an association list | ||
| 2099 | where each entry specifies a buffer, the last start position of that | ||
| 2100 | buffer in the window (@pxref{Window Start and End}) and the last | ||
| 2101 | position of that buffer's point in the window (@pxref{Window Point}). | ||
| 2102 | This list is ordered by the times of the removal of the respective | ||
| 2103 | buffers from the window. In particular, the first element of the list | ||
| 2104 | references the buffer removed most recently. The function | ||
| 2105 | @code{set-window-buffer} pushes an entry for the old buffer of its | ||
| 2106 | window argument on that list before it shows its buffer argument in the | ||
| 2107 | window. | ||
| 2108 | |||
| 2109 | The list of @dfn{next buffers} of a window is a list of buffers that | ||
| 2110 | have been recently re-shown by the function @code{switch-to-prev-buffer} | ||
| 2111 | and is used to avoid that that function switches to such a buffer again | ||
| 2112 | before showing other interesting buffers. | ||
| 2113 | |||
| 2114 | The lists of previous and next buffers and the global buffer list | ||
| 2115 | (@pxref{The Buffer List}) allow to effectively display all buffers in a | ||
| 2116 | window while giving preference to the buffers previously shown in that | ||
| 2117 | window. The commands used for this purpose are | ||
| 2118 | @code{switch-to-prev-buffer} and @code{switch-to-next-buffer} described | ||
| 2119 | below. | ||
| 2120 | |||
| 2121 | The following functions directly operate on the lists of previous and | ||
| 2122 | next buffers. | ||
| 2123 | |||
| 2124 | @defun window-prev-buffers &optional window | ||
| 2125 | This function returns an alist specifying the buffers previously shown | ||
| 2126 | in @var{window} together with their window start and point positions. | ||
| 2127 | The argument @var{window} must be a live window and defaults to the | ||
| 2128 | selected one. | ||
| 2129 | @end defun | ||
| 2130 | |||
| 2131 | @defun set-window-prev-buffers window prev-buffers | ||
| 2132 | This function sets @var{window}'s previous buffers to the value of | ||
| 2133 | @var{prev-buffers}. The argument @var{window} must be a live window and | ||
| 2134 | defaults to the selected one. This function returns | ||
| 2135 | @var{prev-buffers}. | ||
| 2136 | |||
| 2137 | If non-@code{nil}, @var{prev-buffers} must specify an alist of triples | ||
| 2138 | specifying a buffer and two markers for that buffer's start and point | ||
| 2139 | position in @var{window}. | ||
| 2140 | @end defun | ||
| 2141 | |||
| 2142 | @defun window-next-buffers &optional window | ||
| 2143 | This function returns the list of buffers recently re-shown in | ||
| 2144 | @var{window}. The argument @var{window} must be a live window and | ||
| 2145 | defaults to the selected one. | ||
| 2146 | @end defun | ||
| 2147 | |||
| 2148 | @defun set-window-next-buffers window next-buffers | ||
| 2149 | This function sets @var{window}'s next buffers to @var{next-buffers}. | ||
| 2150 | @var{window} must be a live window and defaults to the selected one. | ||
| 2151 | This fucntion returns @var{next-buffers}. | ||
| 2152 | |||
| 2153 | If non-@code{nil}, the argument @var{next-buffers} should specify a list | ||
| 2154 | of buffers that shall be preferably not shown by the command | ||
| 2155 | @code{switch-to-prev-buffer}, see below. | ||
| 2156 | @end defun | ||
| 2157 | |||
| 2158 | The following command is used by @code{replace-buffer-in-windows}, | ||
| 2159 | @code{bury-buffer} and @code{quit-window} to show another buffer in a | ||
| 2160 | window. It can be also used interactively to cycle through the list of | ||
| 2161 | all buffers in a window, preferably showing the buffers recently shown | ||
| 2162 | (but not buried or killed) in that window. | ||
| 2163 | |||
| 2164 | @deffn Command switch-to-prev-buffer &optional window bury-or-kill | ||
| 2165 | This function displays the previous buffer in @var{window}. The | ||
| 2166 | argument @var{window} must be a live window and defaults to the selected | ||
| 2167 | one. If the optional argument @var{bury-or-kill} is non-@code{nil}, | ||
| 2168 | this means that the buffer currently shown in @var{window} is about to | ||
| 2169 | be buried or killed and consequently shall not be switched to in future | ||
| 2170 | invocations of this command. | ||
| 2171 | |||
| 2172 | The previous buffer is usually the buffer shown before the buffer | ||
| 2173 | currently shown in @var{window}. However, a buffer that has been buried | ||
| 2174 | or killed or has been already shown by a recent invocation of | ||
| 2175 | @code{switch-to-prev-buffer} does not qualify as previous buffer. | ||
| 2176 | |||
| 2177 | If repeated invocations of this command have already shown all buffers | ||
| 2178 | previously shown in @var{window}, further invocations will show buffers | ||
| 2179 | from the global buffer list starting with the buffer returned by | ||
| 2180 | @code{last-buffer} (@pxref{The Buffer List}). | ||
| 2181 | @end deffn | ||
| 2182 | |||
| 2183 | The following command can be used to undo the effect of the last undone | ||
| 2184 | @code{switch-to-prev-buffer} command. | ||
| 2185 | |||
| 2186 | @deffn Command switch-to-next-buffer &optional window | ||
| 2187 | This functions switches to the next buffer in @var{window} thus undoing | ||
| 2188 | the effect of the last @code{switch-to-prev-buffer} command in | ||
| 2189 | @var{window}. The argument @var{window} must be a live window and | ||
| 2190 | defaults to the selected one. | ||
| 2191 | |||
| 2192 | If there is no recent invocation of a @code{switch-to-prev-buffer} that | ||
| 2193 | can be undone, @code{switch-to-next-buffer} will try to show the first | ||
| 2194 | buffer from the global buffer list as returned by @code{other-buffer} | ||
| 2195 | (@pxref{The Buffer List}). | ||
| 2196 | @end deffn | ||
| 2197 | |||
| 2198 | Together, @code{switch-to-prev-buffer} and | ||
| 2199 | @code{switch-to-next-buffer} permit to navigate the global buffer list | ||
| 2200 | much like @code{bury-buffer} and @code{unbury-buffer}. In contrast with | ||
| 2201 | the latter, however, they may show a buffer even if it is already shown | ||
| 2202 | in another window. Moreover, they try to restore the window specific | ||
| 2203 | start and point positions of buffers which should handle viewing one and | ||
| 2204 | the same buffer in multiple windows more easily. | ||
| 2205 | |||
| 754 | 2206 | ||
| 755 | @node Displaying Buffers | 2207 | @node Displaying Buffers |
| 756 | @section Displaying Buffers in Windows | 2208 | @section Displaying Buffers in Windows |
| @@ -1931,370 +3383,6 @@ is off the screen due to horizontal scrolling: | |||
| 1931 | @end group | 3383 | @end group |
| 1932 | @end example | 3384 | @end example |
| 1933 | 3385 | ||
| 1934 | @node Size of Window | ||
| 1935 | @section The Size of a Window | ||
| 1936 | @cindex window size | ||
| 1937 | @cindex size of window | ||
| 1938 | |||
| 1939 | An Emacs window is rectangular, and its size information consists of | ||
| 1940 | the height (the number of lines) and the width (the number of character | ||
| 1941 | positions in each line). The mode line is included in the height. But | ||
| 1942 | the width does not count the scroll bar or the column of @samp{|} | ||
| 1943 | characters that separates side-by-side windows. | ||
| 1944 | |||
| 1945 | The following three functions return size information about a window: | ||
| 1946 | |||
| 1947 | @defun window-height &optional window | ||
| 1948 | This function returns the number of lines in @var{window} (by default | ||
| 1949 | the selected window), including any mode line and header line. | ||
| 1950 | The result is almost always less than the value of @code{frame-height} | ||
| 1951 | for the associated frame, because the latter also includes any echo | ||
| 1952 | area. Depending on the toolkit in use, the frame height can also | ||
| 1953 | include the menu bar and tool bar (@pxref{Size and Position}). | ||
| 1954 | Therefore in general it is not straightforward to compare window and | ||
| 1955 | frame heights (see @code{window-full-height-p} below). | ||
| 1956 | |||
| 1957 | @example | ||
| 1958 | @group | ||
| 1959 | (window-height) | ||
| 1960 | @result{} 23 | ||
| 1961 | @end group | ||
| 1962 | @group | ||
| 1963 | (split-window-vertically) | ||
| 1964 | @result{} #<window 4 on windows.texi> | ||
| 1965 | @end group | ||
| 1966 | @group | ||
| 1967 | (window-height) | ||
| 1968 | @result{} 11 | ||
| 1969 | @end group | ||
| 1970 | @end example | ||
| 1971 | @end defun | ||
| 1972 | |||
| 1973 | @defun window-body-height &optional window | ||
| 1974 | Like @code{window-height} but the value does not include the | ||
| 1975 | mode line (if any) or the header line (if any). | ||
| 1976 | @end defun | ||
| 1977 | |||
| 1978 | @defun window-full-height-p &optional window | ||
| 1979 | This function returns non-@code{nil} if @var{window} is as tall as the | ||
| 1980 | frame that contains it. The default for @var{window} is the selected | ||
| 1981 | window. | ||
| 1982 | @end defun | ||
| 1983 | |||
| 1984 | @defun window-width &optional window | ||
| 1985 | This function returns the number of columns in @var{window}. The | ||
| 1986 | default for @var{window} is the selected window. | ||
| 1987 | |||
| 1988 | The return value does not include the window's scroll bar or the column | ||
| 1989 | of @samp{|} characters that separates side-by-side windows. Moreover, | ||
| 1990 | the return value does not include the space used for displaying fringes | ||
| 1991 | and margins. Hence you cannot, in general, compare the return values of | ||
| 1992 | @code{window-width} and @code{frame-width} for equality to determine | ||
| 1993 | whether a window is a wide as the containing frame. Use the function | ||
| 1994 | @code{window-full-width-p}, see below, instead. | ||
| 1995 | |||
| 1996 | @example | ||
| 1997 | @group | ||
| 1998 | (window-width) | ||
| 1999 | @result{} 80 | ||
| 2000 | @end group | ||
| 2001 | @end example | ||
| 2002 | @end defun | ||
| 2003 | |||
| 2004 | @defun window-full-width-p &optional window | ||
| 2005 | This function returns non-@code{nil} if @var{window} is as wide as the | ||
| 2006 | frame that contains it; otherwise @code{nil}. The default for | ||
| 2007 | @var{window} is the selected window. | ||
| 2008 | @end defun | ||
| 2009 | |||
| 2010 | @defun window-edges &optional window | ||
| 2011 | This function returns a list of the edge coordinates of @var{window}. | ||
| 2012 | The default for @var{window} is the selected window. | ||
| 2013 | |||
| 2014 | The order of the list is @code{(@var{left} @var{top} @var{right} | ||
| 2015 | @var{bottom})}, all elements relative to 0, 0 at the top left corner of | ||
| 2016 | the frame. The element @var{right} of the value is one more than the | ||
| 2017 | rightmost column used by @var{window}, and @var{bottom} is one more than | ||
| 2018 | the bottommost row used by @var{window} and its mode-line. | ||
| 2019 | |||
| 2020 | The edges include the space used by the window's scroll bar, display | ||
| 2021 | margins, fringes, header line, and mode line, if it has them. Also, | ||
| 2022 | if the window has a neighbor on the right, its right edge value | ||
| 2023 | includes the width of the separator line between the window and that | ||
| 2024 | neighbor. Since the width of the window does not include this | ||
| 2025 | separator, the width does not usually equal the difference between the | ||
| 2026 | right and left edges. | ||
| 2027 | @end defun | ||
| 2028 | |||
| 2029 | @defun window-inside-edges &optional window | ||
| 2030 | This is similar to @code{window-edges}, but the edge values | ||
| 2031 | it returns include only the text area of the window. They | ||
| 2032 | do not include the header line, mode line, scroll bar or | ||
| 2033 | vertical separator, fringes, or display margins. | ||
| 2034 | @end defun | ||
| 2035 | |||
| 2036 | Here are the results obtained on a typical 24-line terminal with just | ||
| 2037 | one window, with menu bar enabled: | ||
| 2038 | |||
| 2039 | @example | ||
| 2040 | @group | ||
| 2041 | (window-edges (selected-window)) | ||
| 2042 | @result{} (0 1 80 23) | ||
| 2043 | @end group | ||
| 2044 | @group | ||
| 2045 | (window-inside-edges (selected-window)) | ||
| 2046 | @result{} (0 1 80 22) | ||
| 2047 | @end group | ||
| 2048 | @end example | ||
| 2049 | |||
| 2050 | @noindent | ||
| 2051 | The bottom edge is at line 23 because the last line is the echo area. | ||
| 2052 | The bottom inside edge is at line 22, which is the window's mode line. | ||
| 2053 | |||
| 2054 | If @var{window} is at the upper left corner of its frame, and there is | ||
| 2055 | no menu bar, then @var{bottom} returned by @code{window-edges} is the | ||
| 2056 | same as the value of @code{(window-height)}, @var{right} is almost the | ||
| 2057 | same as the value of @code{(window-width)}, and @var{top} and | ||
| 2058 | @var{left} are zero. For example, the edges of the following window | ||
| 2059 | are @w{@samp{0 0 8 5}}. Assuming that the frame has more than 8 | ||
| 2060 | columns, the last column of the window (column 7) holds a border | ||
| 2061 | rather than text. The last row (row 4) holds the mode line, shown | ||
| 2062 | here with @samp{xxxxxxxxx}. | ||
| 2063 | |||
| 2064 | @example | ||
| 2065 | @group | ||
| 2066 | 0 | ||
| 2067 | _______ | ||
| 2068 | 0 | | | ||
| 2069 | | | | ||
| 2070 | | | | ||
| 2071 | | | | ||
| 2072 | xxxxxxxxx 4 | ||
| 2073 | |||
| 2074 | 7 | ||
| 2075 | @end group | ||
| 2076 | @end example | ||
| 2077 | |||
| 2078 | In the following example, let's suppose that the frame is 7 | ||
| 2079 | columns wide. Then the edges of the left window are @w{@samp{0 0 4 3}} | ||
| 2080 | and the edges of the right window are @w{@samp{4 0 7 3}}. | ||
| 2081 | The inside edges of the left window are @w{@samp{0 0 3 2}}, | ||
| 2082 | and the inside edges of the right window are @w{@samp{4 0 7 2}}, | ||
| 2083 | |||
| 2084 | @example | ||
| 2085 | @group | ||
| 2086 | ___ ___ | ||
| 2087 | | | | | ||
| 2088 | | | | | ||
| 2089 | xxxxxxxxx | ||
| 2090 | |||
| 2091 | 0 34 7 | ||
| 2092 | @end group | ||
| 2093 | @end example | ||
| 2094 | |||
| 2095 | @defun window-pixel-edges &optional window | ||
| 2096 | This function is like @code{window-edges} except that, on a graphical | ||
| 2097 | display, the edge values are measured in pixels instead of in | ||
| 2098 | character lines and columns. | ||
| 2099 | @end defun | ||
| 2100 | |||
| 2101 | @defun window-inside-pixel-edges &optional window | ||
| 2102 | This function is like @code{window-inside-edges} except that, on a | ||
| 2103 | graphical display, the edge values are measured in pixels instead of | ||
| 2104 | in character lines and columns. | ||
| 2105 | @end defun | ||
| 2106 | |||
| 2107 | @node Resizing Windows | ||
| 2108 | @section Changing the Size of a Window | ||
| 2109 | @cindex window resizing | ||
| 2110 | @cindex resize window | ||
| 2111 | @cindex changing window size | ||
| 2112 | @cindex window size, changing | ||
| 2113 | |||
| 2114 | The window size functions fall into two classes: high-level commands | ||
| 2115 | that change the size of windows and low-level functions that access | ||
| 2116 | window size. Emacs does not permit overlapping windows or gaps between | ||
| 2117 | windows, so resizing a window always affects at least one other window. | ||
| 2118 | |||
| 2119 | @deffn Command enlarge-window size &optional horizontal | ||
| 2120 | This function makes the selected window @var{size} lines taller by | ||
| 2121 | stealing lines from windows above or below. In a first round, it takes | ||
| 2122 | lines from one window at a time until that window is | ||
| 2123 | @code{window-min-height} lines tall, then takes from another. If, at | ||
| 2124 | the end of the first round, the selected window is still not tall | ||
| 2125 | enough, @code{enlarge-window} starts a second round, where it deletes | ||
| 2126 | windows above or below the selected one. | ||
| 2127 | |||
| 2128 | If @var{horizontal} is non-@code{nil}, this function makes the window | ||
| 2129 | @var{size} columns wider, stealing columns instead of lines. If a | ||
| 2130 | window from which columns are stolen shrinks below | ||
| 2131 | @code{window-min-width} columns, that window disappears. | ||
| 2132 | |||
| 2133 | If the requested size would exceed that of the window's frame, then the | ||
| 2134 | function makes the window occupy the entire height (or width) of the | ||
| 2135 | frame. | ||
| 2136 | |||
| 2137 | If there are various other windows from which lines or columns can be | ||
| 2138 | stolen, and some of them specify fixed size (using | ||
| 2139 | @code{window-size-fixed}, see below), they are left untouched while | ||
| 2140 | other windows are ``robbed.'' If it would be necessary to alter the | ||
| 2141 | size of a fixed-size window, @code{enlarge-window} gets an error | ||
| 2142 | instead. | ||
| 2143 | |||
| 2144 | If @var{size} is negative, this function shrinks the selected window by | ||
| 2145 | @minus{}@var{size} lines or columns. If that makes the window smaller | ||
| 2146 | than the minimum size (@code{window-min-height} and | ||
| 2147 | @code{window-min-width}), then @code{enlarge-window} deletes the window. | ||
| 2148 | |||
| 2149 | @code{enlarge-window} returns @code{nil}. | ||
| 2150 | @end deffn | ||
| 2151 | |||
| 2152 | @deffn Command enlarge-window-horizontally columns | ||
| 2153 | This function makes the selected window @var{columns} wider. | ||
| 2154 | It could be defined as follows: | ||
| 2155 | |||
| 2156 | @example | ||
| 2157 | @group | ||
| 2158 | (defun enlarge-window-horizontally (columns) | ||
| 2159 | (interactive "p") | ||
| 2160 | (enlarge-window columns t)) | ||
| 2161 | @end group | ||
| 2162 | @end example | ||
| 2163 | @end deffn | ||
| 2164 | |||
| 2165 | @deffn Command shrink-window size &optional horizontal | ||
| 2166 | This function is like @code{enlarge-window} but negates the argument | ||
| 2167 | @var{size}, making the selected window smaller by giving lines (or | ||
| 2168 | columns) to the other windows. If the window shrinks below | ||
| 2169 | @code{window-min-height} or @code{window-min-width}, then it disappears. | ||
| 2170 | |||
| 2171 | If @var{size} is negative, the window is enlarged by @minus{}@var{size} | ||
| 2172 | lines or columns. | ||
| 2173 | @end deffn | ||
| 2174 | |||
| 2175 | @deffn Command shrink-window-horizontally columns | ||
| 2176 | This function makes the selected window @var{columns} narrower. | ||
| 2177 | It could be defined as follows: | ||
| 2178 | |||
| 2179 | @example | ||
| 2180 | @group | ||
| 2181 | (defun shrink-window-horizontally (columns) | ||
| 2182 | (interactive "p") | ||
| 2183 | (shrink-window columns t)) | ||
| 2184 | @end group | ||
| 2185 | @end example | ||
| 2186 | @end deffn | ||
| 2187 | |||
| 2188 | @defun adjust-window-trailing-edge window delta horizontal | ||
| 2189 | This function makes the selected window @var{delta} lines taller or | ||
| 2190 | @var{delta} columns wider, by moving the bottom or right edge. This | ||
| 2191 | function does not delete other windows; if it cannot make the | ||
| 2192 | requested size adjustment, it signals an error. On success, this | ||
| 2193 | function returns @code{nil}. | ||
| 2194 | @end defun | ||
| 2195 | |||
| 2196 | @deffn Command fit-window-to-buffer &optional window max-height min-height | ||
| 2197 | This command makes @var{window} the right height to display its | ||
| 2198 | contents exactly. The default for @var{window} is the selected window. | ||
| 2199 | |||
| 2200 | The optional argument @var{max-height} specifies the maximum height the | ||
| 2201 | window is allowed to be; @code{nil} means use the maximum permissible | ||
| 2202 | height of a window on @var{window}'s frame. The optional argument | ||
| 2203 | @var{min-height} specifies the minimum height for the window; @code{nil} | ||
| 2204 | means use @code{window-min-height}. All these height values include the | ||
| 2205 | mode line and/or header line. | ||
| 2206 | |||
| 2207 | This function can delete windows when their height shrinks below | ||
| 2208 | @var{min-height}. It returns non-@code{nil} if it orderly resized | ||
| 2209 | @var{window}, and @code{nil} otherwise. | ||
| 2210 | @end deffn | ||
| 2211 | |||
| 2212 | @deffn Command shrink-window-if-larger-than-buffer &optional window | ||
| 2213 | This command shrinks @var{window} vertically to be as small as possible | ||
| 2214 | while still showing the full contents of its buffer---but not less than | ||
| 2215 | @code{window-min-height} lines. The default for @var{window} is | ||
| 2216 | the selected window. | ||
| 2217 | |||
| 2218 | However, this command does nothing if the window is already too small to | ||
| 2219 | display the whole text of the buffer, or if part of the contents are | ||
| 2220 | currently scrolled off screen, or if the window is not the full width of | ||
| 2221 | its frame, or if the window is the only window in its frame. | ||
| 2222 | |||
| 2223 | This command returns non-@code{nil} if it actually shrank the window | ||
| 2224 | and @code{nil} otherwise. | ||
| 2225 | @end deffn | ||
| 2226 | |||
| 2227 | @cindex fixed-size window | ||
| 2228 | @defvar window-size-fixed | ||
| 2229 | If this variable is non-@code{nil}, in a given buffer, then the size of | ||
| 2230 | any window displaying that buffer remains fixed unless you either | ||
| 2231 | explicitly change it or Emacs has no other choice. | ||
| 2232 | |||
| 2233 | If the value is @code{height}, then only the window's height is fixed; | ||
| 2234 | if the value is @code{width}, then only the window's width is fixed. | ||
| 2235 | Any other non-@code{nil} value fixes both the width and the height. | ||
| 2236 | |||
| 2237 | This variable automatically becomes buffer-local when set. | ||
| 2238 | |||
| 2239 | Explicit size-change functions such as @code{enlarge-window} | ||
| 2240 | get an error if they would have to change a window size which is fixed. | ||
| 2241 | Therefore, when you want to change the size of such a window, | ||
| 2242 | you should bind @code{window-size-fixed} to @code{nil}, like this: | ||
| 2243 | |||
| 2244 | @example | ||
| 2245 | (let ((window-size-fixed nil)) | ||
| 2246 | (enlarge-window 10)) | ||
| 2247 | @end example | ||
| 2248 | |||
| 2249 | Deleting an adjacent window or changing the frame size may change the | ||
| 2250 | size of a fixed-size window, if there is no other alternative. | ||
| 2251 | @end defvar | ||
| 2252 | |||
| 2253 | @cindex minimum window size | ||
| 2254 | The following two variables constrain the window-structure-changing | ||
| 2255 | functions to a minimum height and width. | ||
| 2256 | |||
| 2257 | @defopt window-min-height | ||
| 2258 | The value of this variable specifies how short a window may become | ||
| 2259 | before it is automatically deleted. Making a window smaller than | ||
| 2260 | @code{window-min-height} automatically deletes it, and no window may be | ||
| 2261 | created shorter than this. The value is measured in line units. When | ||
| 2262 | the window wants a mode line and/or a header line, they are counted as | ||
| 2263 | one line each. The default value is @code{4}. A value less than | ||
| 2264 | @code{1} is ignored. | ||
| 2265 | @end defopt | ||
| 2266 | |||
| 2267 | @defopt window-min-width | ||
| 2268 | The value of this variable specifies how narrow a window may become | ||
| 2269 | before it is automatically deleted. Making a window smaller than | ||
| 2270 | @code{window-min-width} automatically deletes it, and no window may be | ||
| 2271 | created narrower than this. The value is measured in characters and | ||
| 2272 | includes any fringes or the scroll bar. The default value is @code{10}. | ||
| 2273 | A value less than @code{2} is ignored. | ||
| 2274 | @end defopt | ||
| 2275 | |||
| 2276 | @cindex balancing window sizes | ||
| 2277 | Emacs provides two functions to balance windows, that is, to even out | ||
| 2278 | the sizes of windows on the same frame. The minibuffer window and | ||
| 2279 | fixed-size windows are not resized by these functions. | ||
| 2280 | |||
| 2281 | @deffn Command balance-windows &optional window-or-frame | ||
| 2282 | This function balances windows in a way that gives more space to | ||
| 2283 | full-width and/or full-height windows. If @var{window-or-frame} | ||
| 2284 | specifies a frame, it balances all windows on that frame. If | ||
| 2285 | @var{window-or-frame} specifies a window, it balances this window and | ||
| 2286 | its ``siblings'' only. Think of a sibling as the other (original or | ||
| 2287 | new) window with respect to the present one, involved in the process of | ||
| 2288 | splitting; see @ref{Splitting Windows}. Since a sibling may have been | ||
| 2289 | split again, a window can have more than one sibling. | ||
| 2290 | @end deffn | ||
| 2291 | |||
| 2292 | @deffn Command balance-windows-area | ||
| 2293 | This function attempts to give all windows on the selected frame | ||
| 2294 | approximately the same share of the screen area. This means that | ||
| 2295 | full-width or full-height windows are not given more space than other | ||
| 2296 | windows. | ||
| 2297 | @end deffn | ||
| 2298 | 3386 | ||
| 2299 | @node Coordinates and Windows | 3387 | @node Coordinates and Windows |
| 2300 | @section Coordinates and Windows | 3388 | @section Coordinates and Windows |
| @@ -2357,31 +3445,6 @@ The function @code{coordinates-in-window-p} does not require a frame as | |||
| 2357 | argument because it always uses the frame that @var{window} is on. | 3445 | argument because it always uses the frame that @var{window} is on. |
| 2358 | @end defun | 3446 | @end defun |
| 2359 | 3447 | ||
| 2360 | @node Window Tree | ||
| 2361 | @section The Window Tree | ||
| 2362 | @cindex window tree | ||
| 2363 | |||
| 2364 | A @dfn{window tree} specifies the layout, size, and relationship | ||
| 2365 | between all windows in one frame. | ||
| 2366 | |||
| 2367 | @defun window-tree &optional frame | ||
| 2368 | This function returns the window tree for frame @var{frame}. | ||
| 2369 | If @var{frame} is omitted, the selected frame is used. | ||
| 2370 | |||
| 2371 | The return value is a list of the form @code{(@var{root} @var{mini})}, | ||
| 2372 | where @var{root} represents the window tree of the frame's | ||
| 2373 | root window, and @var{mini} is the frame's minibuffer window. | ||
| 2374 | |||
| 2375 | If the root window is not split, @var{root} is the root window itself. | ||
| 2376 | Otherwise, @var{root} is a list @code{(@var{dir} @var{edges} @var{w1} | ||
| 2377 | @var{w2} ...)} where @var{dir} is @code{nil} for a horizontal split, | ||
| 2378 | and @code{t} for a vertical split, @var{edges} gives the combined size and | ||
| 2379 | position of the subwindows in the split, and the rest of the elements | ||
| 2380 | are the subwindows in the split. Each of the subwindows may again be | ||
| 2381 | a window or a list representing a window split, and so on. The | ||
| 2382 | @var{edges} element is a list @code{(@var{left}@var{ top}@var{ right}@var{ bottom})} | ||
| 2383 | similar to the value returned by @code{window-edges}. | ||
| 2384 | @end defun | ||
| 2385 | 3448 | ||
| 2386 | @node Window Configurations | 3449 | @node Window Configurations |
| 2387 | @section Window Configurations | 3450 | @section Window Configurations |