Merge r21-2-24-utf-2000-0_13-0.
[chise/xemacs-chise.git-] / info / lispref.info-25
1 This is ../info/lispref.info, produced by makeinfo version 3.12s from
2 lispref/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           (window-edges w2)
532                => (0 15 80 50)    ; Bottom window;
533                                   ;   top is line 15
534           (window-edges w)
535                => (0 0 80 15)     ; Top window
536
537      The frame looks like this:
538
539                    __________
540                   |          |  line 0
541                   |    w     |
542                   |__________|
543                   |          |  line 15
544                   |    w2    |
545                   |__________|
546                                 line 50
547            column 0   column 80
548
549      Next, the top window is split horizontally:
550
551           (setq w3 (split-window w 35 t))
552                => #<window 32 on windows.texi>
553           (window-edges w3)
554                => (35 0 80 15)  ; Left edge at column 35
555           (window-edges w)
556                => (0 0 35 15)   ; Right edge at column 35
557           (window-edges w2)
558                => (0 15 80 50)  ; Bottom window unchanged
559
560      Now, the screen looks like this:
561
562                column 35
563                    __________
564                   |   |      |  line 0
565                   | w |  w3  |
566                   |___|______|
567                   |          |  line 15
568                   |    w2    |
569                   |__________|
570                                 line 50
571            column 0   column 80
572
573      Normally, Emacs indicates the border between two side-by-side
574      windows with a scroll bar (*note Scroll Bars: X Frame Properties.)
575      or `|' characters.  The display table can specify alternative
576      border characters; see *Note Display Tables::.
577
578  - Command: split-window-vertically &optional size
579      This function splits the selected window into two windows, one
580      above the other, leaving the selected window with SIZE lines.
581
582      This function is simply an interface to `split-windows'.  Here is
583      the complete function definition for it:
584
585           (defun split-window-vertically (&optional arg)
586             "Split current window into two windows, one above the other."
587             (interactive "P")
588             (split-window nil (and arg (prefix-numeric-value arg))))
589
590  - Command: split-window-horizontally &optional size
591      This function splits the selected window into two windows
592      side-by-side, leaving the selected window with SIZE columns.
593
594      This function is simply an interface to `split-windows'.  Here is
595      the complete definition for `split-window-horizontally' (except for
596      part of the documentation string):
597
598           (defun split-window-horizontally (&optional arg)
599             "Split selected window into two windows, side by side..."
600             (interactive "P")
601             (split-window nil (and arg (prefix-numeric-value arg)) t))
602
603  - Function: one-window-p &optional no-mini all-frames
604      This function returns non-`nil' if there is only one window.  The
605      argument NO-MINI, if non-`nil', means don't count the minibuffer
606      even if it is active; otherwise, the minibuffer window is
607      included, if active, in the total number of windows, which is
608      compared against one.
609
610      The argument ALL-FRAMES specifies which frames to consider.  Here
611      are the possible values and their meanings:
612
613     `nil'
614           Count the windows in the selected frame, plus the minibuffer
615           used by that frame even if it lies in some other frame.
616
617     `t'
618           Count all windows in all existing frames.
619
620     `visible'
621           Count all windows in all visible frames.
622
623     0
624           Count all windows in all visible or iconified frames.
625
626     anything else
627           Count precisely the windows in the selected frame, and no
628           others.
629
630 \1f
631 File: lispref.info,  Node: Deleting Windows,  Next: Selecting Windows,  Prev: Splitting Windows,  Up: Windows
632
633 Deleting Windows
634 ================
635
636    A window remains visible on its frame unless you "delete" it by
637 calling certain functions that delete windows.  A deleted window cannot
638 appear on the screen, but continues to exist as a Lisp object until
639 there are no references to it.  There is no way to cancel the deletion
640 of a window aside from restoring a saved window configuration (*note
641 Window Configurations::).  Restoring a window configuration also
642 deletes any windows that aren't part of that configuration.
643
644    When you delete a window, the space it took up is given to one
645 adjacent sibling.  (In Emacs version 18, the space was divided evenly
646 among all the siblings.)
647
648  - Function: window-live-p window
649      This function returns `nil' if WINDOW is deleted, and `t'
650      otherwise.
651
652      *Warning:* Erroneous information or fatal errors may result from
653      using a deleted window as if it were live.
654
655  - Command: delete-window &optional window
656      This function removes WINDOW from the display.  If WINDOW is
657      omitted, then the selected window is deleted.  An error is signaled
658      if there is only one window when `delete-window' is called.
659
660      This function returns `nil'.
661
662      When `delete-window' is called interactively, WINDOW defaults to
663      the selected window.
664
665  - Command: delete-other-windows &optional window
666      This function makes WINDOW the only window on its frame, by
667      deleting the other windows in that frame.  If WINDOW is omitted or
668      `nil', then the selected window is used by default.
669
670      The result is `nil'.
671
672  - Command: delete-windows-on buffer &optional frame
673      This function deletes all windows showing BUFFER.  If there are no
674      windows showing BUFFER, it does nothing.
675
676      `delete-windows-on' operates frame by frame.  If a frame has
677      several windows showing different buffers, then those showing
678      BUFFER are removed, and the others expand to fill the space.  If
679      all windows in some frame are showing BUFFER (including the case
680      where there is only one window), then the frame reverts to having a
681      single window showing another buffer chosen with `other-buffer'.
682      *Note The Buffer List::.
683
684      The argument FRAME controls which frames to operate on:
685
686         * If it is `nil', operate on the selected frame.
687
688         * If it is `t', operate on all frames.
689
690         * If it is `visible', operate on all visible frames.
691
692         * 0 If it is 0, operate on all visible or iconified frames.
693
694         * If it is a frame, operate on that frame.
695
696      This function always returns `nil'.
697
698 \1f
699 File: lispref.info,  Node: Selecting Windows,  Next: Cyclic Window Ordering,  Prev: Deleting Windows,  Up: Windows
700
701 Selecting Windows
702 =================
703
704    When a window is selected, the buffer in the window becomes the
705 current buffer, and the cursor will appear in it.
706
707  - Function: selected-window &optional device
708      This function returns the selected window.  This is the window in
709      which the cursor appears and to which many commands apply.  Each
710      separate device can have its own selected window, which is
711      remembered as focus changes from device to device.  Optional
712      argument DEVICE specifies which device to return the selected
713      window for, and defaults to the selected device.
714
715  - Function: select-window window &optional norecord
716      This function makes WINDOW the selected window.  The cursor then
717      appears in WINDOW (on redisplay).  The buffer being displayed in
718      WINDOW is immediately designated the current buffer.
719
720      If optional argument NORECORD is non-`nil' then the global and
721      per-frame buffer orderings are not modified, as by the function
722      `record-buffer'.
723
724      The return value is WINDOW.
725
726           (setq w (next-window))
727           (select-window w)
728                => #<window 65 on windows.texi>
729
730  - Macro: save-selected-window forms...
731      This macro records the selected window, executes FORMS in
732      sequence, then restores the earlier selected window.  It does not
733      save or restore anything about the sizes, arrangement or contents
734      of windows; therefore, if the FORMS change them, the changes are
735      permanent.
736
737    The following functions choose one of the windows on the screen,
738 offering various criteria for the choice.
739
740  - Function: get-lru-window &optional frame
741      This function returns the window least recently "used" (that is,
742      selected).  The selected window is always the most recently used
743      window.
744
745      The selected window can be the least recently used window if it is
746      the only window.  A newly created window becomes the least
747      recently used window until it is selected.  A minibuffer window is
748      never a candidate.
749
750      The argument FRAME controls which windows are considered.
751
752         * If it is `nil', consider windows on the selected frame.
753
754         * If it is `t', consider windows on all frames.
755
756         * If it is `visible', consider windows on all visible frames.
757
758         * If it is 0, consider windows on all visible or iconified
759           frames.
760
761         * If it is a frame, consider windows on that frame.
762
763  - Function: get-largest-window &optional frame
764      This function returns the window with the largest area (height
765      times width).  If there are no side-by-side windows, then this is
766      the window with the most lines.  A minibuffer window is never a
767      candidate.
768
769      If there are two windows of the same size, then the function
770      returns the window that is first in the cyclic ordering of windows
771      (see following section), starting from the selected window.
772
773      The argument FRAME controls which set of windows are considered.
774      See `get-lru-window', above.
775
776 \1f
777 File: lispref.info,  Node: Cyclic Window Ordering,  Next: Buffers and Windows,  Prev: Selecting Windows,  Up: Windows
778
779 Cyclic Ordering of Windows
780 ==========================
781
782    When you use the command `C-x o' (`other-window') to select the next
783 window, it moves through all the windows on the screen in a specific
784 cyclic order.  For any given configuration of windows, this order never
785 varies.  It is called the "cyclic ordering of windows".
786
787    This ordering generally goes from top to bottom, and from left to
788 right.  But it may go down first or go right first, depending on the
789 order in which the windows were split.
790
791    If the first split was vertical (into windows one above each other),
792 and then the subwindows were split horizontally, then the ordering is
793 left to right in the top of the frame, and then left to right in the
794 next lower part of the frame, and so on.  If the first split was
795 horizontal, the ordering is top to bottom in the left part, and so on.
796 In general, within each set of siblings at any level in the window tree,
797 the order is left to right, or top to bottom.
798
799  - Function: next-window &optional window minibuf all-frames
800      This function returns the window following WINDOW in the cyclic
801      ordering of windows.  This is the window that `C-x o' would select
802      if typed when WINDOW is selected.  If WINDOW is the only window
803      visible, then this function returns WINDOW.  If omitted, WINDOW
804      defaults to the selected window.
805
806      The value of the argument MINIBUF determines whether the
807      minibuffer is included in the window order.  Normally, when
808      MINIBUF is `nil', the minibuffer is included if it is currently
809      active; this is the behavior of `C-x o'.  (The minibuffer window
810      is active while the minibuffer is in use.  *Note Minibuffers::.)
811
812      If MINIBUF is `t', then the cyclic ordering includes the
813      minibuffer window even if it is not active.
814
815      If MINIBUF is neither `t' nor `nil', then the minibuffer window is
816      not included even if it is active.
817
818      The argument ALL-FRAMES specifies which frames to consider.  Here
819      are the possible values and their meanings:
820
821     `nil'
822           Consider all the windows in WINDOW's frame, plus the
823           minibuffer used by that frame even if it lies in some other
824           frame.
825
826     `t'
827           Consider all windows in all existing frames.
828
829     `visible'
830           Consider all windows in all visible frames.  (To get useful
831           results, you must ensure WINDOW is in a visible frame.)
832
833     0
834           Consider all windows in all visible or iconified frames.
835
836     anything else
837           Consider precisely the windows in WINDOW's frame, and no
838           others.
839
840      This example assumes there are two windows, both displaying the
841      buffer `windows.texi':
842
843           (selected-window)
844                => #<window 56 on windows.texi>
845           (next-window (selected-window))
846                => #<window 52 on windows.texi>
847           (next-window (next-window (selected-window)))
848                => #<window 56 on windows.texi>
849
850  - Function: previous-window &optional window minibuf all-frames
851      This function returns the window preceding WINDOW in the cyclic
852      ordering of windows.  The other arguments specify which windows to
853      include in the cycle, as in `next-window'.
854
855  - Command: other-window count &optional frame
856      This function selects the COUNTth following window in the cyclic
857      order.  If count is negative, then it selects the -COUNTth
858      preceding window.  It returns `nil'.
859
860      In an interactive call, COUNT is the numeric prefix argument.
861
862      The argument FRAME controls which set of windows are considered.
863         * If it is `nil' or omitted, then windows on the selected frame
864           are considered.
865
866         * If it is a frame, then windows on that frame are considered.
867
868         * If it is `t', then windows on all frames that currently exist
869           (including invisible and iconified frames) are considered.
870
871         * If it is the symbol `visible', then windows on all visible
872           frames are considered.
873
874         * If it is the number 0, then windows on all visible and
875           iconified frames are considered.
876
877         * If it is any other value, then the behavior is undefined.
878
879  - Function: walk-windows proc &optional minibuf all-frames
880      This function cycles through all windows, calling `proc' once for
881      each window with the window as its sole argument.
882
883      The optional arguments MINIBUF and ALL-FRAMES specify the set of
884      windows to include in the scan.  See `next-window', above, for
885      details.
886
887 \1f
888 File: lispref.info,  Node: Buffers and Windows,  Next: Displaying Buffers,  Prev: Cyclic Window Ordering,  Up: Windows
889
890 Buffers and Windows
891 ===================
892
893    This section describes low-level functions to examine windows or to
894 display buffers in windows in a precisely controlled fashion.  *Note
895 Displaying Buffers::, for related functions that find a window to use
896 and specify a buffer for it.  The functions described there are easier
897 to use than these, but they employ heuristics in choosing or creating a
898 window; use these functions when you need complete control.
899
900  - Function: set-window-buffer window buffer-or-name
901      This function makes WINDOW display BUFFER-OR-NAME as its contents.
902      It returns `nil'.
903
904           (set-window-buffer (selected-window) "foo")
905                => nil
906
907  - Function: window-buffer &optional window
908      This function returns the buffer that WINDOW is displaying.  If
909      WINDOW is omitted, this function returns the buffer for the
910      selected window.
911
912           (window-buffer)
913                => #<buffer windows.texi>
914
915  - Function: get-buffer-window buffer-or-name &optional frame
916      This function returns a window currently displaying
917      BUFFER-OR-NAME, or `nil' if there is none.  If there are several
918      such windows, then the function returns the first one in the
919      cyclic ordering of windows, starting from the selected window.
920      *Note Cyclic Window Ordering::.
921
922      The argument ALL-FRAMES controls which windows to consider.
923
924         * If it is `nil', consider windows on the selected frame.
925
926         * If it is `t', consider windows on all frames.
927
928         * If it is `visible', consider windows on all visible frames.
929
930         * If it is 0, consider windows on all visible or iconified
931           frames.
932
933         * If it is a frame, consider windows on that frame.
934
935 \1f
936 File: lispref.info,  Node: Displaying Buffers,  Next: Choosing Window,  Prev: Buffers and Windows,  Up: Windows
937
938 Displaying Buffers in Windows
939 =============================
940
941    In this section we describe convenient functions that choose a window
942 automatically and use it to display a specified buffer.  These functions
943 can also split an existing window in certain circumstances.  We also
944 describe variables that parameterize the heuristics used for choosing a
945 window.  *Note Buffers and Windows::, for low-level functions that give
946 you more precise control.
947
948    Do not use the functions in this section in order to make a buffer
949 current so that a Lisp program can access or modify it; they are too
950 drastic for that purpose, since they change the display of buffers in
951 windows, which is gratuitous and will surprise the user.  Instead, use
952 `set-buffer' (*note Current Buffer::) and `save-excursion' (*note
953 Excursions::), which designate buffers as current for programmed access
954 without affecting the display of buffers in windows.
955
956  - Command: switch-to-buffer buffer-or-name &optional norecord
957      This function makes BUFFER-OR-NAME the current buffer, and also
958      displays the buffer in the selected window.  This means that a
959      human can see the buffer and subsequent keyboard commands will
960      apply to it.  Contrast this with `set-buffer', which makes
961      BUFFER-OR-NAME the current buffer but does not display it in the
962      selected window.  *Note Current Buffer::.
963
964      If BUFFER-OR-NAME does not identify an existing buffer, then a new
965      buffer by that name is created.  The major mode for the new buffer
966      is set according to the variable `default-major-mode'.  *Note Auto
967      Major Mode::.
968
969      Normally the specified buffer is put at the front of the buffer
970      list.  This affects the operation of `other-buffer'.  However, if
971      NORECORD is non-`nil', this is not done.  *Note The Buffer List::.
972
973      The `switch-to-buffer' function is often used interactively, as
974      the binding of `C-x b'.  It is also used frequently in programs.
975      It always returns `nil'.
976
977  - Command: switch-to-buffer-other-window buffer-or-name
978      This function makes BUFFER-OR-NAME the current buffer and displays
979      it in a window not currently selected.  It then selects that
980      window.  The handling of the buffer is the same as in
981      `switch-to-buffer'.
982
983      The currently selected window is absolutely never used to do the
984      job.  If it is the only window, then it is split to make a
985      distinct window for this purpose.  If the selected window is
986      already displaying the buffer, then it continues to do so, but
987      another window is nonetheless found to display it in as well.
988
989  - Function: pop-to-buffer buffer-or-name &optional other-window
990           on-frame
991      This function makes BUFFER-OR-NAME the current buffer and switches
992      to it in some window, preferably not the window previously
993      selected.  The "popped-to" window becomes the selected window
994      within its frame.
995
996      If the variable `pop-up-frames' is non-`nil', `pop-to-buffer'
997      looks for a window in any visible frame already displaying the
998      buffer; if there is one, it returns that window and makes it be
999      selected within its frame.  If there is none, it creates a new
1000      frame and displays the buffer in it.
1001
1002      If `pop-up-frames' is `nil', then `pop-to-buffer' operates
1003      entirely within the selected frame.  (If the selected frame has
1004      just a minibuffer, `pop-to-buffer' operates within the most
1005      recently selected frame that was not just a minibuffer.)
1006
1007      If the variable `pop-up-windows' is non-`nil', windows may be
1008      split to create a new window that is different from the original
1009      window.  For details, see *Note Choosing Window::.
1010
1011      If OTHER-WINDOW is non-`nil', `pop-to-buffer' finds or creates
1012      another window even if BUFFER-OR-NAME is already visible in the
1013      selected window.  Thus BUFFER-OR-NAME could end up displayed in
1014      two windows.  On the other hand, if BUFFER-OR-NAME is already
1015      displayed in the selected window and OTHER-WINDOW is `nil', then
1016      the selected window is considered sufficient display for
1017      BUFFER-OR-NAME, so that nothing needs to be done.
1018
1019      All the variables that affect `display-buffer' affect
1020      `pop-to-buffer' as well.  *Note Choosing Window::.
1021
1022      If BUFFER-OR-NAME is a string that does not name an existing
1023      buffer, a buffer by that name is created.  The major mode for the
1024      new buffer is set according to the variable `default-major-mode'.
1025      *Note Auto Major Mode::.
1026
1027      If ON-FRAME is non-`nil', it is the frame to pop to this buffer on.
1028
1029      An example use of this function is found at the end of *Note
1030      Filter Functions::.
1031
1032  - Command: replace-buffer-in-windows buffer
1033      This function replaces BUFFER with some other buffer in all
1034      windows displaying it.  The other buffer used is chosen with
1035      `other-buffer'.  In the usual applications of this function, you
1036      don't care which other buffer is used; you just want to make sure
1037      that BUFFER is no longer displayed.
1038
1039      This function returns `nil'.
1040
1041 \1f
1042 File: lispref.info,  Node: Choosing Window,  Next: Window Point,  Prev: Displaying Buffers,  Up: Windows
1043
1044 Choosing a Window for Display
1045 =============================
1046
1047    This section describes the basic facility that chooses a window to
1048 display a buffer in--`display-buffer'.  All the higher-level functions
1049 and commands use this subroutine.  Here we describe how to use
1050 `display-buffer' and how to customize it.
1051
1052  - Command: display-buffer buffer-or-name &optional not-this-window
1053      This command makes BUFFER-OR-NAME appear in some window, like
1054      `pop-to-buffer', but it does not select that window and does not
1055      make the buffer current.  The identity of the selected window is
1056      unaltered by this function.
1057
1058      If NOT-THIS-WINDOW is non-`nil', it means to display the specified
1059      buffer in a window other than the selected one, even if it is
1060      already on display in the selected window.  This can cause the
1061      buffer to appear in two windows at once.  Otherwise, if
1062      BUFFER-OR-NAME is already being displayed in any window, that is
1063      good enough, so this function does nothing.
1064
1065      `display-buffer' returns the window chosen to display
1066      BUFFER-OR-NAME.
1067
1068      Precisely how `display-buffer' finds or creates a window depends on
1069      the variables described below.
1070
1071    A window can be marked as "dedicated" to a particular buffer.  Then
1072 XEmacs will not automatically change which buffer appears in the
1073 window, such as `display-buffer' might normally do.
1074
1075  - Function: window-dedicated-p window
1076      This function returns WINDOW's dedicated object, usually `t' or
1077      `nil'.
1078
1079  - Function: set-window-buffer-dedicated window buffer
1080      This function makes WINDOW display BUFFER and be dedicated to that
1081      buffer.  Then XEmacs will not automatically change which buffer
1082      appears in WINDOW.  If BUFFER is `nil', this function makes WINDOW
1083      not be dedicated (but doesn't change which buffer appears in it
1084      currently).
1085
1086  - User Option: pop-up-windows
1087      This variable controls whether `display-buffer' makes new windows.
1088      If it is non-`nil' and there is only one window, then that window
1089      is split.  If it is `nil', then `display-buffer' does not split
1090      the single window, but uses it whole.
1091
1092  - User Option: split-height-threshold
1093      This variable determines when `display-buffer' may split a window,
1094      if there are multiple windows.  `display-buffer' always splits the
1095      largest window if it has at least this many lines.  If the largest
1096      window is not this tall, it is split only if it is the sole window
1097      and `pop-up-windows' is non-`nil'.
1098
1099  - User Option: pop-up-frames
1100      This variable controls whether `display-buffer' makes new frames.
1101      If it is non-`nil', `display-buffer' looks for an existing window
1102      already displaying the desired buffer, on any visible frame.  If
1103      it finds one, it returns that window.  Otherwise it makes a new
1104      frame.  The variables `pop-up-windows' and
1105      `split-height-threshold' do not matter if `pop-up-frames' is
1106      non-`nil'.
1107
1108      If `pop-up-frames' is `nil', then `display-buffer' either splits a
1109      window or reuses one.
1110
1111      *Note Frames::, for more information.
1112
1113  - Variable: pop-up-frame-function
1114      This variable specifies how to make a new frame if `pop-up-frames'
1115      is non-`nil'.
1116
1117      Its value should be a function of no arguments.  When
1118      `display-buffer' makes a new frame, it does so by calling that
1119      function, which should return a frame.  The default value of the
1120      variable is a function that creates a frame using properties from
1121      `pop-up-frame-plist'.
1122
1123  - Variable: pop-up-frame-plist
1124      This variable holds a plist specifying frame properties used when
1125      `display-buffer' makes a new frame.  *Note Frame Properties::, for
1126      more information about frame properties.
1127
1128  - Variable: special-display-buffer-names
1129      A list of buffer names for buffers that should be displayed
1130      specially.  If the buffer's name is in this list, `display-buffer'
1131      handles the buffer specially.
1132
1133      By default, special display means to give the buffer a dedicated
1134      frame.
1135
1136      If an element is a list, instead of a string, then the CAR of the
1137      list is the buffer name, and the rest of the list says how to
1138      create the frame.  There are two possibilities for the rest of the
1139      list.  It can be a plist, specifying frame properties, or it can
1140      contain a function and arguments to give to it.  (The function's
1141      first argument is always the buffer to be displayed; the arguments
1142      from the list come after that.)
1143
1144  - Variable: special-display-regexps
1145      A list of regular expressions that specify buffers that should be
1146      displayed specially.  If the buffer's name matches any of the
1147      regular expressions in this list, `display-buffer' handles the
1148      buffer specially.
1149
1150      By default, special display means to give the buffer a dedicated
1151      frame.
1152
1153      If an element is a list, instead of a string, then the CAR of the
1154      list is the regular expression, and the rest of the list says how
1155      to create the frame.  See above, under
1156      `special-display-buffer-names'.
1157
1158  - Variable: special-display-function
1159      This variable holds the function to call to display a buffer
1160      specially.  It receives the buffer as an argument, and should
1161      return the window in which it is displayed.
1162
1163      The default value of this variable is
1164      `special-display-popup-frame'.
1165
1166  - Function: special-display-popup-frame buffer
1167      This function makes BUFFER visible in a frame of its own.  If
1168      BUFFER is already displayed in a window in some frame, it makes
1169      the frame visible and raises it, to use that window.  Otherwise, it
1170      creates a frame that will be dedicated to BUFFER.
1171
1172      This function uses an existing window displaying BUFFER whether or
1173      not it is in a frame of its own; but if you set up the above
1174      variables in your init file, before BUFFER was created, then
1175      presumably the window was previously made by this function.
1176
1177  - User Option: special-display-frame-plist
1178      This variable holds frame properties for
1179      `special-display-popup-frame' to use when it creates a frame.
1180
1181  - Variable: same-window-buffer-names
1182      A list of buffer names for buffers that should be displayed in the
1183      selected window.  If the buffer's name is in this list,
1184      `display-buffer' handles the buffer by switching to it in the
1185      selected window.
1186
1187  - Variable: same-window-regexps
1188      A list of regular expressions that specify buffers that should be
1189      displayed in the selected window.  If the buffer's name matches
1190      any of the regular expressions in this list, `display-buffer'
1191      handles the buffer by switching to it in the selected window.
1192
1193  - Variable: display-buffer-function
1194      This variable is the most flexible way to customize the behavior of
1195      `display-buffer'.  If it is non-`nil', it should be a function
1196      that `display-buffer' calls to do the work.  The function should
1197      accept two arguments, the same two arguments that `display-buffer'
1198      received.  It should choose or create a window, display the
1199      specified buffer, and then return the window.
1200
1201      This hook takes precedence over all the other options and hooks
1202      described above.
1203
1204    A window can be marked as "dedicated" to its buffer.  Then
1205 `display-buffer' does not try to use that window.
1206
1207  - Function: window-dedicated-p window
1208      This function returns `t' if WINDOW is marked as dedicated;
1209      otherwise `nil'.
1210
1211  - Function: set-window-dedicated-p window flag
1212      This function marks WINDOW as dedicated if FLAG is non-`nil', and
1213      nondedicated otherwise.
1214