comparison doc/lispref/windows.texi @ 99438:5743d4e279a5

(Windows): Update entries. (Basic Windows): Remove listing of attributes. Reword. (Splitting Windows, Deleting Windows, Window Point): Reword. (Selecting Windows, Cyclic Window Ordering): Reword with special emphasis on order of recently selected windows and buffer list. (Buffers and Windows, Displaying Buffers, Choosing Window): Reword with special emphasis on dedicated windows. (Dedicated Windows): New node and section discussing dedicated windows and associated functions. (Window Start and End): Rename node and section title. Reword. (Textual Scrolling, Vertical Scrolling, Horizontal Scrolling): Minor rewording. (Size of Window): Reword, in particular text on window-width. (Resizing Windows): Reword. Add text on balancing windows. (Window Configurations): Reword. Mention window parameters. (Window Parameters): New node and section on window parameters. (Window Hooks): Reword. Mention that window-configuration-change-hook is run "buffer-locally".
author Martin Rudalics <rudalics@gmx.at>
date Fri, 07 Nov 2008 13:12:08 +0000
parents 1b8fa7deb470
children 910601b61dec
comparison
equal deleted inserted replaced
99437:759f9e60a642 99438:5743d4e279a5
6 @setfilename ../../info/windows 6 @setfilename ../../info/windows
7 @node Windows, Frames, Buffers, Top 7 @node Windows, Frames, Buffers, Top
8 @chapter Windows 8 @chapter Windows
9 9
10 This chapter describes most of the functions and variables related to 10 This chapter describes most of the functions and variables related to
11 Emacs windows. See @ref{Display}, for information on how text is 11 Emacs windows. @xref{Frames and Windows}, for how windows relate to
12 displayed in windows. 12 frames. @xref{Display}, for information on how text is displayed in
13 windows.
13 14
14 @menu 15 @menu
15 * Basic Windows:: Basic information on using windows. 16 * Basic Windows:: Basic information on using windows.
16 * Splitting Windows:: Splitting one window into two windows. 17 * Splitting Windows:: Splitting one window into two windows.
17 * Deleting Windows:: Deleting a window gives its space to other windows. 18 * Deleting Windows:: Deleting a window gives its space to other windows.
19 * Cyclic Window Ordering:: Moving around the existing windows. 20 * Cyclic Window Ordering:: Moving around the existing windows.
20 * Buffers and Windows:: Each window displays the contents of a buffer. 21 * Buffers and Windows:: Each window displays the contents of a buffer.
21 * Displaying Buffers:: Higher-level functions for displaying a buffer 22 * Displaying Buffers:: Higher-level functions for displaying a buffer
22 and choosing a window for it. 23 and choosing a window for it.
23 * Choosing Window:: How to choose a window for displaying a buffer. 24 * Choosing Window:: How to choose a window for displaying a buffer.
25 * Dedicated Windows:: How to avoid displaying another buffer in
26 a specific window.
24 * Window Point:: Each window has its own location of point. 27 * Window Point:: Each window has its own location of point.
25 * Window Start:: The display-start position controls which text 28 * Window Start and End:: Buffer positions indicating which text is
26 is on-screen in the window. 29 on-screen in a window.
27 * Textual Scrolling:: Moving text up and down through the window. 30 * Textual Scrolling:: Moving text up and down through the window.
28 * Vertical Scrolling:: Moving the contents up and down on the window. 31 * Vertical Scrolling:: Moving the contents up and down on the window.
29 * Horizontal Scrolling:: Moving the contents sideways on the window. 32 * Horizontal Scrolling:: Moving the contents sideways on the window.
30 * Size of Window:: Accessing the size of a window. 33 * Size of Window:: Accessing the size of a window.
31 * Resizing Windows:: Changing the size of a window. 34 * Resizing Windows:: Changing the size of a window.
32 * Coordinates and Windows:: Converting coordinates to windows. 35 * Coordinates and Windows:: Converting coordinates to windows.
33 * Window Tree:: The layout and sizes of all windows in a frame. 36 * Window Tree:: The layout and sizes of all windows in a frame.
34 * 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.
35 * Window Hooks:: Hooks for scrolling, window size changes, 39 * Window Hooks:: Hooks for scrolling, window size changes,
36 redisplay going past a certain point, 40 redisplay going past a certain point,
37 or window configuration changes. 41 or window configuration changes.
38 @end menu 42 @end menu
39 43
45 A @dfn{window} in Emacs is the physical area of the screen in which a 49 A @dfn{window} in Emacs is the physical area of the screen in which a
46 buffer is displayed. The term is also used to refer to a Lisp object that 50 buffer is displayed. The term is also used to refer to a Lisp object that
47 represents that screen area in Emacs Lisp. It should be 51 represents that screen area in Emacs Lisp. It should be
48 clear from the context which is meant. 52 clear from the context which is meant.
49 53
50 Emacs groups windows into frames. A frame represents an area of 54 Emacs groups windows into frames, @xref{Frames}. A frame represents
51 screen available for Emacs to use. Each frame always contains at least 55 an area of screen available for Emacs to use. Each frame always
52 one window, but you can subdivide it vertically or horizontally into 56 contains at least one window, but you can subdivide it vertically or
53 multiple nonoverlapping Emacs windows. 57 horizontally into multiple, nonoverlapping Emacs windows.
54 58
55 In each frame, at any time, one and only one window is designated as 59 In each frame, at any time, one and only one window is designated as
56 @dfn{selected within the frame}. The frame's cursor appears in that 60 @dfn{selected within the frame}. The frame's cursor appears in that
57 window, but the other windows have ``non-selected'' cursors, normally 61 window, but the other windows have ``non-selected'' cursors, normally
58 less visible. (@pxref{Cursor Parameters}, for customization of this.) 62 less visible. (@pxref{Cursor Parameters}, for customizing this.) At
59 At any time, one frame is the selected frame; and the window selected 63 any time, one frame is the selected frame; and the window selected
60 within that frame is @dfn{the selected window}. The selected window's 64 within that frame is @dfn{the selected window}. The selected window's
61 buffer is usually the current buffer (except when @code{set-buffer} 65 buffer is usually the current buffer (except when @code{set-buffer} has
62 has been used). @xref{Current Buffer}. 66 been used), @xref{Current Buffer}.
63 67
64 For practical purposes, a window exists only while it is displayed in 68 For practical purposes, a window exists only while it is displayed in
65 a frame. Once removed from the frame, the window is effectively deleted 69 a frame. Once removed from the frame, the window is effectively deleted
66 and should not be used, @emph{even though there may still be references 70 and should not be used, @emph{even though there may still be references
67 to it} from other Lisp objects. Restoring a saved window configuration 71 to it} from other Lisp objects, @xref{Deleting Windows}. Restoring a
68 is the only way for a window no longer on the screen to come back to 72 saved window configuration is the only way for a window no longer on the
69 life. (@xref{Deleting Windows}.) 73 screen to come back to life, @xref{Window Configurations}.
70
71 Each window has the following attributes:
72
73 @itemize @bullet
74 @item
75 containing frame
76
77 @item
78 window height
79
80 @item
81 window width
82
83 @item
84 window edges with respect to the screen or frame
85
86 @item
87 the buffer it displays
88
89 @item
90 buffer position at the upper left corner of the window
91
92 @item
93 amount of horizontal scrolling, in columns
94
95 @item
96 point
97
98 @item
99 the mark
100
101 @item
102 how recently the window was selected
103
104 @item
105 fringe settings
106
107 @item
108 display margins
109
110 @item
111 scroll-bar settings
112 @end itemize
113 74
114 @cindex multiple windows 75 @cindex multiple windows
115 Users create multiple windows so they can look at several buffers at 76 Users create multiple windows so they can look at several buffers at
116 once. Lisp libraries use multiple windows for a variety of reasons, but 77 once. Lisp libraries use multiple windows for a variety of reasons, but
117 most often to display related information. In Rmail, for example, you 78 most often to display related information. In Rmail, for example, you
129 @cindex screen of terminal 90 @cindex screen of terminal
130 @cindex tiled windows 91 @cindex tiled windows
131 Most window systems support arbitrarily located overlapping windows. 92 Most window systems support arbitrarily located overlapping windows.
132 In contrast, Emacs windows are @dfn{tiled}; they never overlap, and 93 In contrast, Emacs windows are @dfn{tiled}; they never overlap, and
133 together they fill the whole screen or frame. Because of the way in 94 together they fill the whole screen or frame. Because of the way in
134 which Emacs creates new windows and resizes them, not all conceivable 95 which Emacs creates new windows (@pxref{Splitting Windows}) and resizes
135 tilings of windows on an Emacs frame are actually possible. 96 them (@pxref{Resizing Windows}), not all conceivable tilings of windows
136 @xref{Splitting Windows}, and @ref{Size of Window}. 97 on an Emacs frame are actually possible.
137
138 @xref{Display}, for information on how the contents of the
139 window's buffer are displayed in the window.
140 98
141 @defun windowp object 99 @defun windowp object
142 This function returns @code{t} if @var{object} is a window. 100 This function returns @code{t} if @var{object} is a window.
143 @end defun 101 @end defun
144 102
145 @node Splitting Windows 103 @node Splitting Windows
146 @section Splitting Windows 104 @section Splitting Windows
147 @cindex splitting windows 105 @cindex splitting windows
148 @cindex window splitting 106 @cindex window splitting
149 107
150 The functions described here are the primitives used to split a window 108 The functions described below are the primitives used to split a window
151 into two windows. Two higher level functions sometimes split a window, 109 into two windows. They do not accept a buffer as an argument. Rather,
152 but not always: @code{pop-to-buffer} and @code{display-buffer} 110 the two ``halves'' of the split window initially display the same buffer
153 (@pxref{Displaying Buffers}).
154
155 The functions described here do not accept a buffer as an argument.
156 The two ``halves'' of the split window initially display the same buffer
157 previously visible in the window that was split. 111 previously visible in the window that was split.
158 112
159 @deffn Command split-window &optional window size horizontal 113 @deffn Command split-window &optional window size horizontal
160 This function splits a new window out of @var{window}'s screen area. 114 This function splits a new window out of @var{window}'s screen area. It
161 It returns the new window. 115 returns the new window. @var{window} defaults to the selected window.
162 116 When you split the selected window, it remains selected.
163 If @var{horizontal} is non-@code{nil}, then @var{window} splits into 117
164 two side by side windows. The original window @var{window} keeps the 118 If @var{horizontal} is non-@code{nil}, then @var{window} splits into two
165 leftmost @var{size} columns, and gives the rest of the columns to the 119 side by side windows. The original window keeps the leftmost @var{size}
166 new window. Otherwise, it splits into windows one above the other, and 120 columns, and gives the rest of the columns to the new window.
167 @var{window} keeps the upper @var{size} lines and gives the rest of the 121 Otherwise, @var{window} splits into windows one above the other, the
168 lines to the new window. The original window is therefore the 122 original window keeps the upper @var{size} lines and gives the rest of
169 left-hand or upper of the two, and the new window is the right-hand or 123 the lines to the new window. The original window @var{window} is
170 lower. 124 therefore the left-hand or upper of the two, and the new window is the
171 125 right-hand or lower.
172 If @var{window} is omitted or @code{nil}, that stands for the selected
173 window. When you split the selected window, it remains selected.
174 126
175 If @var{size} is omitted or @code{nil}, then @var{window} is divided 127 If @var{size} is omitted or @code{nil}, then @var{window} is divided
176 evenly into two parts. (If there is an odd line, it is allocated to 128 evenly into two parts. (If there is an odd line, it is allocated to
177 the new window.) When @code{split-window} is called interactively, 129 the new window.) When @code{split-window} is called interactively,
178 all its arguments are @code{nil}. 130 all its arguments are @code{nil}.
179 131
180 If splitting would result in making a window that is smaller than 132 If splitting would result in making a window that is smaller than
181 @code{window-min-height} or @code{window-min-width}, the function 133 @code{window-min-height} or @code{window-min-width} (@pxref{Resizing
182 signals an error and does not split the window at all. 134 Windows}), @code{split-window} signals an error and does not split the
135 window at all.
183 136
184 The following example starts with one window on a screen that is 50 137 The following example starts with one window on a screen that is 50
185 lines high by 80 columns wide; then it splits the window. 138 lines high by 80 columns wide; then it splits the window.
186 139
187 @smallexample 140 @smallexample
262 column 0 column 80 215 column 0 column 80
263 @end group 216 @end group
264 @end smallexample 217 @end smallexample
265 218
266 Normally, Emacs indicates the border between two side-by-side windows 219 Normally, Emacs indicates the border between two side-by-side windows
267 with a scroll bar (@pxref{Layout Parameters,Scroll Bars}) or @samp{|} 220 with a scroll bar, @xref{Scroll Bars}, or @samp{|} characters. The
268 characters. The display table can specify alternative border 221 display table can specify alternative border characters; @xref{Display
269 characters; see @ref{Display Tables}. 222 Tables}.
270 @end deffn 223 @end deffn
271 224
272 @deffn Command split-window-vertically &optional size 225 @deffn Command split-window-vertically &optional size
273 This function splits the selected window into two windows, one above the 226 This function splits the selected window into two windows, one above the
274 other, leaving the upper of the two windows selected, with @var{size} 227 other, leaving the upper of the two windows selected, with @var{size}
360 of a window aside from restoring a saved window configuration 313 of a window aside from restoring a saved window configuration
361 (@pxref{Window Configurations}). Restoring a window configuration also 314 (@pxref{Window Configurations}). Restoring a window configuration also
362 deletes any windows that aren't part of that configuration. 315 deletes any windows that aren't part of that configuration.
363 316
364 When you delete a window, the space it took up is given to one 317 When you delete a window, the space it took up is given to one
365 adjacent sibling. 318 adjacent window.
366 319
367 @c Emacs 19 feature 320 @c Emacs 19 feature
368 @defun window-live-p window 321 @defun window-live-p window
369 This function returns @code{nil} if @var{window} is deleted, and 322 This function returns @code{nil} if @var{window} is deleted, and
370 @code{t} otherwise. 323 @code{t} otherwise.
372 @strong{Warning:} Erroneous information or fatal errors may result from 325 @strong{Warning:} Erroneous information or fatal errors may result from
373 using a deleted window as if it were live. 326 using a deleted window as if it were live.
374 @end defun 327 @end defun
375 328
376 @deffn Command delete-window &optional window 329 @deffn Command delete-window &optional window
377 This function removes @var{window} from display, and returns @code{nil}. 330 This function removes @var{window} from display and returns @code{nil}.
378 If @var{window} is omitted, then the selected window is deleted. An 331 @var{window} defaults to the selected window. An error is signaled if
379 error is signaled if there is only one window when @code{delete-window} 332 @var{window} is the only window on its frame.
380 is called.
381 @end deffn 333 @end deffn
382 334
383 @deffn Command delete-other-windows &optional window 335 @deffn Command delete-other-windows &optional window
384 This function makes @var{window} the only window on its frame, by 336 This function makes @var{window} the only window on its frame, by
385 deleting the other windows in that frame. If @var{window} is omitted or 337 deleting the other windows in that frame. @var{window} defaults to the
386 @code{nil}, then the selected window is used by default. 338 selected window. The return value is @code{nil}.
387
388 The return value is @code{nil}.
389 @end deffn 339 @end deffn
390 340
391 @deffn Command delete-windows-on &optional buffer-or-name frame 341 @deffn Command delete-windows-on &optional buffer-or-name frame
392 This function deletes all windows showing @var{buffer-or-name}. If 342 This function deletes all windows showing @var{buffer-or-name}. If
393 there are no windows showing @var{buffer-or-name}, it does nothing. 343 there are no windows showing @var{buffer-or-name}, it does nothing.
398 several windows showing different buffers, then those showing 348 several windows showing different buffers, then those showing
399 @var{buffer-or-name} are removed, and the others expand to fill the 349 @var{buffer-or-name} are removed, and the others expand to fill the
400 space. If all windows in some frame are showing @var{buffer-or-name} 350 space. If all windows in some frame are showing @var{buffer-or-name}
401 (including the case where there is only one window), then the frame 351 (including the case where there is only one window), then the frame
402 winds up with a single window showing another buffer chosen with 352 winds up with a single window showing another buffer chosen with
403 @code{other-buffer}. @xref{The Buffer List}. If, however, that window 353 @code{other-buffer} (@pxref{The Buffer List}). If, however, the window
404 is dedicated and there are other frames left, the window's frame is 354 showing @var{buffer-or-name} is dedicated to its buffer
405 deleted. 355 (@pxref{Dedicated Windows}), and there are other frames left, that
356 window's frame is deleted.
406 357
407 The argument @var{frame} specifies which frames to operate on. This 358 The argument @var{frame} specifies which frames to operate on. This
408 function does not use it in quite the same way as the other functions 359 function does not use it in quite the same way as the other functions
409 which scan all windows; specifically, the values @code{t} and @code{nil} 360 which scan all windows; specifically, the values @code{t} and @code{nil}
410 have the opposite of their meanings in other functions. Here are the 361 have the opposite of their meanings in other functions. Here are the
438 which the cursor appears and to which many commands apply. 389 which the cursor appears and to which many commands apply.
439 @end defun 390 @end defun
440 391
441 @defun select-window window &optional norecord 392 @defun select-window window &optional norecord
442 This function makes @var{window} the selected window. The cursor then 393 This function makes @var{window} the selected window. The cursor then
443 appears in @var{window} (on redisplay). Unless @var{window} was 394 appears in @var{window} (on redisplay). Unless @var{window} was already
444 already selected, @code{select-window} makes @var{window}'s buffer the 395 selected, @code{select-window} makes @var{window}'s buffer the current
445 current buffer. 396 buffer. The return value is @var{window}.
446 397
447 Normally @var{window}'s selected buffer is moved to the front of the 398 Normally, @var{window}'s selected buffer is moved to the front of the
448 buffer list, but if @var{norecord} is non-@code{nil}, the buffer list 399 buffer list (@pxref{The Buffer List}) and @var{window} becomes the most
449 order is unchanged. 400 recently selected window. But if @var{norecord} is non-@code{nil}, the
450 401 buffer list remains unchanged and @var{window} does not become the most
451 The return value is @var{window}. 402 recently selected one.
403
452 404
453 @example 405 @example
454 @group 406 @group
455 (setq w (next-window)) 407 (setq w (next-window))
456 (select-window w) 408 (select-window w)
464 of each frame, executes @var{forms} in sequence, then restores the 416 of each frame, executes @var{forms} in sequence, then restores the
465 earlier selected frame and windows. It also saves and restores the 417 earlier selected frame and windows. It also saves and restores the
466 current buffer. It returns the value of the last form in @var{forms}. 418 current buffer. It returns the value of the last form in @var{forms}.
467 419
468 This macro does not save or restore anything about the sizes, 420 This macro does not save or restore anything about the sizes,
469 arrangement or contents of windows; therefore, if the @var{forms} 421 arrangement or contents of windows; therefore, if the @var{forms} change
470 change them, the change persists. If the previously selected window 422 them, the change persists. If the previously selected window of some
471 of some frame is no longer live at the time of exit from @var{forms}, 423 frame is no longer live at the time of exit from @var{forms}, that
472 that frame's selected window is left alone. If the previously 424 frame's selected window is left alone. If the previously selected
473 selected window is no longer live, then whatever window is selected at 425 window is no longer live, then whatever window is selected at the end of
474 the end of @var{forms} remains selected. 426 @var{forms} remains selected. The current buffer is restored if and
427 only if it is still live when exiting @var{forms}.
428
429 This macro changes neither the ordering of recently selected windows nor
430 the buffer list.
475 @end defmac 431 @end defmac
476 432
477 @defmac with-selected-window window forms@dots{} 433 @defmac with-selected-window window forms@dots{}
478 This macro selects @var{window} (without changing the buffer list), 434 This macro selects @var{window}, executes @var{forms} in sequence, then
479 executes @var{forms} in sequence, then restores the previously 435 restores the previously selected window and current buffer. The ordering
480 selected window and current buffer. It is just like 436 of recently selected windows and the buffer list remain unchanged unless
481 @code{save-selected-window}, except that it explicitly selects 437 you deliberately change them within @var{forms}, for example, by calling
482 @var{window}, also without altering the buffer list sequence. 438 @code{select-window} with argument @var{norecord} nil or omitted there.
483 @end defmac 439 @end defmac
484 440
485 @cindex finding windows 441 @cindex finding windows
486 The following functions choose one of the windows on the screen, 442 The following functions choose one of the windows on the screen,
487 offering various criteria for the choice. 443 offering various criteria for the choice.
488 444
489 @defun get-lru-window &optional frame dedicated 445 @defun get-lru-window &optional frame dedicated
490 This function returns the window least recently ``used'' (that is, 446 This function returns the window least recently ``used'' (that is,
491 selected). If any full-width windows are present, it only considers 447 selected). If any full-width windows are present, it only considers
492 these. The selected window is always the most recently used window. 448 these.
493 449
494 The selected window can be the least recently used window if it is the 450 The selected window can be the least recently used window if it is the
495 only window. A newly created window becomes the least recently used 451 only window. A newly created window becomes the least recently used
496 window until it is selected. A minibuffer window is never a 452 window until it is selected. A minibuffer window is never a candidate.
497 candidate. Dedicated windows are never candidates unless the 453 A dedicated window (@pxref{Dedicated Windows}) is never a candidate
498 @var{dedicated} argument is non-@code{nil}, so if all 454 unless the @var{dedicated} argument is non-@code{nil}, so if all
499 existing windows are dedicated, the value is @code{nil}. 455 existing windows are dedicated, the value is @code{nil}.
500 456
501 The argument @var{frame} specifies which windows are considered. 457 The argument @var{frame} specifies which windows are considered.
502 458
503 @itemize @bullet 459 @itemize @bullet
515 @end defun 471 @end defun
516 472
517 @defun get-largest-window &optional frame dedicated 473 @defun get-largest-window &optional frame dedicated
518 This function returns the window with the largest area (height times 474 This function returns the window with the largest area (height times
519 width). If there are no side-by-side windows, then this is the window 475 width). If there are no side-by-side windows, then this is the window
520 with the most lines. A minibuffer window is never a candidate. 476 with the most lines. A minibuffer window is never a candidate. A
521 Dedicated windows are never candidates unless the 477 dedicated window (@pxref{Dedicated Windows}) is never a candidate unless
522 @var{dedicated} argument is non-@code{nil}, so if all existing windows 478 the @var{dedicated} argument is non-@code{nil}, so if all existing
523 are dedicated, the value is @code{nil}. 479 windows are dedicated, the value is @code{nil}.
524 480
525 If there are two candidate windows of the same size, this function 481 If there are two candidate windows of the same size, this function
526 prefers the one that comes first in the cyclic ordering of windows 482 prefers the one that comes first in the cyclic ordering of windows
527 (see following section), starting from the selected window. 483 starting from the selected window (@pxref{Cyclic Window Ordering}).
528 484
529 The argument @var{frame} specifies which set of windows to 485 The argument @var{frame} specifies which set of windows to consider, see
530 consider. See @code{get-lru-window}, above. 486 @code{get-lru-window} above.
531 @end defun 487 @end defun
532 488
533 @cindex window that satisfies a predicate 489 @cindex window that satisfies a predicate
534 @cindex conditional selection of windows 490 @cindex conditional selection of windows
535 @defun get-window-with-predicate predicate &optional minibuf all-frames default 491 @defun get-window-with-predicate predicate &optional minibuf all-frames default
536 This function returns a window satisfying @var{predicate}. It cycles 492 This function returns a window satisfying @var{predicate}. It cycles
537 through all visible windows using @code{walk-windows} (@pxref{Cyclic 493 through all visible windows using @code{walk-windows} (@pxref{Cyclic
538 Window Ordering}), calling @var{predicate} on each one of them 494 Window Ordering}), calling @var{predicate} on each one of them with that
539 with that window as its argument. The function returns the first 495 window as its argument. The function returns the first window for which
540 window for which @var{predicate} returns a non-@code{nil} value; if 496 @var{predicate} returns a non-@code{nil} value; if that never happens,
541 that never happens, it returns @var{default}. 497 it returns @var{default} (which defaults to @code{nil}).
542 498
543 The optional arguments @var{minibuf} and @var{all-frames} specify the 499 The optional arguments @var{minibuf} and @var{all-frames} specify the
544 set of windows to include in the scan. See the description of 500 set of windows to include in the scan. See the description of
545 @code{next-window} in @ref{Cyclic Window Ordering}, for details. 501 @code{next-window} in @ref{Cyclic Window Ordering}, for details.
546 @end defun 502 @end defun
551 @cindex cyclic ordering of windows 507 @cindex cyclic ordering of windows
552 @cindex ordering of windows, cyclic 508 @cindex ordering of windows, cyclic
553 @cindex window ordering, cyclic 509 @cindex window ordering, cyclic
554 510
555 When you use the command @kbd{C-x o} (@code{other-window}) to select 511 When you use the command @kbd{C-x o} (@code{other-window}) to select
556 the next window, it moves through all the windows on the screen in a 512 some other window, it moves through the windows on the screen in a
557 specific cyclic order. For any given configuration of windows, this 513 specific order. For any given configuration of windows, this order
558 order never varies. It is called the @dfn{cyclic ordering of windows}. 514 never varies. It is called the @dfn{cyclic ordering of windows}.
559 515
560 This ordering generally goes from top to bottom, and from left to 516 This ordering generally goes from top to bottom, and from left to
561 right. But it may go down first or go right first, depending on the 517 right. But it may go down first or go right first, depending on the
562 order in which the windows were split. 518 order in which windows were split.
563 519
564 If the first split was vertical (into windows one above each other), 520 If the first split was vertical (into windows one above each other),
565 and then the subwindows were split horizontally, then the ordering is 521 and then the subwindows were split horizontally, then the ordering is
566 left to right in the top of the frame, and then left to right in the 522 left to right in the top of the frame, and then left to right in the
567 next lower part of the frame, and so on. If the first split was 523 next lower part of the frame, and so on. If the first split was
568 horizontal, the ordering is top to bottom in the left part, and so on. 524 horizontal, the ordering is top to bottom in the left part, and so on.
569 In general, within each set of siblings at any level in the window tree, 525 In general, within each set of siblings at any level in the window tree
570 the order is left to right, or top to bottom. 526 (@pxref{Window Tree}), the order is left to right, or top to bottom.
571 527
572 @defun next-window &optional window minibuf all-frames 528 @deffn Command next-window &optional window minibuf all-frames
573 @cindex minibuffer window, and @code{next-window} 529 @cindex minibuffer window, and @code{next-window}
574 This function returns the window following @var{window} in the cyclic 530 This function returns the window following @var{window} in the cyclic
575 ordering of windows. This is the window that @kbd{C-x o} would select 531 ordering of windows. This is the window @kbd{C-x o} selects if typed
576 if typed when @var{window} is selected. If @var{window} is the only 532 when @var{window} is selected. @var{window} defaults to the selected
577 window visible, then this function returns @var{window}. If omitted, 533 window.
578 @var{window} defaults to the selected window. 534
579 535 The value of the argument @var{minibuf} specifies whether the minibuffer
580 The value of the argument @var{minibuf} specifies whether the 536 is included in the window order. Normally, when @var{minibuf} is
581 minibuffer is included in the window order. Normally, when 537 @code{nil}, the minibuffer is included only if it is currently
582 @var{minibuf} is @code{nil}, the minibuffer is included if it is 538 ``active''; this matches the behavior of @kbd{C-x o}. (The minibuffer
583 currently active; this is the behavior of @kbd{C-x o}. (The minibuffer 539 window is active while the minibuffer is in use, @xref{Minibuffers}.)
584 window is active while the minibuffer is in use. @xref{Minibuffers}.) 540
585 541 If @var{minibuf} is @code{t}, the cyclic ordering includes the
586 If @var{minibuf} is @code{t}, then the cyclic ordering includes the 542 minibuffer window even if it is not active. If @var{minibuf} is neither
587 minibuffer window even if it is not active. 543 @code{t} nor @code{nil}, the minibuffer window is not included even if
588 544 it is active.
589 If @var{minibuf} is neither @code{t} nor @code{nil}, then the minibuffer
590 window is not included even if it is active.
591 545
592 The argument @var{all-frames} specifies which frames to consider. Here 546 The argument @var{all-frames} specifies which frames to consider. Here
593 are the possible values and their meanings: 547 are the possible values and their meanings:
594 548
595 @table @asis 549 @table @asis
631 @group 585 @group
632 (next-window (next-window (selected-window))) 586 (next-window (next-window (selected-window)))
633 @result{} #<window 56 on windows.texi> 587 @result{} #<window 56 on windows.texi>
634 @end group 588 @end group
635 @end example 589 @end example
636 @end defun 590 @end deffn
637 591
638 @defun previous-window &optional window minibuf all-frames 592 @deffn Command previous-window &optional window minibuf all-frames
639 This function returns the window preceding @var{window} in the cyclic 593 This function returns the window preceding @var{window} in the cyclic
640 ordering of windows. The other arguments specify which windows to 594 ordering of windows. The other arguments specify which windows to
641 include in the cycle, as in @code{next-window}. 595 include in the cycle, as in @code{next-window}.
642 @end defun 596 @end deffn
643 597
644 @deffn Command other-window count &optional all-frames 598 @deffn Command other-window count &optional all-frames
645 This function selects the @var{count}th following window in the cyclic 599 This function selects another window in the cyclic ordering of windows.
646 order. If count is negative, then it moves back @minus{}@var{count} 600 @var{count} specifies the number of windows to skip in the ordering,
647 windows in the cycle, rather than forward. It returns @code{nil}. 601 starting with the selected window, before making the selection. If
602 @var{count} is a positive number, it skips @var{count} windows forwards.
603 @var{count} negative means skip @minus{}@var{count} windows backwards.
604 If @var{count} is zero, it does not skip any window, thus re-selecting
605 the selected window. In an interactive call, @var{count} is the numeric
606 prefix argument.
648 607
649 The argument @var{all-frames} has the same meaning as in 608 The argument @var{all-frames} has the same meaning as in
650 @code{next-window}, but the @var{minibuf} argument of @code{next-window} 609 @code{next-window}, but the @var{minibuf} argument of @code{next-window}
651 is always effectively @code{nil}. 610 is always effectively @code{nil}. This function returns @code{nil}.
652
653 In an interactive call, @var{count} is the numeric prefix argument.
654 @end deffn 611 @end deffn
655 612
656 @c Emacs 19 feature 613 @c Emacs 19 feature
657 @defun walk-windows proc &optional minibuf all-frames 614 @defun walk-windows proc &optional minibuf all-frames
658 This function cycles through all windows. It calls the function 615 This function cycles through all windows. It calls the function
659 @code{proc} once for each window, with the window as its sole 616 @code{proc} once for each window, with the window as its sole
660 argument. 617 argument.
661 618
662 The optional arguments @var{minibuf} and @var{all-frames} specify the 619 The optional arguments @var{minibuf} and @var{all-frames} specify the
663 set of windows to include in the scan. See @code{next-window}, above, 620 set of windows to include in the walk. See @code{next-window}, above,
664 for details. 621 for details.
665 @end defun 622 @end defun
666 623
667 @defun window-list &optional frame minibuf window 624 @defun window-list &optional frame minibuf window
668 This function returns a list of the windows on @var{frame}, starting 625 This function returns a list of all windows on @var{frame}, starting
669 with @var{window}. If @var{frame} is @code{nil} or omitted, 626 with @var{window}. @var{frame} defaults to the selected frame;
670 @code{window-list} uses the selected frame instead; if @var{window} is 627 @var{window} to the selected window.
671 @code{nil} or omitted, it uses the selected window. 628
672 629 The value of @var{minibuf} specifies if the minibuffer window shall be
673 The value of @var{minibuf} specifies if the minibuffer window is
674 included in the result list. If @var{minibuf} is @code{t}, the result 630 included in the result list. If @var{minibuf} is @code{t}, the result
675 always includes the minibuffer window. If @var{minibuf} is @code{nil} 631 always includes the minibuffer window. If @var{minibuf} is @code{nil}
676 or omitted, that includes the minibuffer window if it is active. If 632 or omitted, that includes the minibuffer window if it is active. If
677 @var{minibuf} is neither @code{nil} nor @code{t}, the result never 633 @var{minibuf} is neither @code{nil} nor @code{t}, the result never
678 includes the minibuffer window. 634 includes the minibuffer window.
691 @end iftex 647 @end iftex
692 @ifnottex 648 @ifnottex
693 @xref{Displaying Buffers}, for 649 @xref{Displaying Buffers}, for
694 @end ifnottex 650 @end ifnottex
695 related functions that find a window to use and specify a buffer for it. 651 related functions that find a window to use and specify a buffer for it.
696 The functions described there are easier to use than these, but they 652 The functions described there are easier to use, but they employ
697 employ heuristics in choosing or creating a window; use these functions 653 heuristics in choosing or creating a window; use the functions described
698 when you need complete control. 654 here when you need complete control.
699 655
700 @defun set-window-buffer window buffer-or-name &optional keep-margins 656 @defun set-window-buffer window buffer-or-name &optional keep-margins
701 This function makes @var{window} display @var{buffer-or-name} as its 657 This function makes @var{window} display @var{buffer-or-name} as its
702 contents. It returns @code{nil}. @var{buffer-or-name} must be a 658 contents. It returns @code{nil}. @var{buffer-or-name} must be a
703 buffer, or the name of an existing buffer. This is the fundamental 659 buffer, or the name of an existing buffer. This is the fundamental
709 (set-window-buffer (selected-window) "foo") 665 (set-window-buffer (selected-window) "foo")
710 @result{} nil 666 @result{} nil
711 @end group 667 @end group
712 @end example 668 @end example
713 669
714 Normally, displaying @var{buffer} in @var{window} resets the window's 670 Normally, displaying @var{buffer-or-name} in @var{window} resets the
715 display margins, fringe widths, scroll bar settings, and position 671 window's position, display margins, fringe widths, and scroll bar
716 based on the local variables of @var{buffer}. However, if 672 settings, to values based on the local variables of that buffer.
717 @var{keep-margins} is non-@code{nil}, the display margins and fringe 673 However, if @var{keep-margins} is non-@code{nil}, display margins and
718 widths of @var{window} remain unchanged. @xref{Fringes}. 674 fringe widths of @var{window} remain unchanged. @xref{Fringes}.
675
676 This function signals an error when @var{window} is @dfn{strongly}
677 dedicated to its buffer (@pxref{Dedicated Windows}) and does not already
678 display @var{buffer-or-name}.
679
680 This function runs @code{window-scroll-functions} before running
681 @code{window-configuration-change-hook}.
719 @end defun 682 @end defun
720 683
721 @defvar buffer-display-count 684 @defvar buffer-display-count
722 This buffer-local variable records the number of times a buffer is 685 This buffer-local variable records the number of times a buffer has been
723 displayed in a window. It is incremented each time 686 displayed in a window. It is incremented each time
724 @code{set-window-buffer} is called for the buffer. 687 @code{set-window-buffer} is called for the buffer.
725 @end defvar 688 @end defvar
726 689
727 @defun window-buffer &optional window 690 @defun window-buffer &optional window
728 This function returns the buffer that @var{window} is displaying. If 691 This function returns the buffer that @var{window} is displaying.
729 @var{window} is omitted, this function returns the buffer for the 692 @var{window} defaults to the selected window.
730 selected window.
731 693
732 @example 694 @example
733 @group 695 @group
734 (window-buffer) 696 (window-buffer)
735 @result{} #<buffer windows.texi> 697 @result{} #<buffer windows.texi>
748 the current buffer. The argument @var{all-frames} specifies which 710 the current buffer. The argument @var{all-frames} specifies which
749 windows to consider: 711 windows to consider:
750 712
751 @itemize @bullet 713 @itemize @bullet
752 @item 714 @item
753 If it is @code{nil}, consider windows on the selected frame. 715 @code{nil} means consider windows on the selected frame.
754 @item 716 @item
755 If it is @code{t}, consider windows on all frames. 717 @code{t} means consider windows on all existing frames.
756 @item 718 @item
757 If it is @code{visible}, consider windows on all visible frames. 719 @code{visible} means consider windows on all visible frames.
758 @item 720 @item
759 If it is 0, consider windows on all visible or iconified frames. 721 0 means consider windows on all visible or iconified frames.
760 @item 722 @item
761 If it is a frame, consider windows on that frame. 723 A frame means consider windows on that frame only.
762 @end itemize 724 @end itemize
725
726 Observe that the behavior of @code{get-buffer-window} may differ from
727 that of @code{next-window} (@pxref{Cyclic Window Ordering}) when
728 @var{all-frames} equals @code{nil} or any value not listed here.
729 Perhaps we will change @code{get-buffer-window} in the future to make it
730 compatible with the other functions.
763 @end defun 731 @end defun
764 732
765 @defun get-buffer-window-list &optional buffer-or-name minibuf all-frames 733 @defun get-buffer-window-list &optional buffer-or-name minibuf all-frames
766 This function returns a list of all windows currently displaying 734 This function returns a list of all windows currently displaying
767 @var{buffer-or-name}. @var{buffer-or-name} may be a buffer or the name 735 @var{buffer-or-name}. @var{buffer-or-name} may be a buffer or the name
768 of an existing buffer and defaults to nil. 736 of an existing buffer and defaults to the current buffer.
769 737
770 The two remaining arguments work like the synonymous arguments of 738 The two remaining arguments work like the same-named arguments of
771 @code{next-window} (@pxref{Cyclic Window Ordering}); they are @emph{not} 739 @code{next-window}; they are @emph{not} like the optional arguments of
772 like the second optional argument of @code{get-buffer-window}. Perhaps 740 @code{get-buffer-window}.
773 we should change @code{get-buffer-window} in the future to make it
774 compatible with the other functions.
775 @end defun 741 @end defun
776 742
777 @defvar buffer-display-time 743 @defvar buffer-display-time
778 This variable records the time at which a buffer was last made visible 744 This variable records the time at which a buffer was last made visible
779 in a window. It is always local in each buffer; each time 745 in a window. It is always local in each buffer; each time
813 @deffn Command switch-to-buffer buffer-or-name &optional norecord 779 @deffn Command switch-to-buffer buffer-or-name &optional norecord
814 This function makes @var{buffer-or-name} the current buffer, and also 780 This function makes @var{buffer-or-name} the current buffer, and also
815 displays the buffer in the selected window. This means that a human can 781 displays the buffer in the selected window. This means that a human can
816 see the buffer and subsequent keyboard commands will apply to it. 782 see the buffer and subsequent keyboard commands will apply to it.
817 Contrast this with @code{set-buffer}, which makes @var{buffer-or-name} 783 Contrast this with @code{set-buffer}, which makes @var{buffer-or-name}
818 the current buffer but does not display it in the selected window. 784 the current buffer but does not display it in the selected window,
819 @xref{Current Buffer}. 785 @xref{Current Buffer}.
820 786
821 If @var{buffer-or-name} does not identify an existing buffer, then a new 787 If @var{buffer-or-name} is @code{nil}, @code{switch-to-buffer} chooses a
822 buffer by that name is created. The major mode for the new buffer is 788 buffer using @code{other-buffer}. If @var{buffer-or-name} is a string
823 set according to the variable @code{default-major-mode}. @xref{Auto 789 that does not identify an existing buffer, then a new buffer by that
824 Major Mode}. If @var{buffer-or-name} is @code{nil}, 790 name is created. The major mode for the new buffer is set according to
825 @code{switch-to-buffer} chooses a buffer using @code{other-buffer}. 791 the variable @code{default-major-mode}, @xref{Auto Major Mode}.
826 792
827 Normally the specified buffer is put at the front of the buffer list 793 Normally the specified buffer is put at the front of the buffer list
828 (both the selected frame's buffer list and the frame-independent buffer 794 (both the selected frame's buffer list and the frame-independent buffer
829 list). This affects the operation of @code{other-buffer}. However, if 795 list). This affects the operation of @code{other-buffer}. However, if
830 @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer 796 @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer
837 803
838 The next two functions are similar to @code{switch-to-buffer}, except 804 The next two functions are similar to @code{switch-to-buffer}, except
839 for the described features. 805 for the described features.
840 806
841 @deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord 807 @deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord
842 This function makes @var{buffer-or-name} the current buffer and 808 This function makes @var{buffer-or-name} the current buffer, displays it
843 displays it in a window not currently selected. It then selects that 809 in a window not currently selected, and selects that window. The
844 window. The handling of the buffer is the same as in 810 handling of the buffer is the same as in @code{switch-to-buffer}.
845 @code{switch-to-buffer}.
846 811
847 The currently selected window is absolutely never used to do the job. 812 The currently selected window is absolutely never used to do the job.
848 If it is the only window, then it is split to make a distinct window for 813 If it is the only window, then it is split to make a distinct window for
849 this purpose. If the selected window is already displaying the buffer, 814 this purpose. If the selected window is already displaying the buffer,
850 then it continues to do so, but another window is nonetheless found to 815 then it continues to do so, but another window is nonetheless found to
852 817
853 This function updates the buffer list just like @code{switch-to-buffer} 818 This function updates the buffer list just like @code{switch-to-buffer}
854 unless @var{norecord} is non-@code{nil}. 819 unless @var{norecord} is non-@code{nil}.
855 @end deffn 820 @end deffn
856 821
857 @defun pop-to-buffer buffer-or-name &optional other-window norecord 822 @deffn Command pop-to-buffer buffer-or-name &optional other-window norecord
858 This function makes @var{buffer-or-name} the current buffer and switches 823 This command makes @var{buffer-or-name} the current buffer and switches
859 to it in some window, preferably not the window previously selected. 824 to it in some window, preferably not the window previously selected.
860 The ``popped-to'' window becomes the selected window. Its frame is 825 The ``popped-to'' window becomes the selected window. Its frame is
861 given the X server's focus if possible, see @ref{Input Focus}. The 826 given the X server's focus, if possible, @xref{Input Focus}. The return
862 return value is the buffer that was switched to. If 827 value is the buffer that was switched to.
863 @var{buffer-or-name} is @code{nil}, that means to choose some other 828
864 buffer, but you don't specify which. 829 If @var{buffer-or-name} is @code{nil}, that means to choose some other
830 buffer, but you don't specify which. If @var{buffer-or-name} is a
831 string that does not name an existing buffer, a buffer by that name is
832 created. The major mode for the new buffer is set according to the
833 variable @code{default-major-mode}. @xref{Auto Major Mode}.
865 834
866 If the variable @code{pop-up-frames} is non-@code{nil}, 835 If the variable @code{pop-up-frames} is non-@code{nil},
867 @code{pop-to-buffer} looks for a window in any visible frame already 836 @code{pop-to-buffer} looks for a window in any visible frame already
868 displaying the buffer; if there is one, it returns that window and makes 837 displaying the buffer; if there is one, it selects and returns that
869 it be selected within its frame. If there is none, it creates a new 838 window. If no such window exists, it creates a new frame and displays
870 frame and displays the buffer in it. 839 the buffer in it.
871 840
872 If @code{pop-up-frames} is @code{nil}, then @code{pop-to-buffer} 841 If @code{pop-up-frames} is @code{nil}, then @code{pop-to-buffer}
873 operates entirely within the selected frame. (If the selected frame has 842 operates entirely within the selected frame. (If the selected frame has
874 just a minibuffer, @code{pop-to-buffer} operates within the most 843 just a minibuffer, @code{pop-to-buffer} operates within the most
875 recently selected frame that was not just a minibuffer.) 844 recently selected frame that was not just a minibuffer.)
876 845
877 If the variable @code{pop-up-windows} is non-@code{nil}, windows may 846 If the variable @code{pop-up-windows} is non-@code{nil}, windows may be
878 be split to create a new window that is different from the original 847 split to create a new window that is different from the original window.
879 window. For details, see @ref{Choosing Window}. 848 For details, @xref{Choosing Window}.
880 849
881 If @var{other-window} is non-@code{nil}, @code{pop-to-buffer} finds or 850 If @var{other-window} is non-@code{nil}, @code{pop-to-buffer} finds or
882 creates another window even if @var{buffer-or-name} is already visible 851 creates another window even if @var{buffer-or-name} is already visible
883 in the selected window. Thus @var{buffer-or-name} could end up 852 in the selected window. Thus @var{buffer-or-name} could end up
884 displayed in two windows. On the other hand, if @var{buffer-or-name} is 853 displayed in two windows. On the other hand, if @var{buffer-or-name} is
885 already displayed in the selected window and @var{other-window} is 854 already displayed in the selected window and @var{other-window} is
886 @code{nil}, then the selected window is considered sufficient display 855 @code{nil}, then the selected window is considered sufficient for
887 for @var{buffer-or-name}, so that nothing needs to be done. 856 displaying @var{buffer-or-name}, so that nothing needs to be done.
888 857
889 All the variables that affect @code{display-buffer} affect 858 All the variables that affect @code{display-buffer} affect
890 @code{pop-to-buffer} as well. @xref{Choosing Window}. 859 @code{pop-to-buffer} as well. @xref{Choosing Window}.
891 860
892 If @var{buffer-or-name} is a string that does not name an existing
893 buffer, a buffer by that name is created. The major mode for the new
894 buffer is set according to the variable @code{default-major-mode}.
895 @xref{Auto Major Mode}.
896
897 This function updates the buffer list just like @code{switch-to-buffer} 861 This function updates the buffer list just like @code{switch-to-buffer}
898 unless @var{norecord} is non-@code{nil}. 862 unless @var{norecord} is non-@code{nil}.
899 @end defun 863 @end deffn
900 864
901 @deffn Command replace-buffer-in-windows &optional buffer-or-name 865 @deffn Command replace-buffer-in-windows &optional buffer-or-name
902 This function replaces @var{buffer-or-name} in all windows displaying 866 This function replaces @var{buffer-or-name} in all windows displaying
903 it with some other buffer. It uses @code{other-buffer} to choose the 867 it with some other buffer. It uses @code{other-buffer} to choose the
904 other buffer. In the usual applications of this function, you 868 other buffer. In the usual applications of this function, you
906 @var{buffer-or-name} is no longer displayed. 870 @var{buffer-or-name} is no longer displayed.
907 871
908 @var{buffer-or-name} may be a buffer or the name of an existing buffer 872 @var{buffer-or-name} may be a buffer or the name of an existing buffer
909 and defaults to the current buffer. 873 and defaults to the current buffer.
910 874
911 If a window displaying @var{buffer-or-name} is dedicated, and is not the 875 If a window displaying @var{buffer-or-name} is dedicated
912 only window on its frame, that window is deleted. If that window is the 876 (@pxref{Dedicated Windows}), and is not the only window on its frame,
913 only window on its frame and there are other frames left, the window's 877 that window is deleted. If that window is the only window on its frame
914 frame is deleted too. If there are no other frames left, some other 878 and there are other frames left, the window's frame is deleted too. If
915 buffer is displayed in that window. 879 there are no other frames left, some other buffer is displayed in that
880 window.
916 881
917 This function returns @code{nil}. 882 This function returns @code{nil}.
918 @end deffn 883 @end deffn
919 884
920 @node Choosing Window 885 @node Choosing Window
921 @section Choosing a Window for Display 886 @section Choosing a Window for Display
922 887
923 This section describes the basic facility that chooses a window to 888 This section describes the basic facility that chooses a window to
924 display a buffer in---@code{display-buffer}. All the higher-level 889 display a buffer in---@code{display-buffer}. Higher-level functions and
925 functions and commands use this subroutine. Here we describe how to use 890 commands like @code{switch-to-buffer} and @code{pop-to-buffer} use this
926 @code{display-buffer} and how to customize it. 891 subroutine. Here we describe how to use @code{display-buffer} and how
892 to customize it.
927 893
928 @deffn Command display-buffer buffer-or-name &optional not-this-window frame 894 @deffn Command display-buffer buffer-or-name &optional not-this-window frame
929 This command makes @var{buffer-or-name} appear in some window, but it 895 This command makes @var{buffer-or-name} appear in some window, but it
930 does not select that window and does not make the buffer specified by 896 does not select that window and does not make the buffer specified by
931 @var{buffer-or-name} current. The identity of the selected window is 897 @var{buffer-or-name} current. The identity of the selected window is
932 unaltered by this function. @var{buffer-or-name} must be a buffer, or 898 unaltered by this function. @var{buffer-or-name} must be a buffer, or
933 the name of an existing buffer. 899 the name of an existing buffer.
934 900
935 If @var{not-this-window} is non-@code{nil}, it means to display the 901 @var{not-this-window} non-@code{nil} means to display the specified
936 specified buffer in a window other than the selected one, even if it is 902 buffer in a window other than the selected one, even if it is already
937 already on display in the selected window. This can cause the buffer to 903 displayed in the selected window. This can cause the buffer to appear
938 appear in two windows at once. Otherwise, if @var{buffer-or-name} is 904 in two windows at once. Otherwise, if @var{buffer-or-name} is already
939 already being displayed in any window, that is good enough, so this 905 being displayed in any window, that is good enough, so this function
940 function does nothing. 906 does nothing.
941 907
942 @code{display-buffer} returns the window chosen to display 908 @code{display-buffer} returns the window chosen to display
943 @var{buffer-or-name}. 909 @var{buffer-or-name}.
944 910
945 If the argument @var{frame} is non-@code{nil}, it specifies which frames 911 If the argument @var{frame} is non-@code{nil}, it specifies which frames
948 @code{display-buffer} simply returns that window. Here are the possible 914 @code{display-buffer} simply returns that window. Here are the possible
949 values of @var{frame}: 915 values of @var{frame}:
950 916
951 @itemize @bullet 917 @itemize @bullet
952 @item 918 @item
953 If it is @code{nil}, consider windows on the selected frame. 919 @code{nil} means consider windows on the selected frame.
954 (Actually, the last non-minibuffer frame.) 920 (Actually, the last non-minibuffer frame.)
955 @item 921 @item
956 If it is @code{t}, consider windows on all frames. 922 @code{t} means consider windows on all frames.
957 @item 923 @item
958 If it is @code{visible}, consider windows on all visible frames. 924 @code{visible} means consider windows on all visible frames.
959 @item 925 @item
960 If it is 0, consider windows on all visible or iconified frames. 926 0 means consider windows on all visible or iconified frames.
961 @item 927 @item
962 If it is a frame, consider windows on that frame. 928 A frame means consider windows on that frame only.
963 @end itemize 929 @end itemize
964 930
965 Precisely how @code{display-buffer} finds or creates a window depends on 931 Precisely how @code{display-buffer} finds or creates a window depends on
966 the variables described below. 932 the variables described below.
967 @end deffn 933 @end deffn
1015 981
1016 A window whose height is fixed (@pxref{Resizing Windows}) cannot be 982 A window whose height is fixed (@pxref{Resizing Windows}) cannot be
1017 split vertically by @code{display-buffer}. Also, @code{display-buffer} 983 split vertically by @code{display-buffer}. Also, @code{display-buffer}
1018 splits a window vertically only if it can accommodate two windows that 984 splits a window vertically only if it can accommodate two windows that
1019 are both at least `window-min-height' lines tall. Moreover, if the 985 are both at least `window-min-height' lines tall. Moreover, if the
1020 window that shall be split has a mode-line, the window must be at least 986 window that shall be split has a mode line, the window must be at least
1021 four lines tall in order to make sure that the new window can have a 987 four lines tall in order to make sure that the new window can have a
1022 mode-line as well. If the original window doesn't have a mode-line, a 988 mode line as well. If the original window doesn't have a mode line, a
1023 height of two lines suffices. 989 height of two lines suffices.
1024 @end defopt 990 @end defopt
1025 991
1026 @defopt split-width-threshold 992 @defopt split-width-threshold
1027 This variable specifies whether @code{display-buffer} may split a window 993 This variable specifies whether @code{display-buffer} may split a window
1052 This variable specifies whether @code{display-buffer} makes new frames. 1018 This variable specifies whether @code{display-buffer} makes new frames.
1053 If it is non-@code{nil}, @code{display-buffer} looks for an existing 1019 If it is non-@code{nil}, @code{display-buffer} looks for an existing
1054 window already displaying the desired buffer, on any visible frame. If 1020 window already displaying the desired buffer, on any visible frame. If
1055 it finds one, it returns that window. Otherwise it makes a new frame, 1021 it finds one, it returns that window. Otherwise it makes a new frame,
1056 unless the variable's value is @code{graphic-only} and the selected 1022 unless the variable's value is @code{graphic-only} and the selected
1057 frame is not on a graphic display. Note that the value of 1023 frame is not on a graphic display. @xref{Frames}, for more information.
1058 @code{pop-up-windows} does not matter if @code{pop-up-frames} is 1024
1059 non-@code{nil}. 1025 Note that the value of @code{pop-up-windows} does not matter if
1060 1026 @code{pop-up-frames} is non-@code{nil}. If @code{pop-up-frames} is
1061 If @code{pop-up-frames} is @code{nil}, then @code{display-buffer} either 1027 @code{nil}, then @code{display-buffer} either splits a window or reuses
1062 splits a window or reuses one. 1028 one.
1063
1064 @xref{Frames}, for more information.
1065 @end defopt 1029 @end defopt
1066 1030
1067 @c Emacs 19 feature 1031 @c Emacs 19 feature
1068 @defopt pop-up-frame-function 1032 @defopt pop-up-frame-function
1069 This variable specifies how to make a new frame if @code{pop-up-frames} 1033 This variable specifies how to make a new frame if @code{pop-up-frames}
1081 @code{display-buffer} makes a new frame. @xref{Frame Parameters}, for 1045 @code{display-buffer} makes a new frame. @xref{Frame Parameters}, for
1082 more information about frame parameters. 1046 more information about frame parameters.
1083 @end defopt 1047 @end defopt
1084 1048
1085 @defopt special-display-buffer-names 1049 @defopt special-display-buffer-names
1086 A list of buffer names for buffers that should be displayed specially. 1050 A list of buffer names identifying buffers that should be displayed
1087 If the name of @var{buffer-or-name} is in this list, 1051 specially. If the name of @var{buffer-or-name} is in this list,
1088 @code{display-buffer} handles the buffer specially. 1052 @code{display-buffer} handles the buffer specially. By default, special
1089 1053 display means to give the buffer a dedicated frame.
1090 By default, special display means to give the buffer a dedicated frame.
1091 1054
1092 If an element is a list, instead of a string, then the @sc{car} of that 1055 If an element is a list, instead of a string, then the @sc{car} of that
1093 list is the buffer name, and the rest of that list says how to create 1056 list is the buffer name, and the rest of that list says how to create
1094 the frame. There are two possibilities for the rest of that list (its 1057 the frame. There are two possibilities for the rest of that list (its
1095 @sc{cdr}): It can be an alist, specifying frame parameters, or it can 1058 @sc{cdr}): It can be an alist, specifying frame parameters, or it can
1115 @var{value})} and @var{value} is non-@code{nil}, that means to display 1078 @var{value})} and @var{value} is non-@code{nil}, that means to display
1116 the buffer in a new window in the currently selected frame. 1079 the buffer in a new window in the currently selected frame.
1117 @end defopt 1080 @end defopt
1118 1081
1119 @defopt special-display-regexps 1082 @defopt special-display-regexps
1120 A list of regular expressions that specify buffers that should be 1083 A list of regular expressions specifying buffers that should be
1121 displayed specially. If the buffer's name matches any of the regular 1084 displayed specially. If the buffer's name matches any of the regular
1122 expressions in this list, @code{display-buffer} handles the buffer 1085 expressions in this list, @code{display-buffer} handles the buffer
1123 specially. 1086 specially. By default, special display means to give the buffer a
1124 1087 dedicated frame.
1125 By default, special display means to give the buffer a dedicated frame.
1126 1088
1127 If an element is a list, instead of a string, then the @sc{car} of the 1089 If an element is a list, instead of a string, then the @sc{car} of the
1128 list is the regular expression, and the rest of the list says how to 1090 list is the regular expression, and the rest of the list says how to
1129 create the frame. See above, under @code{special-display-buffer-names}. 1091 create the frame. See @code{special-display-buffer-names} above.
1130 @end defopt 1092 @end defopt
1131 1093
1132 @defun special-display-p buffer-name 1094 @defun special-display-p buffer-name
1133 This function returns non-@code{nil} if displaying a buffer 1095 This function returns non-@code{nil} if displaying a buffer
1134 named @var{buffer-name} with @code{display-buffer} would 1096 named @var{buffer-name} with @code{display-buffer} would
1138 @end defun 1100 @end defun
1139 1101
1140 @defvar special-display-function 1102 @defvar special-display-function
1141 This variable holds the function to call to display a buffer specially. 1103 This variable holds the function to call to display a buffer specially.
1142 It receives the buffer as an argument, and should return the window in 1104 It receives the buffer as an argument, and should return the window in
1143 which it is displayed. 1105 which it is displayed. The default value of this variable is
1144 1106 @code{special-display-popup-frame}, see below.
1145 The default value of this variable is
1146 @code{special-display-popup-frame}.
1147 @end defvar 1107 @end defvar
1148 1108
1149 @defun special-display-popup-frame buffer &optional args 1109 @defun special-display-popup-frame buffer &optional args
1150 This function makes @var{buffer} visible in a frame of its own. If 1110 This function tries to make @var{buffer} visible in a frame of its own.
1151 @var{buffer} is already displayed in a window in some frame, it makes 1111 If @var{buffer} is already displayed in some window, it makes that
1152 the frame visible and raises it, to use that window. Otherwise, it 1112 window's frame visible and raises it. Otherwise, it creates a frame
1153 creates a frame that will be dedicated to @var{buffer}. This 1113 that is dedicated to @var{buffer}. The return value is the window used
1154 function returns the window it used. 1114 to display @var{buffer}.
1155 1115
1156 If @var{args} is an alist, it specifies frame parameters for the new 1116 If @var{args} is an alist, it specifies frame parameters for the new
1157 frame. 1117 frame. If @var{args} is a list whose @sc{car} is a symbol, then
1158 1118 @code{(car @var{args})} is called as a function to actually create and
1159 If @var{args} is a list whose @sc{car} is a symbol, then @code{(car 1119 set up the frame; it is called with @var{buffer} as first argument, and
1160 @var{args})} is called as a function to actually create and set up the 1120 @code{(cdr @var{args})} as additional arguments.
1161 frame; it is called with @var{buffer} as first argument, and @code{(cdr
1162 @var{args})} as additional arguments.
1163 1121
1164 This function always uses an existing window displaying @var{buffer}, 1122 This function always uses an existing window displaying @var{buffer},
1165 whether or not it is in a frame of its own; but if you set up the above 1123 whether or not it is in a frame of its own; but if you set up the above
1166 variables in your init file, before @var{buffer} was created, then 1124 variables in your init file, before @var{buffer} was created, then
1167 presumably the window was previously made by this function. 1125 presumably the window was previously made by this function.
1204 1162
1205 This variable takes precedence over all the other options described 1163 This variable takes precedence over all the other options described
1206 above. 1164 above.
1207 @end defvar 1165 @end defvar
1208 1166
1209 @c Emacs 19 feature 1167 If all options described above fail to produce a suitable window,
1168 @code{display-buffer} tries to reuse an existing window. As a last
1169 resort, it will try to display @var{buffer-or-name} on a separate frame.
1170 In that case, the value of @code{pop-up-frames} is disregarded.
1171
1172 @node Dedicated Windows
1173 @section Dedicated Windows
1210 @cindex dedicated window 1174 @cindex dedicated window
1211 If all options described above fail to produce a suitable window, 1175
1212 @code{display-buffer} will try to use an existing window. You can avoid 1176 Functions for displaying a buffer can be told to not use specific
1213 that @code{display-buffer} uses a specific window by marking that window 1177 windows by marking these window as @dfn{dedicated} to their buffers.
1214 as @dfn{dedicated} to its buffer. Then @code{display-buffer} will not 1178 @code{display-buffer} (@pxref{Choosing Window}) never uses a dedicated
1215 try to use that window to display any other buffer. Moreover, 1179 window for displaying another buffer in it. @code{get-lru-window} and
1216 @code{set-window-buffer} will signal an error when asked to display 1180 @code{get-largest-window} (@pxref{Selecting Windows}) do not consider
1217 another buffer in it. Both @code{get-lru-window} and 1181 dedicated windows as candidates when their @var{dedicated} argument is
1218 @code{get-largest-window} do not consider dedicated windows as 1182 non-@code{nil}. The behavior of @code{set-window-buffer}
1219 candidates when their @var{dedicated} argument is non-@code{nil}. 1183 (@pxref{Buffers and Windows}) with respect to dedicated windows is
1220 1184 slightly different, see below.
1221 When @code{delete-windows-on} deletes a dedicated window and that window 1185
1222 is the only window on its frame, it will delete that frame as well if 1186 When @code{delete-windows-on} (@pxref{Deleting Windows}) wants to delete
1223 there are other frames left. @code{replace-buffer-in-windows} deletes 1187 a dedicated window and that window is the only window on its frame, it
1224 any dedicated window showing its buffer argument. When such a window is 1188 deletes the window's frame too, provided there are other frames left.
1225 the only window on its frame, that frame is deleted if there are other 1189 @code{replace-buffer-in-windows} (@pxref{Displaying Buffers}) tries to
1226 frames left. If there are no more frames left, some other buffer is 1190 delete all dedicated windows showing its buffer argument. When such a
1227 displayed in the window and the window is marked as non-dedicated. 1191 window is the only window on its frame, that frame is deleted, provided
1192 there are other frames left. If there are no more frames left, some
1193 other buffer is displayed in the window, and the window is marked as
1194 non-dedicated.
1195
1196 When you kill a buffer (@pxref{Killing Buffers}) displayed in a
1197 dedicated window, any such window usually gets deleted too, since
1198 @code{kill-buffer} calls @code{replace-buffer-in-windows} for cleaning
1199 up windows. Burying a buffer (@pxref{The Buffer List}) deletes the
1200 selected window if it is dedicated and shows that buffer. However, if
1201 that window is the only window on its frame, another buffer is displayed
1202 in it and the frame is iconified.
1228 1203
1229 @defun window-dedicated-p &optional window 1204 @defun window-dedicated-p &optional window
1230 This function returns non-@code{nil} if @var{window} is dedicated to its 1205 This function returns non-@code{nil} if @var{window} is dedicated to its
1231 buffer and @code{nil} otherwise. More precisely, the return value is 1206 buffer and @code{nil} otherwise. More precisely, the return value is
1232 the value assigned by the last call of @code{set-window-dedicated-p} for 1207 the value assigned by the last call of @code{set-window-dedicated-p} for
1233 @var{window} or @code{nil} if that function was never called with 1208 @var{window} or @code{nil} if that function was never called with
1234 @var{WINDOW} as its argument. 1209 @var{WINDOW} as its argument. @var{WINDOW} defaults to the selected
1210 window.
1235 @end defun 1211 @end defun
1236 1212
1237 @defun set-window-dedicated-p window flag 1213 @defun set-window-dedicated-p window flag
1238 This function marks @var{window} as dedicated to its buffer if 1214 This function marks @var{window} as dedicated to its buffer if
1239 @var{flag} is non-@code{nil}, and non-dedicated otherwise. 1215 @var{flag} is non-@code{nil}, and non-dedicated otherwise.
1240 @end defun 1216
1241 1217 As a special case, if @var{flag} is @code{t}, @var{window} becomes
1242 As a last resort, @code{display-buffer} tries to display 1218 @dfn{strongly} dedicated to its buffer. @code{set-window-buffer}
1243 @var{buffer-or-name} on a new frame. In this case, the value of 1219 signals an error when the window it acts upon is strongly dedicated to
1244 @code{pop-up-frames} is disregarded. 1220 its buffer and does not already display the buffer it is asked to
1245 1221 display. In any other case, @code{set-window-buffer} will display
1222 another buffer in that window. Other functions do not treat @code{t}
1223 differently from any non-@code{nil} value.
1224 @end defun
1246 1225
1247 @node Window Point 1226 @node Window Point
1248 @section Windows and Point 1227 @section Windows and Point
1249 @cindex window position 1228 @cindex window position
1250 @cindex window point 1229 @cindex window point
1251 @cindex position in window 1230 @cindex position in window
1252 @cindex point in window 1231 @cindex point in window
1253 1232
1254 Each window has its own value of point, independent of the value of 1233 Each window has its own value of point (@pxref{Point}), independent of
1255 point in other windows displaying the same buffer. This makes it useful 1234 the value of point in other windows displaying the same buffer. This
1256 to have multiple windows showing one buffer. 1235 makes it useful to have multiple windows showing one buffer.
1257 1236
1258 @itemize @bullet 1237 @itemize @bullet
1259 @item 1238 @item
1260 The window point is established when a window is first created; it is 1239 The window point is established when a window is first created; it is
1261 initialized from the buffer's point, or from the window point of another 1240 initialized from the buffer's point, or from the window point of another
1272 @item 1251 @item
1273 As long as the selected window displays the current buffer, the window's 1252 As long as the selected window displays the current buffer, the window's
1274 point and the buffer's point always move together; they remain equal. 1253 point and the buffer's point always move together; they remain equal.
1275 @end itemize 1254 @end itemize
1276 1255
1277 @noindent
1278 @xref{Positions}, for more details on buffer positions.
1279
1280 @cindex cursor 1256 @cindex cursor
1281 As far as the user is concerned, point is where the cursor is, and 1257 As far as the user is concerned, point is where the cursor is, and
1282 when the user switches to another buffer, the cursor jumps to the 1258 when the user switches to another buffer, the cursor jumps to the
1283 position of point in that buffer. 1259 position of point in that buffer.
1284 1260
1285 @defun window-point &optional window 1261 @defun window-point &optional window
1286 This function returns the current position of point in @var{window}. 1262 This function returns the current position of point in @var{window}.
1287 For a nonselected window, this is the value point would have (in that 1263 For a nonselected window, this is the value point would have (in that
1288 window's buffer) if that window were selected. If @var{window} is 1264 window's buffer) if that window were selected. @var{window} defaults to
1289 @code{nil}, the selected window is used. 1265 the selected window.
1290 1266
1291 When @var{window} is the selected window and its buffer is also the 1267 When @var{window} is the selected window and its buffer is also the
1292 current buffer, the value returned is the same as point in that buffer. 1268 current buffer, the value returned is the same as point in that buffer.
1293 1269 Strictly speaking, it would be more correct to return the ``top-level''
1294 Strictly speaking, it would be more correct to return the 1270 value of point, outside of any @code{save-excursion} forms. But that
1295 ``top-level'' value of point, outside of any @code{save-excursion} 1271 value is hard to find.
1296 forms. But that value is hard to find.
1297 @end defun 1272 @end defun
1298 1273
1299 @defun set-window-point window position 1274 @defun set-window-point window position
1300 This function positions point in @var{window} at position 1275 This function positions point in @var{window} at position
1301 @var{position} in @var{window}'s buffer. It returns @var{position}. 1276 @var{position} in @var{window}'s buffer. It returns @var{position}.
1302 1277
1303 If @var{window} is selected, and its buffer is current, 1278 If @var{window} is selected, and its buffer is current,
1304 this simply does @code{goto-char}. 1279 this simply does @code{goto-char}.
1305 @end defun 1280 @end defun
1306 1281
1307 @node Window Start 1282 @node Window Start and End
1308 @section The Window Start Position 1283 @section The Window Start and End Positions
1309 @cindex window start position 1284 @cindex window start position
1310 1285
1311 Each window contains a marker used to keep track of a buffer position 1286 Each window maintains a marker used to keep track of a buffer position
1312 that specifies where in the buffer display should start. This position 1287 that specifies where in the buffer display should start. This position
1313 is called the @dfn{display-start} position of the window (or just the 1288 is called the @dfn{display-start} position of the window (or just the
1314 @dfn{start}). The character after this position is the one that appears 1289 @dfn{start}). The character after this position is the one that appears
1315 at the upper left corner of the window. It is usually, but not 1290 at the upper left corner of the window. It is usually, but not
1316 inevitably, at the beginning of a text line. 1291 inevitably, at the beginning of a text line.
1337 @end group 1312 @end group
1338 @end example 1313 @end example
1339 1314
1340 When you create a window, or display a different buffer in it, the 1315 When you create a window, or display a different buffer in it, the
1341 display-start position is set to a display-start position recently used 1316 display-start position is set to a display-start position recently used
1342 for the same buffer, or 1 if the buffer doesn't have any. 1317 for the same buffer, or to @code{point-min} if the buffer doesn't have
1318 any.
1343 1319
1344 Redisplay updates the window-start position (if you have not specified 1320 Redisplay updates the window-start position (if you have not specified
1345 it explicitly since the previous redisplay)---for example, to make sure 1321 it explicitly since the previous redisplay)---to make sure point appears
1346 point appears on the screen. Nothing except redisplay automatically 1322 on the screen. Nothing except redisplay automatically changes the
1347 changes the window-start position; if you move point, do not expect the 1323 window-start position; if you move point, do not expect the window-start
1348 window-start position to change in response until after the next 1324 position to change in response until after the next redisplay.
1349 redisplay.
1350 1325
1351 For a realistic example of using @code{window-start}, see the 1326 For a realistic example of using @code{window-start}, see the
1352 description of @code{count-lines}. @xref{Definition of count-lines}. 1327 description of @code{count-lines}. @xref{Definition of count-lines}.
1353 @end defun 1328 @end defun
1354 1329
1330 @cindex window end position
1355 @defun window-end &optional window update 1331 @defun window-end &optional window update
1356 This function returns the position of the end of the display in window 1332 This function returns the position where display of its buffer ends in
1357 @var{window}. If @var{window} is @code{nil}, the selected window is 1333 @var{window}. @var{window} defaults to the selected window.
1358 used.
1359 1334
1360 Simply changing the buffer text or moving point does not update the 1335 Simply changing the buffer text or moving point does not update the
1361 value that @code{window-end} returns. The value is updated only when 1336 value that @code{window-end} returns. The value is updated only when
1362 Emacs redisplays and redisplay completes without being preempted. 1337 Emacs redisplays and redisplay completes without being preempted.
1363 1338
1364 If the last redisplay of @var{window} was preempted, and did not finish, 1339 If the last redisplay of @var{window} was preempted, and did not finish,
1365 Emacs does not know the position of the end of display in that window. 1340 Emacs does not know the position of the end of display in that window.
1366 In that case, this function returns @code{nil}. 1341 In that case, this function returns @code{nil}.
1367 1342
1368 If @var{update} is non-@code{nil}, @code{window-end} always returns an 1343 If @var{update} is non-@code{nil}, @code{window-end} always returns an
1369 up-to-date value for where the window ends, based on the current 1344 up-to-date value for where display ends, based on the current
1370 @code{window-start} value. If the saved value is valid, 1345 @code{window-start} value. If a previously saved value of that position
1371 @code{window-end} returns that; otherwise it computes the correct 1346 is still valid, @code{window-end} returns that value; otherwise it
1372 value by scanning the buffer text. 1347 computes the correct value by scanning the buffer text.
1373 1348
1374 Even if @var{update} is non-@code{nil}, @code{window-end} does not 1349 Even if @var{update} is non-@code{nil}, @code{window-end} does not
1375 attempt to scroll the display if point has moved off the screen, the 1350 attempt to scroll the display if point has moved off the screen, the
1376 way real redisplay would do. It does not alter the 1351 way real redisplay would do. It does not alter the
1377 @code{window-start} value. In effect, it reports where the displayed 1352 @code{window-start} value. In effect, it reports where the displayed
1442 @end defun 1417 @end defun
1443 1418
1444 @defun pos-visible-in-window-p &optional position window partially 1419 @defun pos-visible-in-window-p &optional position window partially
1445 This function returns non-@code{nil} if @var{position} is within the 1420 This function returns non-@code{nil} if @var{position} is within the
1446 range of text currently visible on the screen in @var{window}. It 1421 range of text currently visible on the screen in @var{window}. It
1447 returns @code{nil} if @var{position} is scrolled vertically out of 1422 returns @code{nil} if @var{position} is scrolled vertically out of view.
1448 view. Locations that are partially obscured are not considered 1423 Locations that are partially obscured are not considered visible unless
1449 visible unless @var{partially} is non-@code{nil}. The argument 1424 @var{partially} is non-@code{nil}. The argument @var{position} defaults
1450 @var{position} defaults to the current position of point in 1425 to the current position of point in @var{window}; @var{window}, to the
1451 @var{window}; @var{window}, to the selected window. 1426 selected window. If @var{position} is @code{t}, that means to check the
1452 1427 last visible position in @var{window}.
1453 If @var{position} is @code{t}, that means to check the last visible
1454 position in @var{window}.
1455 1428
1456 The @code{pos-visible-in-window-p} function considers only vertical 1429 The @code{pos-visible-in-window-p} function considers only vertical
1457 scrolling. If @var{position} is out of view only because @var{window} 1430 scrolling. If @var{position} is out of view only because @var{window}
1458 has been scrolled horizontally, @code{pos-visible-in-window-p} returns 1431 has been scrolled horizontally, @code{pos-visible-in-window-p} returns
1459 non-@code{nil} anyway. @xref{Horizontal Scrolling}. 1432 non-@code{nil} anyway. @xref{Horizontal Scrolling}.
1460 1433
1461 If @var{position} is visible, @code{pos-visible-in-window-p} returns 1434 If @var{position} is visible, @code{pos-visible-in-window-p} returns
1462 @code{t} if @var{partially} is @code{nil}; if @var{partially} is 1435 @code{t} if @var{partially} is @code{nil}; if @var{partially} is
1463 non-@code{nil}, and the character after @var{position} is fully 1436 non-@code{nil}, and the character following @var{position} is fully
1464 visible, it returns a list of the form @code{(@var{x} @var{y})}, where 1437 visible, it returns a list of the form @code{(@var{x} @var{y})}, where
1465 @var{x} and @var{y} are the pixel coordinates relative to the top left 1438 @var{x} and @var{y} are the pixel coordinates relative to the top left
1466 corner of the window; otherwise it returns an extended list of the 1439 corner of the window; otherwise it returns an extended list of the form
1467 form @code{(@var{x} @var{y} @var{rtop} @var{rbot} @var{rowh} 1440 @code{(@var{x} @var{y} @var{rtop} @var{rbot} @var{rowh} @var{vpos})},
1468 @var{vpos})}, where the @var{rtop} and @var{rbot} specify the number 1441 where @var{rtop} and @var{rbot} specify the number of off-window pixels
1469 of off-window pixels at the top and bottom of the row at 1442 at the top and bottom of the row at @var{position}, @var{rowh} specifies
1470 @var{position}, @var{rowh} specifies the visible height of that row, 1443 the visible height of that row, and @var{vpos} specifies the vertical
1471 and @var{vpos} specifies the vertical position (zero-based row number) 1444 position (zero-based row number) of that row.
1472 of that row.
1473 1445
1474 Here is an example: 1446 Here is an example:
1475 1447
1476 @example 1448 @example
1477 @group 1449 @group
1603 @end deffn 1575 @end deffn
1604 1576
1605 @c Emacs 19 feature 1577 @c Emacs 19 feature
1606 @defvar other-window-scroll-buffer 1578 @defvar other-window-scroll-buffer
1607 If this variable is non-@code{nil}, it tells @code{scroll-other-window} 1579 If this variable is non-@code{nil}, it tells @code{scroll-other-window}
1608 which buffer to scroll. 1580 which buffer's window to scroll.
1609 @end defvar 1581 @end defvar
1610 1582
1611 @defopt scroll-margin 1583 @defopt scroll-margin
1612 This option specifies the size of the scroll margin---a minimum number 1584 This option specifies the size of the scroll margin---a minimum number
1613 of lines between point and the top or bottom of a window. Whenever 1585 of lines between point and the top or bottom of a window. Whenever
1619 @defopt scroll-conservatively 1591 @defopt scroll-conservatively
1620 This variable controls how scrolling is done automatically when point 1592 This variable controls how scrolling is done automatically when point
1621 moves off the screen (or into the scroll margin). If the value is a 1593 moves off the screen (or into the scroll margin). If the value is a
1622 positive integer @var{n}, then redisplay scrolls the text up to 1594 positive integer @var{n}, then redisplay scrolls the text up to
1623 @var{n} lines in either direction, if that will bring point back into 1595 @var{n} lines in either direction, if that will bring point back into
1624 proper view. This action is called @dfn{conservative scrolling}. 1596 proper view. This behavior is called @dfn{conservative scrolling}.
1625 Otherwise, scrolling happens in the usual way, under the control of 1597 Otherwise, scrolling happens in the usual way, under the control of
1626 other variables such as @code{scroll-up-aggressively} and 1598 other variables such as @code{scroll-up-aggressively} and
1627 @code{scroll-down-aggressively}. 1599 @code{scroll-down-aggressively}.
1628 1600
1629 The default value is zero, which means that conservative scrolling 1601 The default value is zero, which means that conservative scrolling
1715 @end deffn 1687 @end deffn
1716 1688
1717 @node Vertical Scrolling 1689 @node Vertical Scrolling
1718 @section Vertical Fractional Scrolling 1690 @section Vertical Fractional Scrolling
1719 @cindex vertical fractional scrolling 1691 @cindex vertical fractional scrolling
1720 1692 @cindex vertical scroll position
1721 @dfn{Vertical fractional scrolling} means shifting the image in the 1693
1722 window up or down by a specified multiple or fraction of a line. 1694 @dfn{Vertical fractional scrolling} means shifting text in a window up
1723 Each window has a @dfn{vertical scroll position}, 1695 or down by a specified multiple or fraction of a line. Each window has
1724 which is a number, never less than zero. It specifies how far to raise 1696 a @dfn{vertical scroll position}, which is a number, never less than
1725 the contents of the window. Raising the window contents generally makes 1697 zero. It specifies how far to raise the contents of the window.
1726 all or part of some lines disappear off the top, and all or part of some 1698 Raising the window contents generally makes all or part of some lines
1727 other lines appear at the bottom. The usual value is zero. 1699 disappear off the top, and all or part of some other lines appear at the
1728 1700 bottom. The usual value is zero.
1729 The vertical scroll position is measured in units of the normal line 1701
1702 The vertical scroll position is measured in units of the normal line
1730 height, which is the height of the default font. Thus, if the value is 1703 height, which is the height of the default font. Thus, if the value is
1731 .5, that means the window contents are scrolled up half the normal line 1704 .5, that means the window contents are scrolled up half the normal line
1732 height. If it is 3.3, that means the window contents are scrolled up 1705 height. If it is 3.3, that means the window contents are scrolled up
1733 somewhat over three times the normal line height. 1706 somewhat over three times the normal line height.
1734 1707
1735 What fraction of a line the vertical scrolling covers, or how many 1708 What fraction of a line the vertical scrolling covers, or how many
1736 lines, depends on what the lines contain. A value of .5 could scroll a 1709 lines, depends on what the lines contain. A value of .5 could scroll a
1737 line whose height is very short off the screen, while a value of 3.3 1710 line whose height is very short off the screen, while a value of 3.3
1738 could scroll just part of the way through a tall line or an image. 1711 could scroll just part of the way through a tall line or an image.
1739 1712
1740 @defun window-vscroll &optional window pixels-p 1713 @defun window-vscroll &optional window pixels-p
1741 This function returns the current vertical scroll position of 1714 This function returns the current vertical scroll position of
1742 @var{window}. If @var{window} is @code{nil}, the selected window is 1715 @var{window}. @var{window} defaults to the selected window. If
1743 used. If @var{pixels-p} is non-@code{nil}, the return value is 1716 @var{pixels-p} is non-@code{nil}, the return value is measured in
1744 measured in pixels, rather than in units of the normal line height. 1717 pixels, rather than in units of the normal line height.
1745 1718
1746 @example 1719 @example
1747 @group 1720 @group
1748 (window-vscroll) 1721 (window-vscroll)
1749 @result{} 0 1722 @result{} 0
1751 @end example 1724 @end example
1752 @end defun 1725 @end defun
1753 1726
1754 @defun set-window-vscroll window lines &optional pixels-p 1727 @defun set-window-vscroll window lines &optional pixels-p
1755 This function sets @var{window}'s vertical scroll position to 1728 This function sets @var{window}'s vertical scroll position to
1756 @var{lines}. The argument @var{lines} should be zero or positive; if 1729 @var{lines}. If @var{window} is @code{nil}, the selected window is
1757 not, it is taken as zero. 1730 used. The argument @var{lines} should be zero or positive; if not, it
1758 1731 is taken as zero.
1759 If @var{window} is @code{nil}, the selected window is used. 1732
1760 1733
1761 The actual vertical scroll position must always correspond 1734 The actual vertical scroll position must always correspond
1762 to an integral number of pixels, so the value you specify 1735 to an integral number of pixels, so the value you specify
1763 is rounded accordingly. 1736 is rounded accordingly.
1764 1737
1775 pixels. In this case, the return value is @var{lines}. 1748 pixels. In this case, the return value is @var{lines}.
1776 @end defun 1749 @end defun
1777 1750
1778 @defvar auto-window-vscroll 1751 @defvar auto-window-vscroll
1779 If this variable is non-@code{nil}, the line-move, scroll-up, and 1752 If this variable is non-@code{nil}, the line-move, scroll-up, and
1780 scroll-down functions will automatically modify the window vscroll to 1753 scroll-down functions will automatically modify the vertical scroll
1781 scroll through display rows that are taller that the height of the 1754 position to scroll through display rows that are taller that the height
1782 window, for example in the presence of large images. 1755 of the window, for example in the presence of large images.
1783 @end defvar 1756 @end defvar
1784 1757
1785 @node Horizontal Scrolling 1758 @node Horizontal Scrolling
1786 @section Horizontal Scrolling 1759 @section Horizontal Scrolling
1787 @cindex horizontal scrolling 1760 @cindex horizontal scrolling
1856 @end deffn 1829 @end deffn
1857 1830
1858 @defun window-hscroll &optional window 1831 @defun window-hscroll &optional window
1859 This function returns the total leftward horizontal scrolling of 1832 This function returns the total leftward horizontal scrolling of
1860 @var{window}---the number of columns by which the text in @var{window} 1833 @var{window}---the number of columns by which the text in @var{window}
1861 is scrolled left past the left margin. 1834 is scrolled left past the left margin. @var{window} defaults to the
1862 1835 selected window.
1863 The value is never negative. It is zero when no horizontal scrolling 1836
1864 has been done in @var{window} (which is usually the case). 1837 The return value is never negative. It is zero when no horizontal
1865 1838 scrolling has been done in @var{window} (which is usually the case).
1866 If @var{window} is @code{nil}, the selected window is used. 1839
1867 1840
1868 @example 1841 @example
1869 @group 1842 @group
1870 (window-hscroll) 1843 (window-hscroll)
1871 @result{} 0 1844 @result{} 0
1904 @result{} 10 1877 @result{} 10
1905 @end group 1878 @end group
1906 @end example 1879 @end example
1907 @end defun 1880 @end defun
1908 1881
1909 Here is how you can determine whether a given position @var{position} 1882 Here is how you can determine whether a given position @var{position} is
1910 is off the screen due to horizontal scrolling: 1883 off the screen due to horizontal scrolling:
1911 1884
1912 @example 1885 @example
1913 @group 1886 @group
1914 (defun hscroll-on-screen (window position) 1887 (defun hscroll-on-screen (window position)
1915 (save-excursion 1888 (save-excursion
1933 characters that separates side-by-side windows. 1906 characters that separates side-by-side windows.
1934 1907
1935 The following three functions return size information about a window: 1908 The following three functions return size information about a window:
1936 1909
1937 @defun window-height &optional window 1910 @defun window-height &optional window
1938 This function returns the number of lines in @var{window}, including 1911 This function returns the number of lines in @var{window}, including its
1939 its mode line and header line, if any. If @var{window} fills its 1912 mode line and header line, if any. If @var{window} fills its entire
1940 entire frame except for the echo area, this is typically one less than 1913 frame except for the echo area, this is typically one less than the
1941 the value of @code{frame-height} on that frame. 1914 value of @code{frame-height} on that frame. @var{window} defaults to
1942 1915 the selected window.
1943 If @var{window} is @code{nil}, the function uses the selected window.
1944 1916
1945 @example 1917 @example
1946 @group 1918 @group
1947 (window-height) 1919 (window-height)
1948 @result{} 23 1920 @result{} 23
1962 Like @code{window-height} but the value does not include the 1934 Like @code{window-height} but the value does not include the
1963 mode line (if any) or the header line (if any). 1935 mode line (if any) or the header line (if any).
1964 @end defun 1936 @end defun
1965 1937
1966 @defun window-width &optional window 1938 @defun window-width &optional window
1967 This function returns the number of columns in @var{window}. If 1939 This function returns the number of columns in @var{window}.
1968 @var{window} fills its entire frame, this is the same as the value of 1940 @var{window} defaults to the selected window.
1969 @code{frame-width} on that frame. The width does not include the 1941
1970 window's scroll bar or the column of @samp{|} characters that separates 1942 The return value does not include the window's scroll bar or the column
1971 side-by-side windows. 1943 of @samp{|} characters that separates side-by-side windows. Moreover,
1972 1944 the return value does not include the space used for displaying fringes
1973 If @var{window} is @code{nil}, the function uses the selected window. 1945 and margins. Hence you cannot, in general, compare the return values of
1946 @code{window-width} and @code{frame-width} for equality to determine
1947 whether a window is a wide as the containing frame. Use the function
1948 @code{window-full-width-p}, see below, instead.
1974 1949
1975 @example 1950 @example
1976 @group 1951 @group
1977 (window-width) 1952 (window-width)
1978 @result{} 80 1953 @result{} 80
1979 @end group 1954 @end group
1980 @end example 1955 @end example
1981 @end defun 1956 @end defun
1982 1957
1983 @defun window-full-width-p &optional window 1958 @defun window-full-width-p &optional window
1984 This function returns non-@code{nil} if @var{window} is as wide as 1959 This function returns non-@code{nil} if @var{window} is as wide as the
1985 the frame that contains it; otherwise @code{nil}. 1960 frame that contains it; otherwise @code{nil}. @var{window} defaults to
1986 If @var{window} is @code{nil}, the function uses the selected window. 1961 the selected window.
1987 @end defun 1962 @end defun
1988 1963
1989 @defun window-edges &optional window 1964 @defun window-edges &optional window
1990 This function returns a list of the edge coordinates of @var{window}. 1965 This function returns a list of the edge coordinates of @var{window}.
1991 If @var{window} is @code{nil}, the selected window is used. 1966 @var{window} defaults to the selected window.
1992 1967
1993 The order of the list is @code{(@var{left} @var{top} @var{right} 1968 The order of the list is @code{(@var{left} @var{top} @var{right}
1994 @var{bottom})}, all elements relative to 0, 0 at the top left corner of 1969 @var{bottom})}, all elements relative to 0, 0 at the top left corner of
1995 the frame. The element @var{right} of the value is one more than the 1970 the frame. The element @var{right} of the value is one more than the
1996 rightmost column used by @var{window}, and @var{bottom} is one more than 1971 rightmost column used by @var{window}, and @var{bottom} is one more than
2088 @cindex window resizing 2063 @cindex window resizing
2089 @cindex resize window 2064 @cindex resize window
2090 @cindex changing window size 2065 @cindex changing window size
2091 @cindex window size, changing 2066 @cindex window size, changing
2092 2067
2093 The window size functions fall into two classes: high-level commands 2068 The window size functions fall into two classes: high-level commands
2094 that change the size of windows and low-level functions that access 2069 that change the size of windows and low-level functions that access
2095 window size. Emacs does not permit overlapping windows or gaps between 2070 window size. Emacs does not permit overlapping windows or gaps between
2096 windows, so resizing one window affects other windows. 2071 windows, so resizing a window always affects at least one other window.
2097 2072
2098 @deffn Command enlarge-window size &optional horizontal 2073 @deffn Command enlarge-window size &optional horizontal
2099 This function makes the selected window @var{size} lines taller, 2074 This function makes the selected window @var{size} lines taller by
2100 stealing lines from neighboring windows. It takes the lines from one 2075 stealing lines from windows above or below. In a first round, it takes
2101 window at a time until that window is used up, then takes from another. 2076 lines from one window at a time until that window is
2102 If a window from which lines are stolen shrinks below 2077 @code{window-min-height} lines tall, then takes from another. If, at
2103 @code{window-min-height} lines, that window disappears. 2078 the end of the first round, the selected window is still not tall
2079 enough, @code{enlarge-window} starts a second round, where it deletes
2080 windows above or below the selected one.
2104 2081
2105 If @var{horizontal} is non-@code{nil}, this function makes the window 2082 If @var{horizontal} is non-@code{nil}, this function makes the window
2106 @var{size} columns wider, stealing columns instead of lines. If a 2083 @var{size} columns wider, stealing columns instead of lines. If a
2107 window from which columns are stolen shrinks below 2084 window from which columns are stolen shrinks below
2108 @code{window-min-width} columns, that window disappears. 2085 @code{window-min-width} columns, that window disappears.
2112 frame. 2089 frame.
2113 2090
2114 If there are various other windows from which lines or columns can be 2091 If there are various other windows from which lines or columns can be
2115 stolen, and some of them specify fixed size (using 2092 stolen, and some of them specify fixed size (using
2116 @code{window-size-fixed}, see below), they are left untouched while 2093 @code{window-size-fixed}, see below), they are left untouched while
2117 other windows are ``robbed.'' If it would be necessary to alter the 2094 other windows are ``robbed''. If it would be necessary to alter the
2118 size of a fixed-size window, @code{enlarge-window} gets an error 2095 size of a fixed-size window, @code{enlarge-window} gets an error
2119 instead. 2096 instead.
2120 2097
2121 If @var{size} is negative, this function shrinks the selected window by 2098 If @var{size} is negative, this function shrinks the selected window by
2122 @minus{}@var{size} lines or columns. If that makes the window smaller 2099 @minus{}@var{size} lines or columns. If that makes the window smaller
2123 than the minimum size (@code{window-min-height} and 2100 than the minimum size (@code{window-min-height} and
2124 @code{window-min-width}), @code{enlarge-window} deletes the window. 2101 @code{window-min-width}), then @code{enlarge-window} deletes the window.
2125 2102
2126 @code{enlarge-window} returns @code{nil}. 2103 @code{enlarge-window} returns @code{nil}.
2127 @end deffn 2104 @end deffn
2128 2105
2129 @deffn Command enlarge-window-horizontally columns 2106 @deffn Command enlarge-window-horizontally columns
2170 function returns @code{nil}. 2147 function returns @code{nil}.
2171 @end defun 2148 @end defun
2172 2149
2173 @defun fit-window-to-buffer &optional window max-height min-height 2150 @defun fit-window-to-buffer &optional window max-height min-height
2174 This function makes @var{window} the right height to display its 2151 This function makes @var{window} the right height to display its
2175 contents exactly. If @var{window} is omitted or @code{nil}, it uses 2152 contents exactly. @var{window} defaults to the selected window.
2176 the selected window.
2177 2153
2178 The argument @var{max-height} specifies the maximum height the window 2154 The argument @var{max-height} specifies the maximum height the window
2179 is allowed to be; @code{nil} means use the frame height. The argument 2155 is allowed to be; @code{nil} means use the frame height. The argument
2180 @var{min-height} specifies the minimum height for the window; 2156 @var{min-height} specifies the minimum height for the window;
2181 @code{nil} means use @code{window-min-height}. All these height 2157 @code{nil} means use @code{window-min-height}. All these height
2182 values include the mode-line and/or header-line. 2158 values include the mode line and/or header line.
2183 @end defun 2159 @end defun
2184 2160
2185 @deffn Command shrink-window-if-larger-than-buffer &optional window 2161 @deffn Command shrink-window-if-larger-than-buffer &optional window
2186 This command shrinks @var{window} vertically to be as small as 2162 This command shrinks @var{window} vertically to be as small as possible
2187 possible while still showing the full contents of its buffer---but not 2163 while still showing the full contents of its buffer---but not less than
2188 less than @code{window-min-height} lines. If @var{window} is not 2164 @code{window-min-height} lines. @var{window} defaults to the selected
2189 given, it defaults to the selected window. 2165 window.
2190 2166
2191 However, the command does nothing if the window is already too small to 2167 However, this command does nothing if the window is already too small to
2192 display the whole text of the buffer, or if part of the contents are 2168 display the whole text of the buffer, or if part of the contents are
2193 currently scrolled off screen, or if the window is not the full width of 2169 currently scrolled off screen, or if the window is not the full width of
2194 its frame, or if the window is the only window in its frame. 2170 its frame, or if the window is the only window in its frame.
2195 2171
2196 This command returns non-@code{nil} if it actually shrank the window 2172 This command returns non-@code{nil} if it actually shrank the window
2197 and @code{nil} otherwise. 2173 and @code{nil} otherwise.
2198 @end deffn 2174 @end deffn
2199 2175
2200 @cindex fixed-size window 2176 @cindex fixed-size window
2201 @defvar window-size-fixed 2177 @defvar window-size-fixed
2202 If this variable is non-@code{nil}, in any given buffer, 2178 If this variable is non-@code{nil}, in a given buffer, then the size of
2203 then the size of any window displaying the buffer remains fixed 2179 any window displaying that buffer remains fixed unless you either
2204 unless you explicitly change it or Emacs has no other choice. 2180 explicitly change it or Emacs has no other choice.
2205 2181
2206 If the value is @code{height}, then only the window's height is fixed; 2182 If the value is @code{height}, then only the window's height is fixed;
2207 if the value is @code{width}, then only the window's width is fixed. 2183 if the value is @code{width}, then only the window's width is fixed.
2208 Any other non-@code{nil} value fixes both the width and the height. 2184 Any other non-@code{nil} value fixes both the width and the height.
2209 2185
2217 @example 2193 @example
2218 (let ((window-size-fixed nil)) 2194 (let ((window-size-fixed nil))
2219 (enlarge-window 10)) 2195 (enlarge-window 10))
2220 @end example 2196 @end example
2221 2197
2222 Note that changing the frame size will change the size of a 2198 Deleting an adjacent window or changing the frame size may change the
2223 fixed-size window, if there is no other alternative. 2199 size of a fixed-size window, if there is no other alternative.
2224 @end defvar 2200 @end defvar
2225 2201
2226 @cindex minimum window size 2202 @cindex minimum window size
2227 The following two variables constrain the window-structure-changing 2203 The following two variables constrain the window-structure-changing
2228 functions to a minimum height and width. 2204 functions to a minimum height and width.
2230 @defopt window-min-height 2206 @defopt window-min-height
2231 The value of this variable specifies how short a window may become 2207 The value of this variable specifies how short a window may become
2232 before it is automatically deleted. Making a window smaller than 2208 before it is automatically deleted. Making a window smaller than
2233 @code{window-min-height} automatically deletes it, and no window may be 2209 @code{window-min-height} automatically deletes it, and no window may be
2234 created shorter than this. The value is measured in line units. When 2210 created shorter than this. The value is measured in line units. When
2235 the window wants a mode- and/or header-line, they are counted as one 2211 the window wants a mode line and/or a header line, they are counted as
2236 line each. The default value of this variable is 4. A value less than 2212 one line each. The default value of this variable is @code{4}. A value
2237 1 is ignored. 2213 less than @code{1} is ignored.
2238 @end defopt 2214 @end defopt
2239 2215
2240 @defopt window-min-width 2216 @defopt window-min-width
2241 The value of this variable specifies how narrow a window may become 2217 The value of this variable specifies how narrow a window may become
2242 before it is automatically deleted. Making a window smaller than 2218 before it is automatically deleted. Making a window smaller than
2243 @code{window-min-width} automatically deletes it, and no window may be 2219 @code{window-min-width} automatically deletes it, and no window may be
2244 created narrower than this. The value is measured in characters and 2220 created narrower than this. The value is measured in characters and
2245 includes any fringes or the scroll bar. The default value is 10. A 2221 includes any fringes or the scroll bar. The default value is @code{10}.
2246 value less than 2 is ignored. 2222 A value less than @code{2} is ignored.
2247 @end defopt 2223 @end defopt
2224
2225 @cindex balancing window sizes
2226 Emacs provides two functions to balance windows, that means, to even out
2227 the sizes of windows on the same frame. The minibuffer window and
2228 fixed-size windows are not resized by these functions.
2229
2230 @deffn Command balance-windows &optional window-or-frame
2231 This function balances windows in a way that gives more space to
2232 full-width and/or full-height windows. If @var{window-or-frame}
2233 specifies a frame, it balances all windows on that frame. If
2234 @var{window-or-frame} specifies a window, it balances this window and
2235 its ``siblings'' only. Think of a sibling as the other (original or
2236 new) window with respect to the present one, involved in the process of
2237 splitting, @xref{Splitting Windows}. Since a sibling may have been
2238 split again, a window can have more than one sibling.
2239 @end deffn
2240
2241 @deffn Command balance-windows-area
2242 This function attempts to give all windows on the selected frame
2243 approximately the same share of the screen area. This means, that
2244 full-width or full-height windows are not given more space than other
2245 windows.
2246 @end deffn
2248 2247
2249 @node Coordinates and Windows 2248 @node Coordinates and Windows
2250 @section Coordinates and Windows 2249 @section Coordinates and Windows
2251 2250
2252 This section describes how to relate screen coordinates to windows. 2251 This section describes how to relate screen coordinates to windows.
2337 @section Window Configurations 2336 @section Window Configurations
2338 @cindex window configurations 2337 @cindex window configurations
2339 @cindex saving window information 2338 @cindex saving window information
2340 2339
2341 A @dfn{window configuration} records the entire layout of one 2340 A @dfn{window configuration} records the entire layout of one
2342 frame---all windows, their sizes, which buffers they contain, how 2341 frame---all windows, their sizes, which buffers they contain, how those
2343 those buffers are scrolled, and their values of point and the mark; 2342 buffers are scrolled, and their values of point and the mark; also their
2344 also their fringes, margins, and scroll bar settings. It also 2343 fringes, margins, and scroll bar settings. It also includes the value
2345 includes the values of @code{window-min-height}, 2344 of @code{minibuffer-scroll-window}. As a special exception, the window
2346 @code{window-min-width} and @code{minibuffer-scroll-window}. As a 2345 configuration does not record the value of point in the selected window
2347 special exception, the window configuration does not record the value 2346 for the current buffer. Also, the window configuration does not record
2348 of point in the selected window for the current buffer. 2347 the values of window parameters, @xref{Window Parameters}.
2349 2348
2350 You can bring back an entire previous layout by restoring a window 2349 You can bring back an entire frame layout by restoring a window
2351 configuration previously saved. If you want to record all frames 2350 configuration previously saved. If you want to record the layout of all
2352 instead of just one, use a frame configuration instead of a window 2351 frames instead of just one, use a frame configuration instead of a
2353 configuration. @xref{Frame Configurations}. 2352 window configuration, @xref{Frame Configurations}.
2354 2353
2355 @defun current-window-configuration &optional frame 2354 @defun current-window-configuration &optional frame
2356 This function returns a new object representing @var{frame}'s current 2355 This function returns a new object representing @var{frame}'s current
2357 window configuration. If @var{frame} is omitted, the selected frame 2356 window configuration. @var{frame} defaults to the selected frame.
2358 is used.
2359 @end defun 2357 @end defun
2360 2358
2361 @defun set-window-configuration configuration 2359 @defun set-window-configuration configuration
2362 This function restores the configuration of windows and buffers as 2360 This function restores the configuration of windows and buffers as
2363 specified by @var{configuration}, for the frame that @var{configuration} 2361 specified by @var{configuration}, for the frame that @var{configuration}
2364 was created for. 2362 was created for.
2365 2363
2366 The argument @var{configuration} must be a value that was previously 2364 The argument @var{configuration} must be a value that was previously
2367 returned by @code{current-window-configuration}. This configuration is 2365 returned by @code{current-window-configuration}. The configuration is
2368 restored in the frame from which @var{configuration} was made, whether 2366 restored in the frame from which @var{configuration} was made, whether
2369 that frame is selected or not. This always counts as a window size 2367 that frame is selected or not. This always counts as a window size
2370 change and triggers execution of the @code{window-size-change-functions} 2368 change and triggers execution of the @code{window-size-change-functions}
2371 (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't 2369 (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
2372 know how to tell whether the new configuration actually differs from the 2370 know how to tell whether the new configuration actually differs from the
2400 the current buffer; use @code{save-excursion} also, if you wish to 2398 the current buffer; use @code{save-excursion} also, if you wish to
2401 preserve that. 2399 preserve that.
2402 2400
2403 Don't use this construct when @code{save-selected-window} is sufficient. 2401 Don't use this construct when @code{save-selected-window} is sufficient.
2404 2402
2405 Exit from @code{save-window-excursion} always triggers execution of the 2403 Exit from @code{save-window-excursion} always triggers execution of
2406 @code{window-size-change-functions}. (It doesn't know how to tell 2404 @code{window-size-change-functions}. (It doesn't know how to tell
2407 whether the restored configuration actually differs from the one in 2405 whether the restored configuration actually differs from the one in
2408 effect at the end of the @var{forms}.) 2406 effect at the end of the @var{forms}.)
2409 2407
2410 The return value is the value of the final form in @var{forms}. 2408 The return value is the value of the final form in @var{forms}.
2453 Other primitives to look inside of window configurations would make 2451 Other primitives to look inside of window configurations would make
2454 sense, but are not implemented because we did not need them. See the 2452 sense, but are not implemented because we did not need them. See the
2455 file @file{winner.el} for some more operations on windows 2453 file @file{winner.el} for some more operations on windows
2456 configurations. 2454 configurations.
2457 2455
2456 @node Window Parameters
2457 @section Window Parameters
2458 @cindex window parameters
2459
2460 This sections describes how window parameters can be used to associate
2461 additional information with windows.
2462
2463 @defun window-parameter window parameter
2464 This function returns @var{window}'s value for @var{parameter}.
2465 @var{window} defaults to the selected window. If @var{window} has no
2466 setting for @var{parameter}, this function returns @code{nil}.
2467 @end defun
2468
2469 @defun window-parameters &optional window
2470 This function returns all parameters of @var{window} and their values.
2471 @var{window} defaults to the selected window. The return value is an
2472 association list of elements of the form (@var{parameter}
2473 . @var{value}).
2474 @end defun
2475
2476 @defun set-window-parameter window parameter value
2477 This function sets @var{window}'s value of @var{parameter} to
2478 @var{value} and returns @var{value}. @var{window} defaults to the
2479 selected window.
2480 @end defun
2481
2482 Currently, window parameters are not saved in window configurations and
2483 consequently not restored by @code{set-window-configuration}. Hence,
2484 any change of a parameter introduced via @code{set-window-parameter} can
2485 be undone only by invoking @code{set-window-parameter} for the same
2486 parameter again. Since @code{save-window-excursion} relies on window
2487 configurations, window parameters are not saved and restored by that
2488 special form either, @xref{Window Configurations}.
2489
2458 @node Window Hooks 2490 @node Window Hooks
2459 @section Hooks for Window Scrolling and Changes 2491 @section Hooks for Window Scrolling and Changes
2460 @cindex hooks for window operations 2492 @cindex hooks for window operations
2461 2493
2462 This section describes how a Lisp program can take action whenever a 2494 This section describes how a Lisp program can take action whenever a
2466 The first two actions run @code{window-scroll-functions}; the last runs 2498 The first two actions run @code{window-scroll-functions}; the last runs
2467 @code{window-size-change-functions}. 2499 @code{window-size-change-functions}.
2468 2500
2469 @defvar window-scroll-functions 2501 @defvar window-scroll-functions
2470 This variable holds a list of functions that Emacs should call before 2502 This variable holds a list of functions that Emacs should call before
2471 redisplaying a window with scrolling. It is not a normal hook, because 2503 redisplaying a window with scrolling. Displaying a different buffer in
2472 each function is called with two arguments: the window, and its new 2504 the window also runs these functions.
2473 display-start position. 2505
2474 2506 This variable is not a normal hook, because each function is called with
2475 Displaying a different buffer in the window also runs these functions. 2507 two arguments: the window, and its new display-start position.
2476 2508
2477 These functions must be careful in using @code{window-end} 2509 These functions must be careful in using @code{window-end}
2478 (@pxref{Window Start}); if you need an up-to-date value, you must use 2510 (@pxref{Window Start and End}); if you need an up-to-date value, you
2479 the @var{update} argument to ensure you get it. 2511 must use the @var{update} argument to ensure you get it.
2480 2512
2481 @strong{Warning:} don't use this feature to alter the way the window 2513 @strong{Warning:} don't use this feature to alter the way the window
2482 is scrolled. It's not designed for that, and such use probably won't 2514 is scrolled. It's not designed for that, and such use probably won't
2483 work. 2515 work.
2484 @end defvar 2516 @end defvar
2507 @end defvar 2539 @end defvar
2508 2540
2509 @defvar redisplay-end-trigger-functions 2541 @defvar redisplay-end-trigger-functions
2510 This abnormal hook is run whenever redisplay in a window uses text that 2542 This abnormal hook is run whenever redisplay in a window uses text that
2511 extends past a specified end trigger position. You set the end trigger 2543 extends past a specified end trigger position. You set the end trigger
2512 position with the function @code{set-window-redisplay-end-trigger}. The 2544 position with @code{set-window-redisplay-end-trigger}. The functions
2513 functions are called with two arguments: the window, and the end trigger 2545 are called with two arguments: the window, and the end trigger position.
2514 position. Storing @code{nil} for the end trigger position turns off the 2546 Storing @code{nil} for the end trigger position turns off the feature,
2515 feature, and the trigger value is automatically reset to @code{nil} just 2547 and the trigger value is automatically reset to @code{nil} just after
2516 after the hook is run. 2548 the hook is run.
2517 @end defvar 2549 @end defvar
2518 2550
2519 @defun set-window-redisplay-end-trigger window position 2551 @defun set-window-redisplay-end-trigger window position
2520 This function sets @var{window}'s end trigger position at 2552 This function sets @var{window}'s end trigger position at
2521 @var{position}. 2553 @var{position}.
2528 2560
2529 @defvar window-configuration-change-hook 2561 @defvar window-configuration-change-hook
2530 A normal hook that is run every time you change the window configuration 2562 A normal hook that is run every time you change the window configuration
2531 of an existing frame. This includes splitting or deleting windows, 2563 of an existing frame. This includes splitting or deleting windows,
2532 changing the sizes of windows, or displaying a different buffer in a 2564 changing the sizes of windows, or displaying a different buffer in a
2533 window. The frame whose window configuration has changed is the 2565 window.
2534 selected frame when this hook runs. 2566
2567 The buffer-local part of this hook is run once per each window on the
2568 affected frame, with the relevant window selected and its buffer
2569 current. The global part is run once for the modified frame, with that
2570 frame selected.
2535 @end defvar 2571 @end defvar
2536 2572
2537 @ignore 2573 @ignore
2538 arch-tag: 3f6c36e8-df49-4986-b757-417feed88be3 2574 arch-tag: 3f6c36e8-df49-4986-b757-417feed88be3
2539 @end ignore 2575 @end ignore