aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2011-09-23 11:12:53 +0200
committerMartin Rudalics2011-09-23 11:12:53 +0200
commitb33b68a32cc0d0b7f60a1de9a17e59e38e72a3d1 (patch)
tree73a407c9e44f76dd3a5b02f208e301daa475b119
parent71146d7b6e7524c91b4eee124cfdaaf86aa21643 (diff)
downloademacs-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/ChangeLog30
-rw-r--r--doc/lispref/elisp.texi10
-rw-r--r--doc/lispref/frames.texi49
-rw-r--r--doc/lispref/windows.texi2659
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 @@
12011-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
12011-09-21 Stefan Monnier <monnier@iro.umontreal.ca> 312011-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
927Windows 927Windows
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
1310Window Ordering}. 1308Window 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
1316with @code{window-frame}.
1317
1318@defun window-frame window
1319This 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
1323order. The order runs from the frame's top window, which is at the
1324upper left corner, down and to the right, until it reaches the window at
1325the lower right corner (always the minibuffer window, if the frame has
1326one), and then it moves back to the top. @xref{Cyclic Window Ordering}.
1327
1328@defun frame-first-window &optional frame
1329This returns the topmost, leftmost window of frame @var{frame}.
1330If omitted or @code{nil}, @var{frame} defaults to the selected frame.
1331@end defun
1332
1333At any time, exactly one window on any frame is @dfn{selected within the
1334frame}. The significance of this designation is that selecting the
1335frame also selects this window. Conversely, selecting a window for
1336Emacs with @code{select-window} also makes that window selected within
1337its frame. @xref{Selecting Windows}.
1338
1339@defun frame-selected-window &optional frame
1340This function returns the window on @var{frame} that is selected
1341within @var{frame}. If omitted or @code{nil}, @var{frame} defaults to
1342the selected frame.
1343@end defun
1344
1345@defun set-frame-selected-window frame window &optional norecord
1346This sets the selected window of frame @var{frame} to @var{window}.
1347If @var{frame} is @code{nil}, it operates on the selected frame. If
1348@var{frame} is the selected frame, this makes @var{window} the
1349selected window. This function returns @var{window}.
1350
1351Optional argument @var{norecord} non-@code{nil} means to neither change
1352the order of recently selected windows nor the buffer list (@pxref{The
1353Buffer List}).
1354@end defun
1355
1356 Another function that (usually) returns one of the windows in a given
1357frame 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 10This chapter describes the functions and variables related to Emacs
11Emacs windows. @xref{Frames and Windows}, for how windows relate to 11windows. @xref{Frames}, for how windows are assigned an area of screen
12frames. @xref{Display}, for information on how text is displayed in 12available for Emacs to use. @xref{Display}, for information on how text
13windows. 13is 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
50buffer is displayed. The term is also used to refer to a Lisp object that
51represents that screen area in Emacs Lisp. It should be
52clear from the context which is meant.
53
54 Emacs groups windows into frames; see @ref{Frames}. A frame
55represents an area of screen available for Emacs to use. Each frame
56always contains at least one window, but you can subdivide it
57vertically or horizontally into multiple, nonoverlapping Emacs
58windows.
59 48
60 In each frame, at any time, one and only one window is designated as 49A @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 50buffer is displayed, see @ref{Buffers}. The term is also used to refer
62window, but the other windows have ``non-selected'' cursors, normally 51to a Lisp object that represents that screen area in Emacs Lisp. It
63less visible. (@xref{Cursor Parameters}, for customizing this.) At 52should be clear from the context which is meant.
64any time, one frame is the selected frame; and the window selected
65within that frame is @dfn{the selected window}. The selected window's
66buffer is usually the current buffer (except when @code{set-buffer} has
67been used); see @ref{Current Buffer}.
68
69 For practical purposes, a window exists only while it is displayed in
70a frame. Once removed from the frame, the window is effectively deleted
71and should not be used, @emph{even though there may still be references
72to it} from other Lisp objects; see @ref{Deleting Windows}. Restoring a
73saved window configuration is the only way for a window no longer on the
74screen 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
78once. Lisp libraries use multiple windows for a variety of reasons, but 56contains at least one window, but you can subdivide it into multiple,
79most often to display related information. In Rmail, for example, you 57non-overlapping Emacs windows. Users create multiple windows so they
80can move through a summary buffer in one window while the other window 58can look at several buffers at once. Lisp libraries use multiple
81shows messages one at a time as they are reached. 59windows for a variety of reasons, but most often to display related
60information. In Rmail, for example, you can move through a summary
61buffer in one window while the other window shows messages one at a time
62as 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
84context of general-purpose window systems such as X, but not identical. 67context of general-purpose window systems such as X, but not identical.
85The X Window System places X windows on the screen; Emacs uses one or 68The X Window System places X windows on the screen; Emacs uses one or
86more X windows as frames, and subdivides them into 69more X windows as frames, and subdivides them into Emacs windows. When
87Emacs windows. When you use Emacs on a character-only terminal, Emacs 70you use Emacs on a character-only terminal, Emacs treats the whole
88treats the whole terminal screen as one frame. 71terminal 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.
94In contrast, Emacs windows are @dfn{tiled}; they never overlap, and 75In contrast, Emacs windows are @dfn{tiled}; they never overlap, and
@@ -97,68 +78,937 @@ which Emacs creates new windows (@pxref{Splitting Windows}) and resizes
97them (@pxref{Resizing Windows}), not all conceivable tilings of windows 78them (@pxref{Resizing Windows}), not all conceivable tilings of windows
98on an Emacs frame are actually possible. 79on an Emacs frame are actually possible.
99 80
81 For practical purposes, a window exists only while it is displayed in
82a frame. Once removed from the frame, the window is effectively deleted
83and should not be used, even though the Lisp object representing it
84might be still referenced from other Lisp objects; see @ref{Deleting
85Windows}. Restoring a saved window configuration is the only way for a
86window no longer on the screen to come back to life; see @ref{Window
87Configurations}.
88
100@defun windowp object 89@defun windowp object
101This function returns @code{t} if @var{object} is a window. 90This function returns @code{t} if @var{object} is a window, @code{nil}
91otherwise. It can return @code{t} if @var{object} denotes a window that
92has 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
98if it currently displays a buffer; see @ref{Buffers and Windows}. In
99order to show multiple windows within one and the same frame, Emacs
100organizes them in form of a tree called window tree; see @ref{Windows
101and Frames}. The internal nodes of a window tree are called internal
102windows and are not considered live. The leaf nodes of a window tree
103constitute the windows displaying buffers and only they will be called
104live here.
105
106@defun window-live-p object
107This 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
112This function returns @code{t} if @var{object} denotes a live or an
113internal window and @code{nil} otherwise. In particular, this function
114returns @code{nil} if @var{object} is a window that has been
115deleted.
116@end defun
117
118@cindex selected window
119In 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
121selected frame (@pxref{Input Focus}). The window selected within the
122selected frame is the @dfn{selected window}.
123
124 The selected window is always a live window. Its buffer is usually
125the current buffer (except when @code{set-buffer} has been used); see
126@ref{Current Buffer}.
127
128@defun selected-window
129This function returns the selected window. This is the window in which
130the cursor for selected windows (@pxref{Cursor Parameters}) appears and
131to which many commands apply.
132@end defun
133
134The window handling functions can be roughly grouped into functions
135operating on live windows only and functions that accept any window as
136argument. Many of these functions accept as argument the value
137@code{nil} to specify the selected window. The two functions below can
138be used to ``normalize'' arguments specifying windows in a uniform
139manner.
140
141@defun window-normalize-any-window window
142This function returns the normalized value for @var{window} which can be
143any window that has not been deleted. More precisely, if @var{window}
144is @code{nil}, it returns the selected window. If @var{window} denotes
145a live or internal window, it returns that window. Otherwise, this
146function signals an error.
147@end defun
148
149@defun window-normalize-live-window window
150This functions returns the normalized value for a live window
151@var{window}. More precisely, if @var{window} is @code{nil}, it returns
152the selected window. If @var{window} is a live window, it returns that
153window. Otherwise, this function signals an error.
154@end defun
155
156
157@node Windows and Frames
158@section Windows and Frames
159
160Each window is part of one and only one frame (@pxref{Frames}); you can
161get that frame with the function described next.
162
163@defun window-frame window
164This 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
168The following function returns a list of all live windows on a specific
169frame.
170
171@defun window-list &optional frame minibuf window
172This function returns a list of @var{frame}'s live windows, starting
173with @var{window}. The optional argument @var{frame} has to denote a
174live 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
178The argument @var{minibuf} specifies if the minibuffer window shall be
179included in the return value. If @var{minibuf} is @code{t}, the result
180always includes the minibuffer window. If @var{minibuf} is @code{nil}
181or omitted, that includes the minibuffer window only if it is active.
182If @var{minibuf} is neither @code{nil} nor @code{t}, the result never
183includes the minibuffer window.
184@end defun
185
186@cindex window tree
187Windows within one and the same frame are organized in form of a tree
188called @dfn{window tree}. The leaf nodes of a window tree constitute
189the windows visible to the user. These are the windows associated with
190buffers and are usually called live windows. The internal nodes of a
191window tree are needed for finding, traversing and displaying the live
192windows.
193
194 A minibuffer window (@pxref{Minibuffer Windows}) is not considered
195part of its frame's window tree unless the frame is a minibuffer-only
196frame. Most functions covered in this section accept, however, the
197minibuffer window as argument. Also, the minibuffer window is listed by
198the 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
203This function returns the root window of @var{frame-or-window}. The
204argument @var{frame-or-window} has to denote either a window or a frame
205and defaults to the selected frame. If @var{frame-or-window} denotes a
206window, the return value is the root window of that window's frame.
207This function always returns a window; a live window if the frame
208specified by @var{frame-or-window} contains no other live windows and an
209internal window otherwise.
210@end defun
211
212@cindex subwindow
213All other windows of a frame with the exception of the minibuffer window
214are 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
216window's screen area.
217
218The functions described next allow to access the members of a window
219tree and take an arbitrary window as argument.
220
221@cindex parent window
222@defun window-parent &optional window
223Return @var{window}'s parent in the window tree. The optional argument
224@var{window} can denote an arbitrary window and defaults to the selected
225one. The return value is @code{nil} if @var{window} is a minibuffer
226window 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
231parent window is the rectangular part of the window's frame occupied by
232the window's @dfn{child windows}, that is, the set of windows having
233that window as their parent. Each parent window has at least two child
234windows, so there are no ``Matryoshka'' windows. Minibuffer windows do
235not have child windows.
236
237@cindex window combination
238@cindex vertical combination
239@cindex horizontal combination
240The children of any parent window form either a vertical or a horizontal
241combination of windows. A @dfn{vertical combination} is a set of
242windows arranged one above each other. A @dfn{horizontal combination}
243is a set of windows arranged side by side. Consider the frame shown
244below (for simplicity we assume that the frame does not contain a
245minibuffer 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
266The root window of the frame is @code{W1}---a horizontal combination of
267the live window @code{W2} and the internal window @code{W3}. Hence
268@code{(window-parent W1)} is @code{nil} while @code{(window-parent W2)}
269and @code{(window-parent W3)} are both @code{W1}.
270
271 The internal window @code{W3} is a vertical combination of @code{W4}
272and the live window @code{W5}. The internal window @code{W4} is a
273horizontal combination of the live windows @code{W6} and @code{W7}. The
274windows 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
278functions given next.
279
280@defun window-top-child &optional window
281This function returns @var{window}'s first vertical child window. The
282optional argument @var{window} can be an arbitrary window and defaults
283to the selected one. The return value is @code{nil} if @var{window} is
284a live window or its children form a horizontal combination. In the
285example 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
290This function returns @var{window}'s first horizontal child window. The
291optional argument @var{window} can be an arbitrary window and defaults
292to the selected one. The return value is @code{nil} if @var{window} is
293a live window or its children form a vertical combination. In the
294example 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
299This function return @var{window}'s first child window. The return
300value is @code{nil} if @var{window} is a live window. In the example
301above @code{(window-child W3)} is @code{W4} while @code{(window-child
302W4)} is @code{W6}.
303@end defun
304
305The following function is useful to determine whether a window is part
306of a vertical or horizontal combination.
307
308@defun window-iso-combined-p &optional window horizontal
309This function returns non-@code{nil} if and only if @var{window} is
310vertically combined. The argument @var{window} can specify any window
311and defaults to the selected one. The actual return value is the first
312vertical child of window.
313
314If the optional argument @var{horizontal} is non-@code{nil}, this means
315to return non-@code{nil} if and only if @var{window} is horizontally
316combined. In this case, the return value is the first horizontal child
317of window.
318@end defun
319
320@cindex sibling window
321For any window that is part of a combination, the other windows in that
322combination are called the window's @dfn{siblings}. The only windows
323that do not have siblings are root windows of frames and minibuffer
324windows. A window's siblings can be retrieved with the following two
325functions.
326
327@defun window-next-sibling &optional window
328This function returns @var{window}'s next sibling. The optional
329argument @var{window} can be an arbitrary window and defaults to the
330selected window. It returns @code{nil} if @var{window} is the last
331child 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
336This function returns @var{window}'s previous sibling. The optional
337argument @var{window} can be an arbitrary window and defaults to the
338selected window. It returns @code{nil} if @var{window} is the first
339child 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
343The functions @code{window-next-sibling} and @code{window-prev-sibling}
344should not be confused with the functions @code{next-window} and
345@code{previous-window} which respectively return the next and previous
346window in the cyclic ordering of windows, see @ref{Cyclic Window
347Ordering}.
348
349 In order to find the first live window on a frame, the following
350function can be used.
351
352@defun frame-first-window &optional frame-or-window
353This function returns the live window at the upper left corner of the
354frame specified by @var{frame-or-window}. The argument
355@var{frame-or-window} must denote a window or a live frame and defaults
356to the selected frame. If @var{frame-or-window} specifies a window,
357this function returns the first window on that window's frame. Under
358the assumption that the frame from our canonical example is selected
359@code{(frame-first-window)} returns @code{W2}.
360@end defun
361
362You can get the window tree of a frame with the following function.
363
364@cindex window tree
365@defun window-tree &optional frame
366This function returns the window tree for frame @var{frame}. The
367optional argument @var{frame} must be a live frame and defaults to the
368selected one.
369
370The return value is a list of the form @code{(@var{root} @var{mini})},
371where @var{root} represents the window tree of the frame's
372root window, and @var{mini} is the frame's minibuffer window.
373
374If the root window is live, @var{root} specifies the root window and
375nothing 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
377horizontal combination, and @code{t} for a vertical combination,
378@var{edges} gives the size and position of the combination, and the
379remaining elements are the child windows. Each child window may again
380be a live window or a list representing a window combination, and so on.
381The @var{edges} element is a list @code{(@var{left}@var{ top}@var{
382right}@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
392Emacs windows are rectangular. The structure of a live window can be
393roughly 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
415The text area constitutes the body of the window. In its most simple
416form, a window consists of its body alone. LS and RS stand for the left
417and right scroll bar (@pxref{Scroll Bars}) respectively. Only one of
418them can be present at any time. LF and RF denote the left and right
419fringe, see @ref{Fringes}. LM and RM, finally, stand for the left and
420right display margin, see @ref{Display Margins}. The header line, if
421present, 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
428The @dfn{total height of a window} is specified as the total number of
429lines occupied by the window. Any mode or header line is included in a
430window's total height. For an internal window, the total height is
431calculated 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
437The @dfn{total width of a window} denotes the total number of columns of
438the window. Any scroll bar and the column of @samp{|} characters that
439separate the window from its right sibling are included in a window's
440total width. On a window-system, fringes and display margins are
441included in a window's total width too. For an internal window, the
442total width is calculated recursively from the total widths of its child
443windows.
444
445@cindex total size of a window
446@cindex total window size
447The following function is the standard interface for getting the total
448size of any window:
449
450@defun window-total-size &optional window &optional horizontal
451This function returns the total number of lines of @var{window}. The
452argument @var{window} can denote any window and defaults to the selected
453one. If @var{window} is live, the return value includes any header or
454mode lines of @var{window}. If @var{window} is internal, the return
455value is the sum of the total heights of @var{window}'s child windows
456provided these are vertically combined and the height of @var{window}'s
457first child if they are horizontally combined.
458
459 If the optional argument @var{horizontal} is non-@code{nil}, this
460function returns the total number of columns of @var{window}. If
461@var{window} is live, the return value includes any vertical divider
462column or scroll bars of @var{window}. On a window-system, the return
463value includes the space occupied by any margins and fringes of
464@var{window} too. If @var{window} is internal, the return value is the
465sum of the total widths of @var{window}'s child windows provided these
466are horizontally combined and the width of @var{window}'s first child
467otherwise.
468@end defun
469
470Alternatively, the following two functions can be used to retrieve
471either the total height or the total width of a window:
472
473@defun window-total-height &optional window
474This function returns the total number of lines of @var{window}.
475@var{window} can be any window and defaults to the selected one. The
476return value includes @var{window}'s mode line and header line, if any.
477If @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
479of @var{window}'s first child otherwise.
480@end defun
481
482@defun window-total-width &optional window
483This function returns the total number of columns of @var{window}.
484@var{window} can be any window and defaults to the selected one. The
485return value includes any vertical dividers or scrollbars of
486@var{window}. On a window-system the return value also includes the
487space 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
490of @var{window}'s first child otherwise.
491@end defun
492
493The total height of any window is usually less than the height of the
494window's frame, because the latter may also include the minibuffer
495window. Depending on the toolkit in use, the frame height can also
496include the menu bar and the tool bar (@pxref{Size and Position}).
497Therefore, in general it is not straightforward to compare window and
498frame heights. The following function is useful to determine whether
499there are no other windows above or below a specified window.
500
501@cindex full-height window
502@defun window-full-height-p &optional window
503This function returns non-@code{nil} if there is no other window above
504or below @var{window} on the containing frame. More precisely, this
505function returns @code{t} if and only if the total height of
506@var{window} equals the total height of the root window (@pxref{Windows
507and Frames}) of @var{window}'s frame. The @var{window} argument may
508denote any window and defaults to the selected one.
509@end defun
510
511@cindex full-width window
512The following function can be used to determine whether there are no
513other windows on the left or right of a specified window.
514
515@defun window-full-width-p &optional window
516This function returns non-@code{nil} if there are no other windows on
517the left or right of @var{window}; @code{nil} otherwise. More
518precisely, this function returns @code{t} if and only if the total width
519of @var{window} equals the total width of the root window
520(@pxref{Windows and Frames}) of @var{window}'s frame. The @var{window}
521argument 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
527combination of their top line and left column within that frame.
528
529@defun window-top-line &optional window
530This 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
535This 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
539For a frame displaying one window only, that window's top line and left
540column are both zero. When a frame displays a window @var{WB} below a
541window @var{WA}, the top line of @var{WB} can be calculated by adding
542the total height of @var{WA} to the top line of @var{WA}. When a frame
543displays a window @var{WR} on the right of a window @var{WL}, the left
544column 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
549The @dfn{body height of a window} is specified as the total number of
550lines occupied by the window's text area. Mode or header lines are not
551included in a window's body height.
552
553@cindex window body width
554@cindex body width of a window
555The @dfn{body width of a window} denotes the total number of columns
556occupied by the window's text area. Scroll bars or columns of @samp{|}
557characters that separate side-by-side windows are not included in a
558window's body width.
559
560@cindex body size of a window
561@cindex window body size
562The following functions retrieve height and width of the body of a live
563window:
564
565@defun window-body-size &optional window horizontal
566This 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.
568The return value does not count any mode or header line of @var{window}.
569
570Optional argument @var{horizontal} non-@code{nil} means to return the
571number of columns of @var{window}'s text area. In this case the return
572value 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
574number of columns used for @var{window}'s fringes or display margins
575either.
576@end defun
577
578@defun window-body-height &optional window
579This 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
582The return value does not include @var{window}'s mode line and header
583line, if any. If a line at the bottom of the window is only partially
584visible, that line is included in the return value. If you do not
585want to include a partially visible bottom line in the return value,
586use @code{window-text-height} instead.
587@end defun
588
589@defun window-body-width &optional window
590This 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
593The return value does not include any vertical dividers or scroll bars
594owned by @var{window}. On a window-system the return value does not
595include the number of columns used for @var{window}'s fringes or
596display margins either.
597@end defun
598
599The following functions have been used in earlier versions of Emacs.
600They are still supported but due to the confusing nomenclature they
601should not be used any more in future code.
602
603@defun window-height &optional window
604This function is an alias for `window-total-height', see above.
605@end defun
606
607@defun window-width &optional window
608This 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
613height and width. Their values are honored when windows are split
614(@pxref{Splitting Windows}) or resized (@pxref{Resizing Windows}). Any
615request to make a window smaller than specified here will usually result
616in an error.
617
618@defopt window-min-height
619The value of this variable specifies how short a window may be. The
620value is measured in line units and has to account for any header or
621mode line. The default value for this option is @code{4}. Values less
622than @code{1} are ignored.
623@end defopt
624
625@defopt window-min-width
626The value of this variable specifies how narrow a window may be. The
627value is measured in characters and includes any margins, fringes,
628scroll bar and vertical divider column. The default value for this
629option is @code{10}. A value less than @code{2} is ignored.
630@end defopt
631
632Applications should not rebind these variables. To shrink a specific
633window to a height or width less than the one specified here, they
634should rather invoke @code{window-resize} (@pxref{Resizing Windows})
635with a non-@code{nil} @var{ignore} argument. The function
636@code{split-window} (@pxref{Splitting Windows}) can make a window
637smaller than specified here by calling it with a non-@code{nil}
638@var{size} argument. Interactively, the values specified here cannot be
639overridden.
640
641 Earlier versions of Emacs could delete a window when its size dropped
642below @code{window-min-height} or @code{window-min-width}. As a rule,
643the current version of Emacs does no more delete windows by side-effect.
644The only exception to this rule are requests to resize a frame which may
645implicitly delete windows when they do not fit on the frame any more,
646see @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
653If this variable is non-@code{nil}, in a given buffer, then the size of
654any window displaying that buffer remains fixed unless you either
655explicitly change it or Emacs has no other choice.
656
657If the value is @code{height}, then only the window's height is fixed;
658if the value is @code{width}, then only the window's width is fixed.
659Any other non-@code{nil} value fixes both the width and the height.
660
661This variable automatically becomes buffer-local when set.
662@end defvar
663
664Commands supposed to explicitly change the size of windows such as
665@code{enlarge-window} (@pxref{Resizing Windows}) get an error if they
666had 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
669windows.
670
671 Deleting a window or changing a frame's size may change the size of a
672fixed-size window, if there is no other alternative.
673
674 The height of a vertical combination of windows cannot be changed
675when the height of all these windows is fixed. Its width cannot be
676changed if the width of at least one of these windows is fixed.
677Similarly, the width of a horizontal combination of windows cannot be
678changed when the width of all these windows is fixed. Its height cannot
679be 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
682window is fixed.
683
684@defun window-size-fixed-p &optional window horizontal
685This function returns non-@code{nil} if @var{window}'s height is fixed.
686The argument @var{window} can be an arbitrary window and defaults to the
687selected one. Optional argument @var{horizontal} non-@code{nil} means
688return non-@code{nil} if @var{window}'s width is fixed.
689
690If 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
703Emacs does not permit overlapping windows or gaps between windows, so
704changing the size of a window always affects at least one other window.
705When a frame contains just one window, that window can be resized only
706by resizing the window's frame. The functions described below are
707therefore meaningful only in the context of a frame containing at least
708two windows. The size of the corresponding frame never changes when
709invoking a function described in this section.
710
711 The routines changing window sizes always operate in one dimension at
712a time. This means that windows can be resized only either vertically
713or horizontally. If a window shall be resized in both dimensions, it
714must be resized in one dimension first and in the other dimension
715afterwards. If the second resize operation fails, the frame might end
716up in an unsatisfactory state. To avoid such states, it might be useful
717to save the current window configuration (@pxref{Window Configurations})
718before attempting the first resize operation and restore the saved
719configuration in case the second resize operation fails.
720
721 Functions that resize windows are supposed to obey restrictions
722imposed by window minimum sizes and fixed-size windows, see @ref{Window
723Sizes}. In order to determine whether resizing a specific window is
724possible in the first place, the following function can be used:
725
726@defun window-resizable window delta &optional horizontal ignore side noup nodown
727This function returns @var{delta} if the size of @var{window} can be
728changed 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
731return value of zero means that @var{window} is not resizable.
732
733If @var{delta} is a positive number, this means that @var{window} shall
734be enlarged by @var{delta} lines or columns. If @var{window} cannot be
735enlarged by @var{delta} lines or columns, this function returns the
736maximum value in the range from 0 to @var{delta} by which @var{window}
737can be enlarged.
738
739If @var{delta} is a negative number, this means that @var{window} shall
740be shrunk by -@var{delta} lines or columns. If @var{window} cannot be
741shrunk by -@var{delta} lines or columns, this function returns the
742minimum value in the range from @var{delta} to 0 that can be used for
743shrinking @var{window}.
744
745Optional argument @var{ignore} non-@code{nil} means ignore any
746restrictions imposed by the variables @code{window-min-height} or
747@code{window-min-width} and @code{window-size-fixed}. In this case the
748minimum height of a window is specified as the minimum number of lines
749that allow viewing any header or mode line and at least one line of the
750text area of window. The minimum width of a window includes any
751fringes, margins and the scroll bar as well as two text columns.
752
753If @var{ignore} denotes a window, this means to ignore restrictions for
754that window only. If @var{ignore} equals the constant @code{safe}, this
755means a live window may get as small as one line or two columns.
756
757Optional argument @var{noup} non-@code{nil} means don't go up in the
758window tree but try to steal or distribute the space needed for the
759resize operation among the other windows within @var{window}'s
760combination. Optional argument @var{nodown} non-@code{nil} means don't
761check whether @var{window} itself and its subwindows can be resized.
762@end defun
763
764The function @code{window-resizable} does not change any window sizes.
765The following function does:
766
767@defun window-resize window delta &optional horizontal ignore
768This function resizes @var{window} vertically by @var{delta} lines. The
769argument @var{window} can denote an arbitrary window and defaults to the
770selected one. An attempt to resize the root window of a frame will
771raise an error.
772
773Second argument @var{delta} a positive number means @var{window} shall
774be enlarged by @var{delta} lines. If @var{delta} is negative, that
775means @var{window} shall be shrunk by -@var{delta} lines.
776
777Optional argument @var{horizontal} non-@code{nil} means to resize
778@var{window} horizontally by @var{delta} columns. In this case a
779positive @var{delta} means enlarge @var{window} by @var{delta} columns.
780A negative @var{delta} means @var{window} shall be shrunk by
781-@var{delta} columns.
782
783Optional argument @var{ignore} has the same meaning as for the function
784@code{window-resizable} above.
785
786This function can simultaneously move two edges of WINDOW. Exactly
787which edges of @var{window} are moved and which other windows are
788resized along with @var{window} is determined by the splits and nest
789status of the involved windows (@pxref{Splitting Windows}). If only the
790low (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
794The next four commands are simple interfaces to @code{window-resize}.
795They always operate on the selected window, never delete any window, and
796always raise an error when resizing would violate a restriction imposed
797by @code{window-min-height}, @code{window-min-width}, or
798@code{window-size-fixed}.
799
800@deffn Command enlarge-window delta &optional horizontal
801This function makes the selected window @var{delta} lines taller.
802Interactively, if no argument is given, it makes the selected window one
803line taller. If optional argument @var{horizontal} is non-@code{nil},
804it makes the selected window wider by @var{delta} columns. If
805@var{delta} is negative, it shrinks the selected window by -@var{delta}
806lines or columns. The return value is @code{nil}.
807@end deffn
808
809@deffn Command enlarge-window-horizontally delta
810This function makes the selected window @var{delta} columns wider.
811Interactively, if no argument is given, it makes the selected window one
812column wider.
813@end deffn
814
815@deffn Command shrink-window delta &optional horizontal
816This function makes the selected window @var{delta} lines smaller.
817Interactively, if no argument is given, it makes the selected window one
818line smaller. If optional argument @var{horizontal} is non-@code{nil},
819it makes the selected window narrower by @var{delta} columns. If
820@var{delta} is negative, it enlarges the selected window by -@var{delta}
821lines or columns. The return value is @code{nil}.
822@end deffn
823
824@deffn Command shrink-window-horizontally delta
825This function makes the selected window @var{delta} columns narrower.
826Interactively, if no argument is given, it makes the selected window one
827column narrower.
828@end deffn
829
830The following function is useful for moving the line dividing two
831windows.
832
833@defun adjust-window-trailing-edge window delta &optional horizontal
834This function moves @var{window}'s bottom edge by @var{delta} lines.
835Optional 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
839If @var{delta} is greater zero, this moves the edge downwards or to the
840right. If @var{delta} is less than zero, this moves the edge upwards or
841to the left. If the edge can't be moved by @var{delta} lines or columns,
842it is moved as far as possible in the desired direction but no error is
843signalled.
844
845This function tries to resize windows adjacent to the edge that is
846moved. Only if this is insufficient, it will also resize windows not
847adjacent to that edge. As a consequence, if you move an edge in one
848direction and back in the other direction by the same amount, the
849resulting window configuration will not be necessarily identical to the
850one 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
856This command makes @var{window} the right height to display its
857contents exactly. The default for @var{window} is the selected window.
858
859The optional argument @var{max-height} specifies the maximum total
860height the window is allowed to be; @code{nil} means use the maximum
861permissible height of a window on @var{window}'s frame. The optional
862argument @var{min-height} specifies the minimum toatl height for the
863window; @code{nil} means use @code{window-min-height}. All these height
864values include the mode line and/or header line.
865
866If the optional argument @var{override} is non-@code{nil}, this means to
867ignore any restrictions imposed by @code{window-min-height} and
868@code{window-min-width} on the size of @var{window}.
869
870This function returns non-@code{nil} if it orderly resized @var{window},
871and @code{nil} otherwise.
872@end deffn
873
874@deffn Command shrink-window-if-larger-than-buffer &optional window
875This command shrinks @var{window} vertically to be as small as possible
876while still showing the full contents of its buffer---but not less than
877@code{window-min-height} lines. The argument @var{window} must denote
878a live window and defaults to the selected one.
879
880However, this command does nothing if the window is already too small to
881display the whole text of the buffer, or if part of the contents are
882currently scrolled off screen, or if the window is not the full width of
883its frame, or if the window is the only window in its frame.
884
885This command returns non-@code{nil} if it actually shrank the window
886and @code{nil} otherwise.
887@end deffn
888
889@cindex balancing window sizes
890Emacs provides two functions to balance windows, that is, to even out
891the sizes of all windows on the same frame. The minibuffer window and
892fixed-size windows are not resized by these functions.
893
894@deffn Command balance-windows &optional window-or-frame
895This function balances windows in a way that gives more space to
896full-width and/or full-height windows. If @var{window-or-frame}
897specifies a frame, it balances all windows on that frame. If
898@var{window-or-frame} specifies a window, it balances that window and
899its siblings (@pxref{Windows and Frames}) only.
900@end deffn
901
902@deffn Command balance-windows-area
903This function attempts to give all windows on the selected frame
904approximately the same share of the screen area. This means that
905full-width or full-height windows are not given more space than other
906windows.
907@end deffn
908
909@cindex maximizing windows
910The following function can be used to give a window the maximum possible
911size without deleting other ones.
912
913@deffn Command maximize-window &optional window
914This function maximizes @var{window}. More precisely, this makes
915@var{window} as large as possible without resizing its frame or deleting
916other windows. @var{window} can be any window and defaults to the
917selected one.
918@end deffn
919
920@cindex minimizing windows
921To make a window as small as possible without deleting it the
922following function can be used.
923
924@deffn Command minimize-window &optional window
925This function minimizes @var{window}. More precisely, this makes
926@var{window} as small as possible without deleting it or resizing its
927frame. @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
109The functions described below are the primitives used to split a window 936The functions described below are the primitives needed for creating a
110into two windows. They do not accept a buffer as an argument. Rather, 937new window. They do not accept a buffer as an argument. Rather, they
111the two ``halves'' of the split window initially display the same buffer 938``split'' an existing window into two halves, both displaying the buffer
112previously visible in the window that was split. 939previously 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
115This function splits a new window out of @var{window}'s screen area. It 942This function creates a new window adjacent to @var{window}. It returns
116returns the new window. The default for @var{window} is the selected 943the new window which is always a live window. The argument @var{window}
117window. When you split the selected window, it remains selected. 944can denote any window and defaults to the selected one. This function
118 945does not change the selected window.
119If @var{horizontal} is non-@code{nil}, then @var{window} splits into two 946
120side by side windows. The original window keeps the leftmost @var{size} 947Optional second argument @var{size} a positive number means make
121columns, and gives the rest of the columns to the new window. 948@var{window} @var{size} lines (or columns) tall. If @var{size} is
122Otherwise, @var{window} splits into windows one above the other, the 949negative, make the new window @minus{}@var{size} lines (or columns)
123original window keeps the upper @var{size} lines and gives the rest of 950tall. If @var{size} is omitted or @code{nil}, then @var{window} is
124the lines to the new window. The original window @var{window} is 951divided evenly into two parts. (If there is an odd line, it is
125therefore the left-hand or upper of the two, and the new window is the 952allocated to the new window.)
126right-hand or lower. 953
127 954If splitting would result in making a window smaller than
128If @var{size} is omitted or @code{nil}, then @var{window} is divided 955@code{window-min-height} or @code{window-min-width} (@pxref{Window
129evenly into two parts. (If there is an odd line, it is allocated to 956Sizes}), this function usually signals an error. However, if @var{size}
130the new window.) When @code{split-window} is called interactively, 957is non-@code{nil} and valid, a new window of the requested size is
131all its arguments are @code{nil}. 958created. (A size value would be invalid if it assigned less than one
132 959line or less than two columns to the new window.)
133If splitting would result in making a window that is smaller than 960
134@code{window-min-height} or @code{window-min-width} (@pxref{Resizing 961Optional third argument @var{side} @code{nil} (or @code{below})
135Windows}), @code{split-window} signals an error and does not split the 962specifies that the new window shall be located below @var{window}. The
136window at all. 963value @code{above} means the new window will be located above
964@var{window}. In both cases @var{size} specifies the new number of
965lines for @var{window} (or the new window if @var{size} is negative)
966including space reserved for the mode and/or header line.
967
968If @var{side} is @code{t} or @code{right} the new window will be
969positioned on the right side of @var{window}. The value @code{left}
970means the new window will be located on the left side of @var{window}.
971In both cases @var{size} specifies the new number of columns for
972@var{window} (or the new window provided @var{size} is negative)
973including space reserved for margins, fringes and the scroll bar or a
974divider column.
975
976Any 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,
978application programs should refrain from using other values.
979
980If @var{window} is live, properties of the new window like margins and
981scroll bars are inherited from @var{window}. If @var{window} is an
982internal window, these properties, as well as the buffer shown in the
983new window, are inherited from the window selected on @var{window}'s
984frame.
985
986If @code{ignore-window-parameters} is non-@code{nil}, this function
987ignores window parameters (@pxref{Window Parameters}). Otherwise, if
988the @code{split-window} parameter of @var{window} is @code{t}, it splits
989the window disregarding any other window parameters. If the
990@code{split-window} parameter specifies a function, that function is
991called with the arguments @var{window}, @var{size}, and @var{side} to
992split @var{window}. If that function is @code{ignore}, nothing is done.
993@end deffn
137 994
138The following example starts with one window on a screen that is 50 995The following example starts with one window on a screen that is 50
139lines high by 80 columns wide; then it splits the window. 996lines 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
181Next, split the top window horizontally: 1031Next, 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
221with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The 1067with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The
222display table can specify alternative border characters; see @ref{Display 1068display table can specify alternative border characters; see @ref{Display
223Tables}. 1069Tables}.
224@end deffn
225 1070
226@deffn Command split-window-vertically &optional size 1071Below we describe how @code{split-window} can be used to create the
1072window configuration from our earlier example (@pxref{Windows and
1073Frames}) and how internal windows are created for this purpose. We
1074start with a frame containing one live window @code{W2} (in the
1075following scenarios window names are assigned in an arbitrary manner in
1076order to match the names of the example). Evaluating the form
1077@code{(split-window W2 8 t)} creates a new internal window @code{W1}
1078with two children---@code{W2} (the window we've split) and a new leaf
1079window @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
1100Evaluating now @code{(split-window W6 -3)} creates another internal
1101window @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}
1103embedded 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
1124Finally, evaluating @code{(split-window W6 nil t)} should get us the
1125desired 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
1145The scenario sketched above is the standard way to obtain the desired
1146configuration. In Emacs 23 it was also the only way to do that since
1147Emacs 23 did't allow splitting internal windows.
1148
1149With 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
1151following 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
1172Evaluating now @code{(split-window (window-parent W6) -8 'left)} or,
1173equivalently, @code{(split-window W3 -8 'left)} should now produce the
1174penultimate configuration from the previous scenario from where we can
1175continue as described before.
1176
1177 Another strategy starts with splitting an inital window @code{W6} by
1178evaluating @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
1199Evaluating 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
1221The 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
1226windows @code{W6} and @code{W7} shown above. If we now evaluate
1227@code{(split-window W4 -8 'left)} or @code{(split-window (window-parent
1228W6) -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
1248Evaluating now @code{(split-window W4 -3)} or, for example,
1249@code{(split-window (window-parent W6) -3)} should produce the desired
1250configuration.
1251
1252 The two options described next can be used to tune the operation of
1253@code{split-window}.
1254
1255@defopt window-splits
1256If this variable is nil, the function @code{split-window} can split a
1257window if and only if that window's screen estate is sufficiently large
1258to accomodate both--itself and the new window.
1259
1260If this variable is non-@code{nil}, @code{split-window} tries to resize
1261all windows that are part of the same combination as the old window to
1262accomodate the new window. Hence, the new window can be also created if
1263the old window is of fixed size or too small to split (@pxref{Window
1264Sizes}).
1265
1266In any case, the value of this variable is assigned to the splits status
1267of the new window and, provided old and new window form a new
1268combination, of the old window as well. The splits status of a window
1269can be retrieved by invoking the function @code{window-splits} and
1270altered by the function @code{set-window-splits} described next.
1271
1272If @code{window-nest} (see below) is non-@code{nil}, the space for the
1273new window is exclusively taken from the old window, but the splits
1274status of the involved windows is nevertheless set as described here.
1275@end defopt
1276
1277@defun window-splits &optional window
1278This 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
1282The @dfn{splits status} of a window specifies how resizing and deleting
1283that window may affect the size of other windows in the same window
1284combination. More precisely, if @var{window}'s splits status is
1285@code{nil} and @var{window} is resized, the corresponding space is
1286preferably 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
1290combination.
1291
1292The splits status is initially set by @code{split-window}
1293from the current value of the variable @code{window-splits} (see above)
1294and can be reset by the function @code{set-window-splits} (see below).
1295@end defun
1296
1297@defun set-window-splits window &optional status
1298This function sets the splits status (see above) of @var{window} to
1299@var{status}. The argument @var{window} can be any window and defaults
1300to the selected one. The return value is @var{status}.
1301@end defun
1302
1303To illustrate the use of @code{window-splits} consider the following
1304window 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
1325Splitting window @code{W3} with @code{window-splits} @code{nil}
1326produces 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
1347Splitting @code{W3} with @code{window-splits} non-@code{nil} instead
1348produces a configuration where all windows have approximately the same
1349height:
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
1372If this variable is @code{nil}, @code{split-window} creates a new parent
1373window if and only if the old window has no parent window or shall be
1374split orthogonally to the combination it is part of. If this variable
1375is non-@code{nil}, @code{split-window} always creates a new parent
1376window. If this variable is always non-@code{nil}, a frame's window
1377tree is a binary tree so every window but the frame's root window has
1378exactly one sibling.
1379
1380The value of this variable is also assigned to the nest status of the
1381new parent window. The nest status of any window can be retrieved via
1382the 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
1387This function returns the nest status of @var{window}. The argument
1388@var{window} can be any window and defaults to the selected one. Note,
1389however, that the nest status is currently meaningful for internal
1390windows only.
1391
1392@cindex nest status
1393The @dfn{nest status} of a window specifies whether that window may be
1394removed and its subwindows recombined with that window's siblings when
1395such a sibling's subwindow is deleted. The nest status is initially
1396assigned 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
1400If the return value is @code{nil}, subwindows of @var{window} may be
1401recombined with @var{window}'s siblings when a window gets deleted. A
1402return value of @code{nil} means that subwindows of @var{window} are
1403never (re-)combined with @var{window}'s siblings in such a case.
1404@end defun
1405
1406@defun set-window-nest window &optional status
1407This functions sets the nest status (see above) of @var{window} to
1408@var{status}. The argument @var{window} can be any window and defaults
1409to the selected one. Note that setting the nest status is meaningful
1410for internal windows only. The return value is @var{status}.
1411@end defun
1412
1413To illustrate the use of @code{window-nest} consider the following
1414configuration (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
1436Splitting @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
1458If you now enlarge window @code{W4}, Emacs steals the necessary space
1459from 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
1480Deleting window @code{W4}, will return its space to @code{W2} as
1481follows:
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
1502Hence, with respect to the initial configuration, window @code{W2} has
1503grown at the expense of window @code{W3}. If, however, in the initial
1504configuration 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
1506depicted 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
1527Enlarging @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
1549and the subsequent deletion of @code{W4} would have restored the initial
1550configuration.
1551
1552For interactive use, Emacs provides two commands which always split the
1553selected window.
1554
1555@deffn Command split-window-above-each-other &optional size
227This function splits the selected window into two windows, one above the 1556This function splits the selected window into two windows, one above the
228other, leaving the upper of the two windows selected, with @var{size} 1557other, leaving the upper of the two windows selected, with @var{size}
229lines. (If @var{size} is negative, then the lower of the two windows 1558lines. (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
233window can be selected. 1562window can be selected.
234 1563
235In other respects, this function is similar to @code{split-window}. 1564 In other respects, this function is similar to @code{split-window}.
236In particular, the upper window is the original one and the return 1565In particular, the upper window is the original one and the return value
237value is the new, lower window. 1566is the new, lower window.
238@end deffn 1567@end deffn
239 1568
240@defopt split-window-keep-point 1569@defopt split-window-keep-point
241If this variable is non-@code{nil} (the default), then 1570If 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
244If it is @code{nil}, then @code{split-window-vertically} adjusts point
245in each of the two windows to avoid scrolling. (This is useful on
246slow terminals.) It selects whichever window contains the screen line
247that point was previously on.
248 1572
249This variable affects the behavior of @code{split-window-vertically} 1573 If it is @code{nil}, then @code{split-window-above-each-other}
250only. It has no effect on the other functions described here. 1574adjusts point in each of the two windows to avoid scrolling. (This is
1575useful on slow terminals.) It selects whichever window contains the
1576screen line that point was previously on. Other functions are not
1577affected 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
254This function splits the selected window into two windows 1581This function splits the selected window into two windows
255side-by-side, leaving the selected window on the left with @var{size} 1582side-by-side, leaving the selected window on the left with @var{size}
256columns. If @var{size} is negative, the rightmost window gets 1583columns. 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
258selected. 1585selected.
259
260This function is basically an interface to @code{split-window}.
261You 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
279This function returns non-@code{nil} if there is only one window. The
280argument @var{no-mini}, if non-@code{nil}, means don't count the
281minibuffer even if it is active; otherwise, the minibuffer window is
282counted when it is active.
283
284The argument @var{all-frames} specifies which frames to consider. Here
285are the possible values and their meanings:
286
287@table @asis
288@item @code{nil}
289Count the windows in the selected frame, plus the minibuffer used
290by that frame even if it lies in some other frame.
291
292@item @code{t}
293Count all windows in all existing frames.
294
295@item @code{visible}
296Count all windows in all visible frames.
297
298@item 0
299Count all windows in all visible or iconified frames.
300
301@item anything else
302Count 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
313there are no references to it. There is no way to cancel the deletion 1596there are no references to it. There is no way to cancel the deletion
314of a window aside from restoring a saved window configuration 1597of 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
316deletes any windows that aren't part of that configuration. 1599deletes any windows that aren't part of that configuration. Erroneous
317 1600information 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
319its sibling windows adjacent to it.
320
321@c Emacs 19 feature
322@defun window-live-p window
323This 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
327using 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
331This function removes @var{window} from display and returns @code{nil}. 1603This function removes @var{window} from display and returns @code{nil}.
332The default for @var{window} is the selected window. An error is 1604The argument @var{window} can denote any window and defaults to the
333signaled if @var{window} is the only window on its frame. 1605selected one. An error is signaled if @var{window} is the only window
1606on its frame. Hence @var{window} must have at least one sibling window
1607(@pxref{Windows and Frames}) in order to get deleted.
1608
1609If the variable @code{ignore-window-parameters} (@pxref{Window
1610Parameters}) 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
1613window parameters. If the @code{delete-window} parameter specifies a
1614function, that function is called with @var{window} as its sole
1615argument.
1616
1617If 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
1619if such a window exists and to its right sibling otherwise. If the
1620splits status of @var{window} is non-@code{nil}, its space is
1621proportionally distributed among the remaining windows in the same
1622combination.
334@end deffn 1623@end deffn
335 1624
336@deffn Command delete-other-windows &optional window 1625@deffn Command delete-other-windows &optional window
337This function makes @var{window} the only window on its frame, by 1626This function makes @var{window} fill its frame and returns @code{nil}.
338deleting the other windows in that frame. The default for @var{window} 1627The argument @var{window} can denote an arbitrary window and defaults to
339is the selected window. The return value is @code{nil}. 1628the selected one.
1629
1630If the variable @code{ignore-window-parameters} (@pxref{Window
1631Parameters}) is non-@code{nil}, this function ignores all parameters of
1632@var{window}. Otherwise, if the @code{delete-other-windows} parameter
1633of @var{window} equals @code{t}, it deletes all other windows
1634disregarding any remaining window parameters. If the
1635@code{delete-other-windows} parameter of @var{window} specifies a
1636function, 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
343This function deletes all windows showing @var{buffer-or-name}. If 1640This function deletes all windows showing @var{buffer-or-name} and
344there are no windows showing @var{buffer-or-name}, it does nothing. The 1641returns nil. If there are no windows showing @var{buffer-or-name}, it
345optional argument @var{buffer-or-name} may be a buffer or the name of an 1642does nothing. The optional argument @var{buffer-or-name} may be a
346existing buffer and defaults to the current buffer. 1643buffer or the name of an existing buffer and defaults to the current
347 1644buffer. Invoking this command on a minibuffer signals an error.
348@code{delete-windows-on} operates frame by frame. If a frame has 1645
349several windows showing different buffers, then those showing 1646The 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
351space. If all windows in some frame are showing @var{buffer-or-name} 1648frame 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
353winds up with a single window showing another buffer chosen with 1650the space.
354@code{other-buffer} (@pxref{The Buffer List}). If, however, the window 1651
355showing @var{buffer-or-name} is dedicated to its buffer 1652If all windows in some frame are showing @var{buffer-or-name} (including
356(@pxref{Dedicated Windows}), and there are other frames left, that 1653the case where there is only one window), then that frame is deleted
357window's frame is deleted. 1654provided there are other frames left.
358 1655
359The optional argument @var{frame} specifies which frames to operate on. 1656The optional argument @var{frame} specifies which frames to operate on.
360This function does not use it in quite the same way as the other 1657This function does not use it in quite the same way as the other
361functions which scan all windows; specifically, the values @code{t} and 1658functions which scan all live windows (@pxref{Cyclic Window Ordering});
362@code{nil} have the opposite of their meanings in other functions. Here 1659specifically, the values @code{t} and @code{nil} have the opposite of
363are the full details: 1660their meanings in the other functions. Here are the full details:
364 1661
365@itemize @bullet 1662@itemize @bullet
366@item 1663@item @code{nil}
367If it is @code{nil}, operate on all frames. 1664means operate on all frames.
368@item 1665@item @code{t}
369If it is @code{t}, operate on the selected frame. 1666means operate on the selected frame.
370@item 1667@item @code{visible}
371If it is @code{visible}, operate on all visible frames. 1668means operate on all visible frames.
372@item 1669@item @code{0}
373If it is 0, operate on all visible or iconified frames. 1670means operate on all visible or iconified frames.
374@item 1671@item A frame
375If it is a frame, operate on that frame. 1672means operate on that frame.
376@end itemize 1673@end itemize
377
378This 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
386buffer, and the cursor will appear in it.
387
388@defun selected-window
389This function returns the selected window. This is the window in
390which 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
394This function makes @var{window} the selected window. The cursor then 1682This function makes @var{window} the selected window, see @ref{Basic
395appears in @var{window} (after redisplay). Unless @var{window} was 1683Windows}. Unless @var{window} already is the selected window, this also
396already selected, @code{select-window} makes @var{window}'s buffer the 1684makes @var{window}'s buffer (@pxref{Buffers and Windows}) the current
397current buffer. The return value is @var{window}. 1685buffer. 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
399Normally, @var{window}'s selected buffer is moved to the front of the 1689Normally, @var{window}'s selected buffer is moved to the front of the
400buffer list (@pxref{The Buffer List}) and @var{window} becomes the most 1690buffer list (@pxref{The Buffer List}) and @var{window} becomes the most
401recently selected window. But if @var{norecord} is non-@code{nil}, the 1691recently selected window. But if the optional argument @var{norecord}
402buffer list remains unchanged and @var{window} does not become the most 1692is non-@code{nil}, the buffer list remains unchanged and @var{window}
403recently selected one. 1693does 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
1697The sequence of calls to @code{select-window} with a non-@code{nil}
1698@var{norecord} argument determines an ordering of windows by their
1699selection time. The function @code{get-lru-window} can be used to
1700retrieve 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{}
416This macro records the selected frame, as well as the selected window 1704This macro records the selected frame, as well as the selected window
417of each frame, executes @var{forms} in sequence, then restores the 1705of each frame, executes @var{forms} in sequence, then restores the
@@ -437,138 +1725,105 @@ restores the previously selected window and current buffer. The ordering
437of recently selected windows and the buffer list remain unchanged unless 1725of recently selected windows and the buffer list remain unchanged unless
438you deliberately change them within @var{forms}, for example, by calling 1726you 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,
444offering various criteria for the choice.
445
446@defun get-lru-window &optional frame dedicated
447This function returns the window least recently ``used'' (that is,
448selected) among a set of candidate windows. If any full-width windows
449are present, it only considers these.
450
451The selected window is returned if it is the only candidate. A
452minibuffer window is never a candidate. A dedicated window
453(@pxref{Dedicated Windows}) is never a candidate unless the optional
454argument @var{dedicated} is non-@code{nil}.
455 1728
456The optional argument @var{frame} specifies which windows are 1729The order of recently selected windows and the buffer list are not
457considered. 1730changed by this macro.
1731@end defmac
458 1732
459@itemize @bullet 1733@cindex frame selected window
460@item 1734@cindex window selected within frame
461If it is @code{nil}, consider windows on the selected frame. 1735Earlier (@pxref{Basic Windows}) we mentioned that at any time, exactly
462@item 1736one window on any frame is selected within the frame. The significance
463If it is @code{t}, consider windows on all frames. 1737of this designation is that selecting the frame also selects this
464@item 1738window. Conversely, selecting a window for Emacs with
465If 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
467If it is 0, consider windows on all visible or iconified frames. 1741@defun frame-selected-window &optional frame
468@item 1742This function returns the window on @var{frame} that is selected within
469If 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 1744and 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
474This function returns the window with the largest area (height times 1748This function sets the selected window of frame @var{frame} to
475width). 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
476with the most lines. A minibuffer window is never a candidate. A 1750defaults to the selected one. If @var{frame} is the selected frame,
477dedicated window (@pxref{Dedicated Windows}) is never a candidate unless 1751this also makes @var{window} the selected window. The argument
478the optional argument @var{dedicated} is non-@code{nil}. 1752@var{window} must denote a live window. This function returns
479 1753@var{window}.
480If there are two candidate windows of the same size, this function 1754
481prefers the one that comes first in the cyclic ordering of windows, 1755Optional argument @var{norecord} non-@code{nil} means to neither change
482starting from the selected window (@pxref{Cyclic Window Ordering}). 1756the list of most recently selected windows (@pxref{Selecting Windows})
483 1757nor the buffer list (@pxref{The Buffer List}).
484The optional argument @var{frame} specifies which set of windows to
485consider, 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
491This function returns a window satisfying @var{predicate}. It cycles
492through all visible windows using @code{walk-windows} (@pxref{Cyclic
493Window Ordering}), calling @var{predicate} on each one of them with that
494window as its argument. The function returns the first window for which
495@var{predicate} returns a non-@code{nil} value; if that never happens,
496it returns @var{default} (which defaults to @code{nil}).
497
498The optional arguments @var{minibuf} and @var{all-frames} specify the
499set 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 1767When you use the command @kbd{C-x o} (@code{other-window}) to select
511some other window, it moves through the windows on the screen in a 1768some other window, it moves through live windows in a specific order.
512specific order. For any given configuration of windows, this order 1769For any given configuration of windows, this order never varies. It is
513never varies. It is called the @dfn{cyclic ordering of windows}. 1770called 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
516bottom, and from left to right. But it may go down first or go right 1773tree of that frame, see @ref{Windows and Frames}. More precisely, the
517first, depending on the order in which windows were split. 1774ordering is obtained by a depth-first traversal of the frame's window
1775tree 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
520and then the subwindows were split horizontally, then the ordering is 1778for that frame. Otherwise, the cyclic ordering is obtained by appending
521left to right in the top of the frame, and then left to right in the 1779the orderings for individual frames in order of the list of all live
522next lower part of the frame, and so on. If the first split was 1780frames, @ref{Finding All Frames}. In any case, the ordering is made
523horizontal, 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
524In general, within each set of siblings at any level in the window tree 1782ordering.
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}
529This function returns the window following @var{window} in the cyclic 1786This function returns the window following @var{window} in the cyclic
530ordering of windows. This is the window @kbd{C-x o} selects if typed 1787ordering of windows. The argument @var{window} must specify a live
531when @var{window} is selected. The default for @var{window} is the 1788window and defaults to the selected one.
532selected window.
533 1789
534The value of the optional argument @var{minibuf} specifies whether the 1790The optional argument @var{minibuf} specifies whether minibuffer windows
535minibuffer is included in the window order. Normally, when 1791shall be included in the cyclic ordering. Normally, when @var{minibuf}
536@var{minibuf} is @code{nil}, the minibuffer is included only if it is 1792is @code{nil}, a minibuffer window is included only if it is currently
537currently ``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
538minibuffer window is active while the minibuffer is in use; see 1794minibuffer window is active as long as its minibuffer is in use; see
539@ref{Minibuffers}.) 1795@ref{Minibuffers}).
540 1796
541If @var{minibuf} is @code{t}, the cyclic ordering includes the 1797If @var{minibuf} is @code{t}, the cyclic ordering includes all
542minibuffer window even if it is not active. If @var{minibuf} is neither 1798minibuffer 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.
544it is active.
545 1800
546The optional argument @var{all-frames} specifies which frames to 1801The optional argument @var{all-frames} specifies which frames to
547consider. Here are the possible values and their meanings: 1802consider. Here are the possible values and their meanings:
548 1803
549@table @asis 1804@itemize @bullet
550@item @code{nil} 1805@item @code{nil}
551Consider all the windows in @var{window}'s frame, plus the minibuffer 1806means consider all windows on @var{window}'s frame, plus the minibuffer
552used by that frame even if it lies in some other frame. If the 1807window used by that frame even if it lies in some other frame. If the
553minibuffer counts (as determined by @var{minibuf}), then all windows on 1808minibuffer counts (as determined by @var{minibuf}), then all windows on
554all frames that share that minibuffer count too. 1809all frames that share that minibuffer count too.
555 1810
556@item @code{t} 1811@item @code{t}
557Consider all windows in all existing frames. 1812means consider all windows on all existing frames.
558 1813
559@item @code{visible} 1814@item @code{visible}
560Consider all windows in all visible frames. (To get useful results, you 1815means consider all windows on all visible frames. (To get useful
561must ensure @var{window} is in a visible frame.) 1816results, ensure that @var{window} is on a visible frame.)
562 1817
563@item 0 1818@item 0
564Consider all windows in all visible or iconified frames. 1819means consider all windows on all visible or iconified frames.
565 1820
566@item a frame 1821@item A frame
567Consider all windows on that frame. 1822means consider all windows on that frame.
568 1823
569@item anything else 1824@item Anything else
570Consider precisely the windows in @var{window}'s frame, and no others. 1825means consider the windows on @var{window}'s frame, and no others.
571@end table 1826@end itemize
572 1827
573This example assumes there are two windows, both displaying the 1828This example assumes there are two windows, both displaying the
574buffer @samp{windows.texi}: 1829buffer @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
593This function returns the window preceding @var{window} in the cyclic 1848This function returns the window preceding @var{window} in the cyclic
594ordering of windows. The other arguments specify which windows to 1849ordering of windows. The other arguments specify which windows to
595include in the cycle, as in @code{next-window}. 1850consider 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.
608The optional argument @var{all-frames} has the same meaning as in 1863The 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}
610is always effectively @code{nil}. This function returns @code{nil}. 1865is always effectively @code{nil}. This function returns @code{nil}.
1866
1867This 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 1871The following function returns a copy of the list of windows in the
1872cyclic odering.
1873
1874@defun window-list-1 &optional window &optional minibuf &optional all_frames
1875This function returns a list of live windows. The optional arguments
1876@var{minibuf} and @var{all-frames} specify the set of windows to include
1877in the list. See the description of @code{next-window} for details.
1878
1879The optional argument @var{window} specifies the first window to list
1880and defaults to the selected window. If @var{window} is not on the list
1881of windows returned, some other window will be listed first but no error
1882is signalled.
1883@end defun
1884
1885The functions described below use @code{window-list-1} for generating a
1886copy of the list of all relevant windows. Hence, any change of the
1887window configuration that occurs while one of these functions is
1888executed 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
615This function cycles through all windows. It calls the function 1891This 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.
617argument.
618 1893
619The optional arguments @var{minibuf} and @var{all-frames} specify the 1894The optional arguments @var{minibuf} and @var{all-frames} specify the
620set of windows to include in the walk. See @code{next-window}, above, 1895set of windows to include in the walk, see @code{next-window} above. If
621for details. 1896@var{all-frames} specifies a frame, the first window walked is the first
1897window on that frame as returned by @code{frame-first-window} and not
1898necessarily the selected window.
1899
1900If @var{proc} changes the window configuration by splitting or deleting
1901windows, that change is not reflected in the set of windows walked.
1902That set is determined entirely by the set of live windows at the time
1903this function was invoked.
622@end defun 1904@end defun
623 1905
624@defun window-list &optional frame minibuf window 1906The following function allows to determine whether a specific window is
625This function returns a list of all windows on @var{frame}, starting 1907the only live window.
626with @var{window}. The default for @var{frame} is the selected frame;
627the default for @var{window} is the selected window.
628 1908
629The value of @var{minibuf} specifies if the minibuffer window shall be 1909@defun one-window-p &optional no-mini all-frames
630included in the result list. If @var{minibuf} is @code{t}, the result 1910This function returns non-@code{nil} if the selected window is the only
631always includes the minibuffer window. If @var{minibuf} is @code{nil} 1911window.
632or 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 1913The optional argument @var{no-mini}, if non-@code{nil}, means don't
634includes the minibuffer window. 1914count the minibuffer even if it is active; otherwise, the minibuffer
1915window is counted when it is active. The optional argument
1916@var{all-frames} has the same meaning as for @code{next-window}, see
1917above.
1918@end defun
1919
1920@cindex finding windows
1921 The following functions choose (but do not select) one of the windows
1922on the screen, offering various criteria for the choice.
1923
1924@cindex least recently used window
1925@defun get-lru-window &optional all-frames dedicated
1926This function returns the window least recently ``used'' (that is,
1927selected). If any full-width windows are present, it only considers
1928these. The optional argument @var{all-frames} has the same meaning as
1929in @code{next-window}.
1930
1931The selected window is returned if it is the only candidate. A
1932minibuffer window is never a candidate. A dedicated window
1933(@pxref{Dedicated Windows}) is never a candidate unless the optional
1934argument @var{dedicated} is non-@code{nil}.
1935@end defun
1936
1937@cindex largest window
1938@defun get-largest-window &optional all-frames dedicated
1939This function returns the window with the largest area (height times
1940width). A minibuffer window is never a candidate. A dedicated window
1941(@pxref{Dedicated Windows}) is never a candidate unless the optional
1942argument @var{dedicated} is non-@code{nil}.
1943
1944If there are two candidate windows of the same size, this function
1945prefers the one that comes first in the cyclic ordering of windows,
1946starting from the selected window.
1947
1948The optional argument @var{all-frames} specifies which set of windows to
1949consider 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
1955This function returns a window satisfying @var{predicate}. It cycles
1956through all visible windows calling @var{predicate} on each one of them
1957with that window as its argument. The function returns the first window
1958for which @var{predicate} returns a non-@code{nil} value; if that never
1959happens, it returns @var{default} (which defaults to @code{nil}).
1960
1961The optional arguments @var{minibuf} and @var{all-frames} specify the
1962set 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 1973To find out which buffer is displayed in a given window the following
644display buffers in windows in a precisely controlled fashion. 1974function is used.
645@iftex
646See the following section for
647@end iftex
648@ifnottex
649@xref{Displaying Buffers}, for
650@end ifnottex
651related functions that find a window to use and specify a buffer for it.
652The functions described there are easier to use, but they employ
653heuristics in choosing or creating a window; use the functions described
654here 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
657This function makes @var{window} display @var{buffer-or-name} as its 1977This function returns the buffer that @var{window} is displaying. The
658contents. It returns @code{nil}. The default for @var{window} is the 1978argument @var{window} can be any window and defaults to the selected
659selected window. The argument @var{buffer-or-name} must specify a 1979one. If @var{window} is an internal window, this function returns
660buffer 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 1983The basic, low-level function to associate a window with a buffer is
663buffer is displayed in a window, and all ways of doing that call this 1984@code{set-window-buffer}. Higher-level functions like
664function. 1985@code{display-buffer} try to obey a number of user customizations
1986regulating which windows are supposed to display which buffers. When
1987writing an application, programmers should therefore carefully evaluate
1988whether 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 1991This function makes @var{window} display @var{buffer-or-name} and
668(set-window-buffer (selected-window) "foo") 1992returns @code{nil}. The argument @var{window} has to denote a live
669 @result{} nil 1993window 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 1995buffer. An error is signalled when @var{window} is @dfn{strongly}
1996dedicated to its buffer (@pxref{Dedicated Windows}) and does not already
1997display @var{buffer-or-name}.
672 1998
673Normally, displaying @var{buffer-or-name} in @var{window} resets the 1999Normally, displaying @var{buffer-or-name} in @var{window} resets the
674window's position, display margins, fringe widths, and scroll bar 2000window's position, display margins, fringe widths, and scroll bar
675settings based on the local variables of that buffer. 2001settings based on the local variables of the specified buffer. However,
676However, if @var{keep-margins} is non-@code{nil}, display margins and 2002if the optional argument @var{keep-margins} is non-@code{nil}, display
677fringe widths of @var{window} remain unchanged. @xref{Fringes}. 2003margins 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 2006This function is the fundamental primitive for changing which buffer is
681does not already display @var{buffer-or-name}. 2007displayed in a window, and all ways of doing that call this function.
2008Neither the selected window nor the current buffer are changed by this
2009function.
682 2010
683Note that this function runs @code{window-scroll-functions} before 2011This function runs @code{window-scroll-functions} before running
684running @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
694This function returns the buffer that @var{window} is displaying. The 2022This variable records the time at which a buffer was last made visible
695default for @var{window} is the selected window. 2023in 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 2026When a buffer is first created, @code{buffer-display-time} starts out
699(window-buffer) 2027with 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
706This function returns a window currently displaying 2031This 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
708several such windows, then the function returns the first one in the 2033the function returns the first one in the cyclic ordering of windows,
709cyclic ordering of windows, starting from the selected window. 2034starting from the selected window, @xref{Cyclic Window Ordering}.
710@xref{Cyclic Window Ordering}.
711 2035
712The argument @var{BUFFER-OR-NAME} may be a buffer or a buffer name and 2036The argument @var{buffer-or-name} may be a buffer or a buffer name and
713defaults to the current buffer. The optional argument @var{all-frames} 2037defaults to the current buffer. The optional argument @var{all-frames}
714specifies which windows to consider: 2038specifies which windows to consider:
715 2039
@@ -739,18 +2063,146 @@ This function returns a list of all windows currently displaying
739or the name of an existing buffer and defaults to the current buffer. 2063or the name of an existing buffer and defaults to the current buffer.
740 2064
741The two remaining arguments work like the same-named arguments of 2065The 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}. 2067like the optional arguments of @code{get-buffer-window}.
744@end defun 2068@end defun
745 2069
746@defvar buffer-display-time 2070The following command removes a buffer from all windows showing it.
747This variable records the time at which a buffer was last made visible 2071
748in 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 2073This function replaces @var{buffer-or-name} in all windows displaying it
750@code{(current-time)} in the specified buffer (@pxref{Time of Day}). 2074with some other buffer. It uses @code{switch-to-prev-buffer}, see
751When a buffer is first created, @code{buffer-display-time} starts out 2075below, to choose that other buffer which is usually the last buffer
752with the value @code{nil}. 2076displayed before @var{buffer-or-name} in the respective window.
753@end defvar 2077
2078The argument @var{buffer-or-name} may be a buffer or the name of an
2079existing buffer and defaults to the current buffer.
2080
2081If a window displaying @var{buffer-or-name} is dedicated
2082(@pxref{Dedicated Windows}) has never displayed any other buffers and is
2083not the only window on its frame, that window is deleted. If that
2084window is the only window on its frame and there are other frames left,
2085the window's frame is deleted too. If there are no other frames left,
2086some other buffer is displayed in that window as explained above. You
2087can prevent the deletion of windows and/or frames by customizing the
2088option @var{window-auto-delete}.
2089
2090This function returns @code{nil}.
2091@end deffn
2092
2093 When @code{replace-buffer-in-windows} has to show another buffer in a
2094window, it tries to pick the buffer shown there before. For this
2095purpose each window remembers the buffers it has displayed earlier and
2096the order in which these buffers have been removed from it.
2097
2098The list of @dfn{previous buffers} of a window is an association list
2099where each entry specifies a buffer, the last start position of that
2100buffer in the window (@pxref{Window Start and End}) and the last
2101position of that buffer's point in the window (@pxref{Window Point}).
2102This list is ordered by the times of the removal of the respective
2103buffers from the window. In particular, the first element of the list
2104references the buffer removed most recently. The function
2105@code{set-window-buffer} pushes an entry for the old buffer of its
2106window argument on that list before it shows its buffer argument in the
2107window.
2108
2109The list of @dfn{next buffers} of a window is a list of buffers that
2110have been recently re-shown by the function @code{switch-to-prev-buffer}
2111and is used to avoid that that function switches to such a buffer again
2112before showing other interesting buffers.
2113
2114The lists of previous and next buffers and the global buffer list
2115(@pxref{The Buffer List}) allow to effectively display all buffers in a
2116window while giving preference to the buffers previously shown in that
2117window. The commands used for this purpose are
2118@code{switch-to-prev-buffer} and @code{switch-to-next-buffer} described
2119below.
2120
2121The following functions directly operate on the lists of previous and
2122next buffers.
2123
2124@defun window-prev-buffers &optional window
2125This function returns an alist specifying the buffers previously shown
2126in @var{window} together with their window start and point positions.
2127The argument @var{window} must be a live window and defaults to the
2128selected one.
2129@end defun
2130
2131@defun set-window-prev-buffers window prev-buffers
2132This 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
2134defaults to the selected one. This function returns
2135@var{prev-buffers}.
2136
2137If non-@code{nil}, @var{prev-buffers} must specify an alist of triples
2138specifying a buffer and two markers for that buffer's start and point
2139position in @var{window}.
2140@end defun
2141
2142@defun window-next-buffers &optional window
2143This function returns the list of buffers recently re-shown in
2144@var{window}. The argument @var{window} must be a live window and
2145defaults to the selected one.
2146@end defun
2147
2148@defun set-window-next-buffers window next-buffers
2149This 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.
2151This fucntion returns @var{next-buffers}.
2152
2153If non-@code{nil}, the argument @var{next-buffers} should specify a list
2154of buffers that shall be preferably not shown by the command
2155@code{switch-to-prev-buffer}, see below.
2156@end defun
2157
2158The following command is used by @code{replace-buffer-in-windows},
2159@code{bury-buffer} and @code{quit-window} to show another buffer in a
2160window. It can be also used interactively to cycle through the list of
2161all 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
2165This function displays the previous buffer in @var{window}. The
2166argument @var{window} must be a live window and defaults to the selected
2167one. If the optional argument @var{bury-or-kill} is non-@code{nil},
2168this means that the buffer currently shown in @var{window} is about to
2169be buried or killed and consequently shall not be switched to in future
2170invocations of this command.
2171
2172The previous buffer is usually the buffer shown before the buffer
2173currently shown in @var{window}. However, a buffer that has been buried
2174or killed or has been already shown by a recent invocation of
2175@code{switch-to-prev-buffer} does not qualify as previous buffer.
2176
2177If repeated invocations of this command have already shown all buffers
2178previously shown in @var{window}, further invocations will show buffers
2179from the global buffer list starting with the buffer returned by
2180@code{last-buffer} (@pxref{The Buffer List}).
2181@end deffn
2182
2183The 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
2187This functions switches to the next buffer in @var{window} thus undoing
2188the effect of the last @code{switch-to-prev-buffer} command in
2189@var{window}. The argument @var{window} must be a live window and
2190defaults to the selected one.
2191
2192If there is no recent invocation of a @code{switch-to-prev-buffer} that
2193can be undone, @code{switch-to-next-buffer} will try to show the first
2194buffer 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
2200much like @code{bury-buffer} and @code{unbury-buffer}. In contrast with
2201the latter, however, they may show a buffer even if it is already shown
2202in another window. Moreover, they try to restore the window specific
2203start and point positions of buffers which should handle viewing one and
2204the 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
1940the height (the number of lines) and the width (the number of character
1941positions in each line). The mode line is included in the height. But
1942the width does not count the scroll bar or the column of @samp{|}
1943characters 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
1948This function returns the number of lines in @var{window} (by default
1949the selected window), including any mode line and header line.
1950The result is almost always less than the value of @code{frame-height}
1951for the associated frame, because the latter also includes any echo
1952area. Depending on the toolkit in use, the frame height can also
1953include the menu bar and tool bar (@pxref{Size and Position}).
1954Therefore in general it is not straightforward to compare window and
1955frame 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
1974Like @code{window-height} but the value does not include the
1975mode line (if any) or the header line (if any).
1976@end defun
1977
1978@defun window-full-height-p &optional window
1979This function returns non-@code{nil} if @var{window} is as tall as the
1980frame that contains it. The default for @var{window} is the selected
1981window.
1982@end defun
1983
1984@defun window-width &optional window
1985This function returns the number of columns in @var{window}. The
1986default for @var{window} is the selected window.
1987
1988The return value does not include the window's scroll bar or the column
1989of @samp{|} characters that separates side-by-side windows. Moreover,
1990the return value does not include the space used for displaying fringes
1991and margins. Hence you cannot, in general, compare the return values of
1992@code{window-width} and @code{frame-width} for equality to determine
1993whether 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
2005This function returns non-@code{nil} if @var{window} is as wide as the
2006frame 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
2011This function returns a list of the edge coordinates of @var{window}.
2012The default for @var{window} is the selected window.
2013
2014The 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
2016the frame. The element @var{right} of the value is one more than the
2017rightmost column used by @var{window}, and @var{bottom} is one more than
2018the bottommost row used by @var{window} and its mode-line.
2019
2020The edges include the space used by the window's scroll bar, display
2021margins, fringes, header line, and mode line, if it has them. Also,
2022if the window has a neighbor on the right, its right edge value
2023includes the width of the separator line between the window and that
2024neighbor. Since the width of the window does not include this
2025separator, the width does not usually equal the difference between the
2026right and left edges.
2027@end defun
2028
2029@defun window-inside-edges &optional window
2030This is similar to @code{window-edges}, but the edge values
2031it returns include only the text area of the window. They
2032do not include the header line, mode line, scroll bar or
2033vertical separator, fringes, or display margins.
2034@end defun
2035
2036Here are the results obtained on a typical 24-line terminal with just
2037one 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
2051The bottom edge is at line 23 because the last line is the echo area.
2052The bottom inside edge is at line 22, which is the window's mode line.
2053
2054If @var{window} is at the upper left corner of its frame, and there is
2055no menu bar, then @var{bottom} returned by @code{window-edges} is the
2056same as the value of @code{(window-height)}, @var{right} is almost the
2057same as the value of @code{(window-width)}, and @var{top} and
2058@var{left} are zero. For example, the edges of the following window
2059are @w{@samp{0 0 8 5}}. Assuming that the frame has more than 8
2060columns, the last column of the window (column 7) holds a border
2061rather than text. The last row (row 4) holds the mode line, shown
2062here 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
2078In the following example, let's suppose that the frame is 7
2079columns wide. Then the edges of the left window are @w{@samp{0 0 4 3}}
2080and the edges of the right window are @w{@samp{4 0 7 3}}.
2081The inside edges of the left window are @w{@samp{0 0 3 2}},
2082and 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
2096This function is like @code{window-edges} except that, on a graphical
2097display, the edge values are measured in pixels instead of in
2098character lines and columns.
2099@end defun
2100
2101@defun window-inside-pixel-edges &optional window
2102This function is like @code{window-inside-edges} except that, on a
2103graphical display, the edge values are measured in pixels instead of
2104in 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
2115that change the size of windows and low-level functions that access
2116window size. Emacs does not permit overlapping windows or gaps between
2117windows, so resizing a window always affects at least one other window.
2118
2119@deffn Command enlarge-window size &optional horizontal
2120This function makes the selected window @var{size} lines taller by
2121stealing lines from windows above or below. In a first round, it takes
2122lines from one window at a time until that window is
2123@code{window-min-height} lines tall, then takes from another. If, at
2124the end of the first round, the selected window is still not tall
2125enough, @code{enlarge-window} starts a second round, where it deletes
2126windows above or below the selected one.
2127
2128If @var{horizontal} is non-@code{nil}, this function makes the window
2129@var{size} columns wider, stealing columns instead of lines. If a
2130window from which columns are stolen shrinks below
2131@code{window-min-width} columns, that window disappears.
2132
2133If the requested size would exceed that of the window's frame, then the
2134function makes the window occupy the entire height (or width) of the
2135frame.
2136
2137If there are various other windows from which lines or columns can be
2138stolen, and some of them specify fixed size (using
2139@code{window-size-fixed}, see below), they are left untouched while
2140other windows are ``robbed.'' If it would be necessary to alter the
2141size of a fixed-size window, @code{enlarge-window} gets an error
2142instead.
2143
2144If @var{size} is negative, this function shrinks the selected window by
2145@minus{}@var{size} lines or columns. If that makes the window smaller
2146than 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
2153This function makes the selected window @var{columns} wider.
2154It 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
2166This function is like @code{enlarge-window} but negates the argument
2167@var{size}, making the selected window smaller by giving lines (or
2168columns) to the other windows. If the window shrinks below
2169@code{window-min-height} or @code{window-min-width}, then it disappears.
2170
2171If @var{size} is negative, the window is enlarged by @minus{}@var{size}
2172lines or columns.
2173@end deffn
2174
2175@deffn Command shrink-window-horizontally columns
2176This function makes the selected window @var{columns} narrower.
2177It 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
2189This function makes the selected window @var{delta} lines taller or
2190@var{delta} columns wider, by moving the bottom or right edge. This
2191function does not delete other windows; if it cannot make the
2192requested size adjustment, it signals an error. On success, this
2193function returns @code{nil}.
2194@end defun
2195
2196@deffn Command fit-window-to-buffer &optional window max-height min-height
2197This command makes @var{window} the right height to display its
2198contents exactly. The default for @var{window} is the selected window.
2199
2200The optional argument @var{max-height} specifies the maximum height the
2201window is allowed to be; @code{nil} means use the maximum permissible
2202height of a window on @var{window}'s frame. The optional argument
2203@var{min-height} specifies the minimum height for the window; @code{nil}
2204means use @code{window-min-height}. All these height values include the
2205mode line and/or header line.
2206
2207This 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
2213This command shrinks @var{window} vertically to be as small as possible
2214while still showing the full contents of its buffer---but not less than
2215@code{window-min-height} lines. The default for @var{window} is
2216the selected window.
2217
2218However, this command does nothing if the window is already too small to
2219display the whole text of the buffer, or if part of the contents are
2220currently scrolled off screen, or if the window is not the full width of
2221its frame, or if the window is the only window in its frame.
2222
2223This command returns non-@code{nil} if it actually shrank the window
2224and @code{nil} otherwise.
2225@end deffn
2226
2227@cindex fixed-size window
2228@defvar window-size-fixed
2229If this variable is non-@code{nil}, in a given buffer, then the size of
2230any window displaying that buffer remains fixed unless you either
2231explicitly change it or Emacs has no other choice.
2232
2233If the value is @code{height}, then only the window's height is fixed;
2234if the value is @code{width}, then only the window's width is fixed.
2235Any other non-@code{nil} value fixes both the width and the height.
2236
2237This variable automatically becomes buffer-local when set.
2238
2239Explicit size-change functions such as @code{enlarge-window}
2240get an error if they would have to change a window size which is fixed.
2241Therefore, when you want to change the size of such a window,
2242you 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
2249Deleting an adjacent window or changing the frame size may change the
2250size 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
2255functions to a minimum height and width.
2256
2257@defopt window-min-height
2258The value of this variable specifies how short a window may become
2259before it is automatically deleted. Making a window smaller than
2260@code{window-min-height} automatically deletes it, and no window may be
2261created shorter than this. The value is measured in line units. When
2262the window wants a mode line and/or a header line, they are counted as
2263one 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
2268The value of this variable specifies how narrow a window may become
2269before it is automatically deleted. Making a window smaller than
2270@code{window-min-width} automatically deletes it, and no window may be
2271created narrower than this. The value is measured in characters and
2272includes any fringes or the scroll bar. The default value is @code{10}.
2273A value less than @code{2} is ignored.
2274@end defopt
2275
2276@cindex balancing window sizes
2277Emacs provides two functions to balance windows, that is, to even out
2278the sizes of windows on the same frame. The minibuffer window and
2279fixed-size windows are not resized by these functions.
2280
2281@deffn Command balance-windows &optional window-or-frame
2282This function balances windows in a way that gives more space to
2283full-width and/or full-height windows. If @var{window-or-frame}
2284specifies a frame, it balances all windows on that frame. If
2285@var{window-or-frame} specifies a window, it balances this window and
2286its ``siblings'' only. Think of a sibling as the other (original or
2287new) window with respect to the present one, involved in the process of
2288splitting; see @ref{Splitting Windows}. Since a sibling may have been
2289split again, a window can have more than one sibling.
2290@end deffn
2291
2292@deffn Command balance-windows-area
2293This function attempts to give all windows on the selected frame
2294approximately the same share of the screen area. This means that
2295full-width or full-height windows are not given more space than other
2296windows.
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
2357argument because it always uses the frame that @var{window} is on. 3445argument 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
2365between all windows in one frame.
2366
2367@defun window-tree &optional frame
2368This function returns the window tree for frame @var{frame}.
2369If @var{frame} is omitted, the selected frame is used.
2370
2371The return value is a list of the form @code{(@var{root} @var{mini})},
2372where @var{root} represents the window tree of the frame's
2373root window, and @var{mini} is the frame's minibuffer window.
2374
2375If the root window is not split, @var{root} is the root window itself.
2376Otherwise, @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,
2378and @code{t} for a vertical split, @var{edges} gives the combined size and
2379position of the subwindows in the split, and the rest of the elements
2380are the subwindows in the split. Each of the subwindows may again be
2381a 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})}
2383similar 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