(Windows): Update entries.
[emacs.git] / doc / lispref / windows.texi
blob77f1f30fc02c48f29af309d2d5416c3ffd5696ed
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
4 @c   2002, 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
5 @c See the file elisp.texi for copying conditions.
6 @setfilename ../../info/windows
7 @node Windows, Frames, Buffers, Top
8 @chapter Windows
10   This chapter describes most of the functions and variables related to
11 Emacs windows.  @xref{Frames and Windows}, for how windows relate to
12 frames.  @xref{Display}, for information on how text is displayed in
13 windows.
15 @menu
16 * Basic Windows::           Basic information on using windows.
17 * Splitting Windows::       Splitting one window into two windows.
18 * Deleting Windows::        Deleting a window gives its space to other windows.
19 * Selecting Windows::       The selected window is the one that you edit in.
20 * Cyclic Window Ordering::  Moving around the existing windows.
21 * Buffers and Windows::     Each window displays the contents of a buffer.
22 * Displaying Buffers::      Higher-level functions for displaying a buffer
23                               and choosing a window for it.
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.          
27 * Window Point::            Each window has its own location of point.
28 * Window Start and End::    Buffer positions indicating which text is
29                               on-screen in a window.
30 * Textual Scrolling::       Moving text up and down through the window.
31 * Vertical Scrolling::      Moving the contents up and down on the window.
32 * Horizontal Scrolling::    Moving the contents sideways on the window.
33 * Size of Window::          Accessing the size of a window.
34 * Resizing Windows::        Changing the size of a window.
35 * Coordinates and Windows:: Converting coordinates to windows.
36 * Window Tree::             The layout and sizes of all windows in a frame.
37 * Window Configurations::   Saving and restoring the state of the screen.
38 * Window Parameters::       Associating additional information with windows.
39 * Window Hooks::            Hooks for scrolling, window size changes,
40                               redisplay going past a certain point,
41                               or window configuration changes.
42 @end menu
44 @node Basic Windows
45 @section Basic Concepts of Emacs Windows
46 @cindex window
47 @cindex selected window
49   A @dfn{window} in Emacs is the physical area of the screen in which a
50 buffer is displayed.  The term is also used to refer to a Lisp object that
51 represents that screen area in Emacs Lisp.  It should be
52 clear from the context which is meant.
54   Emacs groups windows into frames, @xref{Frames}.  A frame represents
55 an area of screen available for Emacs to use.  Each frame always
56 contains at least one window, but you can subdivide it vertically or
57 horizontally into multiple, nonoverlapping Emacs windows.
59   In each frame, at any time, one and only one window is designated as
60 @dfn{selected within the frame}.  The frame's cursor appears in that
61 window, but the other windows have ``non-selected'' cursors, normally
62 less visible.  (@pxref{Cursor Parameters}, for customizing this.)  At
63 any time, one frame is the selected frame; and the window selected
64 within that frame is @dfn{the selected window}.  The selected window's
65 buffer is usually the current buffer (except when @code{set-buffer} has
66 been used), @xref{Current Buffer}.
68   For practical purposes, a window exists only while it is displayed in
69 a frame.  Once removed from the frame, the window is effectively deleted
70 and should not be used, @emph{even though there may still be references
71 to it} from other Lisp objects, @xref{Deleting Windows}.  Restoring a
72 saved window configuration is the only way for a window no longer on the
73 screen to come back to life, @xref{Window Configurations}.
75 @cindex multiple windows
76   Users create multiple windows so they can look at several buffers at
77 once.  Lisp libraries use multiple windows for a variety of reasons, but
78 most often to display related information.  In Rmail, for example, you
79 can move through a summary buffer in one window while the other window
80 shows messages one at a time as they are reached.
82   The meaning of ``window'' in Emacs is similar to what it means in the
83 context of general-purpose window systems such as X, but not identical.
84 The X Window System places X windows on the screen; Emacs uses one or
85 more X windows as frames, and subdivides them into
86 Emacs windows.  When you use Emacs on a character-only terminal, Emacs
87 treats the whole terminal screen as one frame.
89 @cindex terminal screen
90 @cindex screen of terminal
91 @cindex tiled windows
92   Most window systems support arbitrarily located overlapping windows.
93 In contrast, Emacs windows are @dfn{tiled}; they never overlap, and
94 together they fill the whole screen or frame.  Because of the way in
95 which Emacs creates new windows (@pxref{Splitting Windows}) and resizes
96 them (@pxref{Resizing Windows}), not all conceivable tilings of windows
97 on an Emacs frame are actually possible.
99 @defun windowp object
100 This function returns @code{t} if @var{object} is a window.
101 @end defun
103 @node Splitting Windows
104 @section Splitting Windows
105 @cindex splitting windows
106 @cindex window splitting
108 The functions described below are the primitives used to split a window
109 into two windows.  They do not accept a buffer as an argument.  Rather,
110 the two ``halves'' of the split window initially display the same buffer
111 previously visible in the window that was split.
113 @deffn Command split-window &optional window size horizontal
114 This function splits a new window out of @var{window}'s screen area.  It
115 returns the new window.  @var{window} defaults to the selected window.
116 When you split the selected window, it remains selected.
118 If @var{horizontal} is non-@code{nil}, then @var{window} splits into two
119 side by side windows.  The original window keeps the leftmost @var{size}
120 columns, and gives the rest of the columns to the new window.
121 Otherwise, @var{window} splits into windows one above the other, the
122 original window keeps the upper @var{size} lines and gives the rest of
123 the lines to the new window.  The original window @var{window} is
124 therefore the left-hand or upper of the two, and the new window is the
125 right-hand or lower.
127 If @var{size} is omitted or @code{nil}, then @var{window} is divided
128 evenly into two parts.  (If there is an odd line, it is allocated to
129 the new window.)  When @code{split-window} is called interactively,
130 all its arguments are @code{nil}.
132 If splitting would result in making a window that is smaller than
133 @code{window-min-height} or @code{window-min-width} (@pxref{Resizing
134 Windows}), @code{split-window} signals an error and does not split the
135 window at all.
137 The following example starts with one window on a screen that is 50
138 lines high by 80 columns wide; then it splits the window.
140 @smallexample
141 @group
142 (setq w (selected-window))
143      @result{} #<window 8 on windows.texi>
144 (window-edges)          ; @r{Edges in order:}
145      @result{} (0 0 80 50)     ;   @r{left--top--right--bottom}
146 @end group
148 @group
149 ;; @r{Returns window created}
150 (setq w2 (split-window w 15))
151      @result{} #<window 28 on windows.texi>
152 @end group
153 @group
154 (window-edges w2)
155      @result{} (0 15 80 50)    ; @r{Bottom window;}
156                         ;   @r{top is line 15}
157 @end group
158 @group
159 (window-edges w)
160      @result{} (0 0 80 15)     ; @r{Top window}
161 @end group
162 @end smallexample
164 The screen looks like this:
166 @smallexample
167 @group
168          __________
169         |          |  line 0
170         |    w     |
171         |__________|
172         |          |  line 15
173         |    w2    |
174         |__________|
175                       line 50
176  column 0   column 80
177 @end group
178 @end smallexample
180 Next, split the top window horizontally:
182 @smallexample
183 @group
184 (setq w3 (split-window w 35 t))
185      @result{} #<window 32 on windows.texi>
186 @end group
187 @group
188 (window-edges w3)
189      @result{} (35 0 80 15)  ; @r{Left edge at column 35}
190 @end group
191 @group
192 (window-edges w)
193      @result{} (0 0 35 15)   ; @r{Right edge at column 35}
194 @end group
195 @group
196 (window-edges w2)
197      @result{} (0 15 80 50)  ; @r{Bottom window unchanged}
198 @end group
199 @end smallexample
201 @need 3000
202 Now the screen looks like this:
204 @smallexample
205 @group
206      column 35
207          __________
208         |   |      |  line 0
209         | w |  w3  |
210         |___|______|
211         |          |  line 15
212         |    w2    |
213         |__________|
214                       line 50
215  column 0   column 80
216 @end group
217 @end smallexample
219 Normally, Emacs indicates the border between two side-by-side windows
220 with a scroll bar, @xref{Scroll Bars}, or @samp{|} characters.  The
221 display table can specify alternative border characters; @xref{Display
222 Tables}.
223 @end deffn
225 @deffn Command split-window-vertically &optional size
226 This function splits the selected window into two windows, one above the
227 other, leaving the upper of the two windows selected, with @var{size}
228 lines.  (If @var{size} is negative, then the lower of the two windows
229 gets @minus{}@var{size} lines and the upper window gets the rest, but
230 the upper window is still the one selected.)  However, if
231 @code{split-window-keep-point} (see below) is @code{nil}, then either
232 window can be selected.
234 In other respects, this function is similar to @code{split-window}.
235 In particular, the upper window is the original one and the return
236 value is the new, lower window.
237 @end deffn
239 @defopt split-window-keep-point
240 If this variable is non-@code{nil} (the default), then
241 @code{split-window-vertically} behaves as described above.
243 If it is @code{nil}, then @code{split-window-vertically} adjusts point
244 in each of the two windows to avoid scrolling.  (This is useful on
245 slow terminals.)  It selects whichever window contains the screen line
246 that point was previously on.
248 This variable affects the behavior of @code{split-window-vertically}
249 only.  It has no effect on the other functions described here.
250 @end defopt
252 @deffn Command split-window-horizontally &optional size
253 This function splits the selected window into two windows
254 side-by-side, leaving the selected window on the left with @var{size}
255 columns.  If @var{size} is negative, the rightmost window gets
256 @minus{}@var{size} columns, but the leftmost window still remains
257 selected.
259 This function is basically an interface to @code{split-window}.
260 You could define a simplified version of the function like this:
262 @smallexample
263 @group
264 (defun split-window-horizontally (&optional arg)
265   "Split selected window into two windows, side by side..."
266   (interactive "P")
267 @end group
268 @group
269   (let ((size (and arg (prefix-numeric-value arg))))
270     (and size (< size 0)
271          (setq size (+ (window-width) size)))
272     (split-window nil size t)))
273 @end group
274 @end smallexample
275 @end deffn
277 @defun one-window-p &optional no-mini all-frames
278 This function returns non-@code{nil} if there is only one window.  The
279 argument @var{no-mini}, if non-@code{nil}, means don't count the
280 minibuffer even if it is active; otherwise, the minibuffer window is
281 counted when it is active.
283 The argument @var{all-frames} specifies which frames to consider.  Here
284 are the possible values and their meanings:
286 @table @asis
287 @item @code{nil}
288 Count the windows in the selected frame, plus the minibuffer used
289 by that frame even if it lies in some other frame.
291 @item @code{t}
292 Count all windows in all existing frames.
294 @item @code{visible}
295 Count all windows in all visible frames.
297 @item 0
298 Count all windows in all visible or iconified frames.
300 @item anything else
301 Count precisely the windows in the selected frame, and no others.
302 @end table
303 @end defun
305 @node Deleting Windows
306 @section Deleting Windows
307 @cindex deleting windows
309 A window remains visible on its frame unless you @dfn{delete} it by
310 calling certain functions that delete windows.  A deleted window cannot
311 appear on the screen, but continues to exist as a Lisp object until
312 there are no references to it.  There is no way to cancel the deletion
313 of a window aside from restoring a saved window configuration
314 (@pxref{Window Configurations}).  Restoring a window configuration also
315 deletes any windows that aren't part of that configuration.
317   When you delete a window, the space it took up is given to one
318 adjacent window.
320 @c Emacs 19 feature
321 @defun window-live-p window
322 This function returns @code{nil} if @var{window} is deleted, and
323 @code{t} otherwise.
325 @strong{Warning:} Erroneous information or fatal errors may result from
326 using a deleted window as if it were live.
327 @end defun
329 @deffn Command delete-window &optional window
330 This function removes @var{window} from display and returns @code{nil}.
331 @var{window} defaults to the selected window.  An error is signaled if
332 @var{window} is the only window on its frame.
333 @end deffn
335 @deffn Command delete-other-windows &optional window
336 This function makes @var{window} the only window on its frame, by
337 deleting the other windows in that frame.  @var{window} defaults to the
338 selected window.  The return value is @code{nil}.
339 @end deffn
341 @deffn Command delete-windows-on &optional buffer-or-name frame
342 This function deletes all windows showing @var{buffer-or-name}.  If
343 there are no windows showing @var{buffer-or-name}, it does nothing.
344 @var{buffer-or-name} may be a buffer or the name of an existing buffer
345 and defaults to the current buffer.
347 @code{delete-windows-on} operates frame by frame.  If a frame has
348 several windows showing different buffers, then those showing
349 @var{buffer-or-name} are removed, and the others expand to fill the
350 space.  If all windows in some frame are showing @var{buffer-or-name}
351 (including the case where there is only one window), then the frame
352 winds up with a single window showing another buffer chosen with
353 @code{other-buffer} (@pxref{The Buffer List}).  If, however, the window
354 showing @var{buffer-or-name} is dedicated to its buffer
355 (@pxref{Dedicated Windows}), and there are other frames left, that
356 window's frame is deleted.
358 The argument @var{frame} specifies which frames to operate on.  This
359 function does not use it in quite the same way as the other functions
360 which scan all windows; specifically, the values @code{t} and @code{nil}
361 have the opposite of their meanings in other functions.  Here are the
362 full details:
364 @itemize @bullet
365 @item
366 If it is @code{nil}, operate on all frames.
367 @item
368 If it is @code{t}, operate on the selected frame.
369 @item
370 If it is @code{visible}, operate on all visible frames.
371 @item
372 If it is 0, operate on all visible or iconified frames.
373 @item
374 If it is a frame, operate on that frame.
375 @end itemize
377 This function always returns @code{nil}.
378 @end deffn
380 @node Selecting Windows
381 @section Selecting Windows
382 @cindex selecting a window
384   When a window is selected, the buffer in the window becomes the current
385 buffer, and the cursor will appear in it.
387 @defun selected-window
388 This function returns the selected window.  This is the window in
389 which the cursor appears and to which many commands apply.
390 @end defun
392 @defun select-window window &optional norecord
393 This function makes @var{window} the selected window.  The cursor then
394 appears in @var{window} (on redisplay).  Unless @var{window} was already
395 selected, @code{select-window} makes @var{window}'s buffer the current
396 buffer.  The return value is @var{window}.
398 Normally, @var{window}'s selected buffer is moved to the front of the
399 buffer list (@pxref{The Buffer List}) and @var{window} becomes the most
400 recently selected window.  But if @var{norecord} is non-@code{nil}, the
401 buffer list remains unchanged and @var{window} does not become the most
402 recently selected one.
405 @example
406 @group
407 (setq w (next-window))
408 (select-window w)
409      @result{} #<window 65 on windows.texi>
410 @end group
411 @end example
412 @end defun
414 @defmac save-selected-window forms@dots{}
415 This macro records the selected frame, as well as the selected window
416 of each frame, executes @var{forms} in sequence, then restores the
417 earlier selected frame and windows.  It also saves and restores the
418 current buffer.  It returns the value of the last form in @var{forms}.
420 This macro does not save or restore anything about the sizes,
421 arrangement or contents of windows; therefore, if the @var{forms} change
422 them, the change persists.  If the previously selected window of some
423 frame is no longer live at the time of exit from @var{forms}, that
424 frame's selected window is left alone.  If the previously selected
425 window is no longer live, then whatever window is selected at the end of
426 @var{forms} remains selected.  The current buffer is restored if and
427 only if it is still live when exiting @var{forms}.
429 This macro changes neither the ordering of recently selected windows nor
430 the buffer list.
431 @end defmac
433 @defmac with-selected-window window forms@dots{}
434 This macro selects @var{window}, executes @var{forms} in sequence, then
435 restores the previously selected window and current buffer.  The ordering
436 of recently selected windows and the buffer list remain unchanged unless
437 you deliberately change them within @var{forms}, for example, by calling
438 @code{select-window} with argument @var{norecord} nil or omitted there.
439 @end defmac
441 @cindex finding windows
442   The following functions choose one of the windows on the screen,
443 offering various criteria for the choice.
445 @defun get-lru-window &optional frame dedicated
446 This function returns the window least recently ``used'' (that is,
447 selected).  If any full-width windows are present, it only considers
448 these.
450 The selected window can be the least recently used window if it is the
451 only window.  A newly created window becomes the least recently used
452 window until it is selected.  A minibuffer window is never a candidate.
453 A dedicated window (@pxref{Dedicated Windows}) is never a candidate
454 unless the @var{dedicated} argument is non-@code{nil}, so if all
455 existing windows are dedicated, the value is @code{nil}.
457 The argument @var{frame} specifies which windows are considered.
459 @itemize @bullet
460 @item
461 If it is @code{nil}, consider windows on the selected frame.
462 @item
463 If it is @code{t}, consider windows on all frames.
464 @item
465 If it is @code{visible}, consider windows on all visible frames.
466 @item
467 If it is 0, consider windows on all visible or iconified frames.
468 @item
469 If it is a frame, consider windows on that frame.
470 @end itemize
471 @end defun
473 @defun get-largest-window &optional frame dedicated
474 This function returns the window with the largest area (height times
475 width).  If there are no side-by-side windows, then this is the window
476 with the most lines.  A minibuffer window is never a candidate.  A
477 dedicated window (@pxref{Dedicated Windows}) is never a candidate unless
478 the @var{dedicated} argument is non-@code{nil}, so if all existing
479 windows are dedicated, the value is @code{nil}.
481 If there are two candidate windows of the same size, this function
482 prefers the one that comes first in the cyclic ordering of windows
483 starting from the selected window (@pxref{Cyclic Window Ordering}).
485 The argument @var{frame} specifies which set of windows to consider, see
486 @code{get-lru-window} above.
487 @end defun
489 @cindex window that satisfies a predicate
490 @cindex conditional selection of windows
491 @defun get-window-with-predicate predicate &optional minibuf all-frames default
492 This function returns a window satisfying @var{predicate}.  It cycles
493 through all visible windows using @code{walk-windows} (@pxref{Cyclic
494 Window Ordering}), calling @var{predicate} on each one of them with that
495 window as its argument.  The function returns the first window for which
496 @var{predicate} returns a non-@code{nil} value; if that never happens,
497 it returns @var{default} (which defaults to @code{nil}).
499 The optional arguments @var{minibuf} and @var{all-frames} specify the
500 set of windows to include in the scan.  See the description of
501 @code{next-window} in @ref{Cyclic Window Ordering}, for details.
502 @end defun
504 @node Cyclic Window Ordering
505 @comment  node-name,  next,  previous,  up
506 @section Cyclic Ordering of Windows
507 @cindex cyclic ordering of windows
508 @cindex ordering of windows, cyclic
509 @cindex window ordering, cyclic
511   When you use the command @kbd{C-x o} (@code{other-window}) to select
512 some other window, it moves through the windows on the screen in a
513 specific order.  For any given configuration of windows, this order
514 never varies.  It is called the @dfn{cyclic ordering of windows}.
516   This ordering generally goes from top to bottom, and from left to
517 right.  But it may go down first or go right first, depending on the
518 order in which windows were split.
520   If the first split was vertical (into windows one above each other),
521 and then the subwindows were split horizontally, then the ordering is
522 left to right in the top of the frame, and then left to right in the
523 next lower part of the frame, and so on.  If the first split was
524 horizontal, the ordering is top to bottom in the left part, and so on.
525 In general, within each set of siblings at any level in the window tree
526 (@pxref{Window Tree}), the order is left to right, or top to bottom.
528 @deffn Command next-window &optional window minibuf all-frames
529 @cindex minibuffer window, and @code{next-window}
530 This function returns the window following @var{window} in the cyclic
531 ordering of windows.  This is the window @kbd{C-x o} selects if typed
532 when @var{window} is selected.  @var{window} defaults to the selected
533 window.
535 The value of the argument @var{minibuf} specifies whether the minibuffer
536 is included in the window order.  Normally, when @var{minibuf} is
537 @code{nil}, the minibuffer is included only if it is currently
538 ``active''; this matches the behavior of @kbd{C-x o}.  (The minibuffer
539 window is active while the minibuffer is in use, @xref{Minibuffers}.)
541 If @var{minibuf} is @code{t}, the cyclic ordering includes the
542 minibuffer window even if it is not active.  If @var{minibuf} is neither
543 @code{t} nor @code{nil}, the minibuffer window is not included even if
544 it is active.
546 The argument @var{all-frames} specifies which frames to consider.  Here
547 are the possible values and their meanings:
549 @table @asis
550 @item @code{nil}
551 Consider all the windows in @var{window}'s frame, plus the minibuffer
552 used by that frame even if it lies in some other frame.  If the
553 minibuffer counts (as determined by @var{minibuf}), then all windows on
554 all frames that share that minibuffer count too.
556 @item @code{t}
557 Consider all windows in all existing frames.
559 @item @code{visible}
560 Consider all windows in all visible frames.  (To get useful results, you
561 must ensure @var{window} is in a visible frame.)
563 @item 0
564 Consider all windows in all visible or iconified frames.
566 @item a frame
567 Consider all windows on that frame.
569 @item anything else
570 Consider precisely the windows in @var{window}'s frame, and no others.
571 @end table
573 This example assumes there are two windows, both displaying the
574 buffer @samp{windows.texi}:
576 @example
577 @group
578 (selected-window)
579      @result{} #<window 56 on windows.texi>
580 @end group
581 @group
582 (next-window (selected-window))
583      @result{} #<window 52 on windows.texi>
584 @end group
585 @group
586 (next-window (next-window (selected-window)))
587      @result{} #<window 56 on windows.texi>
588 @end group
589 @end example
590 @end deffn
592 @deffn Command previous-window &optional window minibuf all-frames
593 This function returns the window preceding @var{window} in the cyclic
594 ordering of windows.  The other arguments specify which windows to
595 include in the cycle, as in @code{next-window}.
596 @end deffn
598 @deffn Command other-window count &optional all-frames
599 This function selects another window in the cyclic ordering of windows.
600 @var{count} specifies the number of windows to skip in the ordering,
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.
608 The argument @var{all-frames} has the same meaning as in
609 @code{next-window}, but the @var{minibuf} argument of @code{next-window}
610 is always effectively @code{nil}.  This function returns @code{nil}.
611 @end deffn
613 @c Emacs 19 feature
614 @defun walk-windows proc &optional minibuf all-frames
615 This function cycles through all windows.  It calls the function
616 @code{proc} once for each window, with the window as its sole
617 argument.
619 The optional arguments @var{minibuf} and @var{all-frames} specify the
620 set of windows to include in the walk.  See @code{next-window}, above,
621 for details.
622 @end defun
624 @defun window-list &optional frame minibuf window
625 This function returns a list of all windows on @var{frame}, starting
626 with @var{window}.  @var{frame} defaults to the selected frame;
627 @var{window} to the selected window.
629 The value of @var{minibuf} specifies if the minibuffer window shall be
630 included in the result list.  If @var{minibuf} is @code{t}, the result
631 always includes the minibuffer window.  If @var{minibuf} is @code{nil}
632 or omitted, that includes the minibuffer window if it is active.  If
633 @var{minibuf} is neither @code{nil} nor @code{t}, the result never
634 includes the minibuffer window.
635 @end defun
637 @node Buffers and Windows
638 @section Buffers and Windows
639 @cindex examining windows
640 @cindex windows, controlling precisely
641 @cindex buffers, controlled in windows
643   This section describes low-level functions to examine windows or to
644 display buffers in windows in a precisely controlled fashion.
645 @iftex
646 See the following section for
647 @end iftex
648 @ifnottex
649 @xref{Displaying Buffers}, for
650 @end ifnottex
651 related functions that find a window to use and specify a buffer for it.
652 The functions described there are easier to use, but they employ
653 heuristics in choosing or creating a window; use the functions described
654 here when you need complete control.
656 @defun set-window-buffer window buffer-or-name &optional keep-margins
657 This function makes @var{window} display @var{buffer-or-name} as its
658 contents.  It returns @code{nil}.  @var{buffer-or-name} must be a
659 buffer, or the name of an existing buffer.  This is the fundamental
660 primitive for changing which buffer is displayed in a window, and all
661 ways of doing that call this function.
663 @example
664 @group
665 (set-window-buffer (selected-window) "foo")
666      @result{} nil
667 @end group
668 @end example
670 Normally, displaying @var{buffer-or-name} in @var{window} resets the
671 window's position, display margins, fringe widths, and scroll bar
672 settings, to values based on the local variables of that buffer.
673 However, if @var{keep-margins} is non-@code{nil}, display margins and
674 fringe widths of @var{window} remain unchanged.  @xref{Fringes}.
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}.
680 This function runs @code{window-scroll-functions} before running
681 @code{window-configuration-change-hook}.
682 @end defun
684 @defvar buffer-display-count
685 This buffer-local variable records the number of times a buffer has been
686 displayed in a window.  It is incremented each time
687 @code{set-window-buffer} is called for the buffer.
688 @end defvar
690 @defun window-buffer &optional window
691 This function returns the buffer that @var{window} is displaying.
692 @var{window} defaults to the selected window.
694 @example
695 @group
696 (window-buffer)
697      @result{} #<buffer windows.texi>
698 @end group
699 @end example
700 @end defun
702 @defun get-buffer-window &optional buffer-or-name all-frames
703 This function returns a window currently displaying
704 @var{buffer-or-name}, or @code{nil} if there is none.  If there are
705 several such windows, then the function returns the first one in the
706 cyclic ordering of windows, starting from the selected window.
707 @xref{Cyclic Window Ordering}.
709 @var{BUFFER-OR-NAME} may be a buffer or a buffer name and defaults to
710 the current buffer.  The argument @var{all-frames} specifies which
711 windows to consider:
713 @itemize @bullet
714 @item
715 @code{nil} means consider windows on the selected frame.
716 @item
717 @code{t} means consider windows on all existing frames.
718 @item
719 @code{visible} means consider windows on all visible frames.
720 @item
721 0 means consider windows on all visible or iconified frames.
722 @item
723 A frame means consider windows on that frame only.
724 @end itemize
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.
731 @end defun
733 @defun get-buffer-window-list &optional buffer-or-name minibuf all-frames
734 This function returns a list of all windows currently displaying
735 @var{buffer-or-name}.  @var{buffer-or-name} may be a buffer or the name
736 of an existing buffer and defaults to the current buffer.
738 The two remaining arguments work like the same-named arguments of
739 @code{next-window}; they are @emph{not} like the optional arguments of
740 @code{get-buffer-window}.
741 @end defun
743 @defvar buffer-display-time
744 This variable records the time at which a buffer was last made visible
745 in a window.  It is always local in each buffer; each time
746 @code{set-window-buffer} is called, it sets this variable to
747 @code{(current-time)} in the specified buffer (@pxref{Time of Day}).
748 When a buffer is first created, @code{buffer-display-time} starts out
749 with the value @code{nil}.
750 @end defvar
752 @node Displaying Buffers
753 @section Displaying Buffers in Windows
754 @cindex switching to a buffer
755 @cindex displaying a buffer
757   In this section we describe convenient functions that choose a window
758 automatically and use it to display a specified buffer.  These functions
759 can also split an existing window in certain circumstances.  We also
760 describe variables that parameterize the heuristics used for choosing a
761 window.
762 @iftex
763 See the preceding section for
764 @end iftex
765 @ifnottex
766 @xref{Buffers and Windows}, for
767 @end ifnottex
768 low-level primitives that give you more precise control.  All of these
769 functions work by calling @code{set-window-buffer}.
771   Do not use the functions in this section in order to make a buffer
772 current so that a Lisp program can access or modify it; they are too
773 drastic for that purpose, since they change the display of buffers in
774 windows, which would be gratuitous and surprise the user.  Instead, use
775 @code{set-buffer} and @code{save-current-buffer} (@pxref{Current
776 Buffer}), which designate buffers as current for programmed access
777 without affecting the display of buffers in windows.
779 @deffn Command switch-to-buffer buffer-or-name &optional norecord
780 This function makes @var{buffer-or-name} the current buffer, and also
781 displays the buffer in the selected window.  This means that a human can
782 see the buffer and subsequent keyboard commands will apply to it.
783 Contrast this with @code{set-buffer}, which makes @var{buffer-or-name}
784 the current buffer but does not display it in the selected window,
785 @xref{Current Buffer}.
787 If @var{buffer-or-name} is @code{nil}, @code{switch-to-buffer} chooses a
788 buffer using @code{other-buffer}.  If @var{buffer-or-name} is a string
789 that does not identify an existing buffer, then a new buffer by that
790 name is created.  The major mode for the new buffer is set according to
791 the variable @code{default-major-mode}, @xref{Auto Major Mode}.
793 Normally the specified buffer is put at the front of the buffer list
794 (both the selected frame's buffer list and the frame-independent buffer
795 list).  This affects the operation of @code{other-buffer}.  However, if
796 @var{norecord} is non-@code{nil}, this is not done.  @xref{The Buffer
797 List}.
799 The @code{switch-to-buffer} function is often used interactively, as
800 the binding of @kbd{C-x b}.  It is also used frequently in programs.  It
801 returns the buffer that it switched to.
802 @end deffn
804 The next two functions are similar to @code{switch-to-buffer}, except
805 for the described features.
807 @deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord
808 This function makes @var{buffer-or-name} the current buffer, displays it
809 in a window not currently selected, and selects that window.  The
810 handling of the buffer is the same as in @code{switch-to-buffer}.
812 The currently selected window is absolutely never used to do the job.
813 If it is the only window, then it is split to make a distinct window for
814 this purpose.  If the selected window is already displaying the buffer,
815 then it continues to do so, but another window is nonetheless found to
816 display it in as well.
818 This function updates the buffer list just like @code{switch-to-buffer}
819 unless @var{norecord} is non-@code{nil}.
820 @end deffn
822 @deffn Command pop-to-buffer buffer-or-name &optional other-window norecord
823 This command makes @var{buffer-or-name} the current buffer and switches
824 to it in some window, preferably not the window previously selected.
825 The ``popped-to'' window becomes the selected window.  Its frame is
826 given the X server's focus, if possible, @xref{Input Focus}.  The return
827 value is the buffer that was switched to.
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}.
835 If the variable @code{pop-up-frames} is non-@code{nil},
836 @code{pop-to-buffer} looks for a window in any visible frame already
837 displaying the buffer; if there is one, it selects and returns that
838 window.  If no such window exists, it creates a new frame and displays
839 the buffer in it.
841 If @code{pop-up-frames} is @code{nil}, then @code{pop-to-buffer}
842 operates entirely within the selected frame.  (If the selected frame has
843 just a minibuffer, @code{pop-to-buffer} operates within the most
844 recently selected frame that was not just a minibuffer.)
846 If the variable @code{pop-up-windows} is non-@code{nil}, windows may be
847 split to create a new window that is different from the original window.
848 For details, @xref{Choosing Window}.
850 If @var{other-window} is non-@code{nil}, @code{pop-to-buffer} finds or
851 creates another window even if @var{buffer-or-name} is already visible
852 in the selected window.  Thus @var{buffer-or-name} could end up
853 displayed in two windows.  On the other hand, if @var{buffer-or-name} is
854 already displayed in the selected window and @var{other-window} is
855 @code{nil}, then the selected window is considered sufficient for
856 displaying @var{buffer-or-name}, so that nothing needs to be done.
858 All the variables that affect @code{display-buffer} affect
859 @code{pop-to-buffer} as well.  @xref{Choosing Window}.
861 This function updates the buffer list just like @code{switch-to-buffer}
862 unless @var{norecord} is non-@code{nil}.
863 @end deffn
865 @deffn Command replace-buffer-in-windows &optional buffer-or-name
866 This function replaces @var{buffer-or-name} in all windows displaying
867 it with some other buffer.  It uses @code{other-buffer} to choose the
868 other buffer.  In the usual applications of this function, you
869 don't care which other buffer is used; you just want to make sure that
870 @var{buffer-or-name} is no longer displayed.
872 @var{buffer-or-name} may be a buffer or the name of an existing buffer
873 and defaults to the current buffer.
875 If a window displaying @var{buffer-or-name} is dedicated
876 (@pxref{Dedicated Windows}), and is not the only window on its frame,
877 that window is deleted.  If that window is the only window on its frame
878 and there are other frames left, the window's frame is deleted too.  If
879 there are no other frames left, some other buffer is displayed in that
880 window.
882 This function returns @code{nil}.
883 @end deffn
885 @node Choosing Window
886 @section Choosing a Window for Display
888   This section describes the basic facility that chooses a window to
889 display a buffer in---@code{display-buffer}.  Higher-level functions and
890 commands like @code{switch-to-buffer} and @code{pop-to-buffer} use this
891 subroutine.  Here we describe how to use @code{display-buffer} and how
892 to customize it.
894 @deffn Command display-buffer buffer-or-name &optional not-this-window frame
895 This command makes @var{buffer-or-name} appear in some window, but it
896 does not select that window and does not make the buffer specified by
897 @var{buffer-or-name} current.  The identity of the selected window is
898 unaltered by this function.  @var{buffer-or-name} must be a buffer, or
899 the name of an existing buffer.
901 @var{not-this-window} non-@code{nil} means to display the specified
902 buffer in a window other than the selected one, even if it is already
903 displayed in the selected window.  This can cause the buffer to appear
904 in two windows at once.  Otherwise, if @var{buffer-or-name} is already
905 being displayed in any window, that is good enough, so this function
906 does nothing.
908 @code{display-buffer} returns the window chosen to display
909 @var{buffer-or-name}.
911 If the argument @var{frame} is non-@code{nil}, it specifies which frames
912 to check when deciding whether the buffer is already displayed.  If the
913 buffer is already displayed in some window on one of these frames,
914 @code{display-buffer} simply returns that window.  Here are the possible
915 values of @var{frame}:
917 @itemize @bullet
918 @item
919 @code{nil} means consider windows on the selected frame.
920 (Actually, the last non-minibuffer frame.)
921 @item
922 @code{t} means consider windows on all frames.
923 @item
924 @code{visible} means consider windows on all visible frames.
925 @item
926 0 means consider windows on all visible or iconified frames.
927 @item
928 A frame means consider windows on that frame only.
929 @end itemize
931 Precisely how @code{display-buffer} finds or creates a window depends on
932 the variables described below.
933 @end deffn
935 @defopt display-buffer-reuse-frames
936 If this variable is non-@code{nil}, @code{display-buffer} searches
937 existing frames for a window displaying @var{buffer-or-name}.  If the
938 buffer is already displayed in a window in some frame,
939 @code{display-buffer} makes the frame visible and raises it, to use that
940 window.  If the buffer is not already displayed, or
941 @code{display-buffer-reuse-frames} is @code{nil}, the behavior of
942 @code{display-buffer} is determined by the variables described next.
943 @end defopt
945 @defopt pop-up-windows
946 This variable specifies whether @code{display-buffer} is allowed to
947 split (@pxref{Splitting Windows}) an existing window .  If it is
948 non-@code{nil}, @code{display-buffer} tries to the split the largest or
949 least recently used window on the selected frame.  (If the selected
950 frame is a minibuffer-only frame, it tries to split a window on another
951 frame instead.)  If @code{pop-up-windows} is nil or the variable
952 @code{pop-up-frames} (see below) is non-@code{nil},
953 @code{display-buffer} does not split any window.
954 @end defopt
956 @defvar split-window-preferred-function
957 This variable specifies how to split a window.  Its value, if
958 non-@code{nil}, should be a function of one argument, which is a
959 window.  If this variable specifies a function, @code{display-buffer}
960 will call it with one or more candidate windows when it looks for a
961 window to split.  If the argument window fits, the function is
962 expected to split it and return a new window.  If the function returns
963 @code{nil}, the argument window will not be split.
965 If the value of this variable is @code{nil}, @code{display-buffer}
966 uses the two variables described next to decide whether and which
967 window to split.
968 @end defvar
970 @defopt split-height-threshold
971 This variable specifies whether @code{display-buffer} may split a window
972 vertically, provided there are multiple windows.  If the value is a
973 number, @code{display-buffer} splits a window only if it has at least
974 this many lines.  If no window is tall enough, or if the value of this
975 variable is @code{nil}, @code{display-buffer} tries to split some window
976 horizontally, subject to restrictions of @code{split-width-threshold}
977 (see below).  If splitting horizontally is impossible too,
978 @code{display-buffer} splits a window vertically only if it's the only
979 window on its frame and not the minibuffer window, and only if
980 @code{pop-up-windows} is non-@code{nil}.
982 A window whose height is fixed (@pxref{Resizing Windows}) cannot be
983 split vertically by @code{display-buffer}.  Also, @code{display-buffer}
984 splits a window vertically only if it can accommodate two windows that
985 are both at least `window-min-height' lines tall.  Moreover, if the
986 window that shall be split has a mode line, the window must be at least
987 four lines tall in order to make sure that the new window can have a
988 mode line as well.  If the original window doesn't have a mode line, a
989 height of two lines suffices.
990 @end defopt
992 @defopt split-width-threshold
993 This variable specifies whether @code{display-buffer} may split a window
994 horizontally.  If the value is a number, @code{display-buffer} may split
995 a window if it has at least this many columns.  If the value of this
996 variable is @code{nil}, @code{display-buffer} will not split any windows
997 horizontally.  (It still might split some window vertically, though, see
998 above.)
1000 A window whose width is fixed (@pxref{Resizing Windows}) cannot be split
1001 horizontally by @code{display-buffer}.  Also, @code{display-buffer}
1002 splits a window horizontally only if it can accommodate two windows that
1003 are both at least `window-min-width' columns wide.
1004 @end defopt
1006 @defopt even-window-heights
1007 This variable specifies whether @code{display-buffer} should even out
1008 window heights if the buffer gets displayed in an existing window, above
1009 or beneath another window.  If @code{even-window-heights} is
1010 non-@code{nil}, the default, window heights will be evened out.  If
1011 either of the involved window has fixed height (@pxref{Resizing
1012 Windows}) or @code{even-window-heights} is @code{nil}, the original
1013 window heights will be left alone.
1014 @end defopt
1016 @c Emacs 19 feature
1017 @defopt pop-up-frames
1018 This variable specifies whether @code{display-buffer} makes new frames.
1019 If it is non-@code{nil}, @code{display-buffer} looks for an existing
1020 window already displaying the desired buffer, on any visible frame.  If
1021 it finds one, it returns that window.  Otherwise it makes a new frame,
1022 unless the variable's value is @code{graphic-only} and the selected
1023 frame is not on a graphic display.  @xref{Frames}, for more information.
1025 Note that the value of @code{pop-up-windows} does not matter if
1026 @code{pop-up-frames} is non-@code{nil}.  If @code{pop-up-frames} is
1027 @code{nil}, then @code{display-buffer} either splits a window or reuses
1028 one.
1029 @end defopt
1031 @c Emacs 19 feature
1032 @defopt pop-up-frame-function
1033 This variable specifies how to make a new frame if @code{pop-up-frames}
1034 is non-@code{nil}.
1036 Its value should be a function of no arguments.  When
1037 @code{display-buffer} makes a new frame, it does so by calling that
1038 function, which should return a frame.  The default value of the
1039 variable is a function that creates a frame using parameters from
1040 @code{pop-up-frame-alist}.
1041 @end defopt
1043 @defopt pop-up-frame-alist
1044 This variable holds an alist specifying frame parameters used when
1045 @code{display-buffer} makes a new frame.  @xref{Frame Parameters}, for
1046 more information about frame parameters.
1047 @end defopt
1049 @defopt special-display-buffer-names
1050 A list of buffer names identifying buffers that should be displayed
1051 specially.  If the name of @var{buffer-or-name} is in this list,
1052 @code{display-buffer} handles the buffer specially.  By default, special
1053 display means to give the buffer a dedicated frame.
1055 If an element is a list, instead of a string, then the @sc{car} of that
1056 list is the buffer name, and the rest of that list says how to create
1057 the frame.  There are two possibilities for the rest of that list (its
1058 @sc{cdr}): It can be an alist, specifying frame parameters, or it can
1059 contain a function and arguments to give to it.  (The function's first
1060 argument is always the buffer to be displayed; the arguments from the
1061 list come after that.)
1063 For example:
1065 @example
1066 (("myfile" (minibuffer) (menu-bar-lines . 0)))
1067 @end example
1069 @noindent
1070 specifies to display a buffer named @samp{myfile} in a dedicated frame
1071 with specified @code{minibuffer} and @code{menu-bar-lines} parameters.
1073 The list of frame parameters can also use the phony frame parameters
1074 @code{same-frame} and @code{same-window}.  If the specified frame
1075 parameters include @code{(same-window . @var{value})} and @var{value}
1076 is non-@code{nil}, that means to display the buffer in the current
1077 selected window.  Otherwise, if they include @code{(same-frame .
1078 @var{value})} and @var{value} is non-@code{nil}, that means to display
1079 the buffer in a new window in the currently selected frame.
1080 @end defopt
1082 @defopt special-display-regexps
1083 A list of regular expressions specifying buffers that should be
1084 displayed specially.  If the buffer's name matches any of the regular
1085 expressions in this list, @code{display-buffer} handles the buffer
1086 specially.  By default, special display means to give the buffer a
1087 dedicated frame.
1089 If an element is a list, instead of a string, then the @sc{car} of the
1090 list is the regular expression, and the rest of the list says how to
1091 create the frame.  See @code{special-display-buffer-names} above.
1092 @end defopt
1094 @defun special-display-p buffer-name
1095 This function returns non-@code{nil} if displaying a buffer
1096 named @var{buffer-name} with @code{display-buffer} would
1097 create a special frame.  The value is @code{t} if it would
1098 use the default frame parameters, or else the specified list
1099 of frame parameters.
1100 @end defun
1102 @defvar special-display-function
1103 This variable holds the function to call to display a buffer specially.
1104 It receives the buffer as an argument, and should return the window in
1105 which it is displayed.  The default value of this variable is
1106 @code{special-display-popup-frame}, see below.
1107 @end defvar
1109 @defun special-display-popup-frame buffer &optional args
1110 This function tries to make @var{buffer} visible in a frame of its own.
1111 If @var{buffer} is already displayed in some window, it makes that
1112 window's frame visible and raises it.  Otherwise, it creates a frame
1113 that is dedicated to @var{buffer}.  The return value is the window used
1114 to display @var{buffer}.
1116 If @var{args} is an alist, it specifies frame parameters for the new
1117 frame.  If @var{args} is a list whose @sc{car} is a symbol, then
1118 @code{(car @var{args})} is called as a function to actually create and
1119 set up the frame; it is called with @var{buffer} as first argument, and
1120 @code{(cdr @var{args})} as additional arguments.
1122 This function always uses an existing window displaying @var{buffer},
1123 whether or not it is in a frame of its own; but if you set up the above
1124 variables in your init file, before @var{buffer} was created, then
1125 presumably the window was previously made by this function.
1126 @end defun
1128 @defopt special-display-frame-alist
1129 @anchor{Definition of special-display-frame-alist}
1130 This variable holds frame parameters for
1131 @code{special-display-popup-frame} to use when it creates a frame.
1132 @end defopt
1134 @defopt same-window-buffer-names
1135 A list of buffer names for buffers that should be displayed in the
1136 selected window.  If the buffer's name is in this list,
1137 @code{display-buffer} handles the buffer by switching to it in the
1138 selected window.
1139 @end defopt
1141 @defopt same-window-regexps
1142 A list of regular expressions that specify buffers that should be
1143 displayed in the selected window.  If the buffer's name matches any of
1144 the regular expressions in this list, @code{display-buffer} handles the
1145 buffer by switching to it in the selected window.
1146 @end defopt
1148 @defun same-window-p buffer-name
1149 This function returns @code{t} if displaying a buffer
1150 named @var{buffer-name} with @code{display-buffer} would
1151 put it in the selected window.
1152 @end defun
1154 @c Emacs 19 feature
1155 @defvar display-buffer-function
1156 This variable is the most flexible way to customize the behavior of
1157 @code{display-buffer}.  If it is non-@code{nil}, it should be a function
1158 that @code{display-buffer} calls to do the work.  The function should
1159 accept two arguments, the first two arguments that @code{display-buffer}
1160 received.  It should choose or create a window, display the specified
1161 buffer in it, and then return the window.
1163 This variable takes precedence over all the other options described
1164 above.
1165 @end defvar
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.
1172 @node Dedicated Windows
1173 @section Dedicated Windows
1174 @cindex dedicated window
1176 Functions for displaying a buffer can be told to not use specific
1177 windows by marking these window as @dfn{dedicated} to their buffers.
1178 @code{display-buffer} (@pxref{Choosing Window}) never uses a dedicated
1179 window for displaying another buffer in it.  @code{get-lru-window} and
1180 @code{get-largest-window} (@pxref{Selecting Windows}) do not consider
1181 dedicated windows as candidates when their @var{dedicated} argument is
1182 non-@code{nil}.  The behavior of @code{set-window-buffer}
1183 (@pxref{Buffers and Windows}) with respect to dedicated windows is
1184 slightly different, see below.
1186 When @code{delete-windows-on} (@pxref{Deleting Windows}) wants to delete
1187 a dedicated window and that window is the only window on its frame, it
1188 deletes the window's frame too, provided there are other frames left.
1189 @code{replace-buffer-in-windows} (@pxref{Displaying Buffers}) tries to
1190 delete all dedicated windows showing its buffer argument.  When such a
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.
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.
1204 @defun window-dedicated-p &optional window
1205 This function returns non-@code{nil} if @var{window} is dedicated to its
1206 buffer and @code{nil} otherwise.  More precisely, the return value is
1207 the value assigned by the last call of @code{set-window-dedicated-p} for
1208 @var{window} or @code{nil} if that function was never called with
1209 @var{WINDOW} as its argument.  @var{WINDOW} defaults to the selected
1210 window.
1211 @end defun
1213 @defun set-window-dedicated-p window flag
1214 This function marks @var{window} as dedicated to its buffer if
1215 @var{flag} is non-@code{nil}, and non-dedicated otherwise.
1217 As a special case, if @var{flag} is @code{t}, @var{window} becomes
1218 @dfn{strongly} dedicated to its buffer.  @code{set-window-buffer}
1219 signals an error when the window it acts upon is strongly dedicated to
1220 its buffer and does not already display the buffer it is asked to
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
1226 @node Window Point
1227 @section Windows and Point
1228 @cindex window position
1229 @cindex window point
1230 @cindex position in window
1231 @cindex point in window
1233   Each window has its own value of point (@pxref{Point}), independent of
1234 the value of point in other windows displaying the same buffer.  This
1235 makes it useful to have multiple windows showing one buffer.
1237 @itemize @bullet
1238 @item
1239 The window point is established when a window is first created; it is
1240 initialized from the buffer's point, or from the window point of another
1241 window opened on the buffer if such a window exists.
1243 @item
1244 Selecting a window sets the value of point in its buffer from the
1245 window's value of point.  Conversely, deselecting a window sets the
1246 window's value of point from that of the buffer.  Thus, when you switch
1247 between windows that display a given buffer, the point value for the
1248 selected window is in effect in the buffer, while the point values for
1249 the other windows are stored in those windows.
1251 @item
1252 As long as the selected window displays the current buffer, the window's
1253 point and the buffer's point always move together; they remain equal.
1254 @end itemize
1256 @cindex cursor
1257 As far as the user is concerned, point is where the cursor is, and
1258 when the user switches to another buffer, the cursor jumps to the
1259 position of point in that buffer.
1261 @defun window-point &optional window
1262 This function returns the current position of point in @var{window}.
1263 For a nonselected window, this is the value point would have (in that
1264 window's buffer) if that window were selected.  @var{window} defaults to
1265 the selected window.
1267 When @var{window} is the selected window and its buffer is also the
1268 current buffer, the value returned is the same as point in that buffer.
1269 Strictly speaking, it would be more correct to return the ``top-level''
1270 value of point, outside of any @code{save-excursion} forms.  But that
1271 value is hard to find.
1272 @end defun
1274 @defun set-window-point window position
1275 This function positions point in @var{window} at position
1276 @var{position} in @var{window}'s buffer.  It returns @var{position}.
1278 If @var{window} is selected, and its buffer is current,
1279 this simply does @code{goto-char}.
1280 @end defun
1282 @node Window Start and End
1283 @section The Window Start and End Positions
1284 @cindex window start position
1286   Each window maintains a marker used to keep track of a buffer position
1287 that specifies where in the buffer display should start.  This position
1288 is called the @dfn{display-start} position of the window (or just the
1289 @dfn{start}).  The character after this position is the one that appears
1290 at the upper left corner of the window.  It is usually, but not
1291 inevitably, at the beginning of a text line.
1293   After switching windows or buffers, and in some other cases, if the
1294 window start is in the middle of a line, Emacs adjusts the window
1295 start to the start of a line.  This prevents certain operations from
1296 leaving the window start at a meaningless point within a line.  This
1297 feature may interfere with testing some Lisp code by executing it
1298 using the commands of Lisp mode, because they trigger this
1299 readjustment.  To test such code, put it into a command and bind the
1300 command to a key.
1302 @defun window-start &optional window
1303 @cindex window top line
1304 This function returns the display-start position of window
1305 @var{window}.  If @var{window} is @code{nil}, the selected window is
1306 used.  For example,
1308 @example
1309 @group
1310 (window-start)
1311      @result{} 7058
1312 @end group
1313 @end example
1315 When you create a window, or display a different buffer in it, the
1316 display-start position is set to a display-start position recently used
1317 for the same buffer, or to @code{point-min} if the buffer doesn't have
1318 any.
1320 Redisplay updates the window-start position (if you have not specified
1321 it explicitly since the previous redisplay)---to make sure point appears
1322 on the screen.  Nothing except redisplay automatically changes the
1323 window-start position; if you move point, do not expect the window-start
1324 position to change in response until after the next redisplay.
1326 For a realistic example of using @code{window-start}, see the
1327 description of @code{count-lines}.  @xref{Definition of count-lines}.
1328 @end defun
1330 @cindex window end position
1331 @defun window-end &optional window update
1332 This function returns the position where display of its buffer ends in
1333 @var{window}.  @var{window} defaults to the selected window.
1335 Simply changing the buffer text or moving point does not update the
1336 value that @code{window-end} returns.  The value is updated only when
1337 Emacs redisplays and redisplay completes without being preempted.
1339 If the last redisplay of @var{window} was preempted, and did not finish,
1340 Emacs does not know the position of the end of display in that window.
1341 In that case, this function returns @code{nil}.
1343 If @var{update} is non-@code{nil}, @code{window-end} always returns an
1344 up-to-date value for where display ends, based on the current
1345 @code{window-start} value.  If a previously saved value of that position
1346 is still valid, @code{window-end} returns that value; otherwise it
1347 computes the correct value by scanning the buffer text.
1349 Even if @var{update} is non-@code{nil}, @code{window-end} does not
1350 attempt to scroll the display if point has moved off the screen, the
1351 way real redisplay would do.  It does not alter the
1352 @code{window-start} value.  In effect, it reports where the displayed
1353 text will end if scrolling is not required.
1354 @end defun
1356 @defun set-window-start window position &optional noforce
1357 This function sets the display-start position of @var{window} to
1358 @var{position} in @var{window}'s buffer.  It returns @var{position}.
1360 The display routines insist that the position of point be visible when a
1361 buffer is displayed.  Normally, they change the display-start position
1362 (that is, scroll the window) whenever necessary to make point visible.
1363 However, if you specify the start position with this function using
1364 @code{nil} for @var{noforce}, it means you want display to start at
1365 @var{position} even if that would put the location of point off the
1366 screen.  If this does place point off screen, the display routines move
1367 point to the left margin on the middle line in the window.
1369 For example, if point @w{is 1} and you set the start of the window
1370 @w{to 37}, the start of the next line, point will be ``above'' the top
1371 of the window.  The display routines will automatically move point if
1372 it is still 1 when redisplay occurs.  Here is an example:
1374 @example
1375 @group
1376 ;; @r{Here is what @samp{foo} looks like before executing}
1377 ;;   @r{the @code{set-window-start} expression.}
1378 @end group
1380 @group
1381 ---------- Buffer: foo ----------
1382 @point{}This is the contents of buffer foo.
1388 ---------- Buffer: foo ----------
1389 @end group
1391 @group
1392 (set-window-start
1393  (selected-window)
1394  (save-excursion
1395    (goto-char 1)
1396    (forward-line 1)
1397    (point)))
1398 @result{} 37
1399 @end group
1401 @group
1402 ;; @r{Here is what @samp{foo} looks like after executing}
1403 ;;   @r{the @code{set-window-start} expression.}
1404 ---------- Buffer: foo ----------
1407 @point{}4
1410 ---------- Buffer: foo ----------
1411 @end group
1412 @end example
1414 If @var{noforce} is non-@code{nil}, and @var{position} would place point
1415 off screen at the next redisplay, then redisplay computes a new window-start
1416 position that works well with point, and thus @var{position} is not used.
1417 @end defun
1419 @defun pos-visible-in-window-p &optional position window partially
1420 This function returns non-@code{nil} if @var{position} is within the
1421 range of text currently visible on the screen in @var{window}.  It
1422 returns @code{nil} if @var{position} is scrolled vertically out of view.
1423 Locations that are partially obscured are not considered visible unless
1424 @var{partially} is non-@code{nil}.  The argument @var{position} defaults
1425 to the current position of point in @var{window}; @var{window}, to the
1426 selected window.  If @var{position} is @code{t}, that means to check the
1427 last visible position in @var{window}.
1429 The @code{pos-visible-in-window-p} function considers only vertical
1430 scrolling.  If @var{position} is out of view only because @var{window}
1431 has been scrolled horizontally, @code{pos-visible-in-window-p} returns
1432 non-@code{nil} anyway.  @xref{Horizontal Scrolling}.
1434 If @var{position} is visible, @code{pos-visible-in-window-p} returns
1435 @code{t} if @var{partially} is @code{nil}; if @var{partially} is
1436 non-@code{nil}, and the character following @var{position} is fully
1437 visible, it returns a list of the form @code{(@var{x} @var{y})}, where
1438 @var{x} and @var{y} are the pixel coordinates relative to the top left
1439 corner of the window; otherwise it returns an extended list of the form
1440 @code{(@var{x} @var{y} @var{rtop} @var{rbot} @var{rowh} @var{vpos})},
1441 where @var{rtop} and @var{rbot} specify the number of off-window pixels
1442 at the top and bottom of the row at @var{position}, @var{rowh} specifies
1443 the visible height of that row, and @var{vpos} specifies the vertical
1444 position (zero-based row number) of that row.
1446 Here is an example:
1448 @example
1449 @group
1450 ;; @r{If point is off the screen now, recenter it now.}
1451 (or (pos-visible-in-window-p
1452      (point) (selected-window))
1453     (recenter 0))
1454 @end group
1455 @end example
1456 @end defun
1458 @defun window-line-height &optional line window
1459 This function returns information about text line @var{line} in @var{window}.
1460 If @var{line} is one of @code{header-line} or @code{mode-line},
1461 @code{window-line-height} returns information about the corresponding
1462 line of the window.  Otherwise, @var{line} is a text line number
1463 starting from 0.  A negative number counts from the end of the window.
1464 The argument @var{line} defaults to the current line in @var{window};
1465 @var{window}, to the selected window.
1467 If the display is not up to date, @code{window-line-height} returns
1468 @code{nil}.  In that case, @code{pos-visible-in-window-p} may be used
1469 to obtain related information.
1471 If there is no line corresponding to the specified @var{line},
1472 @code{window-line-height} returns @code{nil}.  Otherwise, it returns
1473 a list @code{(@var{height} @var{vpos} @var{ypos} @var{offbot})},
1474 where @var{height} is the height in pixels of the visible part of the
1475 line, @var{vpos} and @var{ypos} are the vertical position in lines and
1476 pixels of the line relative to the top of the first text line, and
1477 @var{offbot} is the number of off-window pixels at the bottom of the
1478 text line.  If there are off-window pixels at the top of the (first)
1479 text line, @var{ypos} is negative.
1480 @end defun
1482 @node Textual Scrolling
1483 @section Textual Scrolling
1484 @cindex textual scrolling
1485 @cindex scrolling textually
1487   @dfn{Textual scrolling} means moving the text up or down through a
1488 window.  It works by changing the value of the window's display-start
1489 location.  It may also change the value of @code{window-point} to keep
1490 point on the screen.
1492   Textual scrolling was formerly called ``vertical scrolling,'' but we
1493 changed its name to distinguish it from the new vertical fractional
1494 scrolling feature (@pxref{Vertical Scrolling}).
1496   In the commands @code{scroll-up} and @code{scroll-down}, the directions
1497 ``up'' and ``down'' refer to the motion of the text in the buffer at which
1498 you are looking through the window.  Imagine that the text is
1499 written on a long roll of paper and that the scrolling commands move the
1500 paper up and down.  Thus, if you are looking at text in the middle of a
1501 buffer and repeatedly call @code{scroll-down}, you will eventually see
1502 the beginning of the buffer.
1504   Some people have urged that the opposite convention be used: they
1505 imagine that the window moves over text that remains in place.  Then
1506 ``down'' commands would take you to the end of the buffer.  This view is
1507 more consistent with the actual relationship between windows and the
1508 text in the buffer, but it is less like what the user sees.  The
1509 position of a window on the terminal does not move, and short scrolling
1510 commands clearly move the text up or down on the screen.  We have chosen
1511 names that fit the user's point of view.
1513   The textual scrolling functions (aside from
1514 @code{scroll-other-window}) have unpredictable results if the current
1515 buffer is different from the buffer that is displayed in the selected
1516 window.  @xref{Current Buffer}.
1518   If the window contains a row which is taller than the height of the
1519 window (for example in the presence of a large image), the scroll
1520 functions will adjust the window vscroll to scroll the partially
1521 visible row.  To disable this feature, Lisp code may bind the variable
1522 `auto-window-vscroll' to @code{nil} (@pxref{Vertical Scrolling}).
1524 @deffn Command scroll-up &optional count
1525 This function scrolls the text in the selected window upward
1526 @var{count} lines.  If @var{count} is negative, scrolling is actually
1527 downward.
1529 If @var{count} is @code{nil} (or omitted), then the length of scroll
1530 is @code{next-screen-context-lines} lines less than the usable height of
1531 the window (not counting its mode line).
1533 @code{scroll-up} returns @code{nil}, unless it gets an error
1534 because it can't scroll any further.
1535 @end deffn
1537 @deffn Command scroll-down &optional count
1538 This function scrolls the text in the selected window downward
1539 @var{count} lines.  If @var{count} is negative, scrolling is actually
1540 upward.
1542 If @var{count} is omitted or @code{nil}, then the length of the scroll
1543 is @code{next-screen-context-lines} lines less than the usable height of
1544 the window (not counting its mode line).
1546 @code{scroll-down} returns @code{nil}, unless it gets an error because
1547 it can't scroll any further.
1548 @end deffn
1550 @deffn Command scroll-other-window &optional count
1551 This function scrolls the text in another window upward @var{count}
1552 lines.  Negative values of @var{count}, or @code{nil}, are handled
1553 as in @code{scroll-up}.
1555 You can specify which buffer to scroll by setting the variable
1556 @code{other-window-scroll-buffer} to a buffer.  If that buffer isn't
1557 already displayed, @code{scroll-other-window} displays it in some
1558 window.
1560 When the selected window is the minibuffer, the next window is normally
1561 the one at the top left corner.  You can specify a different window to
1562 scroll, when the minibuffer is selected, by setting the variable
1563 @code{minibuffer-scroll-window}.  This variable has no effect when any
1564 other window is selected.  When it is non-@code{nil} and the
1565 minibuffer is selected, it takes precedence over
1566 @code{other-window-scroll-buffer}.  @xref{Definition of
1567 minibuffer-scroll-window}.
1569 When the minibuffer is active, it is the next window if the selected
1570 window is the one at the bottom right corner.  In this case,
1571 @code{scroll-other-window} attempts to scroll the minibuffer.  If the
1572 minibuffer contains just one line, it has nowhere to scroll to, so the
1573 line reappears after the echo area momentarily displays the message
1574 @samp{Beginning of buffer}.
1575 @end deffn
1577 @c Emacs 19 feature
1578 @defvar other-window-scroll-buffer
1579 If this variable is non-@code{nil}, it tells @code{scroll-other-window}
1580 which buffer's window to scroll.
1581 @end defvar
1583 @defopt scroll-margin
1584 This option specifies the size of the scroll margin---a minimum number
1585 of lines between point and the top or bottom of a window.  Whenever
1586 point gets within this many lines of the top or bottom of the window,
1587 redisplay scrolls the text automatically (if possible) to move point
1588 out of the margin, closer to the center of the window.
1589 @end defopt
1591 @defopt scroll-conservatively
1592 This variable controls how scrolling is done automatically when point
1593 moves off the screen (or into the scroll margin).  If the value is a
1594 positive integer @var{n}, then redisplay scrolls the text up to
1595 @var{n} lines in either direction, if that will bring point back into
1596 proper view.  This behavior is called @dfn{conservative scrolling}.
1597 Otherwise, scrolling happens in the usual way, under the control of
1598 other variables such as @code{scroll-up-aggressively} and
1599 @code{scroll-down-aggressively}.
1601 The default value is zero, which means that conservative scrolling
1602 never happens.
1603 @end defopt
1605 @defopt scroll-down-aggressively
1606 The value of this variable should be either @code{nil} or a fraction
1607 @var{f} between 0 and 1.  If it is a fraction, that specifies where on
1608 the screen to put point when scrolling down.  More precisely, when a
1609 window scrolls down because point is above the window start, the new
1610 start position is chosen to put point @var{f} part of the window
1611 height from the top.  The larger @var{f}, the more aggressive the
1612 scrolling.
1614 A value of @code{nil} is equivalent to .5, since its effect is to center
1615 point.  This variable automatically becomes buffer-local when set in any
1616 fashion.
1617 @end defopt
1619 @defopt scroll-up-aggressively
1620 Likewise, for scrolling up.  The value, @var{f}, specifies how far
1621 point should be placed from the bottom of the window; thus, as with
1622 @code{scroll-up-aggressively}, a larger value scrolls more aggressively.
1623 @end defopt
1625 @defopt scroll-step
1626 This variable is an older variant of @code{scroll-conservatively}.  The
1627 difference is that it if its value is @var{n}, that permits scrolling
1628 only by precisely @var{n} lines, not a smaller number.  This feature
1629 does not work with @code{scroll-margin}.  The default value is zero.
1630 @end defopt
1632 @defopt scroll-preserve-screen-position
1633 If this option is @code{t}, scrolling which would move the current
1634 point position out of the window chooses the new position of point
1635 so that the vertical position of the cursor is unchanged, if possible.
1637 If it is non-@code{nil} and not @code{t}, then the scrolling functions
1638 always preserve the vertical position of point, if possible.
1639 @end defopt
1641 @defopt next-screen-context-lines
1642 The value of this variable is the number of lines of continuity to
1643 retain when scrolling by full screens.  For example, @code{scroll-up}
1644 with an argument of @code{nil} scrolls so that this many lines at the
1645 bottom of the window appear instead at the top.  The default value is
1646 @code{2}.
1647 @end defopt
1649 @deffn Command recenter &optional count
1650 @cindex centering point
1651 This function scrolls the text in the selected window so that point is
1652 displayed at a specified vertical position within the window.  It does
1653 not ``move point'' with respect to the text.
1655 If @var{count} is a nonnegative number, that puts the line containing
1656 point @var{count} lines down from the top of the window.  If
1657 @var{count} is a negative number, then it counts upward from the
1658 bottom of the window, so that @minus{}1 stands for the last usable
1659 line in the window.  If @var{count} is a non-@code{nil} list, then it
1660 stands for the line in the middle of the window.
1662 If @var{count} is @code{nil}, @code{recenter} puts the line containing
1663 point in the middle of the window, then clears and redisplays the entire
1664 selected frame.
1666 When @code{recenter} is called interactively, @var{count} is the raw
1667 prefix argument.  Thus, typing @kbd{C-u} as the prefix sets the
1668 @var{count} to a non-@code{nil} list, while typing @kbd{C-u 4} sets
1669 @var{count} to 4, which positions the current line four lines from the
1670 top.
1672 With an argument of zero, @code{recenter} positions the current line at
1673 the top of the window.  This action is so handy that some people make a
1674 separate key binding to do this.  For example,
1676 @example
1677 @group
1678 (defun line-to-top-of-window ()
1679   "Scroll current line to top of window.
1680 Replaces three keystroke sequence C-u 0 C-l."
1681   (interactive)
1682   (recenter 0))
1684 (global-set-key [kp-multiply] 'line-to-top-of-window)
1685 @end group
1686 @end example
1687 @end deffn
1689 @node Vertical Scrolling
1690 @section Vertical Fractional Scrolling
1691 @cindex vertical fractional scrolling
1692 @cindex vertical scroll position
1694 @dfn{Vertical fractional scrolling} means shifting text in a window up
1695 or down by a specified multiple or fraction of a line.  Each window has
1696 a @dfn{vertical scroll position}, which is a number, never less than
1697 zero.  It specifies how far to raise the contents of the window.
1698 Raising the window contents generally makes all or part of some lines
1699 disappear off the top, and all or part of some other lines appear at the
1700 bottom.  The usual value is zero.
1702 The vertical scroll position is measured in units of the normal line
1703 height, which is the height of the default font.  Thus, if the value is
1704 .5, that means the window contents are scrolled up half the normal line
1705 height.  If it is 3.3, that means the window contents are scrolled up
1706 somewhat over three times the normal line height.
1708 What fraction of a line the vertical scrolling covers, or how many
1709 lines, depends on what the lines contain.  A value of .5 could scroll a
1710 line whose height is very short off the screen, while a value of 3.3
1711 could scroll just part of the way through a tall line or an image.
1713 @defun window-vscroll &optional window pixels-p
1714 This function returns the current vertical scroll position of
1715 @var{window}.  @var{window} defaults to the selected window.  If
1716 @var{pixels-p} is non-@code{nil}, the return value is measured in
1717 pixels, rather than in units of the normal line height.
1719 @example
1720 @group
1721 (window-vscroll)
1722      @result{} 0
1723 @end group
1724 @end example
1725 @end defun
1727 @defun set-window-vscroll window lines &optional pixels-p
1728 This function sets @var{window}'s vertical scroll position to
1729 @var{lines}.  If @var{window} is @code{nil}, the selected window is
1730 used.  The argument @var{lines} should be zero or positive; if not, it
1731 is taken as zero.
1734 The actual vertical scroll position must always correspond
1735 to an integral number of pixels, so the value you specify
1736 is rounded accordingly.
1738 The return value is the result of this rounding.
1740 @example
1741 @group
1742 (set-window-vscroll (selected-window) 1.2)
1743      @result{} 1.13
1744 @end group
1745 @end example
1747 If @var{pixels-p} is non-@code{nil}, @var{lines} specifies a number of
1748 pixels.  In this case, the return value is @var{lines}.
1749 @end defun
1751 @defvar auto-window-vscroll
1752 If this variable is non-@code{nil}, the line-move, scroll-up, and
1753 scroll-down functions will automatically modify the vertical scroll
1754 position to scroll through display rows that are taller that the height
1755 of the window, for example in the presence of large images.
1756 @end defvar
1758 @node Horizontal Scrolling
1759 @section Horizontal Scrolling
1760 @cindex horizontal scrolling
1762   @dfn{Horizontal scrolling} means shifting the image in the window left
1763 or right by a specified multiple of the normal character width.  Each
1764 window has a @dfn{horizontal scroll position}, which is a number, never
1765 less than zero.  It specifies how far to shift the contents left.
1766 Shifting the window contents left generally makes all or part of some
1767 characters disappear off the left, and all or part of some other
1768 characters appear at the right.  The usual value is zero.
1770   The horizontal scroll position is measured in units of the normal
1771 character width, which is the width of space in the default font.  Thus,
1772 if the value is 5, that means the window contents are scrolled left by 5
1773 times the normal character width.  How many characters actually
1774 disappear off to the left depends on their width, and could vary from
1775 line to line.
1777   Because we read from side to side in the ``inner loop,'' and from top
1778 to bottom in the ``outer loop,'' the effect of horizontal scrolling is
1779 not like that of textual or vertical scrolling.  Textual scrolling
1780 involves selection of a portion of text to display, and vertical
1781 scrolling moves the window contents contiguously; but horizontal
1782 scrolling causes part of @emph{each line} to go off screen.
1784   Usually, no horizontal scrolling is in effect; then the leftmost
1785 column is at the left edge of the window.  In this state, scrolling to
1786 the right is meaningless, since there is no data to the left of the edge
1787 to be revealed by it; so this is not allowed.  Scrolling to the left is
1788 allowed; it scrolls the first columns of text off the edge of the window
1789 and can reveal additional columns on the right that were truncated
1790 before.  Once a window has a nonzero amount of leftward horizontal
1791 scrolling, you can scroll it back to the right, but only so far as to
1792 reduce the net horizontal scroll to zero.  There is no limit to how far
1793 left you can scroll, but eventually all the text will disappear off the
1794 left edge.
1796 @vindex auto-hscroll-mode
1797   If @code{auto-hscroll-mode} is set, redisplay automatically alters
1798 the horizontal scrolling of a window as necessary to ensure that point
1799 is always visible.  However, you can still set the horizontal
1800 scrolling value explicitly.  The value you specify serves as a lower
1801 bound for automatic scrolling, i.e. automatic scrolling will not
1802 scroll a window to a column less than the specified one.
1804 @deffn Command scroll-left &optional count set-minimum
1805 This function scrolls the selected window @var{count} columns to the
1806 left (or to the right if @var{count} is negative).  The default
1807 for @var{count} is the window width, minus 2.
1809 The return value is the total amount of leftward horizontal scrolling in
1810 effect after the change---just like the value returned by
1811 @code{window-hscroll} (below).
1813 Once you scroll a window as far right as it can go, back to its normal
1814 position where the total leftward scrolling is zero, attempts to scroll
1815 any farther right have no effect.
1817 If @var{set-minimum} is non-@code{nil}, the new scroll amount becomes
1818 the lower bound for automatic scrolling; that is, automatic scrolling
1819 will not scroll a window to a column less than the value returned by
1820 this function.  Interactive calls pass non-@code{nil} for
1821 @var{set-minimum}.
1822 @end deffn
1824 @deffn Command scroll-right &optional count set-minimum
1825 This function scrolls the selected window @var{count} columns to the
1826 right (or to the left if @var{count} is negative).  The default
1827 for @var{count} is the window width, minus 2.  Aside from the direction
1828 of scrolling, this works just like @code{scroll-left}.
1829 @end deffn
1831 @defun window-hscroll &optional window
1832 This function returns the total leftward horizontal scrolling of
1833 @var{window}---the number of columns by which the text in @var{window}
1834 is scrolled left past the left margin.  @var{window} defaults to the
1835 selected window.
1837 The return value is never negative.  It is zero when no horizontal
1838 scrolling has been done in @var{window} (which is usually the case).
1841 @example
1842 @group
1843 (window-hscroll)
1844      @result{} 0
1845 @end group
1846 @group
1847 (scroll-left 5)
1848      @result{} 5
1849 @end group
1850 @group
1851 (window-hscroll)
1852      @result{} 5
1853 @end group
1854 @end example
1855 @end defun
1857 @defun set-window-hscroll window columns
1858 This function sets horizontal scrolling of @var{window}.  The value of
1859 @var{columns} specifies the amount of scrolling, in terms of columns
1860 from the left margin.  The argument @var{columns} should be zero or
1861 positive; if not, it is taken as zero.  Fractional values of
1862 @var{columns} are not supported at present.
1864 Note that @code{set-window-hscroll} may appear not to work if you test
1865 it by evaluating a call with @kbd{M-:} in a simple way.  What happens
1866 is that the function sets the horizontal scroll value and returns, but
1867 then redisplay adjusts the horizontal scrolling to make point visible,
1868 and this overrides what the function did.  You can observe the
1869 function's effect if you call it while point is sufficiently far from
1870 the left margin that it will remain visible.
1872 The value returned is @var{columns}.
1874 @example
1875 @group
1876 (set-window-hscroll (selected-window) 10)
1877      @result{} 10
1878 @end group
1879 @end example
1880 @end defun
1882 Here is how you can determine whether a given position @var{position} is
1883 off the screen due to horizontal scrolling:
1885 @example
1886 @group
1887 (defun hscroll-on-screen (window position)
1888   (save-excursion
1889     (goto-char position)
1890     (and
1891      (>= (- (current-column) (window-hscroll window)) 0)
1892      (< (- (current-column) (window-hscroll window))
1893         (window-width window)))))
1894 @end group
1895 @end example
1897 @node Size of Window
1898 @section The Size of a Window
1899 @cindex window size
1900 @cindex size of window
1902   An Emacs window is rectangular, and its size information consists of
1903 the height (the number of lines) and the width (the number of character
1904 positions in each line).  The mode line is included in the height.  But
1905 the width does not count the scroll bar or the column of @samp{|}
1906 characters that separates side-by-side windows.
1908   The following three functions return size information about a window:
1910 @defun window-height &optional window
1911 This function returns the number of lines in @var{window}, including its
1912 mode line and header line, if any.  If @var{window} fills its entire
1913 frame except for the echo area, this is typically one less than the
1914 value of @code{frame-height} on that frame.  @var{window} defaults to
1915 the selected window.
1917 @example
1918 @group
1919 (window-height)
1920      @result{} 23
1921 @end group
1922 @group
1923 (split-window-vertically)
1924      @result{} #<window 4 on windows.texi>
1925 @end group
1926 @group
1927 (window-height)
1928      @result{} 11
1929 @end group
1930 @end example
1931 @end defun
1933 @defun window-body-height &optional window
1934 Like @code{window-height} but the value does not include the
1935 mode line (if any) or the header line (if any).
1936 @end defun
1938 @defun window-width &optional window
1939 This function returns the number of columns in @var{window}.
1940 @var{window} defaults to the selected window.
1942 The return value does not include the window's scroll bar or the column
1943 of @samp{|} characters that separates side-by-side windows.  Moreover,
1944 the return value does not include the space used for displaying fringes
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.
1950 @example
1951 @group
1952 (window-width)
1953      @result{} 80
1954 @end group
1955 @end example
1956 @end defun
1958 @defun window-full-width-p &optional window
1959 This function returns non-@code{nil} if @var{window} is as wide as the
1960 frame that contains it; otherwise @code{nil}.  @var{window} defaults to
1961 the selected window.
1962 @end defun
1964 @defun window-edges &optional window
1965 This function returns a list of the edge coordinates of @var{window}.
1966 @var{window} defaults to the selected window.
1968 The order of the list is @code{(@var{left} @var{top} @var{right}
1969 @var{bottom})}, all elements relative to 0, 0 at the top left corner of
1970 the frame.  The element @var{right} of the value is one more than the
1971 rightmost column used by @var{window}, and @var{bottom} is one more than
1972 the bottommost row used by @var{window} and its mode-line.
1974 The edges include the space used by the window's scroll bar, display
1975 margins, fringes, header line, and mode line, if it has them.  Also,
1976 if the window has a neighbor on the right, its right edge value
1977 includes the width of the separator line between the window and that
1978 neighbor.  Since the width of the window does not include this
1979 separator, the width does not usually equal the difference between the
1980 right and left edges.
1981 @end defun
1983 @defun window-inside-edges &optional window
1984 This is similar to @code{window-edges}, but the edge values
1985 it returns include only the text area of the window.  They
1986 do not include the header line, mode line, scroll bar or
1987 vertical separator, fringes, or display margins.
1988 @end defun
1990 Here are the results obtained on a typical 24-line terminal with just
1991 one window, with menu bar enabled:
1993 @example
1994 @group
1995 (window-edges (selected-window))
1996      @result{} (0 1 80 23)
1997 @end group
1998 @group
1999 (window-inside-edges (selected-window))
2000      @result{} (0 1 80 22)
2001 @end group
2002 @end example
2004 @noindent
2005 The bottom edge is at line 23 because the last line is the echo area.
2006 The bottom inside edge is at line 22, which is the window's mode line.
2008 If @var{window} is at the upper left corner of its frame, and there is
2009 no menu bar, then @var{bottom} returned by @code{window-edges} is the
2010 same as the value of @code{(window-height)}, @var{right} is almost the
2011 same as the value of @code{(window-width)}, and @var{top} and
2012 @var{left} are zero.  For example, the edges of the following window
2013 are @w{@samp{0 0 8 5}}.  Assuming that the frame has more than 8
2014 columns, the last column of the window (column 7) holds a border
2015 rather than text.  The last row (row 4) holds the mode line, shown
2016 here with @samp{xxxxxxxxx}.
2018 @example
2019 @group
2020            0
2021            _______
2022         0 |       |
2023           |       |
2024           |       |
2025           |       |
2026           xxxxxxxxx  4
2028                   7
2029 @end group
2030 @end example
2032 In the following example, let's suppose that the frame is 7
2033 columns wide.  Then the edges of the left window are @w{@samp{0 0 4 3}}
2034 and the edges of the right window are @w{@samp{4 0 7 3}}.
2035 The inside edges of the left window are @w{@samp{0 0 3 2}},
2036 and the inside edges of the right window are @w{@samp{4 0 7 2}},
2038 @example
2039 @group
2040            ___ ___
2041           |   |   |
2042           |   |   |
2043           xxxxxxxxx
2045            0  34  7
2046 @end group
2047 @end example
2049 @defun window-pixel-edges &optional window
2050 This function is like @code{window-edges} except that, on a graphical
2051 display, the edge values are measured in pixels instead of in
2052 character lines and columns.
2053 @end defun
2055 @defun window-inside-pixel-edges &optional window
2056 This function is like @code{window-inside-edges} except that, on a
2057 graphical display, the edge values are measured in pixels instead of
2058 in character lines and columns.
2059 @end defun
2061 @node Resizing Windows
2062 @section Changing the Size of a Window
2063 @cindex window resizing
2064 @cindex resize window
2065 @cindex changing window size
2066 @cindex window size, changing
2068 The window size functions fall into two classes: high-level commands
2069 that change the size of windows and low-level functions that access
2070 window size.  Emacs does not permit overlapping windows or gaps between
2071 windows, so resizing a window always affects at least one other window.
2073 @deffn Command enlarge-window size &optional horizontal
2074 This function makes the selected window @var{size} lines taller by
2075 stealing lines from windows above or below.  In a first round, it takes
2076 lines from one window at a time until that window is
2077 @code{window-min-height} lines tall, then takes from another.  If, at
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.
2082 If @var{horizontal} is non-@code{nil}, this function makes the window
2083 @var{size} columns wider, stealing columns instead of lines.  If a
2084 window from which columns are stolen shrinks below
2085 @code{window-min-width} columns, that window disappears.
2087 If the requested size would exceed that of the window's frame, then the
2088 function makes the window occupy the entire height (or width) of the
2089 frame.
2091 If there are various other windows from which lines or columns can be
2092 stolen, and some of them specify fixed size (using
2093 @code{window-size-fixed}, see below), they are left untouched while
2094 other windows are ``robbed''.  If it would be necessary to alter the
2095 size of a fixed-size window, @code{enlarge-window} gets an error
2096 instead.
2098 If @var{size} is negative, this function shrinks the selected window by
2099 @minus{}@var{size} lines or columns.  If that makes the window smaller
2100 than the minimum size (@code{window-min-height} and
2101 @code{window-min-width}), then @code{enlarge-window} deletes the window.
2103 @code{enlarge-window} returns @code{nil}.
2104 @end deffn
2106 @deffn Command enlarge-window-horizontally columns
2107 This function makes the selected window @var{columns} wider.
2108 It could be defined as follows:
2110 @example
2111 @group
2112 (defun enlarge-window-horizontally (columns)
2113   (interactive "p")
2114   (enlarge-window columns t))
2115 @end group
2116 @end example
2117 @end deffn
2119 @deffn Command shrink-window size &optional horizontal
2120 This function is like @code{enlarge-window} but negates the argument
2121 @var{size}, making the selected window smaller by giving lines (or
2122 columns) to the other windows.  If the window shrinks below
2123 @code{window-min-height} or @code{window-min-width}, then it disappears.
2125 If @var{size} is negative, the window is enlarged by @minus{}@var{size}
2126 lines or columns.
2127 @end deffn
2129 @deffn Command shrink-window-horizontally columns
2130 This function makes the selected window @var{columns} narrower.
2131 It could be defined as follows:
2133 @example
2134 @group
2135 (defun shrink-window-horizontally (columns)
2136   (interactive "p")
2137   (shrink-window columns t))
2138 @end group
2139 @end example
2140 @end deffn
2142 @defun adjust-window-trailing-edge window delta horizontal
2143 This function makes the selected window @var{delta} lines taller or
2144 @var{delta} columns wider, by moving the bottom or right edge.  This
2145 function does not delete other windows; if it cannot make the
2146 requested size adjustment, it signals an error.  On success, this
2147 function returns @code{nil}.
2148 @end defun
2150 @defun fit-window-to-buffer &optional window max-height min-height
2151 This function makes @var{window} the right height to display its
2152 contents exactly.  @var{window} defaults to the selected window.
2154 The argument @var{max-height} specifies the maximum height the window
2155 is allowed to be; @code{nil} means use the frame height.  The argument
2156 @var{min-height} specifies the minimum height for the window;
2157 @code{nil} means use @code{window-min-height}.  All these height
2158 values include the mode line and/or header line.
2159 @end defun
2161 @deffn Command shrink-window-if-larger-than-buffer &optional window
2162 This command shrinks @var{window} vertically to be as small as possible
2163 while still showing the full contents of its buffer---but not less than
2164 @code{window-min-height} lines.  @var{window} defaults to the selected
2165 window.
2167 However, this command does nothing if the window is already too small to
2168 display the whole text of the buffer, or if part of the contents are
2169 currently scrolled off screen, or if the window is not the full width of
2170 its frame, or if the window is the only window in its frame.
2172 This command returns non-@code{nil} if it actually shrank the window
2173 and @code{nil} otherwise.
2174 @end deffn
2176 @cindex fixed-size window
2177 @defvar window-size-fixed
2178 If this variable is non-@code{nil}, in a given buffer, then the size of
2179 any window displaying that buffer remains fixed unless you either
2180 explicitly change it or Emacs has no other choice.
2182 If the value is @code{height}, then only the window's height is fixed;
2183 if the value is @code{width}, then only the window's width is fixed.
2184 Any other non-@code{nil} value fixes both the width and the height.
2186 This variable automatically becomes buffer-local when set.
2188 Explicit size-change functions such as @code{enlarge-window}
2189 get an error if they would have to change a window size which is fixed.
2190 Therefore, when you want to change the size of such a window,
2191 you should bind @code{window-size-fixed} to @code{nil}, like this:
2193 @example
2194 (let ((window-size-fixed nil))
2195    (enlarge-window 10))
2196 @end example
2198 Deleting an adjacent window or changing the frame size may change the
2199 size of a fixed-size window, if there is no other alternative.
2200 @end defvar
2202 @cindex minimum window size
2203   The following two variables constrain the window-structure-changing
2204 functions to a minimum height and width.
2206 @defopt window-min-height
2207 The value of this variable specifies how short a window may become
2208 before it is automatically deleted.  Making a window smaller than
2209 @code{window-min-height} automatically deletes it, and no window may be
2210 created shorter than this.  The value is measured in line units.  When
2211 the window wants a mode line and/or a header line, they are counted as
2212 one line each.  The default value of this variable is @code{4}.  A value
2213 less than @code{1} is ignored.
2214 @end defopt
2216 @defopt window-min-width
2217 The value of this variable specifies how narrow a window may become
2218 before it is automatically deleted.  Making a window smaller than
2219 @code{window-min-width} automatically deletes it, and no window may be
2220 created narrower than this.  The value is measured in characters and
2221 includes any fringes or the scroll bar.  The default value is @code{10}.
2222 A value less than @code{2} is ignored.
2223 @end defopt
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.
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
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 @node Coordinates and Windows
2249 @section Coordinates and Windows
2251 This section describes how to relate screen coordinates to windows.
2253 @defun window-at x y &optional frame
2254 This function returns the window containing the specified cursor
2255 position in the frame @var{frame}.  The coordinates @var{x} and @var{y}
2256 are measured in characters and count from the top left corner of the
2257 frame.  If they are out of range, @code{window-at} returns @code{nil}.
2259 If you omit @var{frame}, the selected frame is used.
2260 @end defun
2262 @defun coordinates-in-window-p coordinates window
2263 This function checks whether a particular frame position falls within
2264 the window @var{window}.
2266 The argument @var{coordinates} is a cons cell of the form @code{(@var{x}
2267 . @var{y})}.  The coordinates @var{x} and @var{y} are measured in
2268 characters, and count from the top left corner of the screen or frame.
2270 The value returned by @code{coordinates-in-window-p} is non-@code{nil}
2271 if the coordinates are inside @var{window}.  The value also indicates
2272 what part of the window the position is in, as follows:
2274 @table @code
2275 @item (@var{relx} . @var{rely})
2276 The coordinates are inside @var{window}.  The numbers @var{relx} and
2277 @var{rely} are the equivalent window-relative coordinates for the
2278 specified position, counting from 0 at the top left corner of the
2279 window.
2281 @item mode-line
2282 The coordinates are in the mode line of @var{window}.
2284 @item header-line
2285 The coordinates are in the header line of @var{window}.
2287 @item vertical-line
2288 The coordinates are in the vertical line between @var{window} and its
2289 neighbor to the right.  This value occurs only if the window doesn't
2290 have a scroll bar; positions in a scroll bar are considered outside the
2291 window for these purposes.
2293 @item left-fringe
2294 @itemx right-fringe
2295 The coordinates are in the left or right fringe of the window.
2297 @item left-margin
2298 @itemx right-margin
2299 The coordinates are in the left or right margin of the window.
2301 @item nil
2302 The coordinates are not in any part of @var{window}.
2303 @end table
2305 The function @code{coordinates-in-window-p} does not require a frame as
2306 argument because it always uses the frame that @var{window} is on.
2307 @end defun
2309 @node Window Tree
2310 @section The Window Tree
2311 @cindex window tree
2313   A @dfn{window tree} specifies the layout, size, and relationship
2314 between all windows in one frame.
2316 @defun window-tree &optional frame
2317 This function returns the window tree for frame @var{frame}.
2318 If @var{frame} is omitted, the selected frame is used.
2320 The return value is a list of the form @code{(@var{root} @var{mini})},
2321 where @var{root} represents the window tree of the frame's
2322 root window, and @var{mini} is the frame's minibuffer window.
2324 If the root window is not split, @var{root} is the root window itself.
2325 Otherwise, @var{root} is a list @code{(@var{dir} @var{edges} @var{w1}
2326 @var{w2} ...)} where @var{dir} is @code{nil} for a horizontal split,
2327 and @code{t} for a vertical split, @var{edges} gives the combined size and
2328 position of the subwindows in the split, and the rest of the elements
2329 are the subwindows in the split.  Each of the subwindows may again be
2330 a window or a list representing a window split, and so on.  The
2331 @var{edges} element is a list @code{(@var{left}@var{ top}@var{ right}@var{ bottom})}
2332 similar to the value returned by @code{window-edges}.
2333 @end defun
2335 @node Window Configurations
2336 @section Window Configurations
2337 @cindex window configurations
2338 @cindex saving window information
2340   A @dfn{window configuration} records the entire layout of one
2341 frame---all windows, their sizes, which buffers they contain, how those
2342 buffers are scrolled, and their values of point and the mark; also their
2343 fringes, margins, and scroll bar settings.  It also includes the value
2344 of @code{minibuffer-scroll-window}.  As a special exception, the window
2345 configuration does not record the value of point in the selected window
2346 for the current buffer.  Also, the window configuration does not record
2347 the values of window parameters, @xref{Window Parameters}.
2349   You can bring back an entire frame layout by restoring a window
2350 configuration previously saved.  If you want to record the layout of all
2351 frames instead of just one, use a frame configuration instead of a
2352 window configuration, @xref{Frame Configurations}.
2354 @defun current-window-configuration &optional frame
2355 This function returns a new object representing @var{frame}'s current
2356 window configuration.  @var{frame} defaults to the selected frame.
2357 @end defun
2359 @defun set-window-configuration configuration
2360 This function restores the configuration of windows and buffers as
2361 specified by @var{configuration}, for the frame that @var{configuration}
2362 was created for.
2364 The argument @var{configuration} must be a value that was previously
2365 returned by @code{current-window-configuration}.  The configuration is
2366 restored in the frame from which @var{configuration} was made, whether
2367 that frame is selected or not.  This always counts as a window size
2368 change and triggers execution of the @code{window-size-change-functions}
2369 (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
2370 know how to tell whether the new configuration actually differs from the
2371 old one.
2373 If the frame which @var{configuration} was saved from is dead, all this
2374 function does is restore the three variables @code{window-min-height},
2375 @code{window-min-width} and @code{minibuffer-scroll-window}. In this
2376 case, the function returns @code{nil}.  Otherwise, it returns @code{t}.
2378 Here is a way of using this function to get the same effect
2379 as @code{save-window-excursion}:
2381 @example
2382 @group
2383 (let ((config (current-window-configuration)))
2384   (unwind-protect
2385       (progn (split-window-vertically nil)
2386              @dots{})
2387     (set-window-configuration config)))
2388 @end group
2389 @end example
2390 @end defun
2392 @defspec save-window-excursion forms@dots{}
2393 This special form records the window configuration, executes @var{forms}
2394 in sequence, then restores the earlier window configuration.  The window
2395 configuration includes, for each window, the value of point and the
2396 portion of the buffer that is visible.  It also includes the choice of
2397 selected window.  However, it does not include the value of point in
2398 the current buffer; use @code{save-excursion} also, if you wish to
2399 preserve that.
2401 Don't use this construct when @code{save-selected-window} is sufficient.
2403 Exit from @code{save-window-excursion} always triggers execution of
2404 @code{window-size-change-functions}.  (It doesn't know how to tell
2405 whether the restored configuration actually differs from the one in
2406 effect at the end of the @var{forms}.)
2408 The return value is the value of the final form in @var{forms}.
2409 For example:
2411 @example
2412 @group
2413 (split-window)
2414      @result{} #<window 25 on control.texi>
2415 @end group
2416 @group
2417 (setq w (selected-window))
2418      @result{} #<window 19 on control.texi>
2419 @end group
2420 @group
2421 (save-window-excursion
2422   (delete-other-windows w)
2423   (switch-to-buffer "foo")
2424   'do-something)
2425      @result{} do-something
2426      ;; @r{The screen is now split again.}
2427 @end group
2428 @end example
2429 @end defspec
2431 @defun window-configuration-p object
2432 This function returns @code{t} if @var{object} is a window configuration.
2433 @end defun
2435 @defun compare-window-configurations config1 config2
2436 This function compares two window configurations as regards the
2437 structure of windows, but ignores the values of point and mark and the
2438 saved scrolling positions---it can return @code{t} even if those
2439 aspects differ.
2441 The function @code{equal} can also compare two window configurations; it
2442 regards configurations as unequal if they differ in any respect, even a
2443 saved point or mark.
2444 @end defun
2446 @defun window-configuration-frame config
2447 This function returns the frame for which the window configuration
2448 @var{config} was made.
2449 @end defun
2451   Other primitives to look inside of window configurations would make
2452 sense, but are not implemented because we did not need them.  See the
2453 file @file{winner.el} for some more operations on windows
2454 configurations.
2456 @node Window Parameters
2457 @section Window Parameters
2458 @cindex window parameters
2460 This sections describes how window parameters can be used to associate
2461 additional information with windows.
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
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
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
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}.
2490 @node Window Hooks
2491 @section Hooks for Window Scrolling and Changes
2492 @cindex hooks for window operations
2494 This section describes how a Lisp program can take action whenever a
2495 window displays a different part of its buffer or a different buffer.
2496 There are three actions that can change this: scrolling the window,
2497 switching buffers in the window, and changing the size of the window.
2498 The first two actions run @code{window-scroll-functions}; the last runs
2499 @code{window-size-change-functions}.
2501 @defvar window-scroll-functions
2502 This variable holds a list of functions that Emacs should call before
2503 redisplaying a window with scrolling.  Displaying a different buffer in
2504 the window also runs these functions.
2506 This variable is not a normal hook, because each function is called with
2507 two arguments: the window, and its new display-start position.
2509 These functions must be careful in using @code{window-end}
2510 (@pxref{Window Start and End}); if you need an up-to-date value, you
2511 must use the @var{update} argument to ensure you get it.
2513 @strong{Warning:} don't use this feature to alter the way the window
2514 is scrolled.  It's not designed for that, and such use probably won't
2515 work.
2516 @end defvar
2518 @defvar window-size-change-functions
2519 This variable holds a list of functions to be called if the size of any
2520 window changes for any reason.  The functions are called just once per
2521 redisplay, and just once for each frame on which size changes have
2522 occurred.
2524 Each function receives the frame as its sole argument.  There is no
2525 direct way to find out which windows on that frame have changed size, or
2526 precisely how.  However, if a size-change function records, at each
2527 call, the existing windows and their sizes, it can also compare the
2528 present sizes and the previous sizes.
2530 Creating or deleting windows counts as a size change, and therefore
2531 causes these functions to be called.  Changing the frame size also
2532 counts, because it changes the sizes of the existing windows.
2534 It is not a good idea to use @code{save-window-excursion} (@pxref{Window
2535 Configurations}) in these functions, because that always counts as a
2536 size change, and it would cause these functions to be called over and
2537 over.  In most cases, @code{save-selected-window} (@pxref{Selecting
2538 Windows}) is what you need here.
2539 @end defvar
2541 @defvar redisplay-end-trigger-functions
2542 This abnormal hook is run whenever redisplay in a window uses text that
2543 extends past a specified end trigger position.  You set the end trigger
2544 position with @code{set-window-redisplay-end-trigger}.  The functions
2545 are called with two arguments: the window, and the end trigger position.
2546 Storing @code{nil} for the end trigger position turns off the feature,
2547 and the trigger value is automatically reset to @code{nil} just after
2548 the hook is run.
2549 @end defvar
2551 @defun set-window-redisplay-end-trigger window position
2552 This function sets @var{window}'s end trigger position at
2553 @var{position}.
2554 @end defun
2556 @defun window-redisplay-end-trigger &optional window
2557 This function returns @var{window}'s current end trigger position.
2558 If @var{window} is @code{nil} or omitted, it uses the selected window.
2559 @end defun
2561 @defvar window-configuration-change-hook
2562 A normal hook that is run every time you change the window configuration
2563 of an existing frame.  This includes splitting or deleting windows,
2564 changing the sizes of windows, or displaying a different buffer in a
2565 window.
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.
2571 @end defvar
2573 @ignore
2574    arch-tag: 3f6c36e8-df49-4986-b757-417feed88be3
2575 @end ignore