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