This commit was generated by cvs2svn to compensate for changes in r6453,
[chise/xemacs-chise.git.1] / info / lispref.info-25
1 This is Info file ../../info/lispref.info, produced by Makeinfo version
2 1.68 from the input file lispref.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * Lispref: (lispref).           XEmacs Lisp Reference Manual.
7 END-INFO-DIR-ENTRY
8
9    Edition History:
10
11    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
12 Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
13 Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
14 XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
15 GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
16 Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
17 Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
18 Reference Manual (for 19.15 and 20.1, 20.2, 20.3) v3.2, April, May,
19 November 1997 XEmacs Lisp Reference Manual (for 21.0) v3.3, April 1998
20
21    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
22 Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
23 Copyright (C) 1995, 1996 Ben Wing.
24
25    Permission is granted to make and distribute verbatim copies of this
26 manual provided the copyright notice and this permission notice are
27 preserved on all copies.
28
29    Permission is granted to copy and distribute modified versions of
30 this manual under the conditions for verbatim copying, provided that the
31 entire resulting derived work is distributed under the terms of a
32 permission notice identical to this one.
33
34    Permission is granted to copy and distribute translations of this
35 manual into another language, under the above conditions for modified
36 versions, except that this permission notice may be stated in a
37 translation approved by the Foundation.
38
39    Permission is granted to copy and distribute modified versions of
40 this manual under the conditions for verbatim copying, provided also
41 that the section entitled "GNU General Public License" is included
42 exactly as in the original, and provided that the entire resulting
43 derived work is distributed under the terms of a permission notice
44 identical to this one.
45
46    Permission is granted to copy and distribute translations of this
47 manual into another language, under the above conditions for modified
48 versions, except that the section entitled "GNU General Public License"
49 may be included in a translation approved by the Free Software
50 Foundation instead of in the original English.
51
52 \1f
53 File: lispref.info,  Node: The Buffer List,  Next: Creating Buffers,  Prev: Read Only Buffers,  Up: Buffers
54
55 The Buffer List
56 ===============
57
58    The "buffer list" is a list of all live buffers.  Creating a buffer
59 adds it to this list, and killing a buffer deletes it.  The order of
60 the buffers in the list is based primarily on how recently each buffer
61 has been displayed in the selected window.  Buffers move to the front
62 of the list when they are selected and to the end when they are buried.
63 Several functions, notably `other-buffer', use this ordering.  A
64 buffer list displayed for the user also follows this order.
65
66    Every frame has its own order for the buffer list.  Switching to a
67 new buffer inside of a particular frame changes the buffer list order
68 for that frame, but does not affect the buffer list order of any other
69 frames.  In addition, there is a global, non-frame buffer list order
70 that is independent of the buffer list orders for any particular frame.
71
72    Note that the different buffer lists all contain the same elements.
73 It is only the order of those elements that is different.
74
75  - Function: buffer-list &optional FRAME
76      This function returns a list of all buffers, including those whose
77      names begin with a space.  The elements are actual buffers, not
78      their names.  The order of the list is specific to FRAME, which
79      defaults to the current frame.  If FRAME is `t', the global,
80      non-frame ordering is returned instead.
81
82           (buffer-list)
83                => (#<buffer buffers.texi>
84                    #<buffer  *Minibuf-1*> #<buffer buffer.c>
85                    #<buffer *Help*> #<buffer TAGS>)
86           
87           ;; Note that the name of the minibuffer
88           ;;   begins with a space!
89           (mapcar (function buffer-name) (buffer-list))
90               => ("buffers.texi" " *Minibuf-1*"
91                   "buffer.c" "*Help*" "TAGS")
92
93      Buffers appear earlier in the list if they were current more
94      recently.
95
96      This list is a copy of a list used inside XEmacs; modifying it has
97      no effect on the buffers.
98
99  - Function: other-buffer &optional BUFFER-OR-NAME FRAME VISIBLE-OK
100      This function returns the first buffer in the buffer list other
101      than BUFFER-OR-NAME, in FRAME's ordering for the buffer list.
102      (FRAME defaults to the current frame.  If FRAME is `t', then the
103      global, non-frame ordering is used.) Usually this is the buffer
104      most recently shown in the selected window, aside from
105      BUFFER-OR-NAME.  Buffers are moved to the front of the list when
106      they are selected and to the end when they are buried.  Buffers
107      whose names start with a space are not considered.
108
109      If BUFFER-OR-NAME is not supplied (or if it is not a buffer), then
110      `other-buffer' returns the first buffer on the buffer list that is
111      not visible in any window in a visible frame.
112
113      If the selected frame has a non-`nil' `buffer-predicate' property,
114      then `other-buffer' uses that predicate to decide which buffers to
115      consider.  It calls the predicate once for each buffer, and if the
116      value is `nil', that buffer is ignored.  *Note X Frame
117      Properties::.
118
119      If VISIBLE-OK is `nil', `other-buffer' avoids returning a buffer
120      visible in any window on any visible frame, except as a last
121      resort.   If VISIBLE-OK is non-`nil', then it does not matter
122      whether a buffer is displayed somewhere or not.
123
124      If no suitable buffer exists, the buffer `*scratch*' is returned
125      (and created, if necessary).
126
127      Note that in FSF Emacs 19, there is no FRAME argument, and
128      VISIBLE-OK is the second argument instead of the third.  FSF Emacs
129      19.
130
131  - Command: list-buffers &optional FILES-ONLY
132      This function displays a listing of the names of existing buffers.
133      It clears the buffer `*Buffer List*', then inserts the listing
134      into that buffer and displays it in a window.  `list-buffers' is
135      intended for interactive use, and is described fully in `The XEmacs
136      Reference Manual'.  It returns `nil'.
137
138  - Command: bury-buffer &optional BUFFER-OR-NAME
139      This function puts BUFFER-OR-NAME at the end of the buffer list
140      without changing the order of any of the other buffers on the list.
141      This buffer therefore becomes the least desirable candidate for
142      `other-buffer' to return.
143
144      If BUFFER-OR-NAME is `nil' or omitted, this means to bury the
145      current buffer.  In addition, if the buffer is displayed in the
146      selected window, this switches to some other buffer (obtained using
147      `other-buffer') in the selected window.  But if the buffer is
148      displayed in some other window, it remains displayed there.
149
150      If you wish to replace a buffer in all the windows that display
151      it, use `replace-buffer-in-windows'.  *Note Buffers and Windows::.
152
153 \1f
154 File: lispref.info,  Node: Creating Buffers,  Next: Killing Buffers,  Prev: The Buffer List,  Up: Buffers
155
156 Creating Buffers
157 ================
158
159    This section describes the two primitives for creating buffers.
160 `get-buffer-create' creates a buffer if it finds no existing buffer
161 with the specified name; `generate-new-buffer' always creates a new
162 buffer and gives it a unique name.
163
164    Other functions you can use to create buffers include
165 `with-output-to-temp-buffer' (*note Temporary Displays::.) and
166 `create-file-buffer' (*note Visiting Files::.).  Starting a subprocess
167 can also create a buffer (*note Processes::.).
168
169  - Function: get-buffer-create NAME
170      This function returns a buffer named NAME.  It returns an existing
171      buffer with that name, if one exists; otherwise, it creates a new
172      buffer.  The buffer does not become the current buffer--this
173      function does not change which buffer is current.
174
175      An error is signaled if NAME is not a string.
176
177           (get-buffer-create "foo")
178                => #<buffer foo>
179
180      The major mode for the new buffer is set to Fundamental mode.  The
181      variable `default-major-mode' is handled at a higher level.  *Note
182      Auto Major Mode::.
183
184  - Function: generate-new-buffer NAME
185      This function returns a newly created, empty buffer, but does not
186      make it current.  If there is no buffer named NAME, then that is
187      the name of the new buffer.  If that name is in use, this function
188      adds suffixes of the form `<N>' to NAME, where N is an integer.
189      It tries successive integers starting with 2 until it finds an
190      available name.
191
192      An error is signaled if NAME is not a string.
193
194           (generate-new-buffer "bar")
195                => #<buffer bar>
196           (generate-new-buffer "bar")
197                => #<buffer bar<2>>
198           (generate-new-buffer "bar")
199                => #<buffer bar<3>>
200
201      The major mode for the new buffer is set to Fundamental mode.  The
202      variable `default-major-mode' is handled at a higher level.  *Note
203      Auto Major Mode::.
204
205      See the related function `generate-new-buffer-name' in *Note
206      Buffer Names::.
207
208 \1f
209 File: lispref.info,  Node: Killing Buffers,  Next: Indirect Buffers,  Prev: Creating Buffers,  Up: Buffers
210
211 Killing Buffers
212 ===============
213
214    "Killing a buffer" makes its name unknown to XEmacs and makes its
215 text space available for other use.
216
217    The buffer object for the buffer that has been killed remains in
218 existence as long as anything refers to it, but it is specially marked
219 so that you cannot make it current or display it.  Killed buffers retain
220 their identity, however; two distinct buffers, when killed, remain
221 distinct according to `eq'.
222
223    If you kill a buffer that is current or displayed in a window, XEmacs
224 automatically selects or displays some other buffer instead.  This means
225 that killing a buffer can in general change the current buffer.
226 Therefore, when you kill a buffer, you should also take the precautions
227 associated with changing the current buffer (unless you happen to know
228 that the buffer being killed isn't current).  *Note Current Buffer::.
229
230    If you kill a buffer that is the base buffer of one or more indirect
231 buffers, the indirect buffers are automatically killed as well.
232
233    The `buffer-name' of a killed buffer is `nil'.  To test whether a
234 buffer has been killed, you can either use this feature or the function
235 `buffer-live-p'.
236
237  - Function: buffer-live-p BUFFER
238      This function returns `nil' if BUFFER is deleted, and `t'
239      otherwise.
240
241  - Command: kill-buffer BUFFER-OR-NAME
242      This function kills the buffer BUFFER-OR-NAME, freeing all its
243      memory for use as space for other buffers.  (Emacs version 18 and
244      older was unable to return the memory to the operating system.)
245      It returns `nil'.
246
247      Any processes that have this buffer as the `process-buffer' are
248      sent the `SIGHUP' signal, which normally causes them to terminate.
249      (The basic meaning of `SIGHUP' is that a dialup line has been
250      disconnected.)  *Note Deleting Processes::.
251
252      If the buffer is visiting a file and contains unsaved changes,
253      `kill-buffer' asks the user to confirm before the buffer is killed.
254      It does this even if not called interactively.  To prevent the
255      request for confirmation, clear the modified flag before calling
256      `kill-buffer'.  *Note Buffer Modification::.
257
258      Killing a buffer that is already dead has no effect.
259
260           (kill-buffer "foo.unchanged")
261                => nil
262           (kill-buffer "foo.changed")
263           
264           ---------- Buffer: Minibuffer ----------
265           Buffer foo.changed modified; kill anyway? (yes or no) yes
266           ---------- Buffer: Minibuffer ----------
267           
268                => nil
269
270  - Variable: kill-buffer-query-functions
271      After confirming unsaved changes, `kill-buffer' calls the functions
272      in the list `kill-buffer-query-functions', in order of appearance,
273      with no arguments.  The buffer being killed is the current buffer
274      when they are called.  The idea is that these functions ask for
275      confirmation from the user for various nonstandard reasons.  If
276      any of them returns `nil', `kill-buffer' spares the buffer's life.
277
278  - Variable: kill-buffer-hook
279      This is a normal hook run by `kill-buffer' after asking all the
280      questions it is going to ask, just before actually killing the
281      buffer.  The buffer to be killed is current when the hook
282      functions run.  *Note Hooks::.
283
284  - Variable: buffer-offer-save
285      This variable, if non-`nil' in a particular buffer, tells
286      `save-buffers-kill-emacs' and `save-some-buffers' to offer to save
287      that buffer, just as they offer to save file-visiting buffers.  The
288      variable `buffer-offer-save' automatically becomes buffer-local
289      when set for any reason.  *Note Buffer-Local Variables::.
290
291 \1f
292 File: lispref.info,  Node: Indirect Buffers,  Prev: Killing Buffers,  Up: Buffers
293
294 Indirect Buffers
295 ================
296
297    An "indirect buffer" shares the text of some other buffer, which is
298 called the "base buffer" of the indirect buffer.  In some ways it is
299 the analogue, for buffers, of a symbolic link among files.  The base
300 buffer may not itself be an indirect buffer.  One base buffer may have
301 several "indirect children".
302
303    The text of the indirect buffer is always identical to the text of
304 its base buffer; changes made by editing either one are visible
305 immediately in the other.
306
307    But in all other respects, the indirect buffer and its base buffer
308 are completely separate.  They have different names, different values of
309 point and mark, different narrowing, different markers and extents
310 (though inserting or deleting text in either buffer relocates the
311 markers and extents for both), different major modes, and different
312 local variables.  Unlike in FSF Emacs, XEmacs indirect buffers do not
313 automatically share text properties among themselves and their base
314 buffer.
315
316    An indirect buffer cannot visit a file, but its base buffer can.  If
317 you try to save the indirect buffer, that actually works by saving the
318 base buffer.
319
320    Killing an indirect buffer has no effect on its base buffer.  Killing
321 the base buffer kills all its indirect children.
322
323  - Command: make-indirect-buffer BASE-BUFFER NAME
324      This creates an indirect buffer named NAME whose base buffer is
325      BASE-BUFFER.  The argument BASE-BUFFER may be a buffer or a string.
326
327      If BASE-BUFFER is an indirect buffer, its base buffer is used as
328      the base for the new buffer.
329
330           (make-indirect-buffer "*scratch*" "indirect")
331                => #<buffer "indirect">
332
333  - Function: buffer-base-buffer &optional BUFFER
334      This function returns the base buffer of BUFFER.  If BUFFER is not
335      indirect, the value is `nil'.  Otherwise, the value is another
336      buffer, which is never an indirect buffer.  If BUFFER is not
337      supplied, it defaults to the current buffer.
338
339           (buffer-base-buffer (get-buffer "indirect"))
340                => #<buffer "*scratch*">
341
342  - Function: buffer-indirect-children &optional BUFFER
343      This function returns a list of all indirect buffers whose base
344      buffer is BUFFER.  If BUFFER is indirect, the return value will
345      always be nil; see `make-indirect-buffer'.  If BUFFER is not
346      supplied, it defaults to the current buffer.
347
348           (buffer-indirect-children (get-buffer "*scratch*"))
349                => (#<buffer "indirect">)
350
351 \1f
352 File: lispref.info,  Node: Windows,  Next: Frames,  Prev: Buffers,  Up: Top
353
354 Windows
355 *******
356
357    This chapter describes most of the functions and variables related to
358 Emacs windows.  See *Note Display::, for information on how text is
359 displayed in windows.
360
361 * Menu:
362
363 * Basic Windows::          Basic information on using windows.
364 * Splitting Windows::      Splitting one window into two windows.
365 * Deleting Windows::       Deleting a window gives its space to other windows.
366 * Selecting Windows::      The selected window is the one that you edit in.
367 * Cyclic Window Ordering:: Moving around the existing windows.
368 * Buffers and Windows::    Each window displays the contents of a buffer.
369 * Displaying Buffers::     Higher-lever functions for displaying a buffer
370                              and choosing a window for it.
371 * Choosing Window::        How to choose a window for displaying a buffer.
372 * Window Point::           Each window has its own location of point.
373 * Window Start::           The display-start position controls which text
374                              is on-screen in the window.
375 * Vertical Scrolling::     Moving text up and down in the window.
376 * Horizontal Scrolling::   Moving text sideways on the window.
377 * Size of Window::         Accessing the size of a window.
378 * Position of Window::     Accessing the position of a window.
379 * Resizing Windows::       Changing the size of a window.
380 * Window Configurations::  Saving and restoring the state of the screen.
381
382 \1f
383 File: lispref.info,  Node: Basic Windows,  Next: Splitting Windows,  Up: Windows
384
385 Basic Concepts of Emacs Windows
386 ===============================
387
388    A "window" in XEmacs is the physical area of the screen in which a
389 buffer is displayed.  The term is also used to refer to a Lisp object
390 that represents that screen area in XEmacs Lisp.  It should be clear
391 from the context which is meant.
392
393    XEmacs groups windows into frames.  A frame represents an area of
394 screen available for XEmacs to use.  Each frame always contains at least
395 one window, but you can subdivide it vertically or horizontally into
396 multiple nonoverlapping Emacs windows.
397
398    In each frame, at any time, one and only one window is designated as
399 "selected within the frame".  The frame's cursor appears in that
400 window.  At ant time, one frame is the selected frame; and the window
401 selected within that frame is "the selected window".  The selected
402 window's buffer is usually the current buffer (except when `set-buffer'
403 has been used).  *Note Current Buffer::.
404
405    For practical purposes, a window exists only while it is displayed in
406 a frame.  Once removed from the frame, the window is effectively deleted
407 and should not be used, *even though there may still be references to
408 it* from other Lisp objects.  Restoring a saved window configuration is
409 the only way for a window no longer on the screen to come back to life.
410 (*Note Deleting Windows::.)
411
412    Each window has the following attributes:
413
414    * containing frame
415
416    * window height
417
418    * window width
419
420    * window edges with respect to the frame or screen
421
422    * the buffer it displays
423
424    * position within the buffer at the upper left of the window
425
426    * amount of horizontal scrolling, in columns
427
428    * point
429
430    * the mark
431
432    * how recently the window was selected
433
434    Users create multiple windows so they can look at several buffers at
435 once.  Lisp libraries use multiple windows for a variety of reasons, but
436 most often to display related information.  In Rmail, for example, you
437 can move through a summary buffer in one window while the other window
438 shows messages one at a time as they are reached.
439
440    The meaning of "window" in XEmacs is similar to what it means in the
441 context of general-purpose window systems such as X, but not identical.
442 The X Window System places X windows on the screen; XEmacs uses one or
443 more X windows as frames, and subdivides them into Emacs windows.  When
444 you use XEmacs on a character-only terminal, XEmacs treats the whole
445 terminal screen as one frame.
446
447    Most window systems support arbitrarily located overlapping windows.
448 In contrast, Emacs windows are "tiled"; they never overlap, and
449 together they fill the whole screen or frame.  Because of the way in
450 which XEmacs creates new windows and resizes them, you can't create
451 every conceivable tiling of windows on an Emacs frame.  *Note Splitting
452 Windows::, and *Note Size of Window::.
453
454    *Note Display::, for information on how the contents of the window's
455 buffer are displayed in the window.
456
457  - Function: windowp OBJECT
458      This function returns `t' if OBJECT is a window.
459
460 \1f
461 File: lispref.info,  Node: Splitting Windows,  Next: Deleting Windows,  Prev: Basic Windows,  Up: Windows
462
463 Splitting Windows
464 =================
465
466    The functions described here are the primitives used to split a
467 window into two windows.  Two higher level functions sometimes split a
468 window, but not always: `pop-to-buffer' and `display-buffer' (*note
469 Displaying Buffers::.).
470
471    The functions described here do not accept a buffer as an argument.
472 The two "halves" of the split window initially display the same buffer
473 previously visible in the window that was split.
474
475  - Function: one-window-p &optional NO-MINI ALL-FRAMES
476      This function returns non-`nil' if there is only one window.  The
477      argument NO-MINI, if non-`nil', means don't count the minibuffer
478      even if it is active; otherwise, the minibuffer window is
479      included, if active, in the total number of windows which is
480      compared against one.
481
482      The argument ALL-FRAME controls which set of windows are counted.
483         * If it is `nil' or omitted, then count only the selected
484           frame, plus the minibuffer it uses (which may be on another
485           frame).
486
487         * If it is `t', then windows on all frames that currently exist
488           (including invisible and iconified frames) are counted.
489
490         * If it is the symbol `visible', then windows on all visible
491           frames are counted.
492
493         * If it is the number 0, then windows on all visible and
494           iconified frames are counted.
495
496         * If it is any other value, then precisely the windows in
497           WINDOW's frame are counted, excluding the minibuffer in use
498           if it lies in some other frame.
499
500  - Command: split-window &optional WINDOW SIZE HORIZONTAL
501      This function splits WINDOW into two windows.  The original window
502      WINDOW remains the selected window, but occupies only part of its
503      former screen area.  The rest is occupied by a newly created
504      window which is returned as the value of this function.
505
506      If HORIZONTAL is non-`nil', then WINDOW splits into two side by
507      side windows.  The original window WINDOW keeps the leftmost SIZE
508      columns, and gives the rest of the columns to the new window.
509      Otherwise, it splits into windows one above the other, and WINDOW
510      keeps the upper SIZE lines and gives the rest of the lines to the
511      new window.  The original window is therefore the left-hand or
512      upper of the two, and the new window is the right-hand or lower.
513
514      If WINDOW is omitted or `nil', then the selected window is split.
515      If SIZE is omitted or `nil', then WINDOW is divided evenly into
516      two parts.  (If there is an odd line, it is allocated to the new
517      window.)  When `split-window' is called interactively, all its
518      arguments are `nil'.
519
520      The following example starts with one window on a frame that is 50
521      lines high by 80 columns wide; then the window is split.
522
523           (setq w (selected-window))
524                => #<window 8 on windows.texi>
525           (window-edges)          ; Edges in order:
526                => (0 0 80 50)     ;   left-top-right-bottom
527
528           ;; Returns window created
529           (setq w2 (split-window w 15))
530                => #<window 28 on windows.texi>
531
532           (window-edges w2)
533                => (0 15 80 50)    ; Bottom window;
534                                   ;   top is line 15
535
536           (window-edges w)
537                => (0 0 80 15)     ; Top window
538
539      The frame looks like this:
540
541           __________
542                   |          |  line 0
543                   |    w     |
544                   |__________|
545                   |          |  line 15
546                   |    w2    |
547                   |__________|
548                                 line 50
549            column 0   column 80
550
551      Next, the top window is split horizontally:
552
553           (setq w3 (split-window w 35 t))
554                => #<window 32 on windows.texi>
555
556           (window-edges w3)
557                => (35 0 80 15)  ; Left edge at column 35
558
559           (window-edges w)
560                => (0 0 35 15)   ; Right edge at column 35
561
562           (window-edges w2)
563                => (0 15 80 50)  ; Bottom window unchanged
564
565      Now, the screen looks like this:
566
567           column 35
568                    __________
569                   |   |      |  line 0
570                   | w |  w3  |
571                   |___|______|
572                   |          |  line 15
573                   |    w2    |
574                   |__________|
575                                 line 50
576            column 0   column 80
577
578      Normally, Emacs indicates the border between two side-by-side
579      windows with a scroll bar (*note Scroll Bars: X Frame Properties.)
580      or `|' characters.  The display table can specify alternative
581      border characters; see *Note Display Tables::.
582
583  - Command: split-window-vertically &optional SIZE
584      This function splits the selected window into two windows, one
585      above the other, leaving the selected window with SIZE lines.
586
587      This function is simply an interface to `split-windows'.  Here is
588      the complete function definition for it:
589
590           (defun split-window-vertically (&optional arg)
591             "Split current window into two windows, one above the other."
592             (interactive "P")
593             (split-window nil (and arg (prefix-numeric-value arg))))
594
595  - Command: split-window-horizontally &optional SIZE
596      This function splits the selected window into two windows
597      side-by-side, leaving the selected window with SIZE columns.
598
599      This function is simply an interface to `split-windows'.  Here is
600      the complete definition for `split-window-horizontally' (except for
601      part of the documentation string):
602
603           (defun split-window-horizontally (&optional arg)
604             "Split selected window into two windows, side by side..."
605             (interactive "P")
606             (split-window nil (and arg (prefix-numeric-value arg)) t))
607
608  - Function: one-window-p &optional NO-MINI ALL-FRAMES
609      This function returns non-`nil' if there is only one window.  The
610      argument NO-MINI, if non-`nil', means don't count the minibuffer
611      even if it is active; otherwise, the minibuffer window is
612      included, if active, in the total number of windows, which is
613      compared against one.
614
615      The argument ALL-FRAMES specifies which frames to consider.  Here
616      are the possible values and their meanings:
617
618     `nil'
619           Count the windows in the selected frame, plus the minibuffer
620           used by that frame even if it lies in some other frame.
621
622     `t'
623           Count all windows in all existing frames.
624
625     `visible'
626           Count all windows in all visible frames.
627
628     0
629           Count all windows in all visible or iconified frames.
630
631     anything else
632           Count precisely the windows in the selected frame, and no
633           others.
634
635 \1f
636 File: lispref.info,  Node: Deleting Windows,  Next: Selecting Windows,  Prev: Splitting Windows,  Up: Windows
637
638 Deleting Windows
639 ================
640
641    A window remains visible on its frame unless you "delete" it by
642 calling certain functions that delete windows.  A deleted window cannot
643 appear on the screen, but continues to exist as a Lisp object until
644 there are no references to it.  There is no way to cancel the deletion
645 of a window aside from restoring a saved window configuration (*note
646 Window Configurations::.).  Restoring a window configuration also
647 deletes any windows that aren't part of that configuration.
648
649    When you delete a window, the space it took up is given to one
650 adjacent sibling.  (In Emacs version 18, the space was divided evenly
651 among all the siblings.)
652
653  - Function: window-live-p WINDOW
654      This function returns `nil' if WINDOW is deleted, and `t'
655      otherwise.
656
657      *Warning:* Erroneous information or fatal errors may result from
658      using a deleted window as if it were live.
659
660  - Command: delete-window &optional WINDOW
661      This function removes WINDOW from the display.  If WINDOW is
662      omitted, then the selected window is deleted.  An error is signaled
663      if there is only one window when `delete-window' is called.
664
665      This function returns `nil'.
666
667      When `delete-window' is called interactively, WINDOW defaults to
668      the selected window.
669
670  - Command: delete-other-windows &optional WINDOW
671      This function makes WINDOW the only window on its frame, by
672      deleting the other windows in that frame.  If WINDOW is omitted or
673      `nil', then the selected window is used by default.
674
675      The result is `nil'.
676
677  - Command: delete-windows-on BUFFER &optional FRAME
678      This function deletes all windows showing BUFFER.  If there are no
679      windows showing BUFFER, it does nothing.
680
681      `delete-windows-on' operates frame by frame.  If a frame has
682      several windows showing different buffers, then those showing
683      BUFFER are removed, and the others expand to fill the space.  If
684      all windows in some frame are showing BUFFER (including the case
685      where there is only one window), then the frame reverts to having a
686      single window showing another buffer chosen with `other-buffer'.
687      *Note The Buffer List::.
688
689      The argument FRAME controls which frames to operate on:
690
691         * If it is `nil', operate on the selected frame.
692
693         * If it is `t', operate on all frames.
694
695         * If it is `visible', operate on all visible frames.
696
697         * 0 If it is 0, operate on all visible or iconified frames.
698
699         * If it is a frame, operate on that frame.
700
701      This function always returns `nil'.
702
703 \1f
704 File: lispref.info,  Node: Selecting Windows,  Next: Cyclic Window Ordering,  Prev: Deleting Windows,  Up: Windows
705
706 Selecting Windows
707 =================
708
709    When a window is selected, the buffer in the window becomes the
710 current buffer, and the cursor will appear in it.
711
712  - Function: selected-window &optional DEVICE
713      This function returns the selected window.  This is the window in
714      which the cursor appears and to which many commands apply.  Each
715      separate device can have its own selected window, which is
716      remembered as focus changes from device to device.  Optional
717      argument DEVICE specifies which device to return the selected
718      window for, and defaults to the selected device.
719
720  - Function: select-window WINDOW &optional NORECORD
721      This function makes WINDOW the selected window.  The cursor then
722      appears in WINDOW (on redisplay).  The buffer being displayed in
723      WINDOW is immediately designated the current buffer.
724
725      If optional argument NORECORD is non-`nil' then the global and
726      per-frame buffer orderings are not modified, as by the function
727      `record-buffer'.
728
729      The return value is WINDOW.
730
731           (setq w (next-window))
732           (select-window w)
733                => #<window 65 on windows.texi>
734
735  - Macro: save-selected-window FORMS...
736      This macro records the selected window, executes FORMS in
737      sequence, then restores the earlier selected window.  It does not
738      save or restore anything about the sizes, arrangement or contents
739      of windows; therefore, if the FORMS change them, the changes are
740      permanent.
741
742    The following functions choose one of the windows on the screen,
743 offering various criteria for the choice.
744
745  - Function: get-lru-window &optional FRAME
746      This function returns the window least recently "used" (that is,
747      selected).  The selected window is always the most recently used
748      window.
749
750      The selected window can be the least recently used window if it is
751      the only window.  A newly created window becomes the least
752      recently used window until it is selected.  A minibuffer window is
753      never a candidate.
754
755      The argument FRAME controls which windows are considered.
756
757         * If it is `nil', consider windows on the selected frame.
758
759         * If it is `t', consider windows on all frames.
760
761         * If it is `visible', consider windows on all visible frames.
762
763         * If it is 0, consider windows on all visible or iconified
764           frames.
765
766         * If it is a frame, consider windows on that frame.
767
768  - Function: get-largest-window &optional FRAME
769      This function returns the window with the largest area (height
770      times width).  If there are no side-by-side windows, then this is
771      the window with the most lines.  A minibuffer window is never a
772      candidate.
773
774      If there are two windows of the same size, then the function
775      returns the window that is first in the cyclic ordering of windows
776      (see following section), starting from the selected window.
777
778      The argument FRAME controls which set of windows are considered.
779      See `get-lru-window', above.
780
781 \1f
782 File: lispref.info,  Node: Cyclic Window Ordering,  Next: Buffers and Windows,  Prev: Selecting Windows,  Up: Windows
783
784 Cyclic Ordering of Windows
785 ==========================
786
787    When you use the command `C-x o' (`other-window') to select the next
788 window, it moves through all the windows on the screen in a specific
789 cyclic order.  For any given configuration of windows, this order never
790 varies.  It is called the "cyclic ordering of windows".
791
792    This ordering generally goes from top to bottom, and from left to
793 right.  But it may go down first or go right first, depending on the
794 order in which the windows were split.
795
796    If the first split was vertical (into windows one above each other),
797 and then the subwindows were split horizontally, then the ordering is
798 left to right in the top of the frame, and then left to right in the
799 next lower part of the frame, and so on.  If the first split was
800 horizontal, the ordering is top to bottom in the left part, and so on.
801 In general, within each set of siblings at any level in the window tree,
802 the order is left to right, or top to bottom.
803
804  - Function: next-window &optional WINDOW MINIBUF ALL-FRAMES
805      This function returns the window following WINDOW in the cyclic
806      ordering of windows.  This is the window that `C-x o' would select
807      if typed when WINDOW is selected.  If WINDOW is the only window
808      visible, then this function returns WINDOW.  If omitted, WINDOW
809      defaults to the selected window.
810
811      The value of the argument MINIBUF determines whether the
812      minibuffer is included in the window order.  Normally, when
813      MINIBUF is `nil', the minibuffer is included if it is currently
814      active; this is the behavior of `C-x o'.  (The minibuffer window
815      is active while the minibuffer is in use.  *Note Minibuffers::.)
816
817      If MINIBUF is `t', then the cyclic ordering includes the
818      minibuffer window even if it is not active.
819
820      If MINIBUF is neither `t' nor `nil', then the minibuffer window is
821      not included even if it is active.
822
823      The argument ALL-FRAMES specifies which frames to consider.  Here
824      are the possible values and their meanings:
825
826     `nil'
827           Consider all the windows in WINDOW's frame, plus the
828           minibuffer used by that frame even if it lies in some other
829           frame.
830
831     `t'
832           Consider all windows in all existing frames.
833
834     `visible'
835           Consider all windows in all visible frames.  (To get useful
836           results, you must ensure WINDOW is in a visible frame.)
837
838     0
839           Consider all windows in all visible or iconified frames.
840
841     anything else
842           Consider precisely the windows in WINDOW's frame, and no
843           others.
844
845      This example assumes there are two windows, both displaying the
846      buffer `windows.texi':
847
848           (selected-window)
849                => #<window 56 on windows.texi>
850           (next-window (selected-window))
851                => #<window 52 on windows.texi>
852           (next-window (next-window (selected-window)))
853                => #<window 56 on windows.texi>
854
855  - Function: previous-window &optional WINDOW MINIBUF ALL-FRAMES
856      This function returns the window preceding WINDOW in the cyclic
857      ordering of windows.  The other arguments specify which windows to
858      include in the cycle, as in `next-window'.
859
860  - Command: other-window COUNT &optional FRAME
861      This function selects the COUNTth following window in the cyclic
862      order.  If count is negative, then it selects the -COUNTth
863      preceding window.  It returns `nil'.
864
865      In an interactive call, COUNT is the numeric prefix argument.
866
867      The argument FRAME controls which set of windows are considered.
868         * If it is `nil' or omitted, then windows on the selected frame
869           are considered.
870
871         * If it is a frame, then windows on that frame are considered.
872
873         * If it is `t', then windows on all frames that currently exist
874           (including invisible and iconified frames) are considered.
875
876         * If it is the symbol `visible', then windows on all visible
877           frames are considered.
878
879         * If it is the number 0, then windows on all visible and
880           iconified frames are considered.
881
882         * If it is any other value, then the behavior is undefined.
883
884  - Function: walk-windows PROC &optional MINIBUF ALL-FRAMES
885      This function cycles through all windows, calling `proc' once for
886      each window with the window as its sole argument.
887
888      The optional arguments MINIBUF and ALL-FRAMES specify the set of
889      windows to include in the scan.  See `next-window', above, for
890      details.
891
892 \1f
893 File: lispref.info,  Node: Buffers and Windows,  Next: Displaying Buffers,  Prev: Cyclic Window Ordering,  Up: Windows
894
895 Buffers and Windows
896 ===================
897
898    This section describes low-level functions to examine windows or to
899 display buffers in windows in a precisely controlled fashion.  *Note
900 Displaying Buffers::, for related functions that find a window to use
901 and specify a buffer for it.  The functions described there are easier
902 to use than these, but they employ heuristics in choosing or creating a
903 window; use these functions when you need complete control.
904
905  - Function: set-window-buffer WINDOW BUFFER-OR-NAME
906      This function makes WINDOW display BUFFER-OR-NAME as its contents.
907      It returns `nil'.
908
909           (set-window-buffer (selected-window) "foo")
910                => nil
911
912  - Function: window-buffer &optional WINDOW
913      This function returns the buffer that WINDOW is displaying.  If
914      WINDOW is omitted, this function returns the buffer for the
915      selected window.
916
917           (window-buffer)
918                => #<buffer windows.texi>
919
920  - Function: get-buffer-window BUFFER-OR-NAME &optional FRAME
921      This function returns a window currently displaying
922      BUFFER-OR-NAME, or `nil' if there is none.  If there are several
923      such windows, then the function returns the first one in the
924      cyclic ordering of windows, starting from the selected window.
925      *Note Cyclic Window Ordering::.
926
927      The argument ALL-FRAMES controls which windows to consider.
928
929         * If it is `nil', consider windows on the selected frame.
930
931         * If it is `t', consider windows on all frames.
932
933         * If it is `visible', consider windows on all visible frames.
934
935         * If it is 0, consider windows on all visible or iconified
936           frames.
937
938         * If it is a frame, consider windows on that frame.
939
940 \1f
941 File: lispref.info,  Node: Displaying Buffers,  Next: Choosing Window,  Prev: Buffers and Windows,  Up: Windows
942
943 Displaying Buffers in Windows
944 =============================
945
946    In this section we describe convenient functions that choose a window
947 automatically and use it to display a specified buffer.  These functions
948 can also split an existing window in certain circumstances.  We also
949 describe variables that parameterize the heuristics used for choosing a
950 window.  *Note Buffers and Windows::, for low-level functions that give
951 you more precise control.
952
953    Do not use the functions in this section in order to make a buffer
954 current so that a Lisp program can access or modify it; they are too
955 drastic for that purpose, since they change the display of buffers in
956 windows, which is gratuitous and will surprise the user.  Instead, use
957 `set-buffer' (*note Current Buffer::.) and `save-excursion' (*note
958 Excursions::.), which designate buffers as current for programmed
959 access without affecting the display of buffers in windows.
960
961  - Command: switch-to-buffer BUFFER-OR-NAME &optional NORECORD
962      This function makes BUFFER-OR-NAME the current buffer, and also
963      displays the buffer in the selected window.  This means that a
964      human can see the buffer and subsequent keyboard commands will
965      apply to it.  Contrast this with `set-buffer', which makes
966      BUFFER-OR-NAME the current buffer but does not display it in the
967      selected window.  *Note Current Buffer::.
968
969      If BUFFER-OR-NAME does not identify an existing buffer, then a new
970      buffer by that name is created.  The major mode for the new buffer
971      is set according to the variable `default-major-mode'.  *Note Auto
972      Major Mode::.
973
974      Normally the specified buffer is put at the front of the buffer
975      list.  This affects the operation of `other-buffer'.  However, if
976      NORECORD is non-`nil', this is not done.  *Note The Buffer List::.
977
978      The `switch-to-buffer' function is often used interactively, as
979      the binding of `C-x b'.  It is also used frequently in programs.
980      It always returns `nil'.
981
982  - Command: switch-to-buffer-other-window BUFFER-OR-NAME
983      This function makes BUFFER-OR-NAME the current buffer and displays
984      it in a window not currently selected.  It then selects that
985      window.  The handling of the buffer is the same as in
986      `switch-to-buffer'.
987
988      The currently selected window is absolutely never used to do the
989      job.  If it is the only window, then it is split to make a
990      distinct window for this purpose.  If the selected window is
991      already displaying the buffer, then it continues to do so, but
992      another window is nonetheless found to display it in as well.
993
994  - Function: pop-to-buffer BUFFER-OR-NAME &optional OTHER-WINDOW
995           ON-FRAME
996      This function makes BUFFER-OR-NAME the current buffer and switches
997      to it in some window, preferably not the window previously
998      selected.  The "popped-to" window becomes the selected window
999      within its frame.
1000
1001      If the variable `pop-up-frames' is non-`nil', `pop-to-buffer'
1002      looks for a window in any visible frame already displaying the
1003      buffer; if there is one, it returns that window and makes it be
1004      selected within its frame.  If there is none, it creates a new
1005      frame and displays the buffer in it.
1006
1007      If `pop-up-frames' is `nil', then `pop-to-buffer' operates
1008      entirely within the selected frame.  (If the selected frame has
1009      just a minibuffer, `pop-to-buffer' operates within the most
1010      recently selected frame that was not just a minibuffer.)
1011
1012      If the variable `pop-up-windows' is non-`nil', windows may be
1013      split to create a new window that is different from the original
1014      window.  For details, see *Note Choosing Window::.
1015
1016      If OTHER-WINDOW is non-`nil', `pop-to-buffer' finds or creates
1017      another window even if BUFFER-OR-NAME is already visible in the
1018      selected window.  Thus BUFFER-OR-NAME could end up displayed in
1019      two windows.  On the other hand, if BUFFER-OR-NAME is already
1020      displayed in the selected window and OTHER-WINDOW is `nil', then
1021      the selected window is considered sufficient display for
1022      BUFFER-OR-NAME, so that nothing needs to be done.
1023
1024      All the variables that affect `display-buffer' affect
1025      `pop-to-buffer' as well.  *Note Choosing Window::.
1026
1027      If BUFFER-OR-NAME is a string that does not name an existing
1028      buffer, a buffer by that name is created.  The major mode for the
1029      new buffer is set according to the variable `default-major-mode'.
1030      *Note Auto Major Mode::.
1031
1032      If ON-FRAME is non-`nil', it is the frame to pop to this buffer on.
1033
1034      An example use of this function is found at the end of *Note
1035      Filter Functions::.
1036
1037  - Command: replace-buffer-in-windows BUFFER
1038      This function replaces BUFFER with some other buffer in all
1039      windows displaying it.  The other buffer used is chosen with
1040      `other-buffer'.  In the usual applications of this function, you
1041      don't care which other buffer is used; you just want to make sure
1042      that BUFFER is no longer displayed.
1043
1044      This function returns `nil'.
1045
1046 \1f
1047 File: lispref.info,  Node: Choosing Window,  Next: Window Point,  Prev: Displaying Buffers,  Up: Windows
1048
1049 Choosing a Window for Display
1050 =============================
1051
1052    This section describes the basic facility that chooses a window to
1053 display a buffer in--`display-buffer'.  All the higher-level functions
1054 and commands use this subroutine.  Here we describe how to use
1055 `display-buffer' and how to customize it.
1056
1057  - Command: display-buffer BUFFER-OR-NAME &optional NOT-THIS-WINDOW
1058      This command makes BUFFER-OR-NAME appear in some window, like
1059      `pop-to-buffer', but it does not select that window and does not
1060      make the buffer current.  The identity of the selected window is
1061      unaltered by this function.
1062
1063      If NOT-THIS-WINDOW is non-`nil', it means to display the specified
1064      buffer in a window other than the selected one, even if it is
1065      already on display in the selected window.  This can cause the
1066      buffer to appear in two windows at once.  Otherwise, if
1067      BUFFER-OR-NAME is already being displayed in any window, that is
1068      good enough, so this function does nothing.
1069
1070      `display-buffer' returns the window chosen to display
1071      BUFFER-OR-NAME.
1072
1073      Precisely how `display-buffer' finds or creates a window depends on
1074      the variables described below.
1075
1076    A window can be marked as "dedicated" to a particular buffer.  Then
1077 XEmacs will not automatically change which buffer appears in the
1078 window, such as `display-buffer' might normally do.
1079
1080  - Function: window-dedicated-p WINDOW
1081      This function returns WINDOW's dedicated object, usually `t' or
1082      `nil'.
1083
1084  - Function: set-window-buffer-dedicated WINDOW BUFFER
1085      This function makes WINDOW display BUFFER and be dedicated to that
1086      buffer.  Then XEmacs will not automatically change which buffer
1087      appears in WINDOW.  If BUFFER is `nil', this function makes WINDOW
1088      not be dedicated (but doesn't change which buffer appears in it
1089      currently).
1090
1091  - User Option: pop-up-windows
1092      This variable controls whether `display-buffer' makes new windows.
1093      If it is non-`nil' and there is only one window, then that window
1094      is split.  If it is `nil', then `display-buffer' does not split
1095      the single window, but uses it whole.
1096
1097  - User Option: split-height-threshold
1098      This variable determines when `display-buffer' may split a window,
1099      if there are multiple windows.  `display-buffer' always splits the
1100      largest window if it has at least this many lines.  If the largest
1101      window is not this tall, it is split only if it is the sole window
1102      and `pop-up-windows' is non-`nil'.
1103
1104  - User Option: pop-up-frames
1105      This variable controls whether `display-buffer' makes new frames.
1106      If it is non-`nil', `display-buffer' looks for an existing window
1107      already displaying the desired buffer, on any visible frame.  If
1108      it finds one, it returns that window.  Otherwise it makes a new
1109      frame.  The variables `pop-up-windows' and
1110      `split-height-threshold' do not matter if `pop-up-frames' is
1111      non-`nil'.
1112
1113      If `pop-up-frames' is `nil', then `display-buffer' either splits a
1114      window or reuses one.
1115
1116      *Note Frames::, for more information.
1117
1118  - Variable: pop-up-frame-function
1119      This variable specifies how to make a new frame if `pop-up-frames'
1120      is non-`nil'.
1121
1122      Its value should be a function of no arguments.  When
1123      `display-buffer' makes a new frame, it does so by calling that
1124      function, which should return a frame.  The default value of the
1125      variable is a function that creates a frame using properties from
1126      `pop-up-frame-plist'.
1127
1128  - Variable: pop-up-frame-plist
1129      This variable holds a plist specifying frame properties used when
1130      `display-buffer' makes a new frame.  *Note Frame Properties::, for
1131      more information about frame properties.
1132
1133  - Variable: special-display-buffer-names
1134      A list of buffer names for buffers that should be displayed
1135      specially.  If the buffer's name is in this list, `display-buffer'
1136      handles the buffer specially.
1137
1138      By default, special display means to give the buffer a dedicated
1139      frame.
1140
1141      If an element is a list, instead of a string, then the CAR of the
1142      list is the buffer name, and the rest of the list says how to
1143      create the frame.  There are two possibilities for the rest of the
1144      list.  It can be a plist, specifying frame properties, or it can
1145      contain a function and arguments to give to it.  (The function's
1146      first argument is always the buffer to be displayed; the arguments
1147      from the list come after that.)
1148
1149  - Variable: special-display-regexps
1150      A list of regular expressions that specify buffers that should be
1151      displayed specially.  If the buffer's name matches any of the
1152      regular expressions in this list, `display-buffer' handles the
1153      buffer specially.
1154
1155      By default, special display means to give the buffer a dedicated
1156      frame.
1157
1158      If an element is a list, instead of a string, then the CAR of the
1159      list is the regular expression, and the rest of the list says how
1160      to create the frame.  See above, under
1161      `special-display-buffer-names'.
1162
1163  - Variable: special-display-function
1164      This variable holds the function to call to display a buffer
1165      specially.  It receives the buffer as an argument, and should
1166      return the window in which it is displayed.
1167
1168      The default value of this variable is
1169      `special-display-popup-frame'.
1170
1171  - Function: special-display-popup-frame BUFFER
1172      This function makes BUFFER visible in a frame of its own.  If
1173      BUFFER is already displayed in a window in some frame, it makes
1174      the frame visible and raises it, to use that window.  Otherwise, it
1175      creates a frame that will be dedicated to BUFFER.
1176
1177      This function uses an existing window displaying BUFFER whether or
1178      not it is in a frame of its own; but if you set up the above
1179      variables in your init file, before BUFFER was created, then
1180      presumably the window was previously made by this function.
1181
1182  - User Option: special-display-frame-plist
1183      This variable holds frame properties for
1184      `special-display-popup-frame' to use when it creates a frame.
1185
1186  - Variable: same-window-buffer-names
1187      A list of buffer names for buffers that should be displayed in the
1188      selected window.  If the buffer's name is in this list,
1189      `display-buffer' handles the buffer by switching to it in the
1190      selected window.
1191
1192  - Variable: same-window-regexps
1193      A list of regular expressions that specify buffers that should be
1194      displayed in the selected window.  If the buffer's name matches
1195      any of the regular expressions in this list, `display-buffer'
1196      handles the buffer by switching to it in the selected window.
1197
1198  - Variable: display-buffer-function
1199      This variable is the most flexible way to customize the behavior of
1200      `display-buffer'.  If it is non-`nil', it should be a function
1201      that `display-buffer' calls to do the work.  The function should
1202      accept two arguments, the same two arguments that `display-buffer'
1203      received.  It should choose or create a window, display the
1204      specified buffer, and then return the window.
1205
1206      This hook takes precedence over all the other options and hooks
1207      described above.
1208
1209    A window can be marked as "dedicated" to its buffer.  Then
1210 `display-buffer' does not try to use that window.
1211
1212  - Function: window-dedicated-p WINDOW
1213      This function returns `t' if WINDOW is marked as dedicated;
1214      otherwise `nil'.
1215
1216  - Function: set-window-dedicated-p WINDOW FLAG
1217      This function marks WINDOW as dedicated if FLAG is non-`nil', and
1218      nondedicated otherwise.
1219