XEmacs 21.4.18 (Social Property).
[chise/xemacs-chise.git] / info / lispref.info-5
1 This is ../info/lispref.info, produced by makeinfo version 4.6 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: Create/Delete Dirs,  Next: Magic File Names,  Prev: Contents of Directories,  Up: Files
54
55 Creating and Deleting Directories
56 =================================
57
58 Most XEmacs Lisp file-manipulation functions get errors when used on
59 files that are directories.  For example, you cannot delete a directory
60 with `delete-file'.  These special functions exist to create and delete
61 directories.
62
63  - Command: make-directory dirname &optional parents
64      This function creates a directory named DIRNAME.  Interactively,
65      the default choice of directory to create is the current default
66      directory for file names.  That is useful when you have visited a
67      file in a nonexistent directory.
68
69      Non-interactively, optional argument PARENTS says whether to
70      create parent directories if they don't exist. (Interactively, this
71      always happens.)
72
73  - Command: delete-directory dirname
74      This function deletes the directory named DIRNAME.  The function
75      `delete-file' does not work for files that are directories; you
76      must use `delete-directory' in that case.
77
78 \1f
79 File: lispref.info,  Node: Magic File Names,  Next: Partial Files,  Prev: Create/Delete Dirs,  Up: Files
80
81 Making Certain File Names "Magic"
82 =================================
83
84 You can implement special handling for certain file names.  This is
85 called making those names "magic".  You must supply a regular
86 expression to define the class of names (all those that match the
87 regular expression), plus a handler that implements all the primitive
88 XEmacs file operations for file names that do match.
89
90    The variable `file-name-handler-alist' holds a list of handlers,
91 together with regular expressions that determine when to apply each
92 handler.  Each element has this form:
93
94      (REGEXP . HANDLER)
95
96 All the XEmacs primitives for file access and file name transformation
97 check the given file name against `file-name-handler-alist'.  If the
98 file name matches REGEXP, the primitives handle that file by calling
99 HANDLER.
100
101    The first argument given to HANDLER is the name of the primitive;
102 the remaining arguments are the arguments that were passed to that
103 operation.  (The first of these arguments is typically the file name
104 itself.)  For example, if you do this:
105
106      (file-exists-p FILENAME)
107
108 and FILENAME has handler HANDLER, then HANDLER is called like this:
109
110      (funcall HANDLER 'file-exists-p FILENAME)
111
112    Here are the operations that a magic file name handler gets to
113 handle:
114
115 `add-name-to-file', `copy-file', `delete-directory', `delete-file',
116 `diff-latest-backup-file', `directory-file-name', `directory-files',
117 `dired-compress-file', `dired-uncache', `expand-file-name',
118 `file-accessible-directory-p', `file-attributes', `file-directory-p',
119 `file-executable-p', `file-exists-p', `file-local-copy', `file-modes',
120 `file-name-all-completions', `file-name-as-directory',
121 `file-name-completion', `file-name-directory', `file-name-nondirectory',
122 `file-name-sans-versions', `file-newer-than-file-p', `file-readable-p',
123 `file-regular-p', `file-symlink-p', `file-truename', `file-writable-p',
124 `get-file-buffer', `insert-directory', `insert-file-contents', `load',
125 `make-directory', `make-symbolic-link', `rename-file', `set-file-modes',
126 `set-visited-file-modtime', `unhandled-file-name-directory',
127 `verify-visited-file-modtime', `write-region'.
128
129    Handlers for `insert-file-contents' typically need to clear the
130 buffer's modified flag, with `(set-buffer-modified-p nil)', if the
131 VISIT argument is non-`nil'.  This also has the effect of unlocking the
132 buffer if it is locked.
133
134    The handler function must handle all of the above operations, and
135 possibly others to be added in the future.  It need not implement all
136 these operations itself--when it has nothing special to do for a
137 certain operation, it can reinvoke the primitive, to handle the
138 operation "in the usual way".  It should always reinvoke the primitive
139 for an operation it does not recognize.  Here's one way to do this:
140
141      (defun my-file-handler (operation &rest args)
142        ;; First check for the specific operations
143        ;; that we have special handling for.
144        (cond ((eq operation 'insert-file-contents) ...)
145              ((eq operation 'write-region) ...)
146              ...
147              ;; Handle any operation we don't know about.
148              (t (let ((inhibit-file-name-handlers
149                       (cons 'my-file-handler
150                             (and (eq inhibit-file-name-operation operation)
151                                  inhibit-file-name-handlers)))
152                      (inhibit-file-name-operation operation))
153                   (apply operation args)))))
154
155    When a handler function decides to call the ordinary Emacs primitive
156 for the operation at hand, it needs to prevent the primitive from
157 calling the same handler once again, thus leading to an infinite
158 recursion.  The example above shows how to do this, with the variables
159 `inhibit-file-name-handlers' and `inhibit-file-name-operation'.  Be
160 careful to use them exactly as shown above; the details are crucial for
161 proper behavior in the case of multiple handlers, and for operations
162 that have two file names that may each have handlers.
163
164  - Variable: inhibit-file-name-handlers
165      This variable holds a list of handlers whose use is presently
166      inhibited for a certain operation.
167
168  - Variable: inhibit-file-name-operation
169      The operation for which certain handlers are presently inhibited.
170
171  - Function: find-file-name-handler filename &optional operation
172      This function returns the handler function for file name FILENAME,
173      or `nil' if there is none.  The argument OPERATION should be the
174      operation to be performed on the file--the value you will pass to
175      the handler as its first argument when you call it.  The operation
176      is needed for comparison with `inhibit-file-name-operation'.
177
178  - Function: file-local-copy filename
179      This function copies file FILENAME to an ordinary non-magic file,
180      if it isn't one already.
181
182      If FILENAME specifies a "magic" file name, which programs outside
183      Emacs cannot directly read or write, this copies the contents to
184      an ordinary file and returns that file's name.
185
186      If FILENAME is an ordinary file name, not magic, then this function
187      does nothing and returns `nil'.
188
189  - Function: unhandled-file-name-directory filename
190      This function returns the name of a directory that is not magic.
191      It uses the directory part of FILENAME if that is not magic.
192      Otherwise, it asks the handler what to do.
193
194      This is useful for running a subprocess; every subprocess must
195      have a non-magic directory to serve as its current directory, and
196      this function is a good way to come up with one.
197
198 \1f
199 File: lispref.info,  Node: Partial Files,  Next: Format Conversion,  Prev: Magic File Names,  Up: Files
200
201 Partial Files
202 =============
203
204 * Menu:
205
206 * Intro to Partial Files::
207 * Creating a Partial File::
208 * Detached Partial Files::
209
210 \1f
211 File: lispref.info,  Node: Intro to Partial Files,  Next: Creating a Partial File,  Up: Partial Files
212
213 Intro to Partial Files
214 ----------------------
215
216 A "partial file" is a section of a buffer (called the "master buffer")
217 that is placed in its own buffer and treated as its own file.  Changes
218 made to the partial file are not reflected in the master buffer until
219 the partial file is "saved" using the standard buffer save commands.
220 Partial files can be "reverted" (from the master buffer) just like
221 normal files.  When a file part is active on a master buffer, that
222 section of the master buffer is marked as read-only.  Two file parts on
223 the same master buffer are not allowed to overlap.  Partial file
224 buffers are indicated by the words `File Part' in the modeline.
225
226    The master buffer knows about all the partial files that are active
227 on it, and thus killing or reverting the master buffer will be handled
228 properly.  When the master buffer is saved, if there are any unsaved
229 partial files active on it then the user will be given the opportunity
230 to first save these files.
231
232    When a partial file buffer is first modified, the master buffer is
233 automatically marked as modified so that saving the master buffer will
234 work correctly.
235
236 \1f
237 File: lispref.info,  Node: Creating a Partial File,  Next: Detached Partial Files,  Prev: Intro to Partial Files,  Up: Partial Files
238
239 Creating a Partial File
240 -----------------------
241
242  - Command: make-file-part &optional start end name buffer
243      Make a file part on buffer BUFFER out of the region.  Call it
244      NAME.  This command creates a new buffer containing the contents
245      of the region and marks the buffer as referring to the specified
246      buffer, called the "master buffer".  When the file-part buffer is
247      saved, its changes are integrated back into the master buffer.
248      When the master buffer is deleted, all file parts are deleted with
249      it.
250
251      When called from a function, expects four arguments, START, END,
252      NAME, and BUFFER, all of which are optional and default to the
253      beginning of BUFFER, the end of BUFFER, a name generated from
254      BUFFER's name, and the current buffer, respectively.
255
256 \1f
257 File: lispref.info,  Node: Detached Partial Files,  Prev: Creating a Partial File,  Up: Partial Files
258
259 Detached Partial Files
260 ----------------------
261
262 Every partial file has an extent in the master buffer associated with it
263 (called the "master extent"), marking where in the master buffer the
264 partial file begins and ends.  If the text in master buffer that is
265 contained by the extent is deleted, then the extent becomes "detached",
266 meaning that it no longer refers to a specific region of the master
267 buffer.  This can happen either when the text is deleted directly or
268 when the master buffer is reverted.  Neither of these should happen in
269 normal usage because the master buffer should generally not be edited
270 directly.
271
272    Before doing any operation that references a partial file's master
273 extent, XEmacs checks to make sure that the extent is not detached.  If
274 this is the case, XEmacs warns the user of this and the master extent is
275 deleted out of the master buffer, disconnecting the file part.  The file
276 part's filename is cleared and thus must be explicitly specified if the
277 detached file part is to be saved.
278
279 \1f
280 File: lispref.info,  Node: Format Conversion,  Next: Files and MS-DOS,  Prev: Partial Files,  Up: Files
281
282 File Format Conversion
283 ======================
284
285 The variable `format-alist' defines a list of "file formats", which
286 describe textual representations used in files for the data (text,
287 text-properties, and possibly other information) in an Emacs buffer.
288 Emacs performs format conversion if appropriate when reading and writing
289 files.
290
291  - Variable: format-alist
292      This list contains one format definition for each defined file
293      format.
294
295    Each format definition is a list of this form:
296
297      (NAME DOC-STRING REGEXP FROM-FN TO-FN MODIFY MODE-FN)
298
299    Here is what the elements in a format definition mean:
300
301 NAME
302      The name of this format.
303
304 DOC-STRING
305      A documentation string for the format.
306
307 REGEXP
308      A regular expression which is used to recognize files represented
309      in this format.
310
311 FROM-FN
312      A function to call to decode data in this format (to convert file
313      data into the usual Emacs data representation).
314
315      The FROM-FN is called with two args, BEGIN and END, which specify
316      the part of the buffer it should convert.  It should convert the
317      text by editing it in place.  Since this can change the length of
318      the text, FROM-FN should return the modified end position.
319
320      One responsibility of FROM-FN is to make sure that the beginning
321      of the file no longer matches REGEXP.  Otherwise it is likely to
322      get called again.
323
324 TO-FN
325      A function to call to encode data in this format (to convert the
326      usual Emacs data representation into this format).
327
328      The TO-FN is called with two args, BEGIN and END, which specify
329      the part of the buffer it should convert.  There are two ways it
330      can do the conversion:
331
332         * By editing the buffer in place.  In this case, TO-FN should
333           return the end-position of the range of text, as modified.
334
335         * By returning a list of annotations.  This is a list of
336           elements of the form `(POSITION . STRING)', where POSITION is
337           an integer specifying the relative position in the text to be
338           written, and STRING is the annotation to add there.  The list
339           must be sorted in order of position when TO-FN returns it.
340
341           When `write-region' actually writes the text from the buffer
342           to the file, it intermixes the specified annotations at the
343           corresponding positions.  All this takes place without
344           modifying the buffer.
345
346 MODIFY
347      A flag, `t' if the encoding function modifies the buffer, and
348      `nil' if it works by returning a list of annotations.
349
350 MODE
351      A mode function to call after visiting a file converted from this
352      format.
353
354    The function `insert-file-contents' automatically recognizes file
355 formats when it reads the specified file.  It checks the text of the
356 beginning of the file against the regular expressions of the format
357 definitions, and if it finds a match, it calls the decoding function for
358 that format.  Then it checks all the known formats over again.  It
359 keeps checking them until none of them is applicable.
360
361    Visiting a file, with `find-file-noselect' or the commands that use
362 it, performs conversion likewise (because it calls
363 `insert-file-contents'); it also calls the mode function for each
364 format that it decodes.  It stores a list of the format names in the
365 buffer-local variable `buffer-file-format'.
366
367  - Variable: buffer-file-format
368      This variable states the format of the visited file.  More
369      precisely, this is a list of the file format names that were
370      decoded in the course of visiting the current buffer's file.  It
371      is always local in all buffers.
372
373    When `write-region' writes data into a file, it first calls the
374 encoding functions for the formats listed in `buffer-file-format', in
375 the order of appearance in the list.
376
377  - Command: format-write-file file format
378      This command writes the current buffer contents into the file FILE
379      in format FORMAT, and makes that format the default for future
380      saves of the buffer.  The argument FORMAT is a list of format
381      names.
382
383  - Command: format-find-file file format
384      This command finds the file FILE, converting it according to
385      format FORMAT.  It also makes FORMAT the default if the buffer is
386      saved later.
387
388      The argument FORMAT is a list of format names.  If FORMAT is
389      `nil', no conversion takes place.  Interactively, typing just
390      <RET> for FORMAT specifies `nil'.
391
392  - Command: format-insert-file file format &optional start end
393      This command inserts the contents of file FILE, converting it
394      according to format FORMAT.  If START and END are non-`nil', they
395      specify which part of the file to read, as in
396      `insert-file-contents' (*note Reading from Files::).
397
398      The return value is like what `insert-file-contents' returns: a
399      list of the absolute file name and the length of the data inserted
400      (after conversion).
401
402      The argument FORMAT is a list of format names.  If FORMAT is
403      `nil', no conversion takes place.  Interactively, typing just
404      <RET> for FORMAT specifies `nil'.
405
406  - Variable: auto-save-file-format
407      This variable specifies the format to use for auto-saving.  Its
408      value is a list of format names, just like the value of
409      `buffer-file-format'; but it is used instead of
410      `buffer-file-format' for writing auto-save files.  This variable
411      is always local in all buffers.
412
413 \1f
414 File: lispref.info,  Node: Files and MS-DOS,  Prev: Format Conversion,  Up: Files
415
416 Files and MS-DOS
417 ================
418
419 Emacs on MS-DOS makes a distinction between text files and binary
420 files.  This is necessary because ordinary text files on MS-DOS use a
421 two character sequence between lines: carriage-return and linefeed
422 (CRLF).  Emacs expects just a newline character (a linefeed) between
423 lines.  When Emacs reads or writes a text file on MS-DOS, it needs to
424 convert the line separators.  This means it needs to know which files
425 are text files and which are binary.  It makes this decision when
426 visiting a file, and records the decision in the variable
427 `buffer-file-type' for use when the file is saved.
428
429    *Note MS-DOS Subprocesses::, for a related feature for subprocesses.
430
431  - Variable: buffer-file-type
432      This variable, automatically local in each buffer, records the
433      file type of the buffer's visited file.  The value is `nil' for
434      text, `t' for binary.
435
436  - Function: find-buffer-file-type filename
437      This function determines whether file FILENAME is a text file or a
438      binary file.  It returns `nil' for text, `t' for binary.
439
440  - User Option: file-name-buffer-file-type-alist
441      This variable holds an alist for distinguishing text files from
442      binary files.  Each element has the form (REGEXP . TYPE), where
443      REGEXP is matched against the file name, and TYPE may be is `nil'
444      for text, `t' for binary, or a function to call to compute which.
445      If it is a function, then it is called with a single argument (the
446      file name) and should return `t' or `nil'.
447
448  - User Option: default-buffer-file-type
449      This variable specifies the default file type for files whose names
450      don't indicate anything in particular.  Its value should be `nil'
451      for text, or `t' for binary.
452
453  - Command: find-file-text filename
454      Like `find-file', but treat the file as text regardless of its
455      name.
456
457  - Command: find-file-binary filename
458      Like `find-file', but treat the file as binary regardless of its
459      name.
460
461 \1f
462 File: lispref.info,  Node: Backups and Auto-Saving,  Next: Buffers,  Prev: Files,  Up: Top
463
464 Backups and Auto-Saving
465 ***********************
466
467 Backup files and auto-save files are two methods by which XEmacs tries
468 to protect the user from the consequences of crashes or of the user's
469 own errors.  Auto-saving preserves the text from earlier in the current
470 editing session; backup files preserve file contents prior to the
471 current session.
472
473 * Menu:
474
475 * Backup Files::   How backup files are made; how their names are chosen.
476 * Auto-Saving::    How auto-save files are made; how their names are chosen.
477 * Reverting::      `revert-buffer', and how to customize what it does.
478
479 \1f
480 File: lispref.info,  Node: Backup Files,  Next: Auto-Saving,  Up: Backups and Auto-Saving
481
482 Backup Files
483 ============
484
485 A "backup file" is a copy of the old contents of a file you are
486 editing.  XEmacs makes a backup file the first time you save a buffer
487 into its visited file.  Normally, this means that the backup file
488 contains the contents of the file as it was before the current editing
489 session.  The contents of the backup file normally remain unchanged once
490 it exists.
491
492    Backups are usually made by renaming the visited file to a new name.
493 Optionally, you can specify that backup files should be made by copying
494 the visited file.  This choice makes a difference for files with
495 multiple names; it also can affect whether the edited file remains owned
496 by the original owner or becomes owned by the user editing it.
497
498    By default, XEmacs makes a single backup file for each file edited.
499 You can alternatively request numbered backups; then each new backup
500 file gets a new name.  You can delete old numbered backups when you
501 don't want them any more, or XEmacs can delete them automatically.
502
503 * Menu:
504
505 * Making Backups::     How XEmacs makes backup files, and when.
506 * Rename or Copy::     Two alternatives: renaming the old file or copying it.
507 * Numbered Backups::   Keeping multiple backups for each source file.
508 * Backup Names::       How backup file names are computed; customization.
509
510 \1f
511 File: lispref.info,  Node: Making Backups,  Next: Rename or Copy,  Up: Backup Files
512
513 Making Backup Files
514 -------------------
515
516  - Function: backup-buffer
517      This function makes a backup of the file visited by the current
518      buffer, if appropriate.  It is called by `save-buffer' before
519      saving the buffer the first time.
520
521  - Variable: buffer-backed-up
522      This buffer-local variable indicates whether this buffer's file has
523      been backed up on account of this buffer.  If it is non-`nil', then
524      the backup file has been written.  Otherwise, the file should be
525      backed up when it is next saved (if backups are enabled).  This is
526      a permanent local; `kill-local-variables' does not alter it.
527
528  - User Option: make-backup-files
529      This variable determines whether or not to make backup files.  If
530      it is non-`nil', then XEmacs creates a backup of each file when it
531      is saved for the first time--provided that `backup-inhibited' is
532      `nil' (see below).
533
534      The following example shows how to change the `make-backup-files'
535      variable only in the `RMAIL' buffer and not elsewhere.  Setting it
536      `nil' stops XEmacs from making backups of the `RMAIL' file, which
537      may save disk space.  (You would put this code in your `.emacs'
538      file.)
539
540           (add-hook 'rmail-mode-hook
541                     (function (lambda ()
542                                 (make-local-variable
543                                  'make-backup-files)
544                                 (setq make-backup-files nil))))
545
546  - Variable: backup-enable-predicate
547      This variable's value is a function to be called on certain
548      occasions to decide whether a file should have backup files.  The
549      function receives one argument, a file name to consider.  If the
550      function returns `nil', backups are disabled for that file.
551      Otherwise, the other variables in this section say whether and how
552      to make backups.
553
554      The default value is this:
555
556           (lambda (name)
557             (or (< (length name) 5)
558                 (not (string-equal "/tmp/"
559                                    (substring name 0 5)))))
560
561  - Variable: backup-inhibited
562      If this variable is non-`nil', backups are inhibited.  It records
563      the result of testing `backup-enable-predicate' on the visited file
564      name.  It can also coherently be used by other mechanisms that
565      inhibit backups based on which file is visited.  For example, VC
566      sets this variable non-`nil' to prevent making backups for files
567      managed with a version control system.
568
569      This is a permanent local, so that changing the major mode does
570      not lose its value.  Major modes should not set this
571      variable--they should set `make-backup-files' instead.
572
573 \1f
574 File: lispref.info,  Node: Rename or Copy,  Next: Numbered Backups,  Prev: Making Backups,  Up: Backup Files
575
576 Backup by Renaming or by Copying?
577 ---------------------------------
578
579 There are two ways that XEmacs can make a backup file:
580
581    * XEmacs can rename the original file so that it becomes a backup
582      file, and then write the buffer being saved into a new file.
583      After this procedure, any other names (i.e., hard links) of the
584      original file now refer to the backup file.  The new file is owned
585      by the user doing the editing, and its group is the default for
586      new files written by the user in that directory.
587
588    * XEmacs can copy the original file into a backup file, and then
589      overwrite the original file with new contents.  After this
590      procedure, any other names (i.e., hard links) of the original file
591      still refer to the current version of the file.  The file's owner
592      and group will be unchanged.
593
594    The first method, renaming, is the default.
595
596    The variable `backup-by-copying', if non-`nil', says to use the
597 second method, which is to copy the original file and overwrite it with
598 the new buffer contents.  The variable `file-precious-flag', if
599 non-`nil', also has this effect (as a sideline of its main
600 significance).  *Note Saving Buffers::.
601
602  - Variable: backup-by-copying
603      If this variable is non-`nil', XEmacs always makes backup files by
604      copying.
605
606    The following two variables, when non-`nil', cause the second method
607 to be used in certain special cases.  They have no effect on the
608 treatment of files that don't fall into the special cases.
609
610  - Variable: backup-by-copying-when-linked
611      If this variable is non-`nil', XEmacs makes backups by copying for
612      files with multiple names (hard links).
613
614      This variable is significant only if `backup-by-copying' is `nil',
615      since copying is always used when that variable is non-`nil'.
616
617  - Variable: backup-by-copying-when-mismatch
618      If this variable is non-`nil', XEmacs makes backups by copying in
619      cases where renaming would change either the owner or the group of
620      the file.
621
622      The value has no effect when renaming would not alter the owner or
623      group of the file; that is, for files which are owned by the user
624      and whose group matches the default for a new file created there
625      by the user.
626
627      This variable is significant only if `backup-by-copying' is `nil',
628      since copying is always used when that variable is non-`nil'.
629
630 \1f
631 File: lispref.info,  Node: Numbered Backups,  Next: Backup Names,  Prev: Rename or Copy,  Up: Backup Files
632
633 Making and Deleting Numbered Backup Files
634 -----------------------------------------
635
636 If a file's name is `foo', the names of its numbered backup versions
637 are `foo.~V~', for various integers V, like this: `foo.~1~', `foo.~2~',
638 `foo.~3~', ..., `foo.~259~', and so on.
639
640  - User Option: version-control
641      This variable controls whether to make a single non-numbered backup
642      file or multiple numbered backups.
643
644     `nil'
645           Make numbered backups if the visited file already has
646           numbered backups; otherwise, do not.
647
648     `never'
649           Do not make numbered backups.
650
651     ANYTHING ELSE
652           Make numbered backups.
653
654    The use of numbered backups ultimately leads to a large number of
655 backup versions, which must then be deleted.  XEmacs can do this
656 automatically or it can ask the user whether to delete them.
657
658  - User Option: kept-new-versions
659      The value of this variable is the number of newest versions to keep
660      when a new numbered backup is made.  The newly made backup is
661      included in the count.  The default value is 2.
662
663  - User Option: kept-old-versions
664      The value of this variable is the number of oldest versions to keep
665      when a new numbered backup is made.  The default value is 2.
666
667    If there are backups numbered 1, 2, 3, 5, and 7, and both of these
668 variables have the value 2, then the backups numbered 1 and 2 are kept
669 as old versions and those numbered 5 and 7 are kept as new versions;
670 backup version 3 is excess.  The function `find-backup-file-name'
671 (*note Backup Names::) is responsible for determining which backup
672 versions to delete, but does not delete them itself.
673
674  - User Option: delete-old-versions
675      If this variable is non-`nil', then saving a file deletes excess
676      backup versions silently.  Otherwise, it asks the user whether to
677      delete them.
678
679  - User Option: dired-kept-versions
680      This variable specifies how many of the newest backup versions to
681      keep in the Dired command `.' (`dired-clean-directory').  That's
682      the same thing `kept-new-versions' specifies when you make a new
683      backup file.  The default value is 2.
684
685 \1f
686 File: lispref.info,  Node: Backup Names,  Prev: Numbered Backups,  Up: Backup Files
687
688 Naming Backup Files
689 -------------------
690
691 The functions in this section are documented mainly because you can
692 customize the naming conventions for backup files by redefining them.
693 If you change one, you probably need to change the rest.
694
695  - Function: backup-file-name-p filename
696      This function returns a non-`nil' value if FILENAME is a possible
697      name for a backup file.  A file with the name FILENAME need not
698      exist; the function just checks the name.
699
700           (backup-file-name-p "foo")
701                => nil
702           (backup-file-name-p "foo~")
703                => 3
704
705      The standard definition of this function is as follows:
706
707           (defun backup-file-name-p (file)
708             "Return non-nil if FILE is a backup file \
709           name (numeric or not)..."
710             (string-match "~$" file))
711
712      Thus, the function returns a non-`nil' value if the file name ends
713      with a `~'.  (We use a backslash to split the documentation
714      string's first line into two lines in the text, but produce just
715      one line in the string itself.)
716
717      This simple expression is placed in a separate function to make it
718      easy to redefine for customization.
719
720  - Function: make-backup-file-name filename
721      This function returns a string that is the name to use for a
722      non-numbered backup file for file FILENAME.  On Unix, this is just
723      FILENAME with a tilde appended.
724
725      The standard definition of this function is as follows:
726
727           (defun make-backup-file-name (file)
728             "Create the non-numeric backup file name for FILE.
729           ..."
730             (concat file "~"))
731
732      You can change the backup-file naming convention by redefining this
733      function.  The following example redefines `make-backup-file-name'
734      to prepend a `.' in addition to appending a tilde:
735
736           (defun make-backup-file-name (filename)
737             (concat "." filename "~"))
738           
739           (make-backup-file-name "backups.texi")
740                => ".backups.texi~"
741
742  - Function: find-backup-file-name filename
743      This function computes the file name for a new backup file for
744      FILENAME.  It may also propose certain existing backup files for
745      deletion.  `find-backup-file-name' returns a list whose CAR is the
746      name for the new backup file and whose CDR is a list of backup
747      files whose deletion is proposed.
748
749      Two variables, `kept-old-versions' and `kept-new-versions',
750      determine which backup versions should be kept.  This function
751      keeps those versions by excluding them from the CDR of the value.
752      *Note Numbered Backups::.
753
754      In this example, the value says that `~rms/foo.~5~' is the name to
755      use for the new backup file, and `~rms/foo.~3~' is an "excess"
756      version that the caller should consider deleting now.
757
758           (find-backup-file-name "~rms/foo")
759                => ("~rms/foo.~5~" "~rms/foo.~3~")
760
761  - Function: file-newest-backup filename
762      This function returns the name of the most recent backup file for
763      FILENAME, or `nil' if that file has no backup files.
764
765      Some file comparison commands use this function so that they can
766      automatically compare a file with its most recent backup.
767
768 \1f
769 File: lispref.info,  Node: Auto-Saving,  Next: Reverting,  Prev: Backup Files,  Up: Backups and Auto-Saving
770
771 Auto-Saving
772 ===========
773
774 XEmacs periodically saves all files that you are visiting; this is
775 called "auto-saving".  Auto-saving prevents you from losing more than a
776 limited amount of work if the system crashes.  By default, auto-saves
777 happen every 300 keystrokes, or after around 30 seconds of idle time.
778 *Note Auto-Save: (xemacs)Auto Save, for information on auto-save for
779 users.  Here we describe the functions used to implement auto-saving
780 and the variables that control them.
781
782  - Variable: buffer-auto-save-file-name
783      This buffer-local variable is the name of the file used for
784      auto-saving the current buffer.  It is `nil' if the buffer should
785      not be auto-saved.
786
787           buffer-auto-save-file-name
788           => "/xcssun/users/rms/lewis/#files.texi#"
789
790  - Command: auto-save-mode arg
791      When used interactively without an argument, this command is a
792      toggle switch: it turns on auto-saving of the current buffer if it
793      is off, and vice-versa.  With an argument ARG, the command turns
794      auto-saving on if the value of ARG is `t', a nonempty list, or a
795      positive integer.  Otherwise, it turns auto-saving off.
796
797  - Function: auto-save-file-name-p filename
798      This function returns a non-`nil' value if FILENAME is a string
799      that could be the name of an auto-save file.  It works based on
800      knowledge of the naming convention for auto-save files: a name that
801      begins and ends with hash marks (`#') is a possible auto-save file
802      name.  The argument FILENAME should not contain a directory part.
803
804           (make-auto-save-file-name)
805                => "/xcssun/users/rms/lewis/#files.texi#"
806           (auto-save-file-name-p "#files.texi#")
807                => 0
808           (auto-save-file-name-p "files.texi")
809                => nil
810
811      The standard definition of this function is as follows:
812
813           (defun auto-save-file-name-p (filename)
814             "Return non-nil if FILENAME can be yielded by..."
815             (string-match "^#.*#$" filename))
816
817      This function exists so that you can customize it if you wish to
818      change the naming convention for auto-save files.  If you redefine
819      it, be sure to redefine the function `make-auto-save-file-name'
820      correspondingly.
821
822  - Function: make-auto-save-file-name &optional filename
823      This function returns the file name to use for auto-saving the
824      current buffer.  This is just the file name with hash marks (`#')
825      appended and prepended to it.  This function does not look at the
826      variable `auto-save-visited-file-name' (described below); you
827      should check that before calling this function.
828
829           (make-auto-save-file-name)
830                => "/xcssun/users/rms/lewis/#backup.texi#"
831
832      The standard definition of this function is as follows:
833
834           (defun make-auto-save-file-name ()
835             "Return file name to use for auto-saves \
836           of current buffer.
837           ..."
838             (if buffer-file-name
839                 (concat
840                  (file-name-directory buffer-file-name)
841                  "#"
842                  (file-name-nondirectory buffer-file-name)
843                  "#")
844               (expand-file-name
845                (concat "#%" (buffer-name) "#"))))
846
847      This exists as a separate function so that you can redefine it to
848      customize the naming convention for auto-save files.  Be sure to
849      change `auto-save-file-name-p' in a corresponding way.
850
851  - Variable: auto-save-visited-file-name
852      If this variable is non-`nil', XEmacs auto-saves buffers in the
853      files they are visiting.  That is, the auto-save is done in the
854      same file that you are editing.  Normally, this variable is `nil',
855      so auto-save files have distinct names that are created by
856      `make-auto-save-file-name'.
857
858      When you change the value of this variable, the value does not take
859      effect until the next time auto-save mode is reenabled in any given
860      buffer.  If auto-save mode is already enabled, auto-saves continue
861      to go in the same file name until `auto-save-mode' is called again.
862
863  - Function: recent-auto-save-p
864      This function returns `t' if the current buffer has been
865      auto-saved since the last time it was read in or saved.
866
867  - Function: set-buffer-auto-saved
868      This function marks the current buffer as auto-saved.  The buffer
869      will not be auto-saved again until the buffer text is changed
870      again.  The function returns `nil'.
871
872  - User Option: auto-save-interval
873      The value of this variable is the number of characters that XEmacs
874      reads from the keyboard between auto-saves.  Each time this many
875      more characters are read, auto-saving is done for all buffers in
876      which it is enabled.
877
878  - User Option: auto-save-timeout
879      The value of this variable is the number of seconds of idle time
880      that should cause auto-saving.  Each time the user pauses for this
881      long, XEmacs auto-saves any buffers that need it.  (Actually, the
882      specified timeout is multiplied by a factor depending on the size
883      of the current buffer.)
884
885  - Variable: auto-save-hook
886      This normal hook is run whenever an auto-save is about to happen.
887
888  - User Option: auto-save-default
889      If this variable is non-`nil', buffers that are visiting files
890      have auto-saving enabled by default.  Otherwise, they do not.
891
892  - Command: do-auto-save &optional no-message current-only
893      This function auto-saves all buffers that need to be auto-saved.
894      It saves all buffers for which auto-saving is enabled and that
895      have been changed since the previous auto-save.
896
897      Normally, if any buffers are auto-saved, a message that says
898      `Auto-saving...' is displayed in the echo area while auto-saving is
899      going on.  However, if NO-MESSAGE is non-`nil', the message is
900      inhibited.
901
902      If CURRENT-ONLY is non-`nil', only the current buffer is
903      auto-saved.
904
905  - Function: delete-auto-save-file-if-necessary
906      This function deletes the current buffer's auto-save file if
907      `delete-auto-save-files' is non-`nil'.  It is called every time a
908      buffer is saved.
909
910  - Variable: delete-auto-save-files
911      This variable is used by the function
912      `delete-auto-save-file-if-necessary'.  If it is non-`nil', Emacs
913      deletes auto-save files when a true save is done (in the visited
914      file).  This saves disk space and unclutters your directory.
915
916  - Function: rename-auto-save-file
917      This function adjusts the current buffer's auto-save file name if
918      the visited file name has changed.  It also renames an existing
919      auto-save file.  If the visited file name has not changed, this
920      function does nothing.
921
922  - Variable: buffer-saved-size
923      The value of this buffer-local variable is the length of the
924      current buffer as of the last time it was read in, saved, or
925      auto-saved.  This is used to detect a substantial decrease in
926      size, and turn off auto-saving in response.
927
928      If it is -1, that means auto-saving is temporarily shut off in this
929      buffer due to a substantial deletion.  Explicitly saving the buffer
930      stores a positive value in this variable, thus reenabling
931      auto-saving.  Turning auto-save mode off or on also alters this
932      variable.
933
934  - Variable: auto-save-list-file-name
935      This variable (if non-`nil') specifies a file for recording the
936      names of all the auto-save files.  Each time XEmacs does
937      auto-saving, it writes two lines into this file for each buffer
938      that has auto-saving enabled.  The first line gives the name of
939      the visited file (it's empty if the buffer has none), and the
940      second gives the name of the auto-save file.
941
942      If XEmacs exits normally, it deletes this file.  If XEmacs
943      crashes, you can look in the file to find all the auto-save files
944      that might contain work that was otherwise lost.  The
945      `recover-session' command uses these files.
946
947      The default name for this file is in your home directory and
948      starts with `.saves-'.  It also contains the XEmacs process ID and
949      the host name.
950
951 \1f
952 File: lispref.info,  Node: Reverting,  Prev: Auto-Saving,  Up: Backups and Auto-Saving
953
954 Reverting
955 =========
956
957 If you have made extensive changes to a file and then change your mind
958 about them, you can get rid of them by reading in the previous version
959 of the file with the `revert-buffer' command.  *Note Reverting a
960 Buffer: (xemacs)Reverting.
961
962  - Command: revert-buffer &optional check-auto-save noconfirm
963           preserve-modes
964      This command replaces the buffer text with the text of the visited
965      file on disk.  This action undoes all changes since the file was
966      visited or saved.
967
968      If the argument CHECK-AUTO-SAVE is non-`nil', and the latest
969      auto-save file is more recent than the visited file,
970      `revert-buffer' asks the user whether to use that instead.
971      Otherwise, it always uses the text of the visited file itself.
972      Interactively, CHECK-AUTO-SAVE is set if there is a numeric prefix
973      argument.
974
975      Normally, `revert-buffer' asks for confirmation before it changes
976      the buffer; but if the argument NOCONFIRM is non-`nil',
977      `revert-buffer' does not ask for confirmation.
978
979      Optional third argument PRESERVE-MODES non-`nil' means don't alter
980      the files modes.  Normally we reinitialize them using
981      `normal-mode'.
982
983      Reverting tries to preserve marker positions in the buffer by
984      using the replacement feature of `insert-file-contents'.  If the
985      buffer contents and the file contents are identical before the
986      revert operation, reverting preserves all the markers.  If they
987      are not identical, reverting does change the buffer; then it
988      preserves the markers in the unchanged text (if any) at the
989      beginning and end of the buffer.  Preserving any additional
990      markers would be problematical.
991
992    You can customize how `revert-buffer' does its work by setting these
993 variables--typically, as buffer-local variables.
994
995  - Variable: revert-buffer-function
996      The value of this variable is the function to use to revert this
997      buffer.  If non-`nil', it is called as a function with no
998      arguments to do the work of reverting.  If the value is `nil',
999      reverting works the usual way.
1000
1001      Modes such as Dired mode, in which the text being edited does not
1002      consist of a file's contents but can be regenerated in some other
1003      fashion, give this variable a buffer-local value that is a
1004      function to regenerate the contents.
1005
1006  - Variable: revert-buffer-insert-file-contents-function
1007      The value of this variable, if non-`nil', is the function to use to
1008      insert the updated contents when reverting this buffer.  The
1009      function receives two arguments: first the file name to use;
1010      second, `t' if the user has asked to read the auto-save file.
1011
1012  - Variable: before-revert-hook
1013      This normal hook is run by `revert-buffer' before actually
1014      inserting the modified contents--but only if
1015      `revert-buffer-function' is `nil'.
1016
1017      Font Lock mode uses this hook to record that the buffer contents
1018      are no longer fontified.
1019
1020  - Variable: after-revert-hook
1021      This normal hook is run by `revert-buffer' after actually inserting
1022      the modified contents--but only if `revert-buffer-function' is
1023      `nil'.
1024
1025      Font Lock mode uses this hook to recompute the fonts for the
1026      updated buffer contents.
1027
1028 \1f
1029 File: lispref.info,  Node: Buffers,  Next: Windows,  Prev: Backups and Auto-Saving,  Up: Top
1030
1031 Buffers
1032 *******
1033
1034 A "buffer" is a Lisp object containing text to be edited.  Buffers are
1035 used to hold the contents of files that are being visited; there may
1036 also be buffers that are not visiting files.  While several buffers may
1037 exist at one time, exactly one buffer is designated the "current
1038 buffer" at any time.  Most editing commands act on the contents of the
1039 current buffer.  Each buffer, including the current buffer, may or may
1040 not be displayed in any window.
1041
1042 * Menu:
1043
1044 * Buffer Basics::       What is a buffer?
1045 * Current Buffer::      Designating a buffer as current
1046                           so primitives will access its contents.
1047 * Buffer Names::        Accessing and changing buffer names.
1048 * Buffer File Name::    The buffer file name indicates which file is visited.
1049 * Buffer Modification:: A buffer is "modified" if it needs to be saved.
1050 * Modification Time::   Determining whether the visited file was changed
1051                          ``behind XEmacs's back''.
1052 * Read Only Buffers::   Modifying text is not allowed in a read-only buffer.
1053 * The Buffer List::     How to look at all the existing buffers.
1054 * Creating Buffers::    Functions that create buffers.
1055 * Killing Buffers::     Buffers exist until explicitly killed.
1056 * Indirect Buffers::    An indirect buffer shares text with some other buffer.
1057
1058 \1f
1059 File: lispref.info,  Node: Buffer Basics,  Next: Current Buffer,  Up: Buffers
1060
1061 Buffer Basics
1062 =============
1063
1064 A "buffer" is a Lisp object containing text to be edited.  Buffers are
1065 used to hold the contents of files that are being visited; there may
1066 also be buffers that are not visiting files.  While several buffers may
1067 exist at one time, exactly one buffer is designated the "current
1068 buffer" at any time.  Most editing commands act on the contents of the
1069 current buffer.  Each buffer, including the current buffer, may or may
1070 not be displayed in any windows.
1071
1072 Buffers in Emacs editing are objects that have distinct names and hold
1073 text that can be edited.  Buffers appear to Lisp programs as a special
1074 data type.  You can think of the contents of a buffer as an extendible
1075 string; insertions and deletions may occur in any part of the buffer.
1076 *Note Text::.
1077
1078    A Lisp buffer object contains numerous pieces of information.  Some
1079 of this information is directly accessible to the programmer through
1080 variables, while other information is accessible only through
1081 special-purpose functions.  For example, the visited file name is
1082 directly accessible through a variable, while the value of point is
1083 accessible only through a primitive function.
1084
1085    Buffer-specific information that is directly accessible is stored in
1086 "buffer-local" variable bindings, which are variable values that are
1087 effective only in a particular buffer.  This feature allows each buffer
1088 to override the values of certain variables.  Most major modes override
1089 variables such as `fill-column' or `comment-column' in this way.  For
1090 more information about buffer-local variables and functions related to
1091 them, see *Note Buffer-Local Variables::.
1092
1093    For functions and variables related to visiting files in buffers, see
1094 *Note Visiting Files:: and *Note Saving Buffers::.  For functions and
1095 variables related to the display of buffers in windows, see *Note
1096 Buffers and Windows::.
1097
1098  - Function: bufferp object
1099      This function returns `t' if OBJECT is a buffer, `nil' otherwise.
1100
1101 \1f
1102 File: lispref.info,  Node: Current Buffer,  Next: Buffer Names,  Prev: Buffer Basics,  Up: Buffers
1103
1104 The Current Buffer
1105 ==================
1106
1107 There are, in general, many buffers in an Emacs session.  At any time,
1108 one of them is designated as the "current buffer".  This is the buffer
1109 in which most editing takes place, because most of the primitives for
1110 examining or changing text in a buffer operate implicitly on the
1111 current buffer (*note Text::).  Normally the buffer that is displayed on
1112 the screen in the selected window is the current buffer, but this is not
1113 always so: a Lisp program can designate any buffer as current
1114 temporarily in order to operate on its contents, without changing what
1115 is displayed on the screen.
1116
1117    The way to designate a current buffer in a Lisp program is by calling
1118 `set-buffer'.  The specified buffer remains current until a new one is
1119 designated.
1120
1121    When an editing command returns to the editor command loop, the
1122 command loop designates the buffer displayed in the selected window as
1123 current, to prevent confusion: the buffer that the cursor is in when
1124 Emacs reads a command is the buffer that the command will apply to.
1125 (*Note Command Loop::.)  Therefore, `set-buffer' is not the way to
1126 switch visibly to a different buffer so that the user can edit it.  For
1127 this, you must use the functions described in *Note Displaying
1128 Buffers::.
1129
1130    However, Lisp functions that change to a different current buffer
1131 should not depend on the command loop to set it back afterwards.
1132 Editing commands written in XEmacs Lisp can be called from other
1133 programs as well as from the command loop.  It is convenient for the
1134 caller if the subroutine does not change which buffer is current
1135 (unless, of course, that is the subroutine's purpose).  Therefore, you
1136 should normally use `set-buffer' within a `save-excursion' that will
1137 restore the current buffer when your function is done (*note
1138 Excursions::).  Here is an example, the code for the command
1139 `append-to-buffer' (with the documentation string abridged):
1140
1141      (defun append-to-buffer (buffer start end)
1142        "Append to specified buffer the text of the region.
1143      ..."
1144        (interactive "BAppend to buffer: \nr")
1145        (let ((oldbuf (current-buffer)))
1146          (save-excursion
1147            (set-buffer (get-buffer-create buffer))
1148            (insert-buffer-substring oldbuf start end))))
1149
1150 This function binds a local variable to the current buffer, and then
1151 `save-excursion' records the values of point, the mark, and the
1152 original buffer.  Next, `set-buffer' makes another buffer current.
1153 Finally, `insert-buffer-substring' copies the string from the original
1154 current buffer to the new current buffer.
1155
1156    If the buffer appended to happens to be displayed in some window,
1157 the next redisplay will show how its text has changed.  Otherwise, you
1158 will not see the change immediately on the screen.  The buffer becomes
1159 current temporarily during the execution of the command, but this does
1160 not cause it to be displayed.
1161
1162    If you make local bindings (with `let' or function arguments) for a
1163 variable that may also have buffer-local bindings, make sure that the
1164 same buffer is current at the beginning and at the end of the local
1165 binding's scope.  Otherwise you might bind it in one buffer and unbind
1166 it in another!  There are two ways to do this.  In simple cases, you may
1167 see that nothing ever changes the current buffer within the scope of the
1168 binding.  Otherwise, use `save-excursion' to make sure that the buffer
1169 current at the beginning is current again whenever the variable is
1170 unbound.
1171
1172    It is not reliable to change the current buffer back with
1173 `set-buffer', because that won't do the job if a quit happens while the
1174 wrong buffer is current.  Here is what _not_ to do:
1175
1176      (let (buffer-read-only
1177            (obuf (current-buffer)))
1178        (set-buffer ...)
1179        ...
1180        (set-buffer obuf))
1181
1182 Using `save-excursion', as shown below, handles quitting, errors, and
1183 `throw', as well as ordinary evaluation.
1184
1185      (let (buffer-read-only)
1186        (save-excursion
1187          (set-buffer ...)
1188          ...))
1189
1190  - Function: current-buffer
1191      This function returns the current buffer.
1192
1193           (current-buffer)
1194                => #<buffer buffers.texi>
1195
1196  - Function: set-buffer buffer-or-name
1197      This function makes BUFFER-OR-NAME the current buffer.  It does
1198      not display the buffer in the currently selected window or in any
1199      other window, so the user cannot necessarily see the buffer.  But
1200      Lisp programs can in any case work on it.
1201
1202      BUFFER-OR-NAME must be a buffer or the name of an existing
1203      buffer-else an error is signaled.  This function returns the buffer
1204      identified by BUFFER-OR-NAME.
1205
1206 \1f
1207 File: lispref.info,  Node: Buffer Names,  Next: Buffer File Name,  Prev: Current Buffer,  Up: Buffers
1208
1209 Buffer Names
1210 ============
1211
1212 Each buffer has a unique name, which is a string.  Many of the
1213 functions that work on buffers accept either a buffer or a buffer name
1214 as an argument.  Any argument called BUFFER-OR-NAME is of this sort,
1215 and an error is signaled if it is neither a string nor a buffer.  Any
1216 argument called BUFFER must be an actual buffer object, not a name.
1217
1218    Buffers that are ephemeral and generally uninteresting to the user
1219 have names starting with a space, so that the `list-buffers' and
1220 `buffer-menu' commands don't mention them.  A name starting with space
1221 also initially disables recording undo information; see *Note Undo::.
1222
1223  - Function: buffer-name &optional buffer
1224      This function returns the name of BUFFER as a string.  If BUFFER
1225      is not supplied, it defaults to the current buffer.
1226
1227      If `buffer-name' returns `nil', it means that BUFFER has been
1228      killed.  *Note Killing Buffers::.
1229
1230           (buffer-name)
1231                => "buffers.texi"
1232           
1233           (setq foo (get-buffer "temp"))
1234                => #<buffer temp>
1235           (kill-buffer foo)
1236                => nil
1237           (buffer-name foo)
1238                => nil
1239           foo
1240                => #<killed buffer>
1241
1242  - Command: rename-buffer newname &optional unique
1243      This function renames the current buffer to NEWNAME.  An error is
1244      signaled if NEWNAME is not a string, or if there is already a
1245      buffer with that name.  The function returns `nil'.
1246
1247      Ordinarily, `rename-buffer' signals an error if NEWNAME is already
1248      in use.  However, if UNIQUE is non-`nil', it modifies NEWNAME to
1249      make a name that is not in use.  Interactively, you can make
1250      UNIQUE non-`nil' with a numeric prefix argument.
1251
1252      One application of this command is to rename the `*shell*' buffer
1253      to some other name, thus making it possible to create a second
1254      shell buffer under the name `*shell*'.
1255
1256  - Function: get-buffer buffer-or-name
1257      This function returns the buffer named BUFFER-OR-NAME.  If
1258      BUFFER-OR-NAME is a string and there is no buffer with that name,
1259      the value is `nil'.  If BUFFER-OR-NAME is actually a buffer, it is
1260      returned as given.  (That is not very useful, so the argument is
1261      usually a name.)  For example:
1262
1263           (setq b (get-buffer "lewis"))
1264                => #<buffer lewis>
1265           (get-buffer b)
1266                => #<buffer lewis>
1267           (get-buffer "Frazzle-nots")
1268                => nil
1269
1270      See also the function `get-buffer-create' in *Note Creating
1271      Buffers::.
1272
1273  - Function: generate-new-buffer-name starting-name &optional ignore
1274      This function returns a name that would be unique for a new
1275      buffer--but does not create the buffer.  It starts with
1276      STARTING-NAME, and produces a name not currently in use for any
1277      buffer by appending a number inside of `<...>'.
1278
1279      If IGNORE is given, it specifies a name that is okay to use (if it
1280      is in the sequence to be tried), even if a buffer with that name
1281      exists.
1282
1283      See the related function `generate-new-buffer' in *Note Creating
1284      Buffers::.
1285
1286 \1f
1287 File: lispref.info,  Node: Buffer File Name,  Next: Buffer Modification,  Prev: Buffer Names,  Up: Buffers
1288
1289 Buffer File Name
1290 ================
1291
1292 The "buffer file name" is the name of the file that is visited in that
1293 buffer.  When a buffer is not visiting a file, its buffer file name is
1294 `nil'.  Most of the time, the buffer name is the same as the
1295 nondirectory part of the buffer file name, but the buffer file name and
1296 the buffer name are distinct and can be set independently.  *Note
1297 Visiting Files::.
1298
1299  - Function: buffer-file-name &optional buffer
1300      This function returns the absolute file name of the file that
1301      BUFFER is visiting.  If BUFFER is not visiting any file,
1302      `buffer-file-name' returns `nil'.  If BUFFER is not supplied, it
1303      defaults to the current buffer.
1304
1305           (buffer-file-name (other-buffer))
1306                => "/usr/user/lewis/manual/files.texi"
1307
1308  - Variable: buffer-file-name
1309      This buffer-local variable contains the name of the file being
1310      visited in the current buffer, or `nil' if it is not visiting a
1311      file.  It is a permanent local, unaffected by
1312      `kill-local-variables'.
1313
1314           buffer-file-name
1315                => "/usr/user/lewis/manual/buffers.texi"
1316
1317      It is risky to change this variable's value without doing various
1318      other things.  See the definition of `set-visited-file-name' in
1319      `files.el'; some of the things done there, such as changing the
1320      buffer name, are not strictly necessary, but others are essential
1321      to avoid confusing XEmacs.
1322
1323  - Variable: buffer-file-truename
1324      This buffer-local variable holds the truename of the file visited
1325      in the current buffer, or `nil' if no file is visited.  It is a
1326      permanent local, unaffected by `kill-local-variables'.  *Note
1327      Truenames::.
1328
1329  - Variable: buffer-file-number
1330      This buffer-local variable holds the file number and directory
1331      device number of the file visited in the current buffer, or `nil'
1332      if no file or a nonexistent file is visited.  It is a permanent
1333      local, unaffected by `kill-local-variables'.  *Note Truenames::.
1334
1335      The value is normally a list of the form `(FILENUM DEVNUM)'.  This
1336      pair of numbers uniquely identifies the file among all files
1337      accessible on the system.  See the function `file-attributes', in
1338      *Note File Attributes::, for more information about them.
1339
1340  - Function: get-file-buffer filename
1341      This function returns the buffer visiting file FILENAME.  If there
1342      is no such buffer, it returns `nil'.  The argument FILENAME, which
1343      must be a string, is expanded (*note File Name Expansion::), then
1344      compared against the visited file names of all live buffers.
1345
1346           (get-file-buffer "buffers.texi")
1347               => #<buffer buffers.texi>
1348
1349      In unusual circumstances, there can be more than one buffer
1350      visiting the same file name.  In such cases, this function returns
1351      the first such buffer in the buffer list.
1352
1353  - Command: set-visited-file-name filename
1354      If FILENAME is a non-empty string, this function changes the name
1355      of the file visited in current buffer to FILENAME.  (If the buffer
1356      had no visited file, this gives it one.)  The _next time_ the
1357      buffer is saved it will go in the newly-specified file.  This
1358      command marks the buffer as modified, since it does not (as far as
1359      XEmacs knows) match the contents of FILENAME, even if it matched
1360      the former visited file.
1361
1362      If FILENAME is `nil' or the empty string, that stands for "no
1363      visited file".  In this case, `set-visited-file-name' marks the
1364      buffer as having no visited file.
1365
1366      When the function `set-visited-file-name' is called interactively,
1367      it prompts for FILENAME in the minibuffer.
1368
1369      See also `clear-visited-file-modtime' and
1370      `verify-visited-file-modtime' in *Note Buffer Modification::.
1371
1372  - Variable: list-buffers-directory
1373      This buffer-local variable records a string to display in a buffer
1374      listing in place of the visited file name, for buffers that don't
1375      have a visited file name.  Dired buffers use this variable.
1376
1377 \1f
1378 File: lispref.info,  Node: Buffer Modification,  Next: Modification Time,  Prev: Buffer File Name,  Up: Buffers
1379
1380 Buffer Modification
1381 ===================
1382
1383 XEmacs keeps a flag called the "modified flag" for each buffer, to
1384 record whether you have changed the text of the buffer.  This flag is
1385 set to `t' whenever you alter the contents of the buffer, and cleared
1386 to `nil' when you save it.  Thus, the flag shows whether there are
1387 unsaved changes.  The flag value is normally shown in the modeline
1388 (*note Modeline Variables::), and controls saving (*note Saving
1389 Buffers::) and auto-saving (*note Auto-Saving::).
1390
1391    Some Lisp programs set the flag explicitly.  For example, the
1392 function `set-visited-file-name' sets the flag to `t', because the text
1393 does not match the newly-visited file, even if it is unchanged from the
1394 file formerly visited.
1395
1396    The functions that modify the contents of buffers are described in
1397 *Note Text::.
1398
1399  - Function: buffer-modified-p &optional buffer
1400      This function returns `t' if the buffer BUFFER has been modified
1401      since it was last read in from a file or saved, or `nil'
1402      otherwise.  If BUFFER is not supplied, the current buffer is
1403      tested.
1404
1405  - Function: set-buffer-modified-p flag &optional buffer
1406      This function marks BUFFER as modified if FLAG is non-`nil', or as
1407      unmodified if the flag is `nil'.  BUFFER defaults to the current
1408      buffer.
1409
1410      Another effect of calling this function is to cause unconditional
1411      redisplay of the modeline for the current buffer.  In fact, the
1412      function `redraw-modeline' works by doing this:
1413
1414           (set-buffer-modified-p (buffer-modified-p))
1415
1416  - Command: not-modified &optional arg
1417      This command marks the current buffer as unmodified, and not
1418      needing to be saved. (If ARG is non-`nil', the buffer is instead
1419      marked as modified.) Don't use this function in programs, since it
1420      prints a message in the echo area; use `set-buffer-modified-p'
1421      (above) instead.
1422
1423  - Function: buffer-modified-tick &optional buffer
1424      This function returns BUFFER`s modification-count.  This is a
1425      counter that increments every time the buffer is modified.  If
1426      BUFFER is `nil' (or omitted), the current buffer is used.
1427
1428 \1f
1429 File: lispref.info,  Node: Modification Time,  Next: Read Only Buffers,  Prev: Buffer Modification,  Up: Buffers
1430
1431 Comparison of Modification Time
1432 ===============================
1433
1434 Suppose that you visit a file and make changes in its buffer, and
1435 meanwhile the file itself is changed on disk.  At this point, saving the
1436 buffer would overwrite the changes in the file.  Occasionally this may
1437 be what you want, but usually it would lose valuable information.
1438 XEmacs therefore checks the file's modification time using the functions
1439 described below before saving the file.
1440
1441  - Function: verify-visited-file-modtime buffer
1442      This function compares what BUFFER has recorded for the
1443      modification time of its visited file against the actual
1444      modification time of the file as recorded by the operating system.
1445      The two should be the same unless some other process has written
1446      the file since XEmacs visited or saved it.
1447
1448      The function returns `t' if the last actual modification time and
1449      XEmacs's recorded modification time are the same, `nil' otherwise.
1450
1451  - Function: clear-visited-file-modtime
1452      This function clears out the record of the last modification time
1453      of the file being visited by the current buffer.  As a result, the
1454      next attempt to save this buffer will not complain of a
1455      discrepancy in file modification times.
1456
1457      This function is called in `set-visited-file-name' and other
1458      exceptional places where the usual test to avoid overwriting a
1459      changed file should not be done.
1460
1461  - Function: visited-file-modtime
1462      This function returns the buffer's recorded last file modification
1463      time, as a list of the form `(HIGH . LOW)'.  (This is the same
1464      format that `file-attributes' uses to return time values; see
1465      *Note File Attributes::.)
1466
1467  - Function: set-visited-file-modtime &optional time
1468      This function updates the buffer's record of the last modification
1469      time of the visited file, to the value specified by TIME if TIME
1470      is not `nil', and otherwise to the last modification time of the
1471      visited file.
1472
1473      If TIME is not `nil', it should have the form `(HIGH . LOW)' or
1474      `(HIGH LOW)', in either case containing two integers, each of
1475      which holds 16 bits of the time.
1476
1477      This function is useful if the buffer was not read from the file
1478      normally, or if the file itself has been changed for some known
1479      benign reason.
1480
1481  - Function: ask-user-about-supersession-threat filename
1482      This function is used to ask a user how to proceed after an
1483      attempt to modify an obsolete buffer visiting file FILENAME.  An
1484      "obsolete buffer" is an unmodified buffer for which the associated
1485      file on disk is newer than the last save-time of the buffer.  This
1486      means some other program has probably altered the file.
1487
1488      Depending on the user's answer, the function may return normally,
1489      in which case the modification of the buffer proceeds, or it may
1490      signal a `file-supersession' error with data `(FILENAME)', in which
1491      case the proposed buffer modification is not allowed.
1492
1493      This function is called automatically by XEmacs on the proper
1494      occasions.  It exists so you can customize XEmacs by redefining it.
1495      See the file `userlock.el' for the standard definition.
1496
1497      See also the file locking mechanism in *Note File Locks::.
1498
1499 \1f
1500 File: lispref.info,  Node: Read Only Buffers,  Next: The Buffer List,  Prev: Modification Time,  Up: Buffers
1501
1502 Read-Only Buffers
1503 =================
1504
1505 If a buffer is "read-only", then you cannot change its contents,
1506 although you may change your view of the contents by scrolling and
1507 narrowing.
1508
1509    Read-only buffers are used in two kinds of situations:
1510
1511    * A buffer visiting a write-protected file is normally read-only.
1512
1513      Here, the purpose is to show the user that editing the buffer with
1514      the aim of saving it in the file may be futile or undesirable.
1515      The user who wants to change the buffer text despite this can do
1516      so after clearing the read-only flag with `C-x C-q'.
1517
1518    * Modes such as Dired and Rmail make buffers read-only when altering
1519      the contents with the usual editing commands is probably a mistake.
1520
1521      The special commands of these modes bind `buffer-read-only' to
1522      `nil' (with `let') or bind `inhibit-read-only' to `t' around the
1523      places where they change the text.
1524
1525  - Variable: buffer-read-only
1526      This buffer-local variable specifies whether the buffer is
1527      read-only.  The buffer is read-only if this variable is non-`nil'.
1528
1529  - Variable: inhibit-read-only
1530      If this variable is non-`nil', then read-only buffers and read-only
1531      characters may be modified.  Read-only characters in a buffer are
1532      those that have non-`nil' `read-only' properties (either text
1533      properties or extent properties).  *Note Extent Properties::, for
1534      more information about text properties and extent properties.
1535
1536      If `inhibit-read-only' is `t', all `read-only' character
1537      properties have no effect.  If `inhibit-read-only' is a list, then
1538      `read-only' character properties have no effect if they are members
1539      of the list (comparison is done with `eq').
1540
1541  - Command: toggle-read-only &optional arg
1542      This command changes whether the current buffer is read-only.
1543      Interactively, if a prefix arg ARG is supplied, set the current
1544      buffer read only if and only if ARG is positive.
1545
1546      This command is intended for interactive use only; don't use it in
1547      programs.  At any given point in a program, you should know
1548      whether you want the read-only flag on or off; so you can set
1549      `buffer-read-only' explicitly to the proper value, `t' or `nil'.
1550
1551  - Function: barf-if-buffer-read-only &optional buffer start end
1552      This function signals a `buffer-read-only' error if BUFFER is
1553      read-only.  BUFFER defaults to the current buffer.  *Note
1554      Interactive Call::, for another way to signal an error if the
1555      current buffer is read-only.
1556
1557      If optional argument START is non-`nil', all extents in the buffer
1558      which overlap that part of the buffer are checked to ensure none
1559      has a `read-only' property. (Extents that lie completely within the
1560      range, however, are not checked.)  END defaults to the value of
1561      START.
1562
1563      If START and END are equal, the range checked is [START, END]
1564      (i.e.  closed on both ends); otherwise, the range checked is
1565      (START, END) \(open on both ends), except that extents that lie
1566      completely within [START, END] are not checked.  See
1567      `extent-in-region-p' for a fuller discussion.
1568
1569 \1f
1570 File: lispref.info,  Node: The Buffer List,  Next: Creating Buffers,  Prev: Read Only Buffers,  Up: Buffers
1571
1572 The Buffer List
1573 ===============
1574
1575 The "buffer list" is a list of all live buffers.  Creating a buffer
1576 adds it to this list, and killing a buffer deletes it.  The order of
1577 the buffers in the list is based primarily on how recently each buffer
1578 has been displayed in the selected window.  Buffers move to the front
1579 of the list when they are selected and to the end when they are buried.
1580 Several functions, notably `other-buffer', use this ordering.  A
1581 buffer list displayed for the user also follows this order.
1582
1583    Every frame has its own order for the buffer list.  Switching to a
1584 new buffer inside of a particular frame changes the buffer list order
1585 for that frame, but does not affect the buffer list order of any other
1586 frames.  In addition, there is a global, non-frame buffer list order
1587 that is independent of the buffer list orders for any particular frame.
1588
1589    Note that the different buffer lists all contain the same elements.
1590 It is only the order of those elements that is different.
1591
1592  - Function: buffer-list &optional frame
1593      This function returns a list of all buffers, including those whose
1594      names begin with a space.  The elements are actual buffers, not
1595      their names.  The order of the list is specific to FRAME, which
1596      defaults to the current frame.  If FRAME is `t', the global,
1597      non-frame ordering is returned instead.
1598
1599           (buffer-list)
1600                => (#<buffer buffers.texi>
1601                    #<buffer  *Minibuf-1*> #<buffer buffer.c>
1602                    #<buffer *Help*> #<buffer TAGS>)
1603           
1604           ;; Note that the name of the minibuffer
1605           ;;   begins with a space!
1606           (mapcar (function buffer-name) (buffer-list))
1607               => ("buffers.texi" " *Minibuf-1*"
1608                   "buffer.c" "*Help*" "TAGS")
1609
1610      Buffers appear earlier in the list if they were current more
1611      recently.
1612
1613      This list is a copy of a list used inside XEmacs; modifying it has
1614      no effect on the buffers.
1615
1616  - Function: other-buffer &optional buffer-or-name frame visible-ok
1617      This function returns the first buffer in the buffer list other
1618      than BUFFER-OR-NAME, in FRAME's ordering for the buffer list.
1619      (FRAME defaults to the current frame.  If FRAME is `t', then the
1620      global, non-frame ordering is used.) Usually this is the buffer
1621      most recently shown in the selected window, aside from
1622      BUFFER-OR-NAME.  Buffers are moved to the front of the list when
1623      they are selected and to the end when they are buried.  Buffers
1624      whose names start with a space are not considered.
1625
1626      If BUFFER-OR-NAME is not supplied (or if it is not a buffer), then
1627      `other-buffer' returns the first buffer on the buffer list that is
1628      not visible in any window in a visible frame.
1629
1630      If the selected frame has a non-`nil' `buffer-predicate' property,
1631      then `other-buffer' uses that predicate to decide which buffers to
1632      consider.  It calls the predicate once for each buffer, and if the
1633      value is `nil', that buffer is ignored.  *Note X Frame
1634      Properties::.
1635
1636      If VISIBLE-OK is `nil', `other-buffer' avoids returning a buffer
1637      visible in any window on any visible frame, except as a last
1638      resort.   If VISIBLE-OK is non-`nil', then it does not matter
1639      whether a buffer is displayed somewhere or not.
1640
1641      If no suitable buffer exists, the buffer `*scratch*' is returned
1642      (and created, if necessary).
1643
1644      Note that in FSF Emacs 19, there is no FRAME argument, and
1645      VISIBLE-OK is the second argument instead of the third.
1646
1647  - Command: list-buffers &optional files-only
1648      This function displays a listing of the names of existing buffers.
1649      It clears the buffer `*Buffer List*', then inserts the listing
1650      into that buffer and displays it in a window.  `list-buffers' is
1651      intended for interactive use, and is described fully in `The XEmacs
1652      Reference Manual'.  It returns `nil'.
1653
1654  - Command: bury-buffer &optional buffer-or-name before
1655      This function puts BUFFER-OR-NAME at the end of the buffer list
1656      without changing the order of any of the other buffers on the list.
1657      This buffer therefore becomes the least desirable candidate for
1658      `other-buffer' to return.
1659
1660      If BUFFER-OR-NAME is `nil' or omitted, this means to bury the
1661      current buffer.  In addition, if the buffer is displayed in the
1662      selected window, this switches to some other buffer (obtained using
1663      `other-buffer') in the selected window.  But if the buffer is
1664      displayed in some other window, it remains displayed there.
1665
1666      If you wish to replace a buffer in all the windows that display
1667      it, use `replace-buffer-in-windows'.  *Note Buffers and Windows::.
1668
1669 \1f
1670 File: lispref.info,  Node: Creating Buffers,  Next: Killing Buffers,  Prev: The Buffer List,  Up: Buffers
1671
1672 Creating Buffers
1673 ================
1674
1675 This section describes the two primitives for creating buffers.
1676 `get-buffer-create' creates a buffer if it finds no existing buffer
1677 with the specified name; `generate-new-buffer' always creates a new
1678 buffer and gives it a unique name.
1679
1680    Other functions you can use to create buffers include
1681 `with-output-to-temp-buffer' (*note Temporary Displays::) and
1682 `create-file-buffer' (*note Visiting Files::).  Starting a subprocess
1683 can also create a buffer (*note Processes::).
1684
1685  - Function: get-buffer-create name
1686      This function returns a buffer named NAME.  It returns an existing
1687      buffer with that name, if one exists; otherwise, it creates a new
1688      buffer.  The buffer does not become the current buffer--this
1689      function does not change which buffer is current.
1690
1691      An error is signaled if NAME is not a string.
1692
1693           (get-buffer-create "foo")
1694                => #<buffer foo>
1695
1696      The major mode for the new buffer is set to Fundamental mode.  The
1697      variable `default-major-mode' is handled at a higher level.  *Note
1698      Auto Major Mode::.
1699
1700  - Function: generate-new-buffer name
1701      This function returns a newly created, empty buffer, but does not
1702      make it current.  If there is no buffer named NAME, then that is
1703      the name of the new buffer.  If that name is in use, this function
1704      adds suffixes of the form `<N>' to NAME, where N is an integer.
1705      It tries successive integers starting with 2 until it finds an
1706      available name.
1707
1708      An error is signaled if NAME is not a string.
1709
1710           (generate-new-buffer "bar")
1711                => #<buffer bar>
1712           (generate-new-buffer "bar")
1713                => #<buffer bar<2>>
1714           (generate-new-buffer "bar")
1715                => #<buffer bar<3>>
1716
1717      The major mode for the new buffer is set to Fundamental mode.  The
1718      variable `default-major-mode' is handled at a higher level.  *Note
1719      Auto Major Mode::.
1720
1721      See the related function `generate-new-buffer-name' in *Note
1722      Buffer Names::.
1723
1724 \1f
1725 File: lispref.info,  Node: Killing Buffers,  Next: Indirect Buffers,  Prev: Creating Buffers,  Up: Buffers
1726
1727 Killing Buffers
1728 ===============
1729
1730 "Killing a buffer" makes its name unknown to XEmacs and makes its text
1731 space available for other use.
1732
1733    The buffer object for the buffer that has been killed remains in
1734 existence as long as anything refers to it, but it is specially marked
1735 so that you cannot make it current or display it.  Killed buffers retain
1736 their identity, however; two distinct buffers, when killed, remain
1737 distinct according to `eq'.
1738
1739    If you kill a buffer that is current or displayed in a window, XEmacs
1740 automatically selects or displays some other buffer instead.  This means
1741 that killing a buffer can in general change the current buffer.
1742 Therefore, when you kill a buffer, you should also take the precautions
1743 associated with changing the current buffer (unless you happen to know
1744 that the buffer being killed isn't current).  *Note Current Buffer::.
1745
1746    If you kill a buffer that is the base buffer of one or more indirect
1747 buffers, the indirect buffers are automatically killed as well.
1748
1749    The `buffer-name' of a killed buffer is `nil'.  To test whether a
1750 buffer has been killed, you can either use this feature or the function
1751 `buffer-live-p'.
1752
1753  - Function: buffer-live-p object
1754      This function returns `t' if OBJECT is an editor buffer that has
1755      not been deleted, `nil' otherwise.
1756
1757  - Command: kill-buffer buffer-or-name
1758      This function kills the buffer BUFFER-OR-NAME, freeing all its
1759      memory for use as space for other buffers.  (Emacs version 18 and
1760      older was unable to return the memory to the operating system.)
1761      It returns `nil'.  The argument BUFFER-OR-NAME may be a buffer or
1762      the name of one.
1763
1764      Any processes that have this buffer as the `process-buffer' are
1765      sent the `SIGHUP' signal, which normally causes them to terminate.
1766      (The basic meaning of `SIGHUP' is that a dialup line has been
1767      disconnected.)  *Note Deleting Processes::.
1768
1769      If the buffer is visiting a file and contains unsaved changes,
1770      `kill-buffer' asks the user to confirm before the buffer is killed.
1771      It does this even if not called interactively.  To prevent the
1772      request for confirmation, clear the modified flag before calling
1773      `kill-buffer'.  *Note Buffer Modification::.
1774
1775      Killing a buffer that is already dead has no effect.
1776
1777           (kill-buffer "foo.unchanged")
1778                => nil
1779           (kill-buffer "foo.changed")
1780           
1781           ---------- Buffer: Minibuffer ----------
1782           Buffer foo.changed modified; kill anyway? (yes or no) yes
1783           ---------- Buffer: Minibuffer ----------
1784           
1785                => nil
1786
1787  - Variable: kill-buffer-query-functions
1788      After confirming unsaved changes, `kill-buffer' calls the functions
1789      in the list `kill-buffer-query-functions', in order of appearance,
1790      with no arguments.  The buffer being killed is the current buffer
1791      when they are called.  The idea is that these functions ask for
1792      confirmation from the user for various nonstandard reasons.  If
1793      any of them returns `nil', `kill-buffer' spares the buffer's life.
1794
1795  - Variable: kill-buffer-hook
1796      This is a normal hook run by `kill-buffer' after asking all the
1797      questions it is going to ask, just before actually killing the
1798      buffer.  The buffer to be killed is current when the hook
1799      functions run.  *Note Hooks::.
1800
1801  - Variable: buffer-offer-save
1802      This variable, if non-`nil' in a particular buffer, tells
1803      `save-buffers-kill-emacs' and `save-some-buffers' to offer to save
1804      that buffer, just as they offer to save file-visiting buffers.  The
1805      variable `buffer-offer-save' automatically becomes buffer-local
1806      when set for any reason.  *Note Buffer-Local Variables::.
1807
1808 \1f
1809 File: lispref.info,  Node: Indirect Buffers,  Prev: Killing Buffers,  Up: Buffers
1810
1811 Indirect Buffers
1812 ================
1813
1814 An "indirect buffer" shares the text of some other buffer, which is
1815 called the "base buffer" of the indirect buffer.  In some ways it is
1816 the analogue, for buffers, of a symbolic link among files.  The base
1817 buffer may not itself be an indirect buffer.  One base buffer may have
1818 several "indirect children".
1819
1820    The text of the indirect buffer is always identical to the text of
1821 its base buffer; changes made by editing either one are visible
1822 immediately in the other.
1823
1824    But in all other respects, the indirect buffer and its base buffer
1825 are completely separate.  They have different names, different values of
1826 point and mark, different narrowing, different markers and extents
1827 (though inserting or deleting text in either buffer relocates the
1828 markers and extents for both), different major modes, and different
1829 local variables.  Unlike in FSF Emacs, XEmacs indirect buffers do not
1830 automatically share text properties among themselves and their base
1831 buffer.
1832
1833    An indirect buffer cannot visit a file, but its base buffer can.  If
1834 you try to save the indirect buffer, that actually works by saving the
1835 base buffer.
1836
1837    Killing an indirect buffer has no effect on its base buffer.  Killing
1838 the base buffer kills all its indirect children.
1839
1840  - Command: make-indirect-buffer base-buffer name
1841      This creates an indirect buffer named NAME whose base buffer is
1842      BASE-BUFFER.  The argument BASE-BUFFER may be a buffer or a string.
1843
1844      If BASE-BUFFER is an indirect buffer, its base buffer is used as
1845      the base for the new buffer.
1846
1847           (make-indirect-buffer "*scratch*" "indirect")
1848                => #<buffer "indirect">
1849
1850  - Function: buffer-base-buffer &optional buffer
1851      This function returns the base buffer of BUFFER.  If BUFFER is not
1852      indirect, the value is `nil'.  Otherwise, the value is another
1853      buffer, which is never an indirect buffer.  If BUFFER is not
1854      supplied, it defaults to the current buffer.
1855
1856           (buffer-base-buffer (get-buffer "indirect"))
1857                => #<buffer "*scratch*">
1858
1859  - Function: buffer-indirect-children &optional buffer
1860      This function returns a list of all indirect buffers whose base
1861      buffer is BUFFER.  If BUFFER is indirect, the return value will
1862      always be `nil'; see `make-indirect-buffer'.  If BUFFER is not
1863      supplied, it defaults to the current buffer.
1864
1865           (buffer-indirect-children (get-buffer "*scratch*"))
1866                => (#<buffer "indirect">)
1867
1868 \1f
1869 File: lispref.info,  Node: Windows,  Next: Frames,  Prev: Buffers,  Up: Top
1870
1871 Windows
1872 *******
1873
1874 This chapter describes most of the functions and variables related to
1875 Emacs windows.  See *Note Display::, for information on how text is
1876 displayed in windows.
1877
1878 * Menu:
1879
1880 * Basic Windows::          Basic information on using windows.
1881 * Splitting Windows::      Splitting one window into two windows.
1882 * Deleting Windows::       Deleting a window gives its space to other windows.
1883 * Selecting Windows::      The selected window is the one that you edit in.
1884 * Cyclic Window Ordering:: Moving around the existing windows.
1885 * Buffers and Windows::    Each window displays the contents of a buffer.
1886 * Displaying Buffers::     Higher-lever functions for displaying a buffer
1887                              and choosing a window for it.
1888 * Choosing Window::        How to choose a window for displaying a buffer.
1889 * Window Point::           Each window has its own location of point.
1890 * Window Start::           The display-start position controls which text
1891                              is on-screen in the window.
1892 * Vertical Scrolling::     Moving text up and down in the window.
1893 * Horizontal Scrolling::   Moving text sideways on the window.
1894 * Size of Window::         Accessing the size of a window.
1895 * Position of Window::     Accessing the position of a window.
1896 * Resizing Windows::       Changing the size of a window.
1897 * Window Configurations::  Saving and restoring the state of the screen.
1898
1899 \1f
1900 File: lispref.info,  Node: Basic Windows,  Next: Splitting Windows,  Up: Windows
1901
1902 Basic Concepts of Emacs Windows
1903 ===============================
1904
1905 A "window" in XEmacs is the physical area of the screen in which a
1906 buffer is displayed.  The term is also used to refer to a Lisp object
1907 that represents that screen area in XEmacs Lisp.  It should be clear
1908 from the context which is meant.
1909
1910    XEmacs groups windows into frames.  A frame represents an area of
1911 screen available for XEmacs to use.  Each frame always contains at least
1912 one window, but you can subdivide it vertically or horizontally into
1913 multiple nonoverlapping Emacs windows.
1914
1915    In each frame, at any time, one and only one window is designated as
1916 "selected within the frame".  The frame's cursor appears in that
1917 window.  At ant time, one frame is the selected frame; and the window
1918 selected within that frame is "the selected window".  The selected
1919 window's buffer is usually the current buffer (except when `set-buffer'
1920 has been used).  *Note Current Buffer::.
1921
1922    For practical purposes, a window exists only while it is displayed in
1923 a frame.  Once removed from the frame, the window is effectively deleted
1924 and should not be used, _even though there may still be references to
1925 it_ from other Lisp objects.  Restoring a saved window configuration is
1926 the only way for a window no longer on the screen to come back to life.
1927 (*Note Deleting Windows::.)
1928
1929    Each window has the following attributes:
1930
1931    * containing frame
1932
1933    * window height
1934
1935    * window width
1936
1937    * window edges with respect to the frame or screen
1938
1939    * the buffer it displays
1940
1941    * position within the buffer at the upper left of the window
1942
1943    * amount of horizontal scrolling, in columns
1944
1945    * point
1946
1947    * the mark
1948
1949    * how recently the window was selected
1950
1951    Users create multiple windows so they can look at several buffers at
1952 once.  Lisp libraries use multiple windows for a variety of reasons, but
1953 most often to display related information.  In Rmail, for example, you
1954 can move through a summary buffer in one window while the other window
1955 shows messages one at a time as they are reached.
1956
1957    The meaning of "window" in XEmacs is similar to what it means in the
1958 context of general-purpose window systems such as X, but not identical.
1959 The X Window System places X windows on the screen; XEmacs uses one or
1960 more X windows as frames, and subdivides them into Emacs windows.  When
1961 you use XEmacs on a character-only terminal, XEmacs treats the whole
1962 terminal screen as one frame.
1963
1964    Most window systems support arbitrarily located overlapping windows.
1965 In contrast, Emacs windows are "tiled"; they never overlap, and
1966 together they fill the whole screen or frame.  Because of the way in
1967 which XEmacs creates new windows and resizes them, you can't create
1968 every conceivable tiling of windows on an Emacs frame.  *Note Splitting
1969 Windows::, and *Note Size of Window::.
1970
1971    *Note Display::, for information on how the contents of the window's
1972 buffer are displayed in the window.
1973
1974  - Function: windowp object
1975      This function returns `t' if OBJECT is a window.
1976
1977 \1f
1978 File: lispref.info,  Node: Splitting Windows,  Next: Deleting Windows,  Prev: Basic Windows,  Up: Windows
1979
1980 Splitting Windows
1981 =================
1982
1983 The functions described here are the primitives used to split a window
1984 into two windows.  Two higher level functions sometimes split a window,
1985 but not always: `pop-to-buffer' and `display-buffer' (*note Displaying
1986 Buffers::).
1987
1988    The functions described here do not accept a buffer as an argument.
1989 The two "halves" of the split window initially display the same buffer
1990 previously visible in the window that was split.
1991
1992  - Function: one-window-p &optional nomini which-frames which-devices
1993      This function returns non-`nil' if there is only one window.  The
1994      argument NOMINI, if non-`nil', means don't count the minibuffer
1995      even if it is active; otherwise, the minibuffer window is
1996      included, if active, in the total number of windows which is
1997      compared against one.
1998
1999      The remaining arguments controls which set of windows are counted,
2000      as with `next-window'.
2001
2002  - Command: split-window &optional window size horizontal
2003      This function splits WINDOW into two windows.  The original window
2004      WINDOW remains the selected window, but occupies only part of its
2005      former screen area.  The rest is occupied by a newly created
2006      window which is returned as the value of this function.
2007
2008      If HORIZONTAL is non-`nil', then WINDOW splits into two side by
2009      side windows.  The original window WINDOW keeps the leftmost SIZE
2010      columns, and gives the rest of the columns to the new window.
2011      Otherwise, it splits into windows one above the other, and WINDOW
2012      keeps the upper SIZE lines and gives the rest of the lines to the
2013      new window.  The original window is therefore the left-hand or
2014      upper of the two, and the new window is the right-hand or lower.
2015
2016      If WINDOW is omitted or `nil', then the selected window is split.
2017      If SIZE is omitted or `nil', then WINDOW is divided evenly into
2018      two parts.  (If there is an odd line, it is allocated to the new
2019      window.)  When `split-window' is called interactively, all its
2020      arguments are `nil'.
2021
2022      The following example starts with one window on a frame that is 50
2023      lines high by 80 columns wide; then the window is split.
2024
2025           (setq w (selected-window))
2026                => #<window 8 on windows.texi>
2027           (window-edges)          ; Edges in order:
2028                => (0 0 80 50)     ;   left-top-right-bottom
2029           
2030           ;; Returns window created
2031           (setq w2 (split-window w 15))
2032                => #<window 28 on windows.texi>
2033           (window-edges w2)
2034                => (0 15 80 50)    ; Bottom window;
2035                                   ;   top is line 15
2036           (window-edges w)
2037                => (0 0 80 15)     ; Top window
2038
2039      The frame looks like this:
2040
2041                    __________
2042                   |          |  line 0
2043                   |    w     |
2044                   |__________|
2045                   |          |  line 15
2046                   |    w2    |
2047                   |__________|
2048                                 line 50
2049            column 0   column 80
2050
2051      Next, the top window is split horizontally:
2052
2053           (setq w3 (split-window w 35 t))
2054                => #<window 32 on windows.texi>
2055           (window-edges w3)
2056                => (35 0 80 15)  ; Left edge at column 35
2057           (window-edges w)
2058                => (0 0 35 15)   ; Right edge at column 35
2059           (window-edges w2)
2060                => (0 15 80 50)  ; Bottom window unchanged
2061
2062      Now, the screen looks like this:
2063
2064                column 35
2065                    __________
2066                   |   |      |  line 0
2067                   | w |  w3  |
2068                   |___|______|
2069                   |          |  line 15
2070                   |    w2    |
2071                   |__________|
2072                                 line 50
2073            column 0   column 80
2074
2075      Normally, Emacs indicates the border between two side-by-side
2076      windows with a scroll bar (*note Scroll Bars: X Frame Properties.)
2077      or `|' characters.  The display table can specify alternative
2078      border characters; see *Note Display Tables::.
2079
2080  - Command: split-window-vertically &optional size
2081      This function splits the selected window into two windows, one
2082      above the other, leaving the selected window with SIZE lines.
2083
2084      This function is simply an interface to `split-window'.  Here is
2085      the complete function definition for it:
2086
2087           (defun split-window-vertically (&optional arg)
2088             "Split current window into two windows, one above the other."
2089             (interactive "P")
2090             (split-window nil (and arg (prefix-numeric-value arg))))
2091
2092  - Command: split-window-horizontally &optional size
2093      This function splits the selected window into two windows
2094      side-by-side, leaving the selected window with SIZE columns.
2095
2096      This function is simply an interface to `split-window'.  Here is
2097      the complete definition for `split-window-horizontally' (except for
2098      part of the documentation string):
2099
2100           (defun split-window-horizontally (&optional arg)
2101             "Split selected window into two windows, side by side..."
2102             (interactive "P")
2103             (split-window nil (and arg (prefix-numeric-value arg)) t))
2104
2105 \1f
2106 File: lispref.info,  Node: Deleting Windows,  Next: Selecting Windows,  Prev: Splitting Windows,  Up: Windows
2107
2108 Deleting Windows
2109 ================
2110
2111 A window remains visible on its frame unless you "delete" it by calling
2112 certain functions that delete windows.  A deleted window cannot appear
2113 on the screen, but continues to exist as a Lisp object until there are
2114 no references to it.  There is no way to cancel the deletion of a
2115 window aside from restoring a saved window configuration (*note Window
2116 Configurations::).  Restoring a window configuration also deletes any
2117 windows that aren't part of that configuration.
2118
2119    When you delete a window, the space it took up is given to one
2120 adjacent sibling.  (In Emacs version 18, the space was divided evenly
2121 among all the siblings.)
2122
2123  - Function: window-live-p window
2124      This function returns `nil' if WINDOW is deleted, and `t'
2125      otherwise.
2126
2127      *Warning:* Erroneous information or fatal errors may result from
2128      using a deleted window as if it were live.
2129
2130  - Command: delete-window &optional window force
2131      This function removes WINDOW from the display.  If WINDOW is
2132      omitted, then the selected window is deleted. If window is the
2133      only one on its frame, the frame is deleted as well.
2134
2135      Normally, you cannot delete the last non-minibuffer-only frame
2136      (you must use `save-buffers-kill-emacs' or `kill-emacs'); an error
2137      is signaled instead.  However, if optional second argument FORCE is
2138      non-`nil', you can delete the last frame. (This will automatically
2139      call `save-buffers-kill-emacs'.)
2140
2141      This function returns `nil'.
2142
2143      When `delete-window' is called interactively, the selected window
2144      is deleted.
2145
2146  - Command: delete-other-windows &optional window
2147      This function makes WINDOW the only window on its frame, by
2148      deleting the other windows in that frame.  If WINDOW is omitted or
2149      `nil', then the selected window is used by default.
2150
2151      The result is `nil'.
2152
2153  - Command: delete-windows-on buffer &optional which-frames
2154           which-devices
2155      This function deletes all windows showing BUFFER.  If there are no
2156      windows showing BUFFER, it does nothing.
2157
2158      `delete-windows-on' operates frame by frame.  If a frame has
2159      several windows showing different buffers, then those showing
2160      BUFFER are removed, and the others expand to fill the space.  If
2161      all windows in some frame are showing BUFFER (including the case
2162      where there is only one window), then the frame reverts to having a
2163      single window showing another buffer chosen with `other-buffer'.
2164      *Note The Buffer List::.
2165
2166      The argument WHICH-FRAMES controls which frames to operate on:
2167
2168     `nil'
2169           Delete all windows showing BUFFER in any frame.
2170
2171     `t'
2172           Delete only windows showing BUFFER in the selected frame.
2173
2174     `visible'
2175           Delete all windows showing BUFFER in any visible frame.
2176
2177     `0'
2178           Delete all windows showing BUFFER in any visible frame.
2179
2180     FRAME
2181           If it is a frame, delete all windows showing BUFFER in that
2182           frame.
2183
2184      *Warning:* This is similar to, but not identical to, the meaning
2185      of the WHICH-FRAMES argument to `next-window'; the meanings of
2186      `nil' and `t' are reversed.
2187
2188      The optional argument WHICH-DEVICES further clarifies on which
2189      devices to search for frames as specified by WHICH-FRAMES.  This
2190      value is only meaningful if WHICH-FRAMES is not `t'.
2191
2192     `nil'
2193           Consider all devices on the selected console.
2194
2195     DEVICE
2196           Consider only the one device DEVICE.
2197
2198     CONSOLE
2199           Consider all devices on CONSOLE.
2200
2201     DEVICE-TYPE
2202           Consider all devices with device type DEVICE-TYPE.
2203
2204     `window-system'
2205           Consider all devices on window system consoles.
2206
2207     anything else
2208           Consider all devices without restriction.
2209
2210      This function always returns `nil'.
2211
2212 \1f
2213 File: lispref.info,  Node: Selecting Windows,  Next: Cyclic Window Ordering,  Prev: Deleting Windows,  Up: Windows
2214
2215 Selecting Windows
2216 =================
2217
2218 When a window is selected, the buffer in the window becomes the current
2219 buffer, and the cursor will appear in it.
2220
2221  - Function: selected-window &optional device
2222      This function returns the selected window.  This is the window in
2223      which the cursor appears and to which many commands apply.  Each
2224      separate device can have its own selected window, which is
2225      remembered as focus changes from device to device.  Optional
2226      argument DEVICE specifies which device to return the selected
2227      window for, and defaults to the selected device.
2228
2229  - Function: select-window window &optional norecord
2230      This function makes WINDOW the selected window.  The cursor then
2231      appears in WINDOW (on redisplay).  The buffer being displayed in
2232      WINDOW is immediately designated the current buffer.
2233
2234      If optional argument NORECORD is non-`nil' then the global and
2235      per-frame buffer orderings are not modified, as by the function
2236      `record-buffer'.
2237
2238      The return value is WINDOW.
2239
2240           (setq w (next-window))
2241           (select-window w)
2242                => #<window 65 on windows.texi>
2243
2244  - Special Form: save-selected-window forms...
2245      This special form records the selected window, executes FORMS in
2246      sequence, then restores the earlier selected window.  It does not
2247      save or restore anything about the sizes, arrangement or contents
2248      of windows; therefore, if the FORMS change them, the changes are
2249      permanent.
2250
2251    The following functions choose one of the windows on the screen,
2252 offering various criteria for the choice.
2253
2254  - Function: get-lru-window &optional which-frames which-devices
2255      This function returns the window least recently "used" (that is,
2256      selected).  The selected window is always the most recently used
2257      window.
2258
2259      The selected window can be the least recently used window if it is
2260      the only window.  A newly created window becomes the least
2261      recently used window until it is selected.  A minibuffer window is
2262      never a candidate.
2263
2264      By default, only the windows in the selected frame are considered.
2265      The optional argument WHICH-FRAMES changes this behavior.  Here
2266      are the possible values and their meanings:
2267
2268     `nil'
2269           Consider all the windows in the selected windows's frame,
2270           plus the minibuffer used by that frame even if it lies in
2271           some other frame.
2272
2273     `t'
2274           Consider all windows in all existing frames.
2275
2276     `visible'
2277           Consider all windows in all visible frames.  (To get useful
2278           results, you must ensure WINDOW is in a visible frame.)
2279
2280     `0'
2281           Consider all windows in all visible or iconified frames.
2282
2283     FRAME
2284           Consider all windows on frame FRAME.
2285
2286     anything else
2287           Consider precisely the windows in the selected window's
2288           frame, and no others.
2289
2290      The optional argument WHICH-DEVICES further clarifies on which
2291      devices to search for frames as specified by WHICH-FRAMES.  This
2292      value is only meaningful if WHICH-FRAMES is non-`nil'.
2293
2294     `nil'
2295           Consider all devices on the selected console.
2296
2297     DEVICE
2298           Consider only the one device DEVICE.
2299
2300     CONSOLE
2301           Consider all devices on CONSOLE.
2302
2303     DEVICE-TYPE
2304           Consider all devices with device type DEVICE-TYPE.
2305
2306     `window-system'
2307           Consider all devices on window system consoles.
2308
2309     anything else
2310           Consider all devices without restriction.
2311
2312
2313  - Function: get-largest-window &optional which-frames which-devices
2314      This function returns the window with the largest area (height
2315      times width).  If there are no side-by-side windows, then this is
2316      the window with the most lines.  A minibuffer window is never a
2317      candidate.
2318
2319      If there are two windows of the same size, then the function
2320      returns the window that is first in the cyclic ordering of windows
2321      (see following section), starting from the selected window.
2322
2323      The remaining arguments control which set of windows are
2324      considered.  See `next-window', above.
2325
2326 \1f
2327 File: lispref.info,  Node: Cyclic Window Ordering,  Next: Buffers and Windows,  Prev: Selecting Windows,  Up: Windows
2328
2329 Cyclic Ordering of Windows
2330 ==========================
2331
2332 When you use the command `C-x o' (`other-window') to select the next
2333 window, it moves through all the windows on the screen in a specific
2334 cyclic order.  For any given configuration of windows, this order never
2335 varies.  It is called the "cyclic ordering of windows".
2336
2337    This ordering generally goes from top to bottom, and from left to
2338 right.  But it may go down first or go right first, depending on the
2339 order in which the windows were split.
2340
2341    If the first split was vertical (into windows one above each other),
2342 and then the subwindows were split horizontally, then the ordering is
2343 left to right in the top of the frame, and then left to right in the
2344 next lower part of the frame, and so on.  If the first split was
2345 horizontal, the ordering is top to bottom in the left part, and so on.
2346 In general, within each set of siblings at any level in the window tree,
2347 the order is left to right, or top to bottom.
2348
2349  - Function: next-window &optional window minibuf which-frames
2350           which-devices
2351      This function returns the window following WINDOW in the cyclic
2352      ordering of windows.  This is the window that `C-x o' would select
2353      if typed when WINDOW is selected.  If WINDOW is the only window
2354      visible, then this function returns WINDOW.  If omitted, WINDOW
2355      defaults to the selected window.
2356
2357      The value of the argument MINIBUF determines whether the
2358      minibuffer is included in the window order.  Normally, when
2359      MINIBUF is `nil', the minibuffer is included if it is currently
2360      active; this is the behavior of `C-x o'.  (The minibuffer window
2361      is active while the minibuffer is in use.  *Note Minibuffers::.)
2362
2363      If MINIBUF is `t', then the cyclic ordering includes the
2364      minibuffer window even if it is not active.
2365
2366      If MINIBUF is neither `t' nor `nil', then the minibuffer window is
2367      not included even if it is active.
2368
2369      By default, only the windows in the selected frame are considered.
2370      The optional argument WHICH-FRAMES changes this behavior.  Here
2371      are the possible values and their meanings:
2372
2373     `nil'
2374           Consider all the windows in WINDOW's frame, plus the
2375           minibuffer used by that frame even if it lies in some other
2376           frame.
2377
2378     `t'
2379           Consider all windows in all existing frames.
2380
2381     `visible'
2382           Consider all windows in all visible frames.  (To get useful
2383           results, you must ensure WINDOW is in a visible frame.)
2384
2385     `0'
2386           Consider all windows in all visible or iconified frames.
2387
2388     FRAME
2389           Consider all windows on frame FRAME.
2390
2391     anything else
2392           Consider precisely the windows in WINDOW's frame, and no
2393           others.
2394
2395      The optional argument WHICH-DEVICES further clarifies on which
2396      devices to search for frames as specified by WHICH-FRAMES.  This
2397      value is only meaningful if WHICH-FRAMES is non-`nil'.
2398
2399     `nil'
2400           Consider all devices on the selected console.
2401
2402     DEVICE
2403           Consider only the one device DEVICE.
2404
2405     CONSOLE
2406           Consider all devices on CONSOLE.
2407
2408     DEVICE-TYPE
2409           Consider all devices with device type DEVICE-TYPE.
2410
2411     `window-system'
2412           Consider all devices on window system consoles.
2413
2414     anything else
2415           Consider all devices without restriction.
2416
2417      If you use consistent values for MINIBUF, WHICH-FRAMES, and
2418      WHICH-DEVICES, you can use `next-window' to iterate through the
2419      entire cycle of acceptable windows, eventually ending up back at
2420      the window you started with.  `previous-window' traverses the same
2421      cycle, in the reverse order.
2422
2423      This example assumes there are two windows, both displaying the
2424      buffer `windows.texi':
2425
2426           (selected-window)
2427                => #<window 56 on windows.texi>
2428           (next-window (selected-window))
2429                => #<window 52 on windows.texi>
2430           (next-window (next-window (selected-window)))
2431                => #<window 56 on windows.texi>
2432
2433  - Function: previous-window &optional window minibuf which-frames
2434           which-devices
2435      This function returns the window preceding WINDOW in the cyclic
2436      ordering of windows.  The other arguments specify which windows to
2437      include in the cycle, as in `next-window'.
2438
2439  - Command: other-window count &optional which-frames which-devices
2440      This function selects the COUNTth following window in the cyclic
2441      order.  If COUNT is negative, then it selects the -COUNTth
2442      preceding window.  It returns `nil'.
2443
2444      In an interactive call, COUNT is the numeric prefix argument.
2445
2446      The other arguments specify which windows to include in the cycle,
2447      as in `next-window'.
2448
2449  - Function: walk-windows function &optional minibuf which-frames
2450           which-devices
2451      This function cycles through all windows, calling `function' once
2452      for each window with the window as its sole argument.
2453
2454      The other arguments specify which windows to cycle through, as in
2455      `next-window'.
2456
2457 \1f
2458 File: lispref.info,  Node: Buffers and Windows,  Next: Displaying Buffers,  Prev: Cyclic Window Ordering,  Up: Windows
2459
2460 Buffers and Windows
2461 ===================
2462
2463 This section describes low-level functions to examine windows or to
2464 display buffers in windows in a precisely controlled fashion.  *Note
2465 Displaying Buffers::, for related functions that find a window to use
2466 and specify a buffer for it.  The functions described there are easier
2467 to use than these, but they employ heuristics in choosing or creating a
2468 window; use these functions when you need complete control.
2469
2470  - Function: set-window-buffer window buffer-or-name &optional norecord
2471      This function makes WINDOW display BUFFER-OR-NAME as its contents.
2472      BUFFER-OR-NAME can be a buffer or a buffer name.
2473
2474      With non-`nil' optional argument NORECORD, do not modify the
2475      global or per-frame buffer ordering.
2476
2477      This function returns `nil'.
2478
2479           (set-window-buffer (selected-window) "foo")
2480                => nil
2481
2482  - Function: window-buffer &optional window
2483      This function returns the buffer that WINDOW is displaying.  If
2484      WINDOW is omitted, this function returns the buffer for the
2485      selected window.
2486
2487           (window-buffer)
2488                => #<buffer windows.texi>
2489
2490  - Function: get-buffer-window buffer-or-name &optional which-frames
2491           which-devices
2492      This function returns a window currently displaying
2493      BUFFER-OR-NAME, or `nil' if there is none.  If there are several
2494      such windows, then the function returns the first one in the
2495      cyclic ordering of windows, starting from the selected window.
2496      *Note Cyclic Window Ordering::.
2497
2498      The remaining arguments control which windows to consider.  They
2499      have the same meaning as for `next-window'.
2500
2501 \1f
2502 File: lispref.info,  Node: Displaying Buffers,  Next: Choosing Window,  Prev: Buffers and Windows,  Up: Windows
2503
2504 Displaying Buffers in Windows
2505 =============================
2506
2507 In this section we describe convenient functions that choose a window
2508 automatically and use it to display a specified buffer.  These functions
2509 can also split an existing window in certain circumstances.  We also
2510 describe variables that parameterize the heuristics used for choosing a
2511 window.  *Note Buffers and Windows::, for low-level functions that give
2512 you more precise control.
2513
2514    Do not use the functions in this section in order to make a buffer
2515 current so that a Lisp program can access or modify it; they are too
2516 drastic for that purpose, since they change the display of buffers in
2517 windows, which is gratuitous and will surprise the user.  Instead, use
2518 `set-buffer' (*note Current Buffer::) and `save-excursion' (*note
2519 Excursions::), which designate buffers as current for programmed access
2520 without affecting the display of buffers in windows.
2521
2522  - Command: switch-to-buffer buffer-or-name &optional norecord
2523      This function makes BUFFER-OR-NAME the current buffer, and also
2524      displays the buffer in the selected window.  This means that a
2525      human can see the buffer and subsequent keyboard commands will
2526      apply to it.  Contrast this with `set-buffer', which makes
2527      BUFFER-OR-NAME the current buffer but does not display it in the
2528      selected window.  *Note Current Buffer::.
2529
2530      If BUFFER-OR-NAME does not identify an existing buffer, then a new
2531      buffer by that name is created.  The major mode for the new buffer
2532      is set according to the variable `default-major-mode'.  *Note Auto
2533      Major Mode::.
2534
2535      Normally the specified buffer is put at the front of the buffer
2536      list.  This affects the operation of `other-buffer'.  However, if
2537      NORECORD is non-`nil', this is not done.  *Note The Buffer List::.
2538
2539      The `switch-to-buffer' function is often used interactively, as
2540      the binding of `C-x b'.  It is also used frequently in programs.
2541      It always returns `nil'.
2542
2543  - Command: switch-to-buffer-other-window buffer-or-name
2544      This function makes BUFFER-OR-NAME the current buffer and displays
2545      it in a window not currently selected.  It then selects that
2546      window.  The handling of the buffer is the same as in
2547      `switch-to-buffer'.
2548
2549      The currently selected window is absolutely never used to do the
2550      job.  If it is the only window, then it is split to make a
2551      distinct window for this purpose.  If the selected window is
2552      already displaying the buffer, then it continues to do so, but
2553      another window is nonetheless found to display it in as well.
2554
2555  - Function: pop-to-buffer buffer-or-name &optional other-window
2556           on-frame
2557      This function makes BUFFER-OR-NAME the current buffer and switches
2558      to it in some window, preferably not the window previously
2559      selected.  The "popped-to" window becomes the selected window
2560      within its frame.
2561
2562      If the variable `pop-up-frames' is non-`nil', `pop-to-buffer'
2563      looks for a window in any visible frame already displaying the
2564      buffer; if there is one, it returns that window and makes it be
2565      selected within its frame.  If there is none, it creates a new
2566      frame and displays the buffer in it.
2567
2568      If `pop-up-frames' is `nil', then `pop-to-buffer' operates
2569      entirely within the selected frame.  (If the selected frame has
2570      just a minibuffer, `pop-to-buffer' operates within the most
2571      recently selected frame that was not just a minibuffer.)
2572
2573      If the variable `pop-up-windows' is non-`nil', windows may be
2574      split to create a new window that is different from the original
2575      window.  For details, see *Note Choosing Window::.
2576
2577      If OTHER-WINDOW is non-`nil', `pop-to-buffer' finds or creates
2578      another window even if BUFFER-OR-NAME is already visible in the
2579      selected window.  Thus BUFFER-OR-NAME could end up displayed in
2580      two windows.  On the other hand, if BUFFER-OR-NAME is already
2581      displayed in the selected window and OTHER-WINDOW is `nil', then
2582      the selected window is considered sufficient display for
2583      BUFFER-OR-NAME, so that nothing needs to be done.
2584
2585      All the variables that affect `display-buffer' affect
2586      `pop-to-buffer' as well.  *Note Choosing Window::.
2587
2588      If BUFFER-OR-NAME is a string that does not name an existing
2589      buffer, a buffer by that name is created.  The major mode for the
2590      new buffer is set according to the variable `default-major-mode'.
2591      *Note Auto Major Mode::.
2592
2593      If ON-FRAME is non-`nil', it is the frame to pop to this buffer on.
2594
2595      An example use of this function is found at the end of *Note
2596      Filter Functions::.
2597
2598  - Command: replace-buffer-in-windows buffer &optional which-frames
2599           which-devices
2600      This function replaces BUFFER with some other buffer in all
2601      windows displaying it.  The other buffer used is chosen with
2602      `other-buffer'.  In the usual applications of this function, you
2603      don't care which other buffer is used; you just want to make sure
2604      that BUFFER is no longer displayed.
2605
2606      The optional arguments WHICH-FRAMES and WHICH-DEVICES have the
2607      same meaning as with `delete-windows-on'.
2608
2609      This function returns `nil'.
2610
2611 \1f
2612 File: lispref.info,  Node: Choosing Window,  Next: Window Point,  Prev: Displaying Buffers,  Up: Windows
2613
2614 Choosing a Window for Display
2615 =============================
2616
2617 This section describes the basic facility that chooses a window to
2618 display a buffer in--`display-buffer'.  All the higher-level functions
2619 and commands use this subroutine.  Here we describe how to use
2620 `display-buffer' and how to customize it.
2621
2622  - Command: display-buffer buffer-or-name &optional not-this-window
2623           override-frame
2624      This command makes BUFFER-OR-NAME appear in some window, like
2625      `pop-to-buffer', but it does not select that window and does not
2626      make the buffer current.  The identity of the selected window is
2627      unaltered by this function.
2628
2629      BUFFER-OR-NAME can be a buffer or the name of one.
2630
2631      If NOT-THIS-WINDOW is non-`nil', it means to display the specified
2632      buffer in a window other than the selected one, even if it is
2633      already on display in the selected window.  This can cause the
2634      buffer to appear in two windows at once.  Otherwise, if
2635      BUFFER-OR-NAME is already being displayed in any window, that is
2636      good enough, so this function does nothing.
2637
2638      If OVERRIDE-FRAME is non-`nil', display on that frame instead of
2639      the current frame (or the dedicated frame).
2640
2641      `display-buffer' returns the window chosen to display
2642      BUFFER-OR-NAME.
2643
2644      Precisely how `display-buffer' finds or creates a window depends on
2645      the variables described below.
2646
2647    A window can be marked as "dedicated" to a particular buffer.  Then
2648 XEmacs will not automatically change which buffer appears in the
2649 window, such as `display-buffer' might normally do.
2650
2651  - Function: window-dedicated-p window
2652      This function returns WINDOW's dedicated object, usually `t' or
2653      `nil'.
2654
2655  - Function: set-window-buffer-dedicated window buffer
2656      This function makes WINDOW display BUFFER and be dedicated to that
2657      buffer.  Then XEmacs will not automatically change which buffer
2658      appears in WINDOW.  If BUFFER is `nil', this function makes WINDOW
2659      not be dedicated (but doesn't change which buffer appears in it
2660      currently).
2661
2662  - User Option: pop-up-windows
2663      This variable controls whether `display-buffer' makes new windows.
2664      If it is non-`nil' and there is only one window, then that window
2665      is split.  If it is `nil', then `display-buffer' does not split
2666      the single window, but uses it whole.
2667
2668  - User Option: split-height-threshold
2669      This variable determines when `display-buffer' may split a window,
2670      if there are multiple windows.  `display-buffer' always splits the
2671      largest window if it has at least this many lines.  If the largest
2672      window is not this tall, it is split only if it is the sole window
2673      and `pop-up-windows' is non-`nil'.
2674
2675  - User Option: pop-up-frames
2676      This variable controls whether `display-buffer' makes new frames.
2677      If it is non-`nil', `display-buffer' looks for an existing window
2678      already displaying the desired buffer, on any visible frame.  If
2679      it finds one, it returns that window.  Otherwise it makes a new
2680      frame.  The variables `pop-up-windows' and
2681      `split-height-threshold' do not matter if `pop-up-frames' is
2682      non-`nil'.
2683
2684      If `pop-up-frames' is `nil', then `display-buffer' either splits a
2685      window or reuses one.
2686
2687      *Note Frames::, for more information.
2688
2689  - Variable: pop-up-frame-function
2690      This variable specifies how to make a new frame if `pop-up-frames'
2691      is non-`nil'.
2692
2693      Its value should be a function of no arguments.  When
2694      `display-buffer' makes a new frame, it does so by calling that
2695      function, which should return a frame.  The default value of the
2696      variable is a function that creates a frame using properties from
2697      `pop-up-frame-plist'.
2698
2699  - Variable: pop-up-frame-plist
2700      This variable holds a plist specifying frame properties used when
2701      `display-buffer' makes a new frame.  *Note Frame Properties::, for
2702      more information about frame properties.
2703
2704  - Variable: special-display-buffer-names
2705      A list of buffer names for buffers that should be displayed
2706      specially.  If the buffer's name is in this list, `display-buffer'
2707      handles the buffer specially.
2708
2709      By default, special display means to give the buffer a dedicated
2710      frame.
2711
2712      If an element is a list, instead of a string, then the CAR of the
2713      list is the buffer name, and the rest of the list says how to
2714      create the frame.  There are two possibilities for the rest of the
2715      list.  It can be a plist, specifying frame properties, or it can
2716      contain a function and arguments to give to it.  (The function's
2717      first argument is always the buffer to be displayed; the arguments
2718      from the list come after that.)
2719
2720  - Variable: special-display-regexps
2721      A list of regular expressions that specify buffers that should be
2722      displayed specially.  If the buffer's name matches any of the
2723      regular expressions in this list, `display-buffer' handles the
2724      buffer specially.
2725
2726      By default, special display means to give the buffer a dedicated
2727      frame.
2728
2729      If an element is a list, instead of a string, then the CAR of the
2730      list is the regular expression, and the rest of the list says how
2731      to create the frame.  See above, under
2732      `special-display-buffer-names'.
2733
2734  - Variable: special-display-function
2735      This variable holds the function to call to display a buffer
2736      specially.  It receives the buffer as an argument, and should
2737      return the window in which it is displayed.
2738
2739      The default value of this variable is
2740      `special-display-popup-frame'.
2741
2742  - Function: special-display-popup-frame buffer
2743      This function makes BUFFER visible in a frame of its own.  If
2744      BUFFER is already displayed in a window in some frame, it makes
2745      the frame visible and raises it, to use that window.  Otherwise, it
2746      creates a frame that will be dedicated to BUFFER.
2747
2748      This function uses an existing window displaying BUFFER whether or
2749      not it is in a frame of its own; but if you set up the above
2750      variables in your init file, before BUFFER was created, then
2751      presumably the window was previously made by this function.
2752
2753  - User Option: special-display-frame-plist
2754      This variable holds frame properties for
2755      `special-display-popup-frame' to use when it creates a frame.
2756
2757  - Variable: same-window-buffer-names
2758      A list of buffer names for buffers that should be displayed in the
2759      selected window.  If the buffer's name is in this list,
2760      `display-buffer' handles the buffer by switching to it in the
2761      selected window.
2762
2763  - Variable: same-window-regexps
2764      A list of regular expressions that specify buffers that should be
2765      displayed in the selected window.  If the buffer's name matches
2766      any of the regular expressions in this list, `display-buffer'
2767      handles the buffer by switching to it in the selected window.
2768
2769  - Variable: display-buffer-function
2770      This variable is the most flexible way to customize the behavior of
2771      `display-buffer'.  If it is non-`nil', it should be a function
2772      that `display-buffer' calls to do the work.  The function should
2773      accept two arguments, the same two arguments that `display-buffer'
2774      received.  It should choose or create a window, display the
2775      specified buffer, and then return the window.
2776
2777      This hook takes precedence over all the other options and hooks
2778      described above.
2779
2780    A window can be marked as "dedicated" to its buffer.  Then
2781 `display-buffer' does not try to use that window.
2782
2783  - Function: window-dedicated-p window
2784      This function returns `t' if WINDOW is marked as dedicated;
2785      otherwise `nil'.
2786
2787  - Function: set-window-dedicated-p window flag
2788      This function marks WINDOW as dedicated if FLAG is non-`nil', and
2789      nondedicated otherwise.
2790
2791 \1f
2792 File: lispref.info,  Node: Window Point,  Next: Window Start,  Prev: Choosing Window,  Up: Windows
2793
2794 Windows and Point
2795 =================
2796
2797 Each window has its own value of point, independent of the value of
2798 point in other windows displaying the same buffer.  This makes it useful
2799 to have multiple windows showing one buffer.
2800
2801    * The window point is established when a window is first created; it
2802      is initialized from the buffer's point, or from the window point
2803      of another window opened on the buffer if such a window exists.
2804
2805    * Selecting a window sets the value of point in its buffer to the
2806      window's value of point.  Conversely, deselecting a window sets
2807      the window's value of point from that of the buffer.  Thus, when
2808      you switch between windows that display a given buffer, the point
2809      value for the selected window is in effect in the buffer, while
2810      the point values for the other windows are stored in those windows.
2811
2812    * As long as the selected window displays the current buffer, the
2813      window's point and the buffer's point always move together; they
2814      remain equal.
2815
2816    * *Note Positions::, for more details on buffer positions.
2817
2818    As far as the user is concerned, point is where the cursor is, and
2819 when the user switches to another buffer, the cursor jumps to the
2820 position of point in that buffer.
2821
2822  - Function: window-point &optional window
2823      This function returns the current position of point in WINDOW.
2824      For a non-selected window, this is the value point would have (in
2825      that window's buffer) if that window were selected.
2826
2827      When WINDOW is the selected window and its buffer is also the
2828      current buffer, the value returned is the same as the value of
2829      point in that buffer.
2830
2831      Strictly speaking, it would be more correct to return the
2832      "top-level" value of point, outside of any `save-excursion' forms.
2833      But that value is hard to find.
2834
2835  - Function: set-window-point window position
2836      This function positions point in WINDOW at position POSITION in
2837      WINDOW's buffer.
2838
2839 \1f
2840 File: lispref.info,  Node: Window Start,  Next: Vertical Scrolling,  Prev: Window Point,  Up: Windows
2841
2842 The Window Start Position
2843 =========================
2844
2845 Each window contains a marker used to keep track of a buffer position
2846 that specifies where in the buffer display should start.  This position
2847 is called the "display-start" position of the window (or just the
2848 "start").  The character after this position is the one that appears at
2849 the upper left corner of the window.  It is usually, but not
2850 inevitably, at the beginning of a text line.
2851
2852  - Function: window-start &optional window
2853      This function returns the display-start position of window WINDOW.
2854      If WINDOW is `nil', the selected window is used.  For example,
2855
2856           (window-start)
2857                => 7058
2858
2859      When you create a window, or display a different buffer in it, the
2860      display-start position is set to a display-start position recently
2861      used for the same buffer, or 1 if the buffer doesn't have any.
2862
2863      For a realistic example, see the description of `count-lines' in
2864      *Note Text Lines::.
2865
2866  - Function: window-end &optional window guarantee
2867      This function returns the position of the end of the display in
2868      window WINDOW.  If WINDOW is `nil', the selected window is used.
2869
2870      Simply changing the buffer text or setting `window-start' does not
2871      update the value that `window-end' returns.  The value is updated
2872      only when Emacs redisplays and redisplay actually finishes.
2873
2874      If the last redisplay of WINDOW was preempted, and did not finish,
2875      Emacs does not know the position of the end of display in that
2876      window.  In that case, this function returns a value that is not
2877      correct.  In a future version, `window-end' will return `nil' in
2878      that case.
2879
2880      If optional arg GUARANTEE is non-`nil', the return value is
2881      guaranteed to be the same as `window-end' would return at the end
2882      of the next full redisplay assuming nothing else changes in the
2883      meantime.  This function is potentially much slower with this flag
2884      set.
2885
2886
2887  - Function: set-window-start window position &optional noforce
2888      This function sets the display-start position of WINDOW to
2889      POSITION in WINDOW's buffer.  It returns POSITION.
2890
2891      The display routines insist that the position of point be visible
2892      when a buffer is displayed.  Normally, they change the
2893      display-start position (that is, scroll the window) whenever
2894      necessary to make point visible.  However, if you specify the
2895      start position with this function using `nil' for NOFORCE, it
2896      means you want display to start at POSITION even if that would put
2897      the location of point off the screen.  If this does place point
2898      off screen, the display routines move point to the left margin on
2899      the middle line in the window.
2900
2901      For example, if point is 1 and you set the start of the window
2902      to 2, then point would be "above" the top of the window.  The
2903      display routines will automatically move point if it is still 1
2904      when redisplay occurs.  Here is an example:
2905
2906           ;; Here is what `foo' looks like before executing
2907           ;;   the `set-window-start' expression.
2908           
2909           ---------- Buffer: foo ----------
2910           -!-This is the contents of buffer foo.
2911           2
2912           3
2913           4
2914           5
2915           6
2916           ---------- Buffer: foo ----------
2917           
2918           (set-window-start
2919            (selected-window)
2920            (1+ (window-start)))
2921           => 2
2922           
2923           ;; Here is what `foo' looks like after executing
2924           ;;   the `set-window-start' expression.
2925           ---------- Buffer: foo ----------
2926           his is the contents of buffer foo.
2927           2
2928           3
2929           -!-4
2930           5
2931           6
2932           ---------- Buffer: foo ----------
2933
2934      If NOFORCE is non-`nil', and POSITION would place point off screen
2935      at the next redisplay, then redisplay computes a new window-start
2936      position that works well with point, and thus POSITION is not used.
2937
2938  - Function: pos-visible-in-window-p &optional position window
2939      This function returns `t' if POSITION is within the range of text
2940      currently visible on the screen in WINDOW.  It returns `nil' if
2941      POSITION is scrolled vertically out of view.  The argument
2942      POSITION defaults to the current position of point; WINDOW, to the
2943      selected window.  Here is an example:
2944
2945           (or (pos-visible-in-window-p
2946                (point) (selected-window))
2947               (recenter 0))
2948
2949      The `pos-visible-in-window-p' function considers only vertical
2950      scrolling.  If POSITION is out of view only because WINDOW has
2951      been scrolled horizontally, `pos-visible-in-window-p' returns `t'.
2952      *Note Horizontal Scrolling::.
2953
2954 \1f
2955 File: lispref.info,  Node: Vertical Scrolling,  Next: Horizontal Scrolling,  Prev: Window Start,  Up: Windows
2956
2957 Vertical Scrolling
2958 ==================
2959
2960 Vertical scrolling means moving the text up or down in a window.  It
2961 works by changing the value of the window's display-start location.  It
2962 may also change the value of `window-point' to keep it on the screen.
2963
2964    In the commands `scroll-up' and `scroll-down', the directions "up"
2965 and "down" refer to the motion of the text in the buffer at which you
2966 are looking through the window.  Imagine that the text is written on a
2967 long roll of paper and that the scrolling commands move the paper up
2968 and down.  Thus, if you are looking at text in the middle of a buffer
2969 and repeatedly call `scroll-down', you will eventually see the
2970 beginning of the buffer.
2971
2972    Some people have urged that the opposite convention be used: they
2973 imagine that the window moves over text that remains in place.  Then
2974 "down" commands would take you to the end of the buffer.  This view is
2975 more consistent with the actual relationship between windows and the
2976 text in the buffer, but it is less like what the user sees.  The
2977 position of a window on the terminal does not move, and short scrolling
2978 commands clearly move the text up or down on the screen.  We have chosen
2979 names that fit the user's point of view.
2980
2981    The scrolling functions (aside from `scroll-other-window') have
2982 unpredictable results if the current buffer is different from the buffer
2983 that is displayed in the selected window.  *Note Current Buffer::.
2984
2985  - Command: scroll-up &optional lines
2986      This function scrolls the text in the selected window upward LINES
2987      lines.  If LINES is negative, scrolling is actually downward.
2988
2989      If LINES is `nil' (or omitted), then the length of scroll is
2990      `next-screen-context-lines' lines less than the usable height of
2991      the window (not counting its modeline).
2992
2993      `scroll-up' returns `nil'.
2994
2995  - Command: scroll-down &optional lines
2996      This function scrolls the text in the selected window downward
2997      LINES lines.  If LINES is negative, scrolling is actually upward.
2998
2999      If LINES is omitted or `nil', then the length of the scroll is
3000      `next-screen-context-lines' lines less than the usable height of
3001      the window (not counting its mode line).
3002
3003      `scroll-down' returns `nil'.
3004
3005  - Command: scroll-other-window &optional lines
3006      This function scrolls the text in another window upward LINES
3007      lines.  Negative values of LINES, or `nil', are handled as in
3008      `scroll-up'.
3009
3010      You can specify a buffer to scroll with the variable
3011      `other-window-scroll-buffer'.  When the selected window is the
3012      minibuffer, the next window is normally the one at the top left
3013      corner.  You can specify a different window to scroll with the
3014      variable `minibuffer-scroll-window'.  This variable has no effect
3015      when any other window is selected.  *Note Minibuffer Misc::.
3016
3017      When the minibuffer is active, it is the next window if the
3018      selected window is the one at the bottom right corner.  In this
3019      case, `scroll-other-window' attempts to scroll the minibuffer.  If
3020      the minibuffer contains just one line, it has nowhere to scroll
3021      to, so the line reappears after the echo area momentarily displays
3022      the message "Beginning of buffer".
3023
3024  - Variable: other-window-scroll-buffer
3025      If this variable is non-`nil', it tells `scroll-other-window'
3026      which buffer to scroll.
3027
3028  - User Option: scroll-step
3029      This variable controls how scrolling is done automatically when
3030      point moves off the screen.  If the value is zero, then redisplay
3031      scrolls the text to center point vertically in the window.  If the
3032      value is a positive integer N, then redisplay brings point back on
3033      screen by scrolling N lines in either direction, if possible;
3034      otherwise, it centers point.  The default value is zero.
3035
3036  - User Option: scroll-conservatively
3037      This variable controls how many lines Emacs tries to scroll before
3038      recentering.  If you set it to a small number, then when you move
3039      point a short distance off the screen, XEmacs will scroll the
3040      screen just far enough to bring point back on screen, provided
3041      that does not exceed `scroll-conservatively' lines.  This variable
3042      overrides the redisplay preemption.
3043
3044  - User Option: next-screen-context-lines
3045      The value of this variable is the number of lines of continuity to
3046      retain when scrolling by full screens.  For example, `scroll-up'
3047      with an argument of `nil' scrolls so that this many lines at the
3048      bottom of the window appear instead at the top.  The default value
3049      is `2'.
3050
3051  - Command: recenter &optional location window
3052      This function scrolls WINDOW (which defaults to the selected
3053      window) to put the text where point is located at a specified
3054      vertical position within the window.
3055
3056      If LOCATION is a nonnegative number, it puts the line containing
3057      point LOCATION lines down from the top of the window.  If LOCATION
3058      is a negative number, then it counts upward from the bottom of the
3059      window, so that -1 stands for the last usable line in the window.
3060      If LOCATION is a non-`nil' list, then it stands for the line in
3061      the middle of the window.
3062
3063      If LOCATION is `nil', `recenter' puts the line containing point in
3064      the middle of the window, then clears and redisplays the entire
3065      selected frame.
3066
3067      When `recenter' is called interactively, LOCATION is the raw
3068      prefix argument.  Thus, typing `C-u' as the prefix sets the
3069      LOCATION to a non-`nil' list, while typing `C-u 4' sets LOCATION
3070      to 4, which positions the current line four lines from the top.
3071
3072      With an argument of zero, `recenter' positions the current line at
3073      the top of the window.  This action is so handy that some people
3074      make a separate key binding to do this.  For example,
3075
3076           (defun line-to-top-of-window ()
3077             "Scroll current line to top of window.
3078           Replaces three keystroke sequence C-u 0 C-l."
3079             (interactive)
3080             (recenter 0))
3081           
3082           (global-set-key [kp-multiply] 'line-to-top-of-window)
3083
3084 \1f
3085 File: lispref.info,  Node: Horizontal Scrolling,  Next: Size of Window,  Prev: Vertical Scrolling,  Up: Windows
3086
3087 Horizontal Scrolling
3088 ====================
3089
3090 Because we read English first from top to bottom and second from left
3091 to right, horizontal scrolling is not like vertical scrolling.  Vertical
3092 scrolling involves selection of a contiguous portion of text to display.
3093 Horizontal scrolling causes part of each line to go off screen.  The
3094 amount of horizontal scrolling is therefore specified as a number of
3095 columns rather than as a position in the buffer.  It has nothing to do
3096 with the display-start position returned by `window-start'.
3097
3098    Usually, no horizontal scrolling is in effect; then the leftmost
3099 column is at the left edge of the window.  In this state, scrolling to
3100 the right is meaningless, since there is no data to the left of the
3101 screen to be revealed by it; so this is not allowed.  Scrolling to the
3102 left is allowed; it scrolls the first columns of text off the edge of
3103 the window and can reveal additional columns on the right that were
3104 truncated before.  Once a window has a nonzero amount of leftward
3105 horizontal scrolling, you can scroll it back to the right, but only so
3106 far as to reduce the net horizontal scroll to zero.  There is no limit
3107 to how far left you can scroll, but eventually all the text will
3108 disappear off the left edge.
3109
3110  - Command: scroll-left &optional count
3111      This function scrolls the selected window COUNT columns to the
3112      left (or to the right if COUNT is negative).  The return value is
3113      the total amount of leftward horizontal scrolling in effect after
3114      the change--just like the value returned by `window-hscroll'
3115      (below).
3116
3117  - Command: scroll-right &optional count
3118      This function scrolls the selected window COUNT columns to the
3119      right (or to the left if COUNT is negative).  The return value is
3120      the total amount of leftward horizontal scrolling in effect after
3121      the change--just like the value returned by `window-hscroll'
3122      (below).
3123
3124      Once you scroll a window as far right as it can go, back to its
3125      normal position where the total leftward scrolling is zero,
3126      attempts to scroll any farther right have no effect.
3127
3128  - Function: window-hscroll &optional window
3129      This function returns the total leftward horizontal scrolling of
3130      WINDOW--the number of columns by which the text in WINDOW is
3131      scrolled left past the left margin.
3132
3133      The value is never negative.  It is zero when no horizontal
3134      scrolling has been done in WINDOW (which is usually the case).
3135
3136      If WINDOW is `nil', the selected window is used.
3137
3138           (window-hscroll)
3139                => 0
3140           (scroll-left 5)
3141                => 5
3142           (window-hscroll)
3143                => 5
3144
3145  - Function: set-window-hscroll window columns
3146      This function sets the number of columns from the left margin that
3147      WINDOW is scrolled to the value of COLUMNS.  The argument COLUMNS
3148      should be zero or positive; if not, it is taken as zero.
3149
3150      The value returned is COLUMNS.
3151
3152           (set-window-hscroll (selected-window) 10)
3153                => 10
3154
3155    Here is how you can determine whether a given position POSITION is
3156 off the screen due to horizontal scrolling:
3157
3158      (defun hscroll-on-screen (window position)
3159        (save-excursion
3160          (goto-char position)
3161          (and
3162           (>= (- (current-column) (window-hscroll window)) 0)
3163           (< (- (current-column) (window-hscroll window))
3164              (window-width window)))))
3165
3166 \1f
3167 File: lispref.info,  Node: Size of Window,  Next: Position of Window,  Prev: Horizontal Scrolling,  Up: Windows
3168
3169 The Size of a Window
3170 ====================
3171
3172 An Emacs window is rectangular, and its size information consists of
3173 the height (in lines or pixels) and the width (in character positions
3174 or pixels).  The modeline is included in the height.  The pixel width
3175 and height values include scrollbars and margins, while the
3176 line/character-position values do not.
3177
3178    Note that the height in lines, and the width in characters, are
3179 determined by dividing the corresponding pixel value by the height or
3180 width of the default font in that window (if this is a variable-width
3181 font, the average width is used).  The resulting values may or may not
3182 represent the actual number of lines in the window, or the actual number
3183 of character positions in any particular line, esp. if there are pixmaps
3184 or various different fonts in the window.
3185
3186    The following functions return size information about a window:
3187
3188  - Function: window-height &optional window
3189      This function returns the number of lines in WINDOW, including its
3190      modeline but not including the horizontal scrollbar, if any (this
3191      is different from `window-pixel-height').  If WINDOW is `nil', the
3192      function uses the selected window.
3193
3194           (window-height)
3195                => 40
3196           (split-window-vertically)
3197                => #<window on "windows.texi" 0x679b>
3198           (window-height)
3199                => 20
3200
3201  - Function: window-width &optional window
3202      This function returns the number of columns in WINDOW, not
3203      including any left margin, right margin, or vertical scrollbar
3204      (this is different from `window-pixel-width').  If WINDOW is
3205      `nil', the function uses the selected window.
3206
3207           (window-width)
3208                => 80
3209           (window-height)
3210                => 40
3211           (split-window-horizontally)
3212                => #<window on "windows.texi" 0x7538>
3213           (window-width)
3214                => 39
3215
3216    Note that after splitting the window into two side-by-side windows,
3217 the width of each window is less the half the width of the original
3218 window because a vertical scrollbar appeared between the windows,
3219 occupying two columns worth of space.  Also, the height shrunk by one
3220 because horizontal scrollbars appeared that weren't there before.
3221 (Horizontal scrollbars appear only when lines are truncated, not when
3222 they wrap.  This is usually the case for horizontally split windows but
3223 not for full-frame windows.  You can change this using the variables
3224 `truncate-lines' and `truncate-partial-width-windows'.)
3225
3226  - Function: window-pixel-height &optional window
3227      This function returns the height of WINDOW in pixels, including
3228      its modeline and horizontal scrollbar, if any.  If WINDOW is
3229      `nil', the function uses the selected window.
3230
3231           (window-pixel-height)
3232                => 600
3233           (split-window-vertically)
3234                => #<window on "windows.texi" 0x68a6>
3235           (window-pixel-height)
3236                => 300
3237
3238  - Function: window-pixel-width &optional window
3239      This function returns the width of WINDOW in pixels, including any
3240      left margin, right margin, or vertical scrollbar that may be
3241      displayed alongside it.  If WINDOW is `nil', the function uses the
3242      selected window.
3243
3244           (window-pixel-width)
3245                => 735
3246           (window-pixel-height)
3247                => 600
3248           (split-window-horizontally)
3249                => #<window on "windows.texi" 0x7538>
3250           (window-pixel-width)
3251                => 367
3252           (window-pixel-height)
3253                => 600
3254
3255  - Function: window-text-area-pixel-height &optional window
3256      This function returns the height in pixels of the text displaying
3257      portion of WINDOW, which defaults to the selected window.  Unlike
3258      `window-pixel-height', the space occupied by the modeline and
3259      horizontal scrollbar, if any, is not counted.
3260
3261  - Function: window-text-area-pixel-width &optional window
3262      This function returns the width in pixels of the text displaying
3263      portion of WINDOW, which defaults to the selected window.  Unlike
3264      `window-pixel-width', the space occupied by the vertical scrollbar
3265      and divider, if any, is not counted.
3266
3267  - Function: window-displayed-text-pixel-height &optional window
3268           noclipped
3269      This function returns the height in pixels of the text displayed in
3270      WINDOW, which defaults to the selected window.  Unlike
3271      `window-text-area-pixel-height', any blank space below the end of
3272      the buffer is not included.  If optional argument NOCLIPPED is
3273      non-`nil', any space occupied by clipped lines will not be
3274      included.
3275
3276 \1f
3277 File: lispref.info,  Node: Position of Window,  Next: Resizing Windows,  Prev: Size of Window,  Up: Windows
3278
3279 The Position of a Window
3280 ========================
3281
3282 XEmacs provides functions to determine the absolute location of windows
3283 within a frame, and the relative location of a window in comparison to
3284 other windows in the same frame.
3285
3286  - Function: window-pixel-edges &optional window
3287      This function returns a list of the pixel edge coordinates of
3288      WINDOW.  If WINDOW is `nil', the selected window is used.
3289
3290      The order of the list is `(LEFT TOP RIGHT BOTTOM)', all elements
3291      relative to 0, 0 at the top left corner of WINDOW's frame.  The
3292      element RIGHT of the value is one more than the rightmost pixel
3293      used by WINDOW (including any left margin, right margin, or
3294      vertical scrollbar displayed alongside it), and BOTTOM is one more
3295      than the bottommost pixel used by WINDOW (including any modeline
3296      or horizontal scrollbar displayed above or below it).  The frame
3297      area does not include any frame menubars, toolbars, or gutters
3298      that may be displayed; thus, for example, if there is only one
3299      window on the frame, the values for LEFT and TOP will always be 0.
3300
3301      If WINDOW is at the upper left corner of its frame, RIGHT and
3302      BOTTOM are the same as the values returned by
3303      `(window-pixel-width)' and `(window-pixel-height)' respectively,
3304      and LEFT and TOP are zero.
3305
3306    There is no longer a function `window-edges' because it does not
3307 make sense in a world with variable-width and variable-height lines, as
3308 are allowed in XEmacs.
3309
3310  - Function: window-highest-p window
3311      This function returns non-`nil' if WINDOW is along the top of its
3312      frame.
3313
3314  - Function: window-lowest-p window
3315      This function returns non-`nil' if WINDOW is along the bottom of
3316      its frame.
3317
3318  - Function: window-text-area-pixel-edges &optional window
3319      This function allows one to determine the location of the
3320      text-displaying portion of WINDOW, which defaults to the selected
3321      window, with respect to the top left corner of the window.  It
3322      returns a list of integer pixel positions `(left top right
3323      bottom)', all relative to `(0,0)' at the top left corner of the
3324      window.
3325
3326 \1f
3327 File: lispref.info,  Node: Resizing Windows,  Next: Window Configurations,  Prev: Position of Window,  Up: Windows
3328
3329 Changing the Size of a Window
3330 =============================
3331
3332 The window size functions fall into two classes: high-level commands
3333 that change the size of windows and low-level functions that access
3334 window size.  XEmacs does not permit overlapping windows or gaps between
3335 windows, so resizing one window affects other windows.
3336
3337  - Command: enlarge-window count &optional horizontal window
3338      This function makes the selected window COUNT lines taller,
3339      stealing lines from neighboring windows.  It takes the lines from
3340      one window at a time until that window is used up, then takes from
3341      another.  If a window from which lines are stolen shrinks below
3342      `window-min-height' lines, that window disappears.
3343
3344      If HORIZONTAL is non-`nil', this function makes WINDOW wider by
3345      COUNT columns, stealing columns instead of lines.  If a window
3346      from which columns are stolen shrinks below `window-min-width'
3347      columns, that window disappears.
3348
3349      If the requested size would exceed that of the window's frame,
3350      then the function makes the window occupy the entire height (or
3351      width) of the frame.
3352
3353      If COUNT is negative, this function shrinks the window by -COUNT
3354      lines or columns.  If that makes the window smaller than the
3355      minimum size (`window-min-height' and `window-min-width'),
3356      `enlarge-window' deletes the window.
3357
3358      If WINDOW is non-`nil', it specifies a window to change instead of
3359      the selected window.
3360
3361      `enlarge-window' returns `nil'.
3362
3363  - Command: enlarge-window-horizontally columns
3364      This function makes the selected window COLUMNS wider.  It could
3365      be defined as follows:
3366
3367           (defun enlarge-window-horizontally (columns)
3368             (enlarge-window columns t))
3369
3370  - Command: enlarge-window-pixels count &optional side window
3371      This function makes the selected window COUNT pixels larger.  When
3372      called from Lisp, optional second argument SIDE non-`nil' means to
3373      grow sideways COUNT pixels, and optional third argument WINDOW
3374      specifies the window to change instead of the selected window.
3375
3376  - Command: shrink-window count &optional horizontal window
3377      This function is like `enlarge-window' but negates the argument
3378      COUNT, making the selected window smaller by giving lines (or
3379      columns) to the other windows.  If the window shrinks below
3380      `window-min-height' or `window-min-width', then it disappears.
3381
3382      If COUNT is negative, the window is enlarged by -COUNT lines or
3383      columns.
3384
3385      If WINDOW is non-`nil', it specifies a window to change instead of
3386      the selected window.
3387
3388  - Command: shrink-window-horizontally columns
3389      This function makes the selected window COLUMNS narrower.  It
3390      could be defined as follows:
3391
3392           (defun shrink-window-horizontally (columns)
3393             (shrink-window columns t))
3394
3395  - Command: shrink-window-pixels count &optional side window
3396      This function makes the selected window COUNT pixels smaller.
3397      When called from Lisp, optional second argument SIDE non-`nil'
3398      means to shrink sideways COUNT pixels, and optional third argument
3399      WINDOW specifies the window to change instead of the selected
3400      window.
3401
3402    The following two variables constrain the window-size-changing
3403 functions to a minimum height and width.
3404
3405  - User Option: window-min-height
3406      The value of this variable determines how short a window may become
3407      before it is automatically deleted.  Making a window smaller than
3408      `window-min-height' automatically deletes it, and no window may be
3409      created shorter than this.  The absolute minimum height is two
3410      (allowing one line for the mode line, and one line for the buffer
3411      display).  Actions that change window sizes reset this variable to
3412      two if it is less than two.  The default value is 4.
3413
3414  - User Option: window-min-width
3415      The value of this variable determines how narrow a window may
3416      become before it automatically deleted.  Making a window smaller
3417      than `window-min-width' automatically deletes it, and no window
3418      may be created narrower than this.  The absolute minimum width is
3419      one; any value below that is ignored.  The default value is 10.
3420
3421  - Variable: window-size-change-functions
3422      This variable holds a list of functions to be called if the size
3423      of any window changes for any reason.  The functions are called
3424      just once per redisplay, and just once for each frame on which
3425      size changes have occurred.
3426
3427      Each function receives the frame as its sole argument.  There is no
3428      direct way to find out which windows changed size, or precisely
3429      how; however, if your size-change function keeps track, after each
3430      change, of the windows that interest you, you can figure out what
3431      has changed by comparing the old size data with the new.
3432
3433      Creating or deleting windows counts as a size change, and therefore
3434      causes these functions to be called.  Changing the frame size also
3435      counts, because it changes the sizes of the existing windows.
3436
3437      It is not a good idea to use `save-window-excursion' in these
3438      functions, because that always counts as a size change, and it
3439      would cause these functions to be called over and over.  In most
3440      cases, `save-selected-window' is what you need here.
3441
3442 \1f
3443 File: lispref.info,  Node: Window Configurations,  Prev: Resizing Windows,  Up: Windows
3444
3445 Window Configurations
3446 =====================
3447
3448 A "window configuration" records the entire layout of a frame--all
3449 windows, their sizes, which buffers they contain, what part of each
3450 buffer is displayed, and the values of point and the mark.  You can
3451 bring back an entire previous layout by restoring a window
3452 configuration previously saved.
3453
3454    If you want to record all frames instead of just one, use a frame
3455 configuration instead of a window configuration.  *Note Frame
3456 Configurations::.
3457
3458  - Function: current-window-configuration &optional frame
3459      This function returns a new object representing the current window
3460      configuration of FRAME, namely the number of windows, their sizes
3461      and current buffers, which window is the selected window, and for
3462      each window the displayed buffer, the display-start position, and
3463      the positions of point and the mark.  An exception is made for
3464      point in the current buffer, whose value is not saved.
3465
3466      FRAME defaults to the selected frame.
3467
3468  - Function: set-window-configuration configuration
3469      This function restores the configuration of XEmacs's windows and
3470      buffers to the state specified by CONFIGURATION.  The argument
3471      CONFIGURATION must be a value that was previously returned by
3472      `current-window-configuration'.
3473
3474      This function always counts as a window size change and triggers
3475      execution of the `window-size-change-functions'.  (It doesn't know
3476      how to tell whether the new configuration actually differs from
3477      the old one.)
3478
3479      Here is a way of using this function to get the same effect as
3480      `save-window-excursion':
3481
3482           (let ((config (current-window-configuration)))
3483             (unwind-protect
3484                 (progn (split-window-vertically nil)
3485                        ...)
3486               (set-window-configuration config)))
3487
3488  - Special Form: save-window-excursion forms...
3489      This special form records the window configuration, executes FORMS
3490      in sequence, then restores the earlier window configuration.  The
3491      window configuration includes the value of point and the portion
3492      of the buffer that is visible.  It also includes the choice of
3493      selected window.  However, it does not include the value of point
3494      in the current buffer; use `save-excursion' if you wish to
3495      preserve that.
3496
3497      Don't use this construct when `save-selected-window' is all you
3498      need.
3499
3500      Exit from `save-window-excursion' always triggers execution of the
3501      `window-size-change-functions'.  (It doesn't know how to tell
3502      whether the restored configuration actually differs from the one in
3503      effect at the end of the FORMS.)
3504
3505      The return value is the value of the final form in FORMS.  For
3506      example:
3507
3508           (split-window)
3509                => #<window 25 on control.texi>
3510           (setq w (selected-window))
3511                => #<window 19 on control.texi>
3512           (save-window-excursion
3513             (delete-other-windows w)
3514             (switch-to-buffer "foo")
3515             'do-something)
3516                => do-something
3517                ;; The frame is now split again.
3518
3519  - Function: window-configuration-p object
3520      This function returns `t' if OBJECT is a window configuration.
3521
3522    Primitives to look inside of window configurations would make sense,
3523 but none are implemented.  It is not clear they are useful enough to be
3524 worth implementing.
3525
3526 \1f
3527 File: lispref.info,  Node: Frames,  Next: Consoles and Devices,  Prev: Windows,  Up: Top
3528
3529 Frames
3530 ******
3531
3532 A FRAME is a rectangle on the screen that contains one or more XEmacs
3533 windows (*note Windows::).  A frame initially contains a single main
3534 window (plus perhaps an echo area), which you can subdivide vertically
3535 or horizontally into smaller windows.  Each window is associated with a
3536 modeline (*note Modeline Format::), and optionally two scrollbars
3537 (*note Scrollbars::).  By default the vertical scrollbar is on, the
3538 horizontal scrollbar is off.
3539
3540    The frame may also contain menubars (*note Menubar::), toolbars
3541 (*note Toolbar Intro::), and gutters (*note Gutter Intro::).  By default
3542 there is one of each at the top of the frame, with menubar topmost,
3543 toolbar next, and gutter lowest, immediately above the windows.
3544 (Warning: the gutter is a new, experimental, and unstable feature of
3545 XEmacs version 21.2.)
3546
3547    When XEmacs runs on a text-only terminal, it starts with one "TTY
3548 frame".  If you create additional ones, XEmacs displays one and only
3549 one at any given time--on the terminal screen, of course.
3550
3551    When XEmacs communicates directly with an X server, it does not have
3552 a TTY frame; instead, it starts with a single "X window frame".  It can
3553 display multiple X window frames at the same time, each in its own X
3554 window.
3555
3556  - Function: framep object
3557      This predicate returns `t' if OBJECT is a frame, and `nil'
3558      otherwise.
3559
3560 * Menu:
3561
3562 * Creating Frames::             Creating additional frames.
3563 * Frame Properties::            Controlling frame size, position, font, etc.
3564 * Frame Titles::                Automatic updating of frame titles.
3565 * Deleting Frames::             Frames last until explicitly deleted.
3566 * Finding All Frames::          How to examine all existing frames.
3567 * Frames and Windows::          A frame contains windows;
3568                                   display of text always works through windows.
3569 * Minibuffers and Frames::      How a frame finds the minibuffer to use.
3570 * Input Focus::                 Specifying the selected frame.
3571 * Visibility of Frames::        Frames may be visible or invisible, or icons.
3572 * Raising and Lowering::        Raising a frame makes it hide other X windows;
3573                                   lowering it makes the others hide them.
3574 * Frame Configurations::        Saving the state of all frames.
3575 * Frame Hooks::                 Hooks for customizing frame behavior.
3576
3577    *Note Display::, for related information.
3578
3579 \1f
3580 File: lispref.info,  Node: Creating Frames,  Next: Frame Properties,  Up: Frames
3581
3582 Creating Frames
3583 ===============
3584
3585 To create a new frame, call the function `make-frame'.
3586
3587  - Command: make-frame &optional props device
3588      This function creates a new frame on DEVICE, if DEVICE permits
3589      creation of frames.  (An X server does; an ordinary terminal does
3590      not (yet).)  DEVICE defaults to the selected device if omitted.
3591      *Note Consoles and Devices::.
3592
3593      The argument PROPS is a property list (a list of alternating
3594      keyword-value specifications) of properties for the new frame. (An
3595      alist is accepted for backward compatibility but should not be
3596      passed in.) Any properties not mentioned in PROPS default
3597      according to the value of the variable `default-frame-plist'.  For
3598      X devices, properties not specified in `default-frame-plist'
3599      default in turn from `default-x-frame-plist' and, if not specified
3600      there, from the X resources.  For TTY devices,
3601      `default-tty-frame-plist' is consulted as well as
3602      `default-frame-plist'.
3603
3604      The set of possible properties depends in principle on what kind of
3605      window system XEmacs uses to display its frames.  *Note X Frame
3606      Properties::, for documentation of individual properties you can
3607      specify when creating an X window frame.
3608
3609 \1f
3610 File: lispref.info,  Node: Frame Properties,  Next: Frame Titles,  Prev: Creating Frames,  Up: Frames
3611
3612 Frame Properties
3613 ================
3614
3615 A frame has many properties that control its appearance and behavior.
3616 Just what properties a frame has depends on which display mechanism it
3617 uses.
3618
3619    Frame properties exist for the sake of window systems.  A terminal
3620 frame has few properties, mostly for compatibility's sake; only the
3621 height, width and `buffer-predicate' properties really do something.
3622
3623 * Menu:
3624
3625 * Property Access::     How to change a frame's properties.
3626 * Initial Properties::  Specifying frame properties when you make a frame.
3627 * X Frame Properties::  List of frame properties.
3628 * Size and Position::   Changing the size and position of a frame.
3629 * Frame Name::          The name of a frame (as opposed to its title).
3630
3631 \1f
3632 File: lispref.info,  Node: Property Access,  Next: Initial Properties,  Up: Frame Properties
3633
3634 Access to Frame Properties
3635 --------------------------
3636
3637 These functions let you read and change the properties of a frame.
3638
3639  - Function: frame-properties &optional frame
3640      This function returns a plist listing all the properties of FRAME
3641      and their values.
3642
3643  - Function: frame-property frame property &optional default
3644      This function returns FRAME's value for the property PROPERTY, or
3645      DEFAULT if there is no such property.
3646
3647  - Function: set-frame-properties frame plist
3648      This function alters the properties of frame FRAME based on the
3649      elements of property list PLIST.  If you don't mention a property
3650      in PLIST, its value doesn't change.
3651
3652  - Function: set-frame-property frame property value
3653      This function sets the property PROPERTY of frame FRAME to the
3654      value VALUE.
3655
3656 \1f
3657 File: lispref.info,  Node: Initial Properties,  Next: X Frame Properties,  Prev: Property Access,  Up: Frame Properties
3658
3659 Initial Frame Properties
3660 ------------------------
3661
3662 You can specify the properties for the initial startup frame by setting
3663 `initial-frame-plist' in your `.emacs' file.
3664
3665  - Variable: initial-frame-plist
3666      This variable's value is a plist of alternating property-value
3667      pairs used when creating the initial X window frame.
3668
3669      XEmacs creates the initial frame before it reads your `~/.emacs'
3670      file.  After reading that file, XEmacs checks
3671      `initial-frame-plist', and applies the property settings in the
3672      altered value to the already created initial frame.
3673
3674      If these settings affect the frame geometry and appearance, you'll
3675      see the frame appear with the wrong ones and then change to the
3676      specified ones.  If that bothers you, you can specify the same
3677      geometry and appearance with X resources; those do take affect
3678      before the frame is created.  *Note X Resources: (xemacs)Resources
3679      X.
3680
3681      X resource settings typically apply to all frames.  If you want to
3682      specify some X resources solely for the sake of the initial frame,
3683      and you don't want them to apply to subsequent frames, here's how
3684      to achieve this: specify properties in `default-frame-plist' to
3685      override the X resources for subsequent frames; then, to prevent
3686      these from affecting the initial frame, specify the same
3687      properties in `initial-frame-plist' with values that match the X
3688      resources.
3689
3690    If these properties specify a separate minibuffer-only frame via a
3691 `minibuffer' property of `nil', and you have not yet created one,
3692 XEmacs creates one for you.
3693
3694  - Variable: minibuffer-frame-plist
3695      This variable's value is a plist of properties used when creating
3696      an initial minibuffer-only frame--if such a frame is needed,
3697      according to the properties for the main initial frame.
3698
3699  - Variable: default-frame-plist
3700      This is a plist specifying default values of frame properties for
3701      subsequent XEmacs frames (not the initial ones).
3702
3703    See also `special-display-frame-plist', in *Note Choosing Window::.
3704
3705    If you use options that specify window appearance when you invoke
3706 XEmacs, they take effect by adding elements to `default-frame-plist'.
3707 One exception is `-geometry', which adds the specified position to
3708 `initial-frame-plist' instead.  *Note Command Arguments:
3709 (xemacs)Command Arguments.
3710
3711 \1f
3712 File: lispref.info,  Node: X Frame Properties,  Next: Size and Position,  Prev: Initial Properties,  Up: Frame Properties
3713
3714 X Window Frame Properties
3715 -------------------------
3716
3717 Just what properties a frame has depends on what display mechanism it
3718 uses.  Here is a table of the properties of an X window frame; of these,
3719 `name', `height', `width', and `buffer-predicate' provide meaningful
3720 information in non-X frames.
3721
3722 `name'
3723      The name of the frame.  Most window managers display the frame's
3724      name in the frame's border, at the top of the frame.  If you don't
3725      specify a name, and you have more than one frame, XEmacs sets the
3726      frame name based on the buffer displayed in the frame's selected
3727      window.
3728
3729      If you specify the frame name explicitly when you create the
3730      frame, the name is also used (instead of the name of the XEmacs
3731      executable) when looking up X resources for the frame.
3732
3733 `display'
3734      The display on which to open this frame.  It should be a string of
3735      the form `"HOST:DPY.SCREEN"', just like the `DISPLAY' environment
3736      variable.
3737
3738 `left'
3739      The screen position of the left edge, in pixels, with respect to
3740      the left edge of the screen.  The value may be a positive number
3741      POS, or a list of the form `(+ POS)' which permits specifying a
3742      negative POS value.
3743
3744      A negative number -POS, or a list of the form `(- POS)', actually
3745      specifies the position of the right edge of the window with
3746      respect to the right edge of the screen.  A positive value of POS
3747      counts toward the left.  If the property is a negative integer
3748      -POS then POS is positive!
3749
3750 `top'
3751      The screen position of the top edge, in pixels, with respect to the
3752      top edge of the screen.  The value may be a positive number POS,
3753      or a list of the form `(+ POS)' which permits specifying a
3754      negative POS value.
3755
3756      A negative number -POS, or a list of the form `(- POS)', actually
3757      specifies the position of the bottom edge of the window with
3758      respect to the bottom edge of the screen.  A positive value of POS
3759      counts toward the top.  If the property is a negative integer -POS
3760      then POS is positive!
3761
3762 `icon-left'
3763      The screen position of the left edge _of the frame's icon_, in
3764      pixels, counting from the left edge of the screen.  This takes
3765      effect if and when the frame is iconified.
3766
3767 `icon-top'
3768      The screen position of the top edge _of the frame's icon_, in
3769      pixels, counting from the top edge of the screen.  This takes
3770      effect if and when the frame is iconified.
3771
3772 `user-position'
3773      Non-`nil' if the screen position of the frame was explicitly
3774      requested by the user (for example, with the `-geometry' option).
3775      Nothing automatically makes this property non-`nil'; it is up to
3776      Lisp programs that call `make-frame' to specify this property as
3777      well as specifying the `left' and `top' properties.
3778
3779 `height'
3780      The height of the frame contents, in characters.  (To get the
3781      height in pixels, call `frame-pixel-height'; see *Note Size and
3782      Position::.)
3783
3784 `width'
3785      The width of the frame contents, in characters.  (To get the
3786      height in pixels, call `frame-pixel-width'; see *Note Size and
3787      Position::.)
3788
3789 `window-id'
3790      The number of the X window for the frame.
3791
3792 `minibuffer'
3793      Whether this frame has its own minibuffer.  The value `t' means
3794      yes, `nil' means no, `only' means this frame is just a minibuffer.
3795      If the value is a minibuffer window (in some other frame), the
3796      new frame uses that minibuffer. (Minibuffer-only and
3797      minibuffer-less frames are not yet implemented in XEmacs.)
3798
3799 `buffer-predicate'
3800      The buffer-predicate function for this frame.  The function
3801      `other-buffer' uses this predicate (from the selected frame) to
3802      decide which buffers it should consider, if the predicate is not
3803      `nil'.  It calls the predicate with one arg, a buffer, once for
3804      each buffer; if the predicate returns a non-`nil' value, it
3805      considers that buffer.
3806
3807 `scroll-bar-width'
3808      The width of the vertical scroll bar, in pixels.
3809
3810 `cursor-color'
3811      The color for the cursor that shows point.
3812
3813 `border-color'
3814      The color for the border of the frame.
3815
3816 `border-width'
3817      The width in pixels of the window border.
3818
3819 `internal-border-width'
3820      The distance in pixels between text and border.
3821
3822 `unsplittable'
3823      If non-`nil', this frame's window is never split automatically.
3824
3825 `inter-line-space'
3826      The space in pixels between adjacent lines of text. (Not currently
3827      implemented.)
3828
3829 `modeline'
3830      Whether the frame has a modeline.
3831
3832 \1f
3833 File: lispref.info,  Node: Size and Position,  Next: Frame Name,  Prev: X Frame Properties,  Up: Frame Properties
3834
3835 Frame Size And Position
3836 -----------------------
3837
3838 You can read or change the size and position of a frame using the frame
3839 properties `left', `top', `height', and `width'.  Whatever geometry
3840 properties you don't specify are chosen by the window manager in its
3841 usual fashion.
3842
3843    Here are some special features for working with sizes and positions:
3844
3845  - Function: set-frame-position frame left top
3846      This function sets the position of the top left corner of FRAME to
3847      LEFT and TOP.  These arguments are measured in pixels, and count
3848      from the top left corner of the screen.  Negative property values
3849      count up or rightward from the top left corner of the screen.
3850
3851  - Function: frame-height &optional frame
3852  - Function: frame-width &optional frame
3853      These functions return the height and width of FRAME, measured in
3854      lines and columns.  If you don't supply FRAME, they use the
3855      selected frame.
3856
3857  - Function: frame-pixel-height &optional frame
3858  - Function: frame-pixel-width &optional frame
3859      These functions return the height and width of FRAME, measured in
3860      pixels.  If you don't supply FRAME, they use the selected frame.
3861
3862  - Function: set-frame-size frame cols rows &optional pretend
3863      This function sets the size of FRAME, measured in characters; COLS
3864      and ROWS specify the new width and height.  (If PRETEND is
3865      non-`nil', it means that redisplay should act as if the frame's
3866      size is COLS by ROWS, but the actual size of the frame should not
3867      be changed.  You should not normally use this option.)
3868
3869    You can also use the functions `set-frame-height' and
3870 `set-frame-width' to set the height and width individually.  The frame
3871 is the first argument and the size (in rows or columns) is the second.
3872 (There is an optional third argument, PRETEND, which has the same
3873 purpose as the corresponding argument in `set-frame-size'.)
3874
3875 \1f
3876 File: lispref.info,  Node: Frame Name,  Prev: Size and Position,  Up: Frame Properties
3877
3878 The Name of a Frame (As Opposed to Its Title)
3879 ---------------------------------------------
3880
3881 Under X, every frame has a name, which is not the same as the title of
3882 the frame.  A frame's name is used to look up its resources and does
3883 not normally change over the lifetime of a frame.  It is perfectly
3884 allowable, and quite common, for multiple frames to have the same name.
3885
3886  - Function: frame-name &optional frame
3887      This function returns the name of FRAME, which defaults to the
3888      selected frame if not specified.  The name of a frame can also be
3889      obtained from the frame's properties.  *Note Frame Properties::.
3890
3891  - Variable: default-frame-name
3892      This variable holds the default name to assign to newly-created
3893      frames.  This can be overridden by arguments to `make-frame'.  This
3894      must be a string.
3895
3896 \1f
3897 File: lispref.info,  Node: Frame Titles,  Next: Deleting Frames,  Prev: Frame Properties,  Up: Frames
3898
3899 Frame Titles
3900 ============
3901
3902 Every frame has a title; most window managers display the frame title at
3903 the top of the frame.  You can specify an explicit title with the
3904 `name' frame property.  But normally you don't specify this explicitly,
3905 and XEmacs computes the title automatically.
3906
3907    XEmacs computes the frame title based on a template stored in the
3908 variable `frame-title-format'.
3909
3910  - Variable: frame-title-format
3911      This variable specifies how to compute a title for a frame when
3912      you have not explicitly specified one.
3913
3914      The variable's value is actually a modeline construct, just like
3915      `modeline-format'.  *Note Modeline Data::.
3916
3917  - Variable: frame-icon-title-format
3918      This variable specifies how to compute the title for an iconified
3919      frame, when you have not explicitly specified the frame title.
3920      This title appears in the icon itself.
3921
3922  - Function: x-set-frame-icon-pixmap frame pixmap &optional mask
3923      This function sets the icon of the given frame to the given image
3924      instance, which should be an image instance object (as returned by
3925      `make-image-instance'), a glyph object (as returned by
3926      `make-glyph'), or `nil'.  If a glyph object is given, the glyph
3927      will be instantiated on the frame to produce an image instance
3928      object.
3929
3930      If the given image instance has a mask, that will be used as the
3931      icon mask; however, not all window managers support this.
3932
3933      The window manager is also not required to support color pixmaps,
3934      only bitmaps (one plane deep).
3935
3936      If the image instance does not have a mask, then the optional
3937      third argument may be the image instance to use as the mask (it
3938      must be one plane deep).  *Note Glyphs::.
3939
3940 \1f
3941 File: lispref.info,  Node: Deleting Frames,  Next: Finding All Frames,  Prev: Frame Titles,  Up: Frames
3942
3943 Deleting Frames
3944 ===============
3945
3946 Frames remain potentially visible until you explicitly "delete" them.
3947 A deleted frame cannot appear on the screen, but continues to exist as
3948 a Lisp object until there are no references to it.
3949
3950  - Command: delete-frame &optional frame force
3951      This function deletes the frame FRAME.  By default, FRAME is the
3952      selected frame.
3953
3954      A frame may not be deleted if its minibuffer is used by other
3955      frames.  Normally, you cannot delete the last non-minibuffer-only
3956      frame (you must use `save-buffers-kill-emacs' or `kill-emacs').
3957      However, if optional second argument FORCE is non-`nil', you can
3958      delete the last frame. (This will automatically call
3959      `save-buffers-kill-emacs'.)
3960
3961  - Function: frame-live-p frame
3962      The function `frame-live-p' returns non-`nil' if the frame FRAME
3963      has not been deleted.
3964
3965 \1f
3966 File: lispref.info,  Node: Finding All Frames,  Next: Frames and Windows,  Prev: Deleting Frames,  Up: Frames
3967
3968 Finding All Frames
3969 ==================
3970
3971  - Function: frame-list
3972      The function `frame-list' returns a list of all the frames that
3973      have not been deleted.  It is analogous to `buffer-list' for
3974      buffers.  The list that you get is newly created, so modifying the
3975      list doesn't have any effect on the internals of XEmacs.
3976
3977  - Function: device-frame-list &optional device
3978      This function returns a list of all frames on DEVICE.  If DEVICE
3979      is `nil', the selected device will be used.
3980
3981  - Function: visible-frame-list &optional device
3982      This function returns a list of just the currently visible frames.
3983      If DEVICE is specified only frames on that device will be returned.
3984      *Note Visibility of Frames::.  (TTY frames always count as
3985      "visible", even though only the selected one is actually
3986      displayed.)
3987
3988  - Function: next-frame &optional frame which-frames which-devices
3989      The function `next-frame' lets you cycle conveniently through all
3990      the frames from an arbitrary starting point.  It returns the "next"
3991      frame after FRAME in the cycle.  If FRAME defaults to the selected
3992      frame.
3993
3994      The second argument, WHICH-FRAMES, says which frames to consider:
3995
3996     `visible'
3997           Consider only frames that are visible.
3998
3999     `iconic'
4000           Consider only frames that are iconic.
4001
4002     `invisible'
4003           Consider only frames that are invisible (this is different
4004           from iconic).
4005
4006     `visible-iconic'
4007           Consider frames that are visible or iconic.
4008
4009     `invisible-iconic'
4010           Consider frames that are invisible or iconic.
4011
4012     `nomini'
4013           Consider all frames except minibuffer-only ones.
4014
4015     `visible-nomini'
4016           Like `visible' but omits minibuffer-only frames.
4017
4018     `iconic-nomini'
4019           Like `iconic' but omits minibuffer-only frames.
4020
4021     `invisible-nomini'
4022           Like `invisible' but omits minibuffer-only frames.
4023
4024     `visible-iconic-nomini'
4025           Like `visible-iconic' but omits minibuffer-only frames.
4026
4027     `invisible-iconic-nomini'
4028           Like `invisible-iconic' but omits minibuffer-only frames.
4029
4030     `nil'
4031           Identical to `nomini'.
4032
4033     WINDOW
4034           Consider only the window WINDOW's frame and any frame now
4035           using WINDOW as the minibuffer.
4036
4037     any other value
4038           Consider all frames.
4039
4040      The optional argument WHICH-DEVICES further clarifies on which
4041      devices to search for frames as specified by WHICH-FRAMES.
4042
4043     `nil'
4044           Consider all devices on the selected console.
4045
4046     DEVICE
4047           Consider only the one device DEVICE.
4048
4049     CONSOLE
4050           Consider all devices on CONSOLE.
4051
4052     DEVICE-TYPE
4053           Consider all devices with device type DEVICE-TYPE.
4054
4055     `window-system'
4056           Consider all devices on window system consoles.
4057
4058     anything else
4059           Consider all devices without restriction.
4060
4061  - Function: previous-frame &optional frame which-frames which-devices
4062      Like `next-frame', but cycles through all frames in the opposite
4063      direction.
4064
4065    See also `next-window' and `previous-window', in *Note Cyclic Window
4066 Ordering::.
4067
4068 \1f
4069 File: lispref.info,  Node: Frames and Windows,  Next: Minibuffers and Frames,  Prev: Finding All Frames,  Up: Frames
4070
4071 Frames and Windows
4072 ==================
4073
4074 Each window is part of one and only one frame; you can get the frame
4075 with `window-frame'.
4076
4077  - Function: frame-root-window &optional frame
4078      This returns the root window of frame FRAME.  FRAME defaults to
4079      the selected frame if not specified.
4080
4081  - Function: window-frame &optional window
4082      This function returns the frame that WINDOW is on.  WINDOW
4083      defaults to the selected window if omitted.
4084
4085    All the non-minibuffer windows in a frame are arranged in a cyclic
4086 order.  The order runs from the frame's top window, which is at the
4087 upper left corner, down and to the right, until it reaches the window at
4088 the lower right corner (always the minibuffer window, if the frame has
4089 one), and then it moves back to the top.
4090
4091  - Function: frame-highest-window &optional frame position
4092      This function returns the topmost, leftmost window of frame FRAME
4093      at position POSITION.
4094
4095      If omitted, FRAME defaults to the currently selected frame.
4096
4097      POSITION is used to distinguish between multiple windows that abut
4098      the top of the frame: 0 means the leftmost window abutting the top
4099      of the frame, 1 the next-leftmost, etc.  POSITION can also be less
4100      than zero: -1 means the rightmost window abutting the top of the
4101      frame, -2 the next-rightmost, etc.  If omitted, POSITION defaults
4102      to 0, i.e. the leftmost highest window.  If there is no window at
4103      the given POSITION, `nil' is returned.
4104
4105    The following three functions work similarly.
4106
4107  - Function: frame-lowest-window &optional frame position
4108      This function returns the lowest window on FRAME which is at
4109      POSITION.
4110
4111  - Function: frame-leftmost-window &optional frame position
4112      This function returns the leftmost window on FRAME which is at
4113      POSITION.
4114
4115  - Function: frame-rightmost-window &optional frame position
4116      This function returns the rightmost window on FRAME which is at
4117      POSITION.
4118
4119    At any time, exactly one window on any frame is "selected within the
4120 frame".  The significance of this designation is that selecting the
4121 frame also selects this window.  You can get the frame's current
4122 selected window with `frame-selected-window'.
4123
4124  - Function: frame-selected-window &optional frame
4125      This function returns the window on FRAME that is selected within
4126      FRAME.  FRAME defaults to the selected frame if not specified.
4127
4128    Conversely, selecting a window for XEmacs with `select-window' also
4129 makes that window selected within its frame.  *Note Selecting Windows::.
4130
4131    Another function that (usually) returns one of the windows in a
4132 frame is `minibuffer-window'.  *Note Minibuffer Misc::.
4133
4134 \1f
4135 File: lispref.info,  Node: Minibuffers and Frames,  Next: Input Focus,  Prev: Frames and Windows,  Up: Frames
4136
4137 Minibuffers and Frames
4138 ======================
4139
4140 Normally, each frame has its own minibuffer window at the bottom, which
4141 is used whenever that frame is selected.  If the frame has a minibuffer,
4142 you can get it with `minibuffer-window' (*note Minibuffer Misc::).
4143
4144    However, you can also create a frame with no minibuffer.  Such a
4145 frame must use the minibuffer window of some other frame.  When you
4146 create the frame, you can specify explicitly the minibuffer window to
4147 use (in some other frame).  If you don't, then the minibuffer is found
4148 in the frame which is the value of the variable
4149 `default-minibuffer-frame'.  Its value should be a frame which does
4150 have a minibuffer.
4151
4152  - Variable: default-minibuffer-frame
4153      This variable specifies the frame to use for the minibuffer
4154      window, by default.
4155
4156 \1f
4157 File: lispref.info,  Node: Input Focus,  Next: Visibility of Frames,  Prev: Minibuffers and Frames,  Up: Frames
4158
4159 Input Focus
4160 ===========
4161
4162 At any time, one frame in XEmacs is the "selected frame".  The selected
4163 window always resides on the selected frame.  As the focus moves from
4164 device to device, the selected frame on each device is remembered and
4165 restored when the focus moves back to that device.
4166
4167  - Function: selected-frame &optional device
4168      This function returns the selected frame on DEVICE.  If DEVICE is
4169      not specified, the selected device will be used.  If no frames
4170      exist on the device, `nil' is returned.
4171
4172    The X server normally directs keyboard input to the X window that the
4173 mouse is in.  Some window managers use mouse clicks or keyboard events
4174 to "shift the focus" to various X windows, overriding the normal
4175 behavior of the server.
4176
4177    Lisp programs can switch frames "temporarily" by calling the
4178 function `select-frame'.  This does not override the window manager;
4179 rather, it escapes from the window manager's control until that control
4180 is somehow reasserted.
4181
4182    When using a text-only terminal, there is no window manager;
4183 therefore, `select-frame' is the only way to switch frames, and the
4184 effect lasts until overridden by a subsequent call to `select-frame'.
4185 Only the selected terminal frame is actually displayed on the terminal.
4186 Each terminal screen except for the initial one has a number, and the
4187 number of the selected frame appears in the mode line after the word
4188 `XEmacs' (*note Modeline Variables::).
4189
4190  - Function: select-frame frame
4191      This function selects frame FRAME, temporarily disregarding the
4192      focus of the X server if any.  The selection of FRAME lasts until
4193      the next time the user does something to select a different frame,
4194      or until the next time this function is called.
4195
4196      Note that `select-frame' does not actually cause the window-system
4197      focus to be set to this frame, or the `select-frame-hook' or
4198      `deselect-frame-hook' to be run, until the next time that XEmacs is
4199      waiting for an event.
4200
4201      Also note that when the variable `focus-follows-mouse' is
4202      non-`nil', the frame selection is temporary and is reverted when
4203      the current command terminates, much like the buffer selected by
4204      `set-buffer'.  In order to effect a permanent focus change use
4205      `focus-frame'.
4206
4207  - Function: focus-frame frame
4208      This function selects FRAME and gives it the window system focus.
4209      The operation of `focus-frame' is not affected by the value of
4210      `focus-follows-mouse'.
4211
4212  - Special Form: save-selected-frame forms...
4213      This special form records the selected frame, executes FORMS in
4214      sequence, then restores the earlier selected frame.  The value
4215      returned is the value of the last form.
4216
4217  - Special Form: with-selected-frame frame forms...
4218      This special form records the selected frame, then selects FRAME
4219      and executes FORMS in sequence.  After the last form is finished,
4220      the earlier selected frame is restored.  The value returned is the
4221      value of the last form.
4222
4223 \1f
4224 File: lispref.info,  Node: Visibility of Frames,  Next: Raising and Lowering,  Prev: Input Focus,  Up: Frames
4225
4226 Visibility of Frames
4227 ====================
4228
4229 An frame on a window system may be "visible", "invisible", or
4230 "iconified".  If it is visible, you can see its contents.  If it is
4231 iconified, the frame's contents do not appear on the screen, but an icon
4232 does.  If the frame is invisible, it doesn't show on the screen, not
4233 even as an icon.
4234
4235    Visibility is meaningless for TTY frames, since only the selected
4236 one is actually displayed in any case.
4237
4238  - Function: make-frame-visible &optional frame
4239      This function makes frame FRAME visible.  If you omit FRAME, it
4240      makes the selected frame visible.
4241
4242  - Function: make-frame-invisible &optional frame force
4243      This function makes frame FRAME invisible.
4244
4245  - Command: iconify-frame &optional frame
4246      This function iconifies frame FRAME.
4247
4248  - Function: Command deiconify-frame &optional frame
4249      This function de-iconifies frame FRAME.  Under a window system,
4250      this is equivalent to `make-frame-visible'.
4251
4252  - Function: frame-visible-p &optional frame
4253      This returns whether FRAME is currently "visible" (actually in use
4254      for display).  A frame that is not visible is not updated, and, if
4255      it works through a window system, may not show at all.
4256
4257  - Function: frame-iconified-p &optional frame
4258      This returns whether FRAME is iconified.  Not all window managers
4259      use icons; some merely unmap the window, so this function is not
4260      the inverse of `frame-visible-p'.  It is possible for a frame to
4261      not be visible and not be iconified either.  However, if the frame
4262      is iconified, it will not be visible.  (Under FSF Emacs, the
4263      functionality of this function is obtained through
4264      `frame-visible-p'.)
4265
4266  - Function: frame-totally-visible-p &optional frame
4267      This returns whether FRAME is not obscured by any other X windows.
4268      On TTY frames, this is the same as `frame-visible-p'.
4269
4270 \1f
4271 File: lispref.info,  Node: Raising and Lowering,  Next: Frame Configurations,  Prev: Visibility of Frames,  Up: Frames
4272
4273 Raising and Lowering Frames
4274 ===========================
4275
4276 The X Window System uses a desktop metaphor.  Part of this metaphor is
4277 the idea that windows are stacked in a notional third dimension
4278 perpendicular to the screen surface, and thus ordered from "highest" to
4279 "lowest".  Where two windows overlap, the one higher up covers the one
4280 underneath.  Even a window at the bottom of the stack can be seen if no
4281 other window overlaps it.
4282
4283    A window's place in this ordering is not fixed; in fact, users tend
4284 to change the order frequently.  "Raising" a window means moving it
4285 "up", to the top of the stack.  "Lowering" a window means moving it to
4286 the bottom of the stack.  This motion is in the notional third
4287 dimension only, and does not change the position of the window on the
4288 screen.
4289
4290    You can raise and lower XEmacs's X windows with these functions:
4291
4292  - Command: raise-frame &optional frame
4293      This function raises frame FRAME.
4294
4295  - Command: lower-frame &optional frame
4296      This function lowers frame FRAME.
4297
4298    You can also specify auto-raise (raising automatically when a frame
4299 is selected) or auto-lower (lowering automatically when it is
4300 deselected).  Under X, most ICCCM-compliant window managers will have
4301 an option to do this for you, but the following variables are provided
4302 in case you're using a broken WM.  (Under FSF Emacs, the same
4303 functionality is provided through the `auto-raise' and `auto-lower'
4304 frame properties.)
4305
4306  - Variable: auto-raise-frame
4307      This variable's value is `t' if frames will be raised to the top
4308      when selected.
4309
4310  - Variable: auto-lower-frame
4311      This variable's value is `t' if frames will be lowered to the
4312      bottom when no longer selected.
4313
4314    Auto-raising and auto-lowering is implemented through functions
4315 attached to `select-frame-hook' and `deselect-frame-hook' (*note Frame
4316 Hooks::).  Under normal circumstances, you should not call these
4317 functions directly.
4318
4319  - Function: default-select-frame-hook
4320      This hook function implements the `auto-raise-frame' variable; it
4321      is for use as the value of `select-frame-hook'.
4322
4323  - Function: default-deselect-frame-hook
4324      This hook function implements the `auto-lower-frame' variable; it
4325      is for use as the value of `deselect-frame-hook'.
4326
4327 \1f
4328 File: lispref.info,  Node: Frame Configurations,  Next: Frame Hooks,  Prev: Raising and Lowering,  Up: Frames
4329
4330 Frame Configurations
4331 ====================
4332
4333 A "frame configuration" records the current arrangement of frames, all
4334 their properties, and the window configuration of each one.
4335
4336  - Function: current-frame-configuration
4337      This function returns a frame configuration list that describes
4338      the current arrangement of frames and their contents.
4339
4340  - Function: set-frame-configuration configuration &optional nodelete
4341      This function restores the state of frames described by
4342      CONFIGURATION, which should be the return value from a previous
4343      call to `current-frame-configuration'.
4344
4345      Each frame listed in CONFIGURATION has its position, size, window
4346      configuration, and other properties set as specified in
4347      CONFIGURATION.
4348
4349      Ordinarily, this function deletes all existing frames not listed in
4350      CONFIGURATION.  But if optional second argument NODELETE is
4351      non-`nil', the unwanted frames are iconified instead.
4352
4353 \1f
4354 File: lispref.info,  Node: Frame Hooks,  Prev: Frame Configurations,  Up: Frames
4355
4356 Hooks for Customizing Frame Behavior
4357 ====================================
4358
4359 XEmacs provides many hooks that are called at various times during a
4360 frame's lifetime.  *Note Hooks::.
4361
4362  - Variable: create-frame-hook
4363      This hook is called each time a frame is created.  The functions
4364      are called with one argument, the newly-created frame.
4365
4366  - Variable: delete-frame-hook
4367      This hook is called each time a frame is deleted.  The functions
4368      are called with one argument, the about-to-be-deleted frame.
4369
4370  - Variable: select-frame-hook
4371      This is a normal hook that is run just after a frame is selected.
4372      The function `default-select-frame-hook', which implements
4373      auto-raising (*note Raising and Lowering::), is normally attached
4374      to this hook.
4375
4376      Note that calling `select-frame' does not necessarily set the
4377      focus: The actual window-system focus will not be changed until
4378      the next time that XEmacs is waiting for an event, and even then,
4379      the window manager may refuse the focus-change request.
4380
4381  - Variable: deselect-frame-hook
4382      This is a normal hook that is run just before a frame is deselected
4383      (and another frame is selected).  The function
4384      `default-deselect-frame-hook', which implements auto-lowering
4385      (*note Raising and Lowering::), is normally attached to this hook.
4386
4387  - Variable: map-frame-hook
4388      This hook is called each time a frame is mapped (i.e. made
4389      visible).  The functions are called with one argument, the newly
4390      mapped frame.
4391
4392  - Variable: unmap-frame-hook
4393      This hook is called each time a frame is unmapped (i.e. made
4394      invisible or iconified).  The functions are called with one
4395      argument, the newly unmapped frame.
4396
4397 \1f
4398 File: lispref.info,  Node: Consoles and Devices,  Next: Positions,  Prev: Frames,  Up: Top
4399
4400 Consoles and Devices
4401 ********************
4402
4403 A "console" is an object representing a single input connection to
4404 XEmacs, such as an X display or a TTY connection.  It is possible for
4405 XEmacs to have frames on multiple consoles at once (even on
4406 heterogeneous types--you can simultaneously have a frame on an X
4407 display and a TTY connection).  Normally, there is only one console in
4408 existence.
4409
4410    A "device" is an object representing a single output device, such as
4411 a particular screen on an X display. (Usually there is exactly one
4412 device per X console connection, but there may be more than one if you
4413 have a multi-headed X display.  For TTY connections, there is always
4414 exactly one device per console.)
4415
4416    Each device has one or more "frames" in which text can be displayed.
4417 For X displays and the like, a frame corresponds to the normal
4418 window-system concept of a window.  Frames can overlap, be displayed at
4419 various locations within the display, be resized, etc.  For TTY, only
4420 one frame can be displayed at a time, and it occupies the entire TTY
4421 display area.
4422
4423    However, you can still define multiple frames and switch between
4424 them.  Their contents are entirely separate from each other.  These
4425 sorts of frames resemble the "virtual console" capability provided
4426 under Linux or the multiple screens provided by the multiplexing program
4427 `screen' under Unix.
4428
4429    When you start up XEmacs, an initial console and device are created
4430 to receive input and display frames on.  This will either be an X
4431 display or a TTY connection, depending on what mode you started XEmacs
4432 in (this is determined by the `DISPLAY' environment variable, the
4433 `-nw', `-t' and `-display' command-line options, etc.).
4434
4435    You can connect to other X displays and TTY connections by creating
4436 new console objects, and to other X screens on an existing display by
4437 creating new device objects, as described below.  Many functions (for
4438 example the frame-creation functions) take an optional device argument
4439 specifying which device the function pertains to.  If the argument is
4440 omitted, it defaults to the selected device (see below).
4441
4442  - Function: consolep object
4443      This returns non-`nil' if OBJECT is a console.
4444
4445  - Function: devicep object
4446      This returns non-`nil' if OBJECT is a device.
4447
4448 * Menu:
4449
4450 * Basic Console Functions::     Functions for working with consoles.
4451 * Basic Device Functions::      Functions for working with devices.
4452 * Console Types and Device Classes::
4453                                 I/O and color characteristics.
4454 * Connecting to a Console or Device::
4455 * The Selected Console and Device::
4456 * Console and Device I/O::      Controlling input and output.
4457
4458 \1f
4459 File: lispref.info,  Node: Basic Console Functions,  Next: Basic Device Functions,  Up: Consoles and Devices
4460
4461 Basic Console Functions
4462 =======================
4463
4464  - Function: console-list
4465      This function returns a list of all existing consoles.
4466
4467  - Function: console-device-list &optional console
4468      This function returns a list of all devices on CONSOLE.  If
4469      CONSOLE is `nil', the selected console will be used.
4470
4471 \1f
4472 File: lispref.info,  Node: Basic Device Functions,  Next: Console Types and Device Classes,  Prev: Basic Console Functions,  Up: Consoles and Devices
4473
4474 Basic Device Functions
4475 ======================
4476
4477  - Function: device-list
4478      This function returns a list of all existing devices.
4479
4480  - Function: device-or-frame-p object
4481      This function returns non-`nil' if OBJECT is a device or frame.
4482      This function is useful because devices and frames are similar in
4483      many respects and many functions can operate on either one.
4484
4485  - Function: device-frame-list &optional device
4486      This function returns a list of all frames on DEVICE.  DEVICE
4487      defaults to the currently selected device.
4488
4489  - Function: frame-device &optional frame
4490      This function returns the device that FRAME is on.  FRAME defaults
4491      to the currently selected frame.
4492
4493 \1f
4494 File: lispref.info,  Node: Console Types and Device Classes,  Next: Connecting to a Console or Device,  Prev: Basic Device Functions,  Up: Consoles and Devices
4495
4496 Console Types and Device Classes
4497 ================================
4498
4499 Every device is of a particular "type", which describes how the
4500 connection to that device is made and how the device operates, and a
4501 particular "class", which describes other characteristics of the device
4502 (currently, the color capabilities of the device).
4503
4504    The currently-defined device types are
4505
4506 `x'
4507      A connection to an X display (such as `willow:0').
4508
4509 `tty'
4510      A connection to a tty (such as `/dev/ttyp3').
4511
4512 `stream'
4513      A stdio connection.  This describes a device for which input and
4514      output is only possible in a stream-like fashion, such as when
4515      XEmacs in running in batch mode.  The very first device created by
4516      XEmacs is a terminal device and is used to print out messages of
4517      various sorts (for example, the help message when you use the
4518      `-help' command-line option).
4519
4520    The currently-defined device classes are
4521 `color'
4522      A color device.
4523
4524 `grayscale'
4525      A grayscale device (a device that can display multiple shades of
4526      gray, but no color).
4527
4528 `mono'
4529      A device that can only display two colors (e.g. black and white).
4530
4531  - Function: device-type &optional device
4532      This function returns the type of DEVICE.  This is a symbol whose
4533      name is one of the device types mentioned above.  DEVICE defaults
4534      to the selected device.
4535
4536  - Function: device-or-frame-type device-or-frame
4537      This function returns the type of DEVICE-OR-FRAME.
4538
4539  - Function: device-class &optional device
4540      This function returns the class (color behavior) of DEVICE.  This
4541      is a symbol whose name is one of the device classes mentioned
4542      above.
4543
4544  - Function: valid-device-type-p device-type
4545      This function returns whether DEVICE-TYPE (which should be a
4546      symbol) specifies a valid device type.
4547
4548  - Function: valid-device-class-p device-class
4549      This function returns whether DEVICE-CLASS (which should be a
4550      symbol) specifies a valid device class.
4551
4552  - Variable: terminal-device
4553      This variable holds the initial terminal device object, which
4554      represents XEmacs's stdout.
4555
4556 \1f
4557 File: lispref.info,  Node: Connecting to a Console or Device,  Next: The Selected Console and Device,  Prev: Console Types and Device Classes,  Up: Consoles and Devices
4558
4559 Connecting to a Console or Device
4560 =================================
4561
4562  - Function: make-device type connection &optional props
4563      This function creates a new device.
4564
4565    The following two functions create devices of specific types and are
4566 written in terms of `make-device'.
4567
4568  - Function: make-tty-device &optional tty terminal-type
4569      This function creates a new tty device on TTY.  This also creates
4570      the tty's first frame.  TTY should be a string giving the name of
4571      a tty device file (e.g. `/dev/ttyp3' under SunOS et al.), as
4572      returned by the `tty' command issued from the Unix shell.  A value
4573      of `nil' means use the stdin and stdout as passed to XEmacs from
4574      the shell.  If TERMINAL-TYPE is non-`nil', it should be a string
4575      specifying the type of the terminal attached to the specified tty.
4576      If it is `nil', the terminal type will be inferred from the
4577      `TERM' environment variable.
4578
4579  - Function: make-x-device &optional display argv-list
4580      This function creates a new device connected to DISPLAY.  Optional
4581      argument ARGV-LIST is a list of strings describing command line
4582      options.
4583
4584  - Function: delete-device device &optional force
4585      This function deletes DEVICE, permanently eliminating it from use.
4586      This disconnects XEmacs's connection to the device.
4587
4588  - Variable: create-device-hook
4589      This variable, if non-`nil', should contain a list of functions,
4590      which are called when a device is created.
4591
4592  - Variable: delete-device-hook
4593      This variable, if non-`nil', should contain a list of functions,
4594      which are called when a device is deleted.
4595
4596  - Function: console-live-p object
4597      This function returns non-`nil' if OBJECT is a console that has
4598      not been deleted.
4599
4600  - Function: device-live-p object
4601      This function returns non-`nil' if OBJECT is a device that has not
4602      been deleted.
4603
4604  - Function: device-x-display device
4605      This function returns the X display which DEVICE is connected to,
4606      if DEVICE is an X device.
4607
4608 \1f
4609 File: lispref.info,  Node: The Selected Console and Device,  Next: Console and Device I/O,  Prev: Connecting to a Console or Device,  Up: Consoles and Devices
4610
4611 The Selected Console and Device
4612 ===============================
4613
4614  - Function: select-console console
4615      This function selects the console CONSOLE.  Subsequent editing
4616      commands apply to its selected device, selected frame, and selected
4617      window.  The selection of CONSOLE lasts until the next time the
4618      user does something to select a different console, or until the
4619      next time this function is called.
4620
4621  - Function: selected-console
4622      This function returns the console which is currently active.
4623
4624  - Function: select-device device
4625      This function selects the device DEVICE.
4626
4627  - Function: selected-device &optional console
4628      This function returns the device which is currently active.  If
4629      optional CONSOLE is non-`nil', this function returns the device
4630      that would be currently active if CONSOLE were the selected
4631      console.
4632
4633 \1f
4634 File: lispref.info,  Node: Console and Device I/O,  Prev: The Selected Console and Device,  Up: Consoles and Devices
4635
4636 Console and Device I/O
4637 ======================
4638
4639  - Function: console-disable-input console
4640      This function disables input on console CONSOLE.
4641
4642  - Function: console-enable-input console
4643      This function enables input on console CONSOLE.
4644
4645    Each device has a "baud rate" value associated with it.  On most
4646 systems, changing this value will affect the amount of padding and
4647 other strategic decisions made during redisplay.
4648
4649  - Function: device-baud-rate &optional device
4650      This function returns the output baud rate of DEVICE.
4651
4652  - Function: set-device-baud-rate device rate
4653      This function sets the output baud rate of DEVICE to RATE.
4654
4655 \1f
4656 File: lispref.info,  Node: Positions,  Next: Markers,  Prev: Consoles and Devices,  Up: Top
4657
4658 Positions
4659 *********
4660
4661 A "position" is the index of a character in the text of a buffer.  More
4662 precisely, a position identifies the place between two characters (or
4663 before the first character, or after the last character), so we can
4664 speak of the character before or after a given position.  However, we
4665 often speak of the character "at" a position, meaning the character
4666 after that position.
4667
4668    Positions are usually represented as integers starting from 1, but
4669 can also be represented as "markers"--special objects that relocate
4670 automatically when text is inserted or deleted so they stay with the
4671 surrounding characters.  *Note Markers::.
4672
4673 * Menu:
4674
4675 * Point::         The special position where editing takes place.
4676 * Motion::        Changing point.
4677 * Excursions::    Temporary motion and buffer changes.
4678 * Narrowing::     Restricting editing to a portion of the buffer.
4679
4680 \1f
4681 File: lispref.info,  Node: Point,  Next: Motion,  Up: Positions
4682
4683 Point
4684 =====
4685
4686 "Point" is a special buffer position used by many editing commands,
4687 including the self-inserting typed characters and text insertion
4688 functions.  Other commands move point through the text to allow editing
4689 and insertion at different places.
4690
4691    Like other positions, point designates a place between two characters
4692 (or before the first character, or after the last character), rather
4693 than a particular character.  Usually terminals display the cursor over
4694 the character that immediately follows point; point is actually before
4695 the character on which the cursor sits.
4696
4697    The value of point is a number between 1 and the buffer size plus 1.
4698 If narrowing is in effect (*note Narrowing::), then point is constrained
4699 to fall within the accessible portion of the buffer (possibly at one end
4700 of it).
4701
4702    Each buffer has its own value of point, which is independent of the
4703 value of point in other buffers.  Each window also has a value of point,
4704 which is independent of the value of point in other windows on the same
4705 buffer.  This is why point can have different values in various windows
4706 that display the same buffer.  When a buffer appears in only one window,
4707 the buffer's point and the window's point normally have the same value,
4708 so the distinction is rarely important.  *Note Window Point::, for more
4709 details.
4710
4711  - Function: point &optional buffer
4712      This function returns the value of point in BUFFER, as an integer.
4713      BUFFER defaults to the current buffer if omitted.
4714
4715           (point)
4716                => 175
4717
4718  - Function: point-min &optional buffer
4719      This function returns the minimum accessible value of point in
4720      BUFFER.  This is normally 1, but if narrowing is in effect, it is
4721      the position of the start of the region that you narrowed to.
4722      (*Note Narrowing::.) BUFFER defaults to the current buffer if
4723      omitted.
4724
4725  - Function: point-max &optional buffer
4726      This function returns the maximum accessible value of point in
4727      BUFFER.  This is `(1+ (buffer-size buffer))', unless narrowing is
4728      in effect, in which case it is the position of the end of the
4729      region that you narrowed to. (*note Narrowing::).  BUFFER defaults
4730      to the current buffer if omitted.
4731
4732  - Function: buffer-end flag &optional buffer
4733      This function returns `(point-min buffer)' if FLAG is less than 1,
4734      `(point-max buffer)' otherwise.  The argument FLAG must be a
4735      number.  BUFFER defaults to the current buffer if omitted.
4736
4737  - Function: buffer-size &optional buffer
4738      This function returns the total number of characters in BUFFER.
4739      In the absence of any narrowing (*note Narrowing::), `point-max'
4740      returns a value one larger than this.  BUFFER defaults to the
4741      current buffer if omitted.
4742
4743           (buffer-size)
4744                => 35
4745           (point-max)
4746                => 36
4747
4748  - Variable: buffer-saved-size
4749      The value of this buffer-local variable is the former length of the
4750      current buffer, as of the last time it was read in, saved or
4751      auto-saved.
4752
4753 \1f
4754 File: lispref.info,  Node: Motion,  Next: Excursions,  Prev: Point,  Up: Positions
4755
4756 Motion
4757 ======
4758
4759 Motion functions change the value of point, either relative to the
4760 current value of point, relative to the beginning or end of the buffer,
4761 or relative to the edges of the selected window.  *Note Point::.
4762
4763 * Menu:
4764
4765 * Character Motion::       Moving in terms of characters.
4766 * Word Motion::            Moving in terms of words.
4767 * Buffer End Motion::      Moving to the beginning or end of the buffer.
4768 * Text Lines::             Moving in terms of lines of text.
4769 * Screen Lines::           Moving in terms of lines as displayed.
4770 * List Motion::            Moving by parsing lists and sexps.
4771 * Skipping Characters::    Skipping characters belonging to a certain set.
4772
4773 \1f
4774 File: lispref.info,  Node: Character Motion,  Next: Word Motion,  Up: Motion
4775
4776 Motion by Characters
4777 --------------------
4778
4779 These functions move point based on a count of characters.  `goto-char'
4780 is the fundamental primitive; the other functions use that.
4781
4782  - Command: goto-char position &optional buffer
4783      This function sets point in `buffer' to the value POSITION.  If
4784      POSITION is less than 1, it moves point to the beginning of the
4785      buffer.  If POSITION is greater than the length of the buffer, it
4786      moves point to the end.  BUFFER defaults to the current buffer if
4787      omitted.
4788
4789      If narrowing is in effect, POSITION still counts from the
4790      beginning of the buffer, but point cannot go outside the accessible
4791      portion.  If POSITION is out of range, `goto-char' moves point to
4792      the beginning or the end of the accessible portion.
4793
4794      When this function is called interactively, POSITION is the
4795      numeric prefix argument, if provided; otherwise it is read from the
4796      minibuffer.
4797
4798      `goto-char' returns POSITION.
4799
4800  - Command: forward-char &optional count buffer
4801      This function moves point COUNT characters forward, towards the
4802      end of the buffer (or backward, towards the beginning of the
4803      buffer, if COUNT is negative).  If the function attempts to move
4804      point past the beginning or end of the buffer (or the limits of
4805      the accessible portion, when narrowing is in effect), an error is
4806      signaled with error code `beginning-of-buffer' or `end-of-buffer'.
4807      BUFFER defaults to the current buffer if omitted.
4808
4809      In an interactive call, COUNT is the numeric prefix argument.
4810
4811  - Command: backward-char &optional count buffer
4812      This function moves point COUNT characters backward, towards the
4813      beginning of the buffer (or forward, towards the end of the
4814      buffer, if COUNT is negative).  If the function attempts to move
4815      point past the beginning or end of the buffer (or the limits of
4816      the accessible portion, when narrowing is in effect), an error is
4817      signaled with error code `beginning-of-buffer' or `end-of-buffer'.
4818      BUFFER defaults to the current buffer if omitted.
4819
4820      In an interactive call, COUNT is the numeric prefix argument.
4821
4822 \1f
4823 File: lispref.info,  Node: Word Motion,  Next: Buffer End Motion,  Prev: Character Motion,  Up: Motion
4824
4825 Motion by Words
4826 ---------------
4827
4828 These functions for parsing words use the syntax table to decide
4829 whether a given character is part of a word.  *Note Syntax Tables::.
4830
4831  - Command: forward-word &optional count buffer
4832      This function moves point forward COUNT words (or backward if
4833      COUNT is negative).  Normally it returns `t'.  If this motion
4834      encounters the beginning or end of the buffer, or the limits of the
4835      accessible portion when narrowing is in effect, point stops there
4836      and the value is `nil'.
4837
4838      COUNT defaults to `1' and BUFFER defaults to the current buffer.
4839
4840      In an interactive call, COUNT is set to the numeric prefix
4841      argument.
4842
4843  - Command: backward-word &optional count buffer
4844      This function is just like `forward-word', except that it moves
4845      backward until encountering the front of a word, rather than
4846      forward.  BUFFER defaults to the current buffer if omitted.
4847
4848      In an interactive call, COUNT is set to the numeric prefix
4849      argument.
4850
4851  - Variable: words-include-escapes
4852      This variable affects the behavior of `forward-word' and everything
4853      that uses it.  If it is non-`nil', then characters in the "escape"
4854      and "character quote" syntax classes count as part of words.
4855      Otherwise, they do not.
4856
4857 \1f
4858 File: lispref.info,  Node: Buffer End Motion,  Next: Text Lines,  Prev: Word Motion,  Up: Motion
4859
4860 Motion to an End of the Buffer
4861 ------------------------------
4862
4863 To move point to the beginning of the buffer, write:
4864
4865      (goto-char (point-min))
4866
4867 Likewise, to move to the end of the buffer, use:
4868
4869      (goto-char (point-max))
4870
4871    Here are two commands that users use to do these things.  They are
4872 documented here to warn you not to use them in Lisp programs, because
4873 they set the mark and display messages in the echo area.
4874
4875  - Command: beginning-of-buffer &optional count
4876      This function moves point to the beginning of the buffer (or the
4877      limits of the accessible portion, when narrowing is in effect),
4878      setting the mark at the previous position.  If COUNT is non-`nil',
4879      then it puts point COUNT tenths of the way from the beginning of
4880      the buffer.
4881
4882      In an interactive call, COUNT is the numeric prefix argument, if
4883      provided; otherwise COUNT defaults to `nil'.
4884
4885      Don't use this function in Lisp programs!
4886
4887  - Command: end-of-buffer &optional count
4888      This function moves point to the end of the buffer (or the limits
4889      of the accessible portion, when narrowing is in effect), setting
4890      the mark at the previous position.  If COUNT is non-`nil', then it
4891      puts point COUNT tenths of the way from the end of the buffer.
4892
4893      In an interactive call, COUNT is the numeric prefix argument, if
4894      provided; otherwise COUNT defaults to `nil'.
4895
4896      Don't use this function in Lisp programs!
4897
4898 \1f
4899 File: lispref.info,  Node: Text Lines,  Next: Screen Lines,  Prev: Buffer End Motion,  Up: Motion
4900
4901 Motion by Text Lines
4902 --------------------
4903
4904 Text lines are portions of the buffer delimited by newline characters,
4905 which are regarded as part of the previous line.  The first text line
4906 begins at the beginning of the buffer, and the last text line ends at
4907 the end of the buffer whether or not the last character is a newline.
4908 The division of the buffer into text lines is not affected by the width
4909 of the window, by line continuation in display, or by how tabs and
4910 control characters are displayed.
4911
4912  - Command: goto-line line
4913      This function moves point to the front of the LINEth line,
4914      counting from line 1 at beginning of the buffer.  If LINE is less
4915      than 1, it moves point to the beginning of the buffer.  If LINE is
4916      greater than the number of lines in the buffer, it moves point to
4917      the end of the buffer--that is, the _end of the last line_ of the
4918      buffer.  This is the only case in which `goto-line' does not
4919      necessarily move to the beginning of a line.
4920
4921      If narrowing is in effect, then LINE still counts from the
4922      beginning of the buffer, but point cannot go outside the accessible
4923      portion.  So `goto-line' moves point to the beginning or end of the
4924      accessible portion, if the line number specifies an inaccessible
4925      position.
4926
4927      The return value of `goto-line' is the difference between LINE and
4928      the line number of the line to which point actually was able to
4929      move (in the full buffer, before taking account of narrowing).
4930      Thus, the value is positive if the scan encounters the real end of
4931      the buffer.  The value is zero if scan encounters the end of the
4932      accessible portion but not the real end of the buffer.
4933
4934      In an interactive call, LINE is the numeric prefix argument if one
4935      has been provided.  Otherwise LINE is read in the minibuffer.
4936
4937  - Command: beginning-of-line &optional count buffer
4938      This function moves point to the beginning of the current line.
4939      With an argument COUNT not `nil' or 1, it moves forward COUNT-1
4940      lines and then to the beginning of the line.  BUFFER defaults to
4941      the current buffer if omitted.
4942
4943      If this function reaches the end of the buffer (or of the
4944      accessible portion, if narrowing is in effect), it positions point
4945      there.  No error is signaled.
4946
4947  - Command: end-of-line &optional count buffer
4948      This function moves point to the end of the current line.  With an
4949      argument COUNT not `nil' or 1, it moves forward COUNT-1 lines and
4950      then to the end of the line.  BUFFER defaults to the current
4951      buffer if omitted.
4952
4953      If this function reaches the end of the buffer (or of the
4954      accessible portion, if narrowing is in effect), it positions point
4955      there.  No error is signaled.
4956
4957  - Command: forward-line &optional count buffer
4958      This function moves point forward COUNT lines, to the beginning of
4959      the line.  If COUNT is negative, it moves point -COUNT lines
4960      backward, to the beginning of a line.  If COUNT is zero, it moves
4961      point to the beginning of the current line.  BUFFER defaults to
4962      the current buffer if omitted.
4963
4964      If `forward-line' encounters the beginning or end of the buffer (or
4965      of the accessible portion) before finding that many lines, it sets
4966      point there.  No error is signaled.
4967
4968      `forward-line' returns the difference between COUNT and the number
4969      of lines actually moved.  If you attempt to move down five lines
4970      from the beginning of a buffer that has only three lines, point
4971      stops at the end of the last line, and the value will be 2.
4972
4973      In an interactive call, COUNT is the numeric prefix argument.
4974
4975  - Function: count-lines start end &optional ignore-invisible-lines-flag
4976      This function returns the number of lines between the positions
4977      START and END in the current buffer.  If START and END are equal,
4978      then it returns 0.  Otherwise it returns at least 1, even if START
4979      and END are on the same line.  This is because the text between
4980      them, considered in isolation, must contain at least one line
4981      unless it is empty.
4982
4983      With optional IGNORE-INVISIBLE-LINES-FLAG non-`nil', lines
4984      collapsed with selective-display are excluded from the line count.
4985
4986      *Note:* The expression to return the current line number is not
4987      obvious:
4988
4989           (1+ (count-lines 1 (point-at-bol)))
4990
4991      Here is an example of using `count-lines':
4992
4993           (defun current-line ()
4994             "Return the vertical position of point..."
4995             (+ (count-lines (window-start) (point))
4996                (if (= (current-column) 0) 1 0)
4997                -1))
4998
4999    Also see the functions `bolp' and `eolp' in *Note Near Point::.
5000 These functions do not move point, but test whether it is already at the
5001 beginning or end of a line.
5002
5003 \1f
5004 File: lispref.info,  Node: Screen Lines,  Next: List Motion,  Prev: Text Lines,  Up: Motion
5005
5006 Motion by Screen Lines
5007 ----------------------
5008
5009 The line functions in the previous section count text lines, delimited
5010 only by newline characters.  By contrast, these functions count screen
5011 lines, which are defined by the way the text appears on the screen.  A
5012 text line is a single screen line if it is short enough to fit the width
5013 of the selected window, but otherwise it may occupy several screen
5014 lines.
5015
5016    In some cases, text lines are truncated on the screen rather than
5017 continued onto additional screen lines.  In these cases,
5018 `vertical-motion' moves point much like `forward-line'.  *Note
5019 Truncation::.
5020
5021    Because the width of a given string depends on the flags that control
5022 the appearance of certain characters, `vertical-motion' behaves
5023 differently, for a given piece of text, depending on the buffer it is
5024 in, and even on the selected window (because the width, the truncation
5025 flag, and display table may vary between windows).  *Note Usual
5026 Display::.
5027
5028    These functions scan text to determine where screen lines break, and
5029 thus take time proportional to the distance scanned.  If you intend to
5030 use them heavily, Emacs provides caches which may improve the
5031 performance of your code.  *Note cache-long-line-scans: Text Lines.
5032
5033  - Function: vertical-motion count &optional window pixels
5034      This function moves point to the start of the frame line COUNT
5035      frame lines down from the frame line containing point.  If COUNT
5036      is negative, it moves up instead.  The optional second argument
5037      WINDOW may be used to specify a window other than the selected
5038      window in which to perform the motion.
5039
5040      Normally, `vertical-motion' returns the number of lines moved.  The
5041      value may be less in absolute value than COUNT if the beginning or
5042      end of the buffer was reached.  If the optional third argument,
5043      PIXELS is non-`nil', the vertical pixel height of the motion which
5044      took place is returned instead of the actual number of lines
5045      moved.  A motion of zero lines returns the height of the current
5046      line.
5047
5048      Note that `vertical-motion' sets WINDOW's buffer's point, not
5049      WINDOW's point. (This differs from FSF Emacs, which buggily always
5050      sets current buffer's point, regardless of WINDOW.)
5051
5052  - Function: vertical-motion-pixels count &optional window how
5053      This function moves point to the start of the frame line PIXELS
5054      vertical pixels down from the frame line containing point, or up if
5055      PIXELS is negative.  The optional second argument WINDOW is the
5056      window to move in, and defaults to the selected window.  The
5057      optional third argument HOW specifies the stopping condition.  A
5058      negative integer indicates that the motion should be no more than
5059      PIXELS.  A positive value indicates that the motion should be at
5060      least PIXELS.  Any other value indicates that the motion should be
5061      as close as possible to PIXELS.
5062
5063  - Command: move-to-window-line count &optional window
5064      This function moves point with respect to the text currently
5065      displayed in WINDOW, which defaults to the selected window.  It
5066      moves point to the beginning of the screen line COUNT screen lines
5067      from the top of the window.  If COUNT is negative, that specifies a
5068      position -COUNT lines from the bottom (or the last line of the
5069      buffer, if the buffer ends above the specified screen position).
5070
5071      If COUNT is `nil', then point moves to the beginning of the line
5072      in the middle of the window.  If the absolute value of COUNT is
5073      greater than the size of the window, then point moves to the place
5074      that would appear on that screen line if the window were tall
5075      enough.  This will probably cause the next redisplay to scroll to
5076      bring that location onto the screen.
5077
5078      In an interactive call, COUNT is the numeric prefix argument.
5079
5080      The value returned is the window line number point has moved to,
5081      with the top line in the window numbered 0.
5082
5083 \1f
5084 File: lispref.info,  Node: List Motion,  Next: Skipping Characters,  Prev: Screen Lines,  Up: Motion
5085
5086 Moving over Balanced Expressions
5087 --------------------------------
5088
5089 Here are several functions concerned with balanced-parenthesis
5090 expressions (also called "sexps" in connection with moving across them
5091 in XEmacs).  The syntax table controls how these functions interpret
5092 various characters; see *Note Syntax Tables::.  *Note Parsing
5093 Expressions::, for lower-level primitives for scanning sexps or parts of
5094 sexps.  For user-level commands, see *Note Lists and Sexps:
5095 (xemacs)Lists and Sexps.
5096
5097  - Command: forward-list &optional arg
5098      This function moves forward across ARG balanced groups of
5099      parentheses. (Other syntactic entities such as words or paired
5100      string quotes are ignored.) ARG defaults to 1 if omitted.  If ARG
5101      is negative, move backward across that many groups of parentheses.
5102
5103  - Command: backward-list &optional count
5104      This function moves backward across COUNT balanced groups of
5105      parentheses. (Other syntactic entities such as words or paired
5106      string quotes are ignored.) COUNT defaults to 1 if omitted.  If
5107      COUNT is negative, move forward across that many groups of
5108      parentheses.
5109
5110  - Command: up-list &optional count
5111      This function moves forward out of COUNT levels of parentheses.  A
5112      negative argument means move backward but still to a less deep
5113      spot.
5114
5115  - Command: down-list &optional count
5116      This function moves forward into COUNT levels of parentheses.  A
5117      negative argument means move backward but still go deeper in
5118      parentheses (-COUNT levels).
5119
5120  - Command: forward-sexp &optional count
5121      This function moves forward across COUNT balanced expressions.
5122      Balanced expressions include both those delimited by parentheses
5123      and other kinds, such as words and string constants.  COUNT
5124      defaults to 1 if omitted.  If COUNT is negative, move backward
5125      across that many balanced expressions.  For example,
5126
5127           ---------- Buffer: foo ----------
5128           (concat-!- "foo " (car x) y z)
5129           ---------- Buffer: foo ----------
5130           
5131           (forward-sexp 3)
5132                => nil
5133           
5134           ---------- Buffer: foo ----------
5135           (concat "foo " (car x) y-!- z)
5136           ---------- Buffer: foo ----------
5137
5138  - Command: backward-sexp &optional count
5139      This function moves backward across COUNT balanced expressions.
5140      COUNT defaults to 1 if omitted.  If COUNT is negative, move
5141      forward across that many balanced expressions.
5142
5143  - Command: beginning-of-defun &optional count
5144      This function moves back to the COUNTth beginning of a defun.  If
5145      COUNT is negative, this actually moves forward, but it still moves
5146      to the beginning of a defun, not to the end of one.  COUNT
5147      defaults to 1 if omitted.
5148
5149  - Command: end-of-defun &optional count
5150      This function moves forward to the COUNTth end of a defun.  If
5151      COUNT is negative, this actually moves backward, but it still
5152      moves to the end of a defun, not to the beginning of one.  COUNT
5153      defaults to 1 if omitted.
5154
5155  - User Option: defun-prompt-regexp
5156      If non-`nil', this variable holds a regular expression that
5157      specifies what text can appear before the open-parenthesis that
5158      starts a defun.  That is to say, a defun begins on a line that
5159      starts with a match for this regular expression, followed by a
5160      character with open-parenthesis syntax.
5161
5162 \1f
5163 File: lispref.info,  Node: Skipping Characters,  Prev: List Motion,  Up: Motion
5164
5165 Skipping Characters
5166 -------------------
5167
5168 The following two functions move point over a specified set of
5169 characters.  For example, they are often used to skip whitespace.  For
5170 related functions, see *Note Motion and Syntax::.
5171
5172  - Function: skip-chars-forward character-set &optional limit buffer
5173      This function moves point in BUFFER forward, skipping over a given
5174      set of characters.  It examines the character following point,
5175      then advances point if the character matches CHARACTER-SET.  This
5176      continues until it reaches a character that does not match.  The
5177      function returns `nil'.  BUFFER defaults to the current buffer if
5178      omitted.
5179
5180      The argument CHARACTER-SET is like the inside of a `[...]' in a
5181      regular expression except that `]' is never special and `\' quotes
5182      `^', `-' or `\'.  Thus, `"a-zA-Z"' skips over all letters,
5183      stopping before the first non-letter, and `"^a-zA-Z'" skips
5184      non-letters stopping before the first letter.  *Note Regular
5185      Expressions::.
5186
5187      If LIMIT is supplied (it must be a number or a marker), it
5188      specifies the maximum position in the buffer that point can be
5189      skipped to.  Point will stop at or before LIMIT.
5190
5191      In the following example, point is initially located directly
5192      before the `T'.  After the form is evaluated, point is located at
5193      the end of that line (between the `t' of `hat' and the newline).
5194      The function skips all letters and spaces, but not newlines.
5195
5196           ---------- Buffer: foo ----------
5197           I read "-!-The cat in the hat
5198           comes back" twice.
5199           ---------- Buffer: foo ----------
5200           
5201           (skip-chars-forward "a-zA-Z ")
5202                => nil
5203           
5204           ---------- Buffer: foo ----------
5205           I read "The cat in the hat-!-
5206           comes back" twice.
5207           ---------- Buffer: foo ----------
5208
5209  - Function: skip-chars-backward character-set &optional limit buffer
5210      This function moves point backward, skipping characters that match
5211      CHARACTER-SET, until LIMIT.  It just like `skip-chars-forward'
5212      except for the direction of motion.
5213
5214 \1f
5215 File: lispref.info,  Node: Excursions,  Next: Narrowing,  Prev: Motion,  Up: Positions
5216
5217 Excursions
5218 ==========
5219
5220 It is often useful to move point "temporarily" within a localized
5221 portion of the program, or to switch buffers temporarily.  This is
5222 called an "excursion", and it is done with the `save-excursion' special
5223 form.  This construct saves the current buffer and its values of point
5224 and the mark so they can be restored after the completion of the
5225 excursion.
5226
5227    The forms for saving and restoring the configuration of windows are
5228 described elsewhere (see *Note Window Configurations:: and *note Frame
5229 Configurations::).
5230
5231  - Special Form: save-excursion forms...
5232      The `save-excursion' special form saves the identity of the current
5233      buffer and the values of point and the mark in it, evaluates
5234      FORMS, and finally restores the buffer and its saved values of
5235      point and the mark.  All three saved values are restored even in
5236      case of an abnormal exit via `throw' or error (*note Nonlocal
5237      Exits::).
5238
5239      The `save-excursion' special form is the standard way to switch
5240      buffers or move point within one part of a program and avoid
5241      affecting the rest of the program.  It is used more than 500 times
5242      in the Lisp sources of XEmacs.
5243
5244      `save-excursion' does not save the values of point and the mark for
5245      other buffers, so changes in other buffers remain in effect after
5246      `save-excursion' exits.
5247
5248      Likewise, `save-excursion' does not restore window-buffer
5249      correspondences altered by functions such as `switch-to-buffer'.
5250      One way to restore these correspondences, and the selected window,
5251      is to use `save-window-excursion' inside `save-excursion' (*note
5252      Window Configurations::).
5253
5254      The value returned by `save-excursion' is the result of the last of
5255      FORMS, or `nil' if no FORMS are given.
5256
5257           (save-excursion
5258             FORMS)
5259           ==
5260           (let ((old-buf (current-buffer))
5261                 (old-pnt (point-marker))
5262                 (old-mark (copy-marker (mark-marker))))
5263             (unwind-protect
5264                 (progn FORMS)
5265               (set-buffer old-buf)
5266               (goto-char old-pnt)
5267               (set-marker (mark-marker) old-mark)))
5268
5269  - Special Form: save-current-buffer forms...
5270      This special form is similar to `save-excursion' but it only saves
5271      and restores the current buffer.  Beginning with XEmacs 20.3,
5272      `save-current-buffer' is a primitive.
5273
5274  - Special Form: with-current-buffer buffer forms...
5275      This special form evaluates FORMS with BUFFER as the current
5276      buffer.  It returns the value of the last form.
5277
5278  - Special Form: with-temp-file filename forms...
5279      This special form creates a new buffer, evaluates FORMS there, and
5280      writes the buffer to FILENAME.  It returns the value of the last
5281      form evaluated.
5282
5283  - Special Form: save-selected-window forms...
5284      This special form is similar to `save-excursion' but it saves and
5285      restores the selected window and nothing else.
5286
5287 \1f
5288 File: lispref.info,  Node: Narrowing,  Prev: Excursions,  Up: Positions
5289
5290 Narrowing
5291 =========
5292
5293 "Narrowing" means limiting the text addressable by XEmacs editing
5294 commands to a limited range of characters in a buffer.  The text that
5295 remains addressable is called the "accessible portion" of the buffer.
5296
5297    Narrowing is specified with two buffer positions which become the
5298 beginning and end of the accessible portion.  For most editing commands
5299 and most Emacs primitives, these positions replace the values of the
5300 beginning and end of the buffer.  While narrowing is in effect, no text
5301 outside the accessible portion is displayed, and point cannot move
5302 outside the accessible portion.
5303
5304    Values such as positions or line numbers, which usually count from
5305 the beginning of the buffer, do so despite narrowing, but the functions
5306 which use them refuse to operate on text that is inaccessible.
5307
5308    The commands for saving buffers are unaffected by narrowing; they
5309 save the entire buffer regardless of any narrowing.
5310
5311  - Command: narrow-to-region start end &optional buffer
5312      This function sets the accessible portion of BUFFER to start at
5313      START and end at END.  Both arguments should be character
5314      positions.  BUFFER defaults to the current buffer if omitted.
5315
5316      In an interactive call, START and END are set to the bounds of the
5317      current region (point and the mark, with the smallest first).
5318
5319  - Command: narrow-to-page &optional move-count
5320      This function sets the accessible portion of the current buffer to
5321      include just the current page.  An optional first argument
5322      MOVE-COUNT non-`nil' means to move forward or backward by
5323      MOVE-COUNT pages and then narrow.  The variable `page-delimiter'
5324      specifies where pages start and end (*note Standard Regexps::).
5325
5326      In an interactive call, MOVE-COUNT is set to the numeric prefix
5327      argument.
5328
5329  - Command: widen &optional buffer
5330      This function cancels any narrowing in BUFFER, so that the entire
5331      contents are accessible.  This is called "widening".  It is
5332      equivalent to the following expression:
5333
5334           (narrow-to-region 1 (1+ (buffer-size)))
5335
5336      BUFFER defaults to the current buffer if omitted.
5337
5338  - Special Form: save-restriction body...
5339      This special form saves the current bounds of the accessible
5340      portion, evaluates the BODY forms, and finally restores the saved
5341      bounds, thus restoring the same state of narrowing (or absence
5342      thereof) formerly in effect.  The state of narrowing is restored
5343      even in the event of an abnormal exit via `throw' or error (*note
5344      Nonlocal Exits::).  Therefore, this construct is a clean way to
5345      narrow a buffer temporarily.
5346
5347      The value returned by `save-restriction' is that returned by the
5348      last form in BODY, or `nil' if no body forms were given.
5349
5350      *Caution:* it is easy to make a mistake when using the
5351      `save-restriction' construct.  Read the entire description here
5352      before you try it.
5353
5354      If BODY changes the current buffer, `save-restriction' still
5355      restores the restrictions on the original buffer (the buffer whose
5356      restrictions it saved from), but it does not restore the identity
5357      of the current buffer.
5358
5359      `save-restriction' does _not_ restore point and the mark; use
5360      `save-excursion' for that.  If you use both `save-restriction' and
5361      `save-excursion' together, `save-excursion' should come first (on
5362      the outside).  Otherwise, the old point value would be restored
5363      with temporary narrowing still in effect.  If the old point value
5364      were outside the limits of the temporary narrowing, this would
5365      fail to restore it accurately.
5366
5367      The `save-restriction' special form records the values of the
5368      beginning and end of the accessible portion as distances from the
5369      beginning and end of the buffer.  In other words, it records the
5370      amount of inaccessible text before and after the accessible
5371      portion.
5372
5373      This method yields correct results if BODY does further narrowing.
5374      However, `save-restriction' can become confused if the body widens
5375      and then make changes outside the range of the saved narrowing.
5376      When this is what you want to do, `save-restriction' is not the
5377      right tool for the job.  Here is what you must use instead:
5378
5379           (let ((start (point-min-marker))
5380                 (end (point-max-marker)))
5381             (unwind-protect
5382                 (progn BODY)
5383               (save-excursion
5384                 (set-buffer (marker-buffer start))
5385                 (narrow-to-region start end))))
5386
5387      Here is a simple example of correct use of `save-restriction':
5388
5389           ---------- Buffer: foo ----------
5390           This is the contents of foo
5391           This is the contents of foo
5392           This is the contents of foo-!-
5393           ---------- Buffer: foo ----------
5394           
5395           (save-excursion
5396             (save-restriction
5397               (goto-char 1)
5398               (forward-line 2)
5399               (narrow-to-region 1 (point))
5400               (goto-char (point-min))
5401               (replace-string "foo" "bar")))
5402           
5403           ---------- Buffer: foo ----------
5404           This is the contents of bar
5405           This is the contents of bar
5406           This is the contents of foo-!-
5407           ---------- Buffer: foo ----------
5408
5409 \1f
5410 File: lispref.info,  Node: Markers,  Next: Text,  Prev: Positions,  Up: Top
5411
5412 Markers
5413 *******
5414
5415 A "marker" is a Lisp object used to specify a position in a buffer
5416 relative to the surrounding text.  A marker changes its offset from the
5417 beginning of the buffer automatically whenever text is inserted or
5418 deleted, so that it stays with the two characters on either side of it.
5419
5420 * Menu:
5421
5422 * Overview of Markers::      The components of a marker, and how it relocates.
5423 * Predicates on Markers::    Testing whether an object is a marker.
5424 * Creating Markers::         Making empty markers or markers at certain places.
5425 * Information from Markers:: Finding the marker's buffer or character position.
5426 * Changing Markers::         Moving the marker to a new buffer or position.
5427 * The Mark::                 How ``the mark'' is implemented with a marker.
5428 * The Region::               How to access ``the region''.
5429
5430 \1f
5431 File: lispref.info,  Node: Overview of Markers,  Next: Predicates on Markers,  Up: Markers
5432
5433 Overview of Markers
5434 ===================
5435
5436 A marker specifies a buffer and a position in that buffer.  The marker
5437 can be used to represent a position in the functions that require one,
5438 just as an integer could be used.  *Note Positions::, for a complete
5439 description of positions.
5440
5441    A marker has two attributes: the marker position, and the marker
5442 buffer.  The marker position is an integer that is equivalent (at a
5443 given time) to the marker as a position in that buffer.  But the
5444 marker's position value can change often during the life of the marker.
5445 Insertion and deletion of text in the buffer relocate the marker.  The
5446 idea is that a marker positioned between two characters remains between
5447 those two characters despite insertion and deletion elsewhere in the
5448 buffer.  Relocation changes the integer equivalent of the marker.
5449
5450    Deleting text around a marker's position leaves the marker between
5451 the characters immediately before and after the deleted text.  Inserting
5452 text at the position of a marker normally leaves the marker in front of
5453 the new text--unless it is inserted with `insert-before-markers' (*note
5454 Insertion::).
5455
5456    Insertion and deletion in a buffer must check all the markers and
5457 relocate them if necessary.  This slows processing in a buffer with a
5458 large number of markers.  For this reason, it is a good idea to make a
5459 marker point nowhere if you are sure you don't need it any more.
5460 Unreferenced markers are garbage collected eventually, but until then
5461 will continue to use time if they do point somewhere.
5462
5463    Because it is common to perform arithmetic operations on a marker
5464 position, most of the arithmetic operations (including `+' and `-')
5465 accept markers as arguments.  In such cases, the marker stands for its
5466 current position.
5467
5468    Note that you can use extents to achieve the same functionality, and
5469 more, as markers. (Markers were defined before extents, which is why
5470 they both continue to exist.) A zero-length extent with the
5471 `detachable' property removed is almost identical to a marker.  (*Note
5472 Extent Endpoints::, for more information on zero-length extents.)
5473
5474    In particular:
5475
5476    * In order to get marker-like behavior in a zero-length extent, the
5477      `detachable' property must be removed (otherwise, the extent will
5478      disappear when text near it is deleted) and exactly one endpoint
5479      must be closed (if both endpoints are closed, the extent will
5480      expand to contain text inserted where it is located).
5481
5482    * If a zero-length extent has the `end-open' property but not the
5483      `start-open' property (this is the default), text inserted at the
5484      extent's location causes the extent to move forward, just like a
5485      marker.
5486
5487    * If a zero-length extent has the `start-open' property but not the
5488      `end-open' property, text inserted at the extent's location causes
5489      the extent to remain before the text, like what happens to markers
5490      when `insert-before-markers' is used.
5491
5492    * Markers end up after or before inserted text depending on whether
5493      `insert' or `insert-before-markers' was called.  These functions
5494      do not affect zero-length extents differently; instead, the
5495      presence or absence of the `start-open' and `end-open' extent
5496      properties determines this, as just described.
5497
5498    * Markers are automatically removed from a buffer when they are no
5499      longer in use.  Extents remain around until explicitly removed
5500      from a buffer.
5501
5502    * Many functions are provided for listing the extents in a buffer or
5503      in a region of a buffer.  No such functions exist for markers.
5504
5505    Here are examples of creating markers, setting markers, and moving
5506 point to markers:
5507
5508      ;; Make a new marker that initially does not point anywhere:
5509      (setq m1 (make-marker))
5510           => #<marker in no buffer>
5511      
5512      ;; Set `m1' to point between the 99th and 100th characters
5513      ;;   in the current buffer:
5514      (set-marker m1 100)
5515           => #<marker at 100 in markers.texi>
5516      
5517      ;; Now insert one character at the beginning of the buffer:
5518      (goto-char (point-min))
5519           => 1
5520      (insert "Q")
5521           => nil
5522      
5523      ;; `m1' is updated appropriately.
5524      m1
5525           => #<marker at 101 in markers.texi>
5526      
5527      ;; Two markers that point to the same position
5528      ;;   are not `eq', but they are `equal'.
5529      (setq m2 (copy-marker m1))
5530           => #<marker at 101 in markers.texi>
5531      (eq m1 m2)
5532           => nil
5533      (equal m1 m2)
5534           => t
5535      
5536      ;; When you are finished using a marker, make it point nowhere.
5537      (set-marker m1 nil)
5538           => #<marker in no buffer>
5539
5540 \1f
5541 File: lispref.info,  Node: Predicates on Markers,  Next: Creating Markers,  Prev: Overview of Markers,  Up: Markers
5542
5543 Predicates on Markers
5544 =====================
5545
5546 You can test an object to see whether it is a marker, or whether it is
5547 either an integer or a marker or either an integer, a character, or a
5548 marker.  The latter tests are useful in connection with the arithmetic
5549 functions that work with any of markers, integers, or characters.
5550
5551  - Function: markerp object
5552      This function returns `t' if OBJECT is a marker, `nil' otherwise.
5553      Note that integers are not markers, even though many functions
5554      will accept either a marker or an integer.
5555
5556  - Function: integer-or-marker-p object
5557      This function returns `t' if OBJECT is an integer or a marker,
5558      `nil' otherwise.
5559
5560  - Function: integer-char-or-marker-p object
5561      This function returns `t' if OBJECT is an integer, a character, or
5562      a marker, `nil' otherwise.
5563
5564  - Function: number-or-marker-p object
5565      This function returns `t' if OBJECT is a number (either kind) or a
5566      marker, `nil' otherwise.
5567
5568  - Function: number-char-or-marker-p object
5569      This function returns `t' if OBJECT is a number (either kind), a
5570      character, or a marker, `nil' otherwise.
5571
5572 \1f
5573 File: lispref.info,  Node: Creating Markers,  Next: Information from Markers,  Prev: Predicates on Markers,  Up: Markers
5574
5575 Functions That Create Markers
5576 =============================
5577
5578 When you create a new marker, you can make it point nowhere, or point
5579 to the present position of point, or to the beginning or end of the
5580 accessible portion of the buffer, or to the same place as another given
5581 marker.
5582
5583  - Function: make-marker
5584      This functions returns a newly created marker that does not point
5585      anywhere.
5586
5587           (make-marker)
5588                => #<marker in no buffer>
5589
5590  - Function: point-marker &optional dont-copy-p buffer
5591      This function returns a marker that points to the present position
5592      of point in BUFFER, which defaults to the current buffer.  *Note
5593      Point::.  For an example, see `copy-marker', below.
5594
5595      Internally, a marker corresponding to point is always maintained.
5596      Normally the marker returned by `point-marker' is a copy; you may
5597      modify it with reckless abandon.  However, if optional argument
5598      DONT-COPY-P is non-`nil', then the real point-marker is returned;
5599      modifying the position of this marker will move point.  It is
5600      illegal to change the buffer of it, or make it point nowhere.
5601
5602  - Function: point-min-marker &optional buffer
5603      This function returns a new marker that points to the beginning of
5604      the accessible portion of BUFFER, which defaults to the current
5605      buffer.  This will be the beginning of the buffer unless narrowing
5606      is in effect.  *Note Narrowing::.
5607
5608  - Function: point-max-marker &optional buffer
5609      This function returns a new marker that points to the end of the
5610      accessible portion of BUFFER, which defaults to the current
5611      buffer.  This will be the end of the buffer unless narrowing is in
5612      effect.  *Note Narrowing::.
5613
5614      Here are examples of this function and `point-min-marker', shown in
5615      a buffer containing a version of the source file for the text of
5616      this chapter.
5617
5618           (point-min-marker)
5619                => #<marker at 1 in markers.texi>
5620           (point-max-marker)
5621                => #<marker at 15573 in markers.texi>
5622           
5623           (narrow-to-region 100 200)
5624                => nil
5625           (point-min-marker)
5626                => #<marker at 100 in markers.texi>
5627           (point-max-marker)
5628                => #<marker at 200 in markers.texi>
5629
5630  - Function: copy-marker marker-or-integer &optional marker-type
5631      If passed a marker as its argument, `copy-marker' returns a new
5632      marker that points to the same place and the same buffer as does
5633      MARKER-OR-INTEGER.  If passed an integer as its argument,
5634      `copy-marker' returns a new marker that points to position
5635      MARKER-OR-INTEGER in the current buffer.
5636
5637      If passed an integer argument less than 1, `copy-marker' returns a
5638      new marker that points to the beginning of the current buffer.  If
5639      passed an integer argument greater than the length of the buffer,
5640      `copy-marker' returns a new marker that points to the end of the
5641      buffer.
5642
5643      An error is signaled if MARKER-OR-INTEGER is neither a marker nor
5644      an integer.
5645
5646      Optional second argument MARKER-TYPE specifies the insertion type
5647      of the new marker; see `marker-insertion-type'.
5648
5649           (setq p (point-marker))
5650                => #<marker at 2139 in markers.texi>
5651           
5652           (setq q (copy-marker p))
5653                => #<marker at 2139 in markers.texi>
5654           
5655           (eq p q)
5656                => nil
5657           
5658           (equal p q)
5659                => t
5660           
5661           (point)
5662                => 2139
5663           
5664           (set-marker p 3000)
5665                => #<marker at 3000 in markers.texi>
5666           
5667           (point)
5668                => 2139
5669           
5670           (setq p (point-marker t))
5671                => #<marker at 2139 in markers.texi>
5672           
5673           (set-marker p 3000)
5674                => #<marker at 3000 in markers.texi>
5675           
5676           (point)
5677                => 3000
5678           
5679           (copy-marker 0)
5680                => #<marker at 1 in markers.texi>
5681           
5682           (copy-marker 20000)
5683                => #<marker at 7572 in markers.texi>
5684
5685 \1f
5686 File: lispref.info,  Node: Information from Markers,  Next: Changing Markers,  Prev: Creating Markers,  Up: Markers
5687
5688 Information from Markers
5689 ========================
5690
5691 This section describes the functions for accessing the components of a
5692 marker object.
5693
5694  - Function: marker-position marker
5695      This function returns the position that MARKER points to, or `nil'
5696      if it points nowhere.
5697
5698  - Function: marker-buffer marker
5699      This function returns the buffer that MARKER points into, or `nil'
5700      if it points nowhere.
5701
5702           (setq m (make-marker))
5703                => #<marker in no buffer>
5704           (marker-position m)
5705                => nil
5706           (marker-buffer m)
5707                => nil
5708           
5709           (set-marker m 3770 (current-buffer))
5710                => #<marker at 3770 in markers.texi>
5711           (marker-buffer m)
5712                => #<buffer markers.texi>
5713           (marker-position m)
5714                => 3770
5715
5716    Two distinct markers are considered `equal' (even though not `eq')
5717 to each other if they have the same position and buffer, or if they
5718 both point nowhere.
5719
5720 \1f
5721 File: lispref.info,  Node: Changing Markers,  Next: The Mark,  Prev: Information from Markers,  Up: Markers
5722
5723 Changing Marker Positions
5724 =========================
5725
5726 This section describes how to change the position of an existing
5727 marker.  When you do this, be sure you know whether the marker is used
5728 outside of your program, and, if so, what effects will result from
5729 moving it--otherwise, confusing things may happen in other parts of
5730 Emacs.
5731
5732  - Function: set-marker marker position &optional buffer
5733      This function moves MARKER to POSITION in BUFFER.  If BUFFER is
5734      not provided, it defaults to the current buffer.
5735
5736      POSITION can be a marker, an integer or `nil'.  If POSITION is an
5737      integer, `set-marker' moves MARKER to point before the POSITIONth
5738      character in BUFFER.  If POSITION is `nil', MARKER is made to
5739      point nowhere.  Then it no longer slows down editing in any
5740      buffer.  If POSITION is less than 1, MARKER is moved to the
5741      beginning of BUFFER.  If POSITION is greater than the size of
5742      BUFFER, MARKER is moved to the end of BUFFER.
5743
5744      The value returned is MARKER.
5745
5746           (setq m (point-marker))
5747                => #<marker at 4714 in markers.texi>
5748           (set-marker m 55)
5749                => #<marker at 55 in markers.texi>
5750           (setq b (get-buffer "foo"))
5751                => #<buffer foo>
5752           (set-marker m 0 b)
5753                => #<marker at 1 in foo>
5754
5755  - Function: move-marker marker position &optional buffer
5756      This is another name for `set-marker'.
5757
5758 \1f
5759 File: lispref.info,  Node: The Mark,  Next: The Region,  Prev: Changing Markers,  Up: Markers
5760
5761 The Mark
5762 ========
5763
5764 One special marker in each buffer is designated "the mark".  It records
5765 a position for the user for the sake of commands such as `C-w' and `C-x
5766 <TAB>'.  Lisp programs should set the mark only to values that have a
5767 potential use to the user, and never for their own internal purposes.
5768 For example, the `replace-regexp' command sets the mark to the value of
5769 point before doing any replacements, because this enables the user to
5770 move back there conveniently after the replace is finished.
5771
5772    Once the mark "exists" in a buffer, it normally never ceases to
5773 exist.  However, it may become "inactive", and usually does so after
5774 each command (other than simple motion commands and some commands that
5775 explicitly activate the mark).  When the mark is active, the region
5776 between point and the mark is called the "active region" and is
5777 highlighted specially.
5778
5779    Many commands are designed so that when called interactively they
5780 operate on the text between point and the mark.  Such commands work
5781 only when an active region exists, i.e. when the mark is active.  (The
5782 reason for this is to prevent you from accidentally deleting or
5783 changing large chunks of your text.) If you are writing such a command,
5784 don't examine the mark directly; instead, use `interactive' with the
5785 `r' specification.  This provides the values of point and the mark as
5786 arguments to the command in an interactive call, but permits other Lisp
5787 programs to specify arguments explicitly, and automatically signals an
5788 error if the command is called interactively when no active region
5789 exists.  *Note Interactive Codes::.
5790
5791    Each buffer has its own value of the mark that is independent of the
5792 value of the mark in other buffers. (When a buffer is created, the mark
5793 exists but does not point anywhere.  We consider this state as "the
5794 absence of a mark in that buffer.") However, only one active region can
5795 exist at a time.  Activating the mark in one buffer automatically
5796 deactivates an active mark in any other buffer.  Note that the user can
5797 explicitly activate a mark at any time by using the command
5798 `activate-region' (normally bound to `M-C-z') or by using the command
5799 `exchange-point-and-mark' (normally bound to `C-x C-x'), which has the
5800 side effect of activating the mark.
5801
5802    Some people do not like active regions, so they disable this behavior
5803 by setting the variable `zmacs-regions' to `nil'.  This makes the mark
5804 always active (except when a buffer is just created and the mark points
5805 nowhere), and turns off the highlighting of the region between point
5806 and the mark.  Commands that explicitly retrieve the value of the mark
5807 should make sure that they behave correctly and consistently
5808 irrespective of the setting of `zmacs-regions'; some primitives are
5809 provided to ensure this behavior.
5810
5811    In addition to the mark, each buffer has a "mark ring" which is a
5812 list of markers containing previous values of the mark.  When editing
5813 commands change the mark, they should normally save the old value of the
5814 mark on the mark ring.  The variable `mark-ring-max' specifies the
5815 maximum number of entries in the mark ring; once the list becomes this
5816 long, adding a new element deletes the last element.
5817
5818  - Function: mark &optional force buffer
5819      This function returns BUFFER's mark position as an integer.
5820      BUFFER defaults to the current buffer if omitted.
5821
5822      If the mark is inactive, `mark' normally returns `nil'.  However,
5823      if FORCE is non-`nil', then `mark' returns the mark position
5824      anyway--or `nil', if the mark is not yet set for the buffer.
5825
5826      (Remember that if `zmacs-regions' is `nil', the mark is always
5827      active as long as it exists, and the FORCE argument will have no
5828      effect.)
5829
5830      If you are using this in an editing command, you are most likely
5831      making a mistake; see the documentation of `set-mark' below.
5832
5833  - Function: mark-marker &optional force buffer
5834      This function returns BUFFER's mark.  BUFFER defaults to the
5835      current buffer if omitted.  This is the very marker that records
5836      the mark location inside XEmacs, not a copy.  Therefore, changing
5837      this marker's position will directly affect the position of the
5838      mark.  Don't do it unless that is the effect you want.
5839
5840      If the mark is inactive, `mark-marker' normally returns `nil'.
5841      However, if FORCE is non-`nil', then `mark-marker' returns the
5842      mark anyway.
5843           (setq m (mark-marker))
5844                => #<marker at 3420 in markers.texi>
5845           (set-marker m 100)
5846                => #<marker at 100 in markers.texi>
5847           (mark-marker)
5848                => #<marker at 100 in markers.texi>
5849
5850      Like any marker, this marker can be set to point at any buffer you
5851      like.  We don't recommend that you make it point at any buffer
5852      other than the one of which it is the mark.  If you do, it will
5853      yield perfectly consistent, but rather odd, results.
5854
5855  - Function: set-mark position &optional buffer
5856      This function sets `buffer''s mark to POSITION, and activates the
5857      mark.  BUFFER defaults to the current buffer if omitted.  The old
5858      value of the mark is _not_ pushed onto the mark ring.
5859
5860      *Please note:* Use this function only if you want the user to see
5861      that the mark has moved, and you want the previous mark position to
5862      be lost.  Normally, when a new mark is set, the old one should go
5863      on the `mark-ring'.  For this reason, most applications should use
5864      `push-mark' and `pop-mark', not `set-mark'.
5865
5866      Novice XEmacs Lisp programmers often try to use the mark for the
5867      wrong purposes.  The mark saves a location for the user's
5868      convenience.  An editing command should not alter the mark unless
5869      altering the mark is part of the user-level functionality of the
5870      command.  (And, in that case, this effect should be documented.)
5871      To remember a location for internal use in the Lisp program, store
5872      it in a Lisp variable.  For example:
5873
5874           (let ((start (point)))
5875             (forward-line 1)
5876             (delete-region start (point))).
5877
5878  - Command: exchange-point-and-mark &optional dont-activate-region
5879      This function exchanges the positions of point and the mark.  It
5880      is intended for interactive use.  The mark is also activated
5881      unless DONT-ACTIVATE-REGION is non-`nil'.
5882
5883  - Function: push-mark &optional position nomsg activate buffer
5884      This function sets BUFFER's mark to POSITION, and pushes a copy of
5885      the previous mark onto `mark-ring'.  BUFFER defaults to the
5886      current buffer if omitted.  If POSITION is `nil', then the value
5887      of point is used.  `push-mark' returns `nil'.
5888
5889      If the last global mark pushed was not in BUFFER, also push
5890      POSITION on the global mark ring (see below).
5891
5892      The function `push-mark' normally _does not_ activate the mark.
5893      To do that, specify `t' for the argument ACTIVATE.
5894
5895      A `Mark set' message is displayed unless NOMSG is non-`nil'.
5896
5897  - Function: pop-mark
5898      This function pops off the top element of `mark-ring' and makes
5899      that mark become the buffer's actual mark.  This does not move
5900      point in the buffer, and it does nothing if `mark-ring' is empty.
5901      It deactivates the mark.
5902
5903      The return value is not meaningful.
5904
5905  - Variable: mark-ring
5906      The value of this buffer-local variable is the list of saved former
5907      marks of the current buffer, most recent first.
5908
5909           mark-ring
5910           => (#<marker at 11050 in markers.texi>
5911               #<marker at 10832 in markers.texi>
5912               ...)
5913
5914  - User Option: mark-ring-max
5915      The value of this variable is the maximum size of `mark-ring'.  If
5916      more marks than this are pushed onto the `mark-ring', `push-mark'
5917      discards an old mark when it adds a new one.
5918
5919    In additional to a per-buffer mark ring, there is a "global mark
5920 ring".  Marks are pushed onto the global mark ring the first time you
5921 set a mark after switching buffers.
5922
5923  - Variable: global-mark-ring
5924      The value of this variable is the list of saved former global
5925      marks, most recent first.
5926
5927  - User Option: mark-ring-max
5928      The value of this variable is the maximum size of
5929      `global-mark-ring'.  If more marks than this are pushed onto the
5930      `global-mark-ring', `push-mark' discards an old mark when it adds
5931      a new one.
5932
5933  - Command: pop-global-mark
5934      This function pops a mark off the global mark ring and jumps to
5935      that location.
5936
5937 \1f
5938 File: lispref.info,  Node: The Region,  Prev: The Mark,  Up: Markers
5939
5940 The Region
5941 ==========
5942
5943 The text between point and the mark is known as "the region".  Various
5944 functions operate on text delimited by point and the mark, but only
5945 those functions specifically related to the region itself are described
5946 here.
5947
5948    When `zmacs-regions' is non-`nil' (this is the default), the concept
5949 of an "active region" exists.  The region is active when the
5950 corresponding mark is active.  Note that only one active region at a
5951 time can exist--i.e. only one buffer's region is active at a time.
5952 *Note The Mark::, for more information about active regions.
5953
5954  - User Option: zmacs-regions
5955      If non-`nil' (the default), active regions are used.  *Note The
5956      Mark::, for a detailed explanation of what this means.
5957
5958    A number of functions are provided for explicitly determining the
5959 bounds of the region and whether it is active.  Few programs need to use
5960 these functions, however.  A command designed to operate on a region
5961 should normally use `interactive' with the `r' specification to find
5962 the beginning and end of the region.  This lets other Lisp programs
5963 specify the bounds explicitly as arguments and automatically respects
5964 the user's setting for `zmacs-regions'.  (*Note Interactive Codes::.)
5965
5966  - Function: region-beginning &optional buffer
5967      This function returns the position of the beginning of BUFFER's
5968      region (as an integer).  This is the position of either point or
5969      the mark, whichever is smaller.  BUFFER defaults to the current
5970      buffer if omitted.
5971
5972      If the mark does not point anywhere, an error is signaled.  Note
5973      that this function ignores whether the region is active.
5974
5975  - Function: region-end &optional buffer
5976      This function returns the position of the end of BUFFER's region
5977      (as an integer).  This is the position of either point or the mark,
5978      whichever is larger.  BUFFER defaults to the current buffer if
5979      omitted.
5980
5981      If the mark does not point anywhere, an error is signaled.  Note
5982      that this function ignores whether the region is active.
5983
5984  - Function: region-exists-p
5985      This function is non-`nil' if the region exists.  If active regions
5986      are in use (i.e. `zmacs-regions' is true), this means that the
5987      region is active.  Otherwise, this means that the user has pushed
5988      a mark in this buffer at some point in the past.  If this function
5989      returns `nil', a function that uses the `r' interactive
5990      specification will cause an error when called interactively.
5991
5992  - Function: region-active-p
5993      If `zmacs-regions' is true, this is equivalent to
5994      `region-exists-p'.  Otherwise, this function always returns false.
5995      This function is used by commands such as
5996      `fill-paragraph-or-region' and `capitalize-region-or-word', which
5997      operate either on the active region or on something else (e.g. the
5998      word or paragraph at point).
5999
6000  - Variable: zmacs-region-stays
6001      If a command sets this variable to true, the currently active
6002      region will remain activated when the command finishes. (Normally
6003      the region is deactivated when each command terminates.) If
6004      `zmacs-regions' is false, however, this has no effect.  Under
6005      normal circumstances, you do not need to set this; use the
6006      interactive specification `_' instead, if you want the region to
6007      remain active.
6008
6009  - Function: zmacs-activate-region
6010      This function activates the region in the current buffer (this is
6011      equivalent to activating the current buffer's mark).  This will
6012      normally also highlight the text in the active region and set
6013      `zmacs-region-stays' to `t'. (If `zmacs-regions' is false,
6014      however, this function has no effect.)
6015
6016  - Function: zmacs-deactivate-region
6017      This function deactivates the region in the current buffer (this is
6018      equivalent to deactivating the current buffer's mark).  This will
6019      normally also unhighlight the text in the active region and set
6020      `zmacs-region-stays' to `nil'. (If `zmacs-regions' is false,
6021      however, this function has no effect.)
6022
6023  - Function: zmacs-update-region
6024      This function updates the active region, if it's currently active.
6025      (If there is no active region, this function does nothing.) This
6026      has the effect of updating the highlighting on the text in the
6027      region; but you should never need to call this except under rather
6028      strange circumstances.  The command loop automatically calls it
6029      when appropriate.  Calling this function will call the hook
6030      `zmacs-update-region-hook', if the region is active.
6031
6032  - Variable: zmacs-activate-region-hook
6033      This normal hook is called when a region becomes active. (Usually
6034      this happens as a result of a command that activates the region,
6035      such as `set-mark-command', `activate-region', or
6036      `exchange-point-and-mark'.) Note that calling
6037      `zmacs-activate-region' will call this hook, even if the region is
6038      already active.  If `zmacs-regions' is false, however, this hook
6039      will never get called under any circumstances.
6040
6041  - Variable: zmacs-deactivate-region-hook
6042      This normal hook is called when an active region becomes inactive.
6043      (Calling `zmacs-deactivate-region' when the region is inactive will
6044      _not_ cause this hook to be called.)  If `zmacs-regions' is false,
6045      this hook will never get called.
6046
6047  - Variable: zmacs-update-region-hook
6048      This normal hook is called when an active region is "updated" by
6049      `zmacs-update-region'.  This normally gets called at the end of
6050      each command that sets `zmacs-region-stays' to `t', indicating
6051      that the region should remain activated.  The motion commands do
6052      this.
6053
6054 \1f
6055 File: lispref.info,  Node: Text,  Next: Searching and Matching,  Prev: Markers,  Up: Top
6056
6057 Text
6058 ****
6059
6060 This chapter describes the functions that deal with the text in a
6061 buffer.  Most examine, insert, or delete text in the current buffer,
6062 often in the vicinity of point.  Many are interactive.  All the
6063 functions that change the text provide for undoing the changes (*note
6064 Undo::).
6065
6066    Many text-related functions operate on a region of text defined by
6067 two buffer positions passed in arguments named START and END.  These
6068 arguments should be either markers (*note Markers::) or numeric
6069 character positions (*note Positions::).  The order of these arguments
6070 does not matter; it is all right for START to be the end of the region
6071 and END the beginning.  For example, `(delete-region 1 10)' and
6072 `(delete-region 10 1)' are equivalent.  An `args-out-of-range' error is
6073 signaled if either START or END is outside the accessible portion of
6074 the buffer.  In an interactive call, point and the mark are used for
6075 these arguments.
6076
6077    Throughout this chapter, "text" refers to the characters in the
6078 buffer, together with their properties (when relevant).
6079
6080 * Menu:
6081
6082 * Near Point::       Examining text in the vicinity of point.
6083 * Buffer Contents::  Examining text in a general fashion.
6084 * Comparing Text::   Comparing substrings of buffers.
6085 * Insertion::        Adding new text to a buffer.
6086 * Commands for Insertion::  User-level commands to insert text.
6087 * Deletion::         Removing text from a buffer.
6088 * User-Level Deletion::     User-level commands to delete text.
6089 * The Kill Ring::    Where removed text sometimes is saved for later use.
6090 * Undo::             Undoing changes to the text of a buffer.
6091 * Maintaining Undo:: How to enable and disable undo information.
6092                         How to control how much information is kept.
6093 * Filling::          Functions for explicit filling.
6094 * Margins::          How to specify margins for filling commands.
6095 * Auto Filling::     How auto-fill mode is implemented to break lines.
6096 * Sorting::          Functions for sorting parts of the buffer.
6097 * Columns::          Computing horizontal positions, and using them.
6098 * Indentation::      Functions to insert or adjust indentation.
6099 * Case Changes::     Case conversion of parts of the buffer.
6100 * Text Properties::  Assigning Lisp property lists to text characters.
6101 * Substitution::     Replacing a given character wherever it appears.
6102 * Registers::        How registers are implemented.  Accessing the text or
6103                        position stored in a register.
6104 * Transposition::    Swapping two portions of a buffer.
6105 * Change Hooks::     Supplying functions to be run when text is changed.
6106 * Transformations::  MD5 and base64 support.
6107
6108 \1f
6109 File: lispref.info,  Node: Near Point,  Next: Buffer Contents,  Up: Text
6110
6111 Examining Text Near Point
6112 =========================
6113
6114 Many functions are provided to look at the characters around point.
6115 Several simple functions are described here.  See also `looking-at' in
6116 *Note Regexp Search::.
6117
6118    Many of these functions take an optional BUFFER argument.  In all
6119 such cases, the current buffer will be used if this argument is
6120 omitted. (In FSF Emacs, and earlier versions of XEmacs, these functions
6121 usually did not have these optional BUFFER arguments and always
6122 operated on the current buffer.)
6123
6124  - Function: char-after &optional position buffer
6125      This function returns the character in the buffer at (i.e.,
6126      immediately after) position POSITION.  If POSITION is out of range
6127      for this purpose, either before the beginning of the buffer, or at
6128      or beyond the end, then the value is `nil'.  The default for
6129      POSITION is point.  If optional argument BUFFER is `nil', the
6130      current buffer is assumed.
6131
6132      In the following example, assume that the first character in the
6133      buffer is `@':
6134
6135           (char-to-string (char-after 1))
6136                => "@"
6137
6138  - Function: char-before &optional position buffer
6139      This function returns the character in the current buffer
6140      immediately before position POSITION.  If POSITION is out of range
6141      for this purpose, either at or before the beginning of the buffer,
6142      or beyond the end, then the value is `nil'.  The default for
6143      POSITION is point.  If optional argument BUFFER is `nil', the
6144      current buffer is assumed.
6145
6146  - Function: following-char &optional buffer
6147      This function returns the character following point in the buffer.
6148      This is similar to `(char-after (point))'.  However, if point is at
6149      the end of the buffer, then the result of `following-char' is 0.
6150      If optional argument BUFFER is `nil', the current buffer is
6151      assumed.
6152
6153      Remember that point is always between characters, and the terminal
6154      cursor normally appears over the character following point.
6155      Therefore, the character returned by `following-char' is the
6156      character the cursor is over.
6157
6158      In this example, point is between the `a' and the `c'.
6159
6160           ---------- Buffer: foo ----------
6161           Gentlemen may cry ``Pea-!-ce! Peace!,''
6162           but there is no peace.
6163           ---------- Buffer: foo ----------
6164           
6165           (char-to-string (preceding-char))
6166                => "a"
6167           (char-to-string (following-char))
6168                => "c"
6169
6170  - Function: preceding-char &optional buffer
6171      This function returns the character preceding point in the buffer.
6172      See above, under `following-char', for an example.  If point is at
6173      the beginning of the buffer, `preceding-char' returns 0.  If
6174      optional argument BUFFER is `nil', the current buffer is assumed.
6175
6176  - Function: bobp &optional buffer
6177      This function returns `t' if point is at the beginning of the
6178      buffer.  If narrowing is in effect, this means the beginning of the
6179      accessible portion of the text.  If optional argument BUFFER is
6180      `nil', the current buffer is assumed.  See also `point-min' in
6181      *Note Point::.
6182
6183  - Function: eobp &optional buffer
6184      This function returns `t' if point is at the end of the buffer.
6185      If narrowing is in effect, this means the end of accessible
6186      portion of the text.  If optional argument BUFFER is `nil', the
6187      current buffer is assumed.  See also `point-max' in *Note Point::.
6188
6189  - Function: bolp &optional buffer
6190      This function returns `t' if point is at the beginning of a line.
6191      If optional argument BUFFER is `nil', the current buffer is
6192      assumed.  *Note Text Lines::.  The beginning of the buffer (or its
6193      accessible portion) always counts as the beginning of a line.
6194
6195  - Function: eolp &optional buffer
6196      This function returns `t' if point is at the end of a line.  The
6197      end of the buffer is always considered the end of a line.  If
6198      optional argument BUFFER is `nil', the current buffer is assumed.
6199      The end of the buffer (or of its accessible portion) is always
6200      considered the end of a line.
6201
6202 \1f
6203 File: lispref.info,  Node: Buffer Contents,  Next: Comparing Text,  Prev: Near Point,  Up: Text
6204
6205 Examining Buffer Contents
6206 =========================
6207
6208 This section describes two functions that allow a Lisp program to
6209 convert any portion of the text in the buffer into a string.
6210
6211  - Function: buffer-substring start end &optional buffer
6212  - Function: buffer-string start end &optional buffer
6213      These functions are equivalent and return a string containing a
6214      copy of the text of the region defined by positions START and END
6215      in the buffer.  If the arguments are not positions in the
6216      accessible portion of the buffer, `buffer-substring' signals an
6217      `args-out-of-range' error.  If optional argument BUFFER is `nil',
6218      the current buffer is assumed.
6219
6220      If the region delineated by START and END contains duplicable
6221      extents, they will be remembered in the string.  *Note Duplicable
6222      Extents::.
6223
6224      It is not necessary for START to be less than END; the arguments
6225      can be given in either order.  But most often the smaller argument
6226      is written first.
6227
6228           ---------- Buffer: foo ----------
6229           This is the contents of buffer foo
6230           
6231           ---------- Buffer: foo ----------
6232           
6233           (buffer-substring 1 10)
6234           => "This is t"
6235           (buffer-substring (point-max) 10)
6236           => "he contents of buffer foo
6237           "
6238
6239 \1f
6240 File: lispref.info,  Node: Comparing Text,  Next: Insertion,  Prev: Buffer Contents,  Up: Text
6241
6242 Comparing Text
6243 ==============
6244
6245 This function lets you compare portions of the text in a buffer, without
6246 copying them into strings first.
6247
6248  - Function: compare-buffer-substrings buffer1 start1 end1 buffer2
6249           start2 end2
6250      This function lets you compare two substrings of the same buffer
6251      or two different buffers.  The first three arguments specify one
6252      substring, giving a buffer and two positions within the buffer.
6253      The last three arguments specify the other substring in the same
6254      way.  You can use `nil' for BUFFER1, BUFFER2, or both to stand for
6255      the current buffer.
6256
6257      The value is negative if the first substring is less, positive if
6258      the first is greater, and zero if they are equal.  The absolute
6259      value of the result is one plus the index of the first differing
6260      characters within the substrings.
6261
6262      This function ignores case when comparing characters if
6263      `case-fold-search' is non-`nil'.  It always ignores text
6264      properties.
6265
6266      Suppose the current buffer contains the text `foobarbar
6267      haha!rara!'; then in this example the two substrings are `rbar '
6268      and `rara!'.  The value is 2 because the first substring is greater
6269      at the second character.
6270
6271           (compare-buffer-substring nil 6 11 nil 16 21)
6272                => 2
6273
6274 \1f
6275 File: lispref.info,  Node: Insertion,  Next: Commands for Insertion,  Prev: Comparing Text,  Up: Text
6276
6277 Inserting Text
6278 ==============
6279
6280 "Insertion" means adding new text to a buffer.  The inserted text goes
6281 at point--between the character before point and the character after
6282 point.
6283
6284    Insertion relocates markers that point at positions after the
6285 insertion point, so that they stay with the surrounding text (*note
6286 Markers::).  When a marker points at the place of insertion, insertion
6287 normally doesn't relocate the marker, so that it points to the
6288 beginning of the inserted text; however, certain special functions such
6289 as `insert-before-markers' relocate such markers to point after the
6290 inserted text.
6291
6292    Some insertion functions leave point before the inserted text, while
6293 other functions leave it after.  We call the former insertion "after
6294 point" and the latter insertion "before point".
6295
6296    If a string with non-`nil' extent data is inserted, the remembered
6297 extents will also be inserted.  *Note Duplicable Extents::.
6298
6299    Insertion functions signal an error if the current buffer is
6300 read-only.
6301
6302    These functions copy text characters from strings and buffers along
6303 with their properties.  The inserted characters have exactly the same
6304 properties as the characters they were copied from.  By contrast,
6305 characters specified as separate arguments, not part of a string or
6306 buffer, inherit their text properties from the neighboring text.
6307
6308  - Function: insert &rest args
6309      This function inserts the strings and/or characters ARGS into the
6310      current buffer, at point, moving point forward.  In other words, it
6311      inserts the text before point.  An error is signaled unless all
6312      ARGS are either strings or characters.  The value is `nil'.
6313
6314  - Function: insert-before-markers &rest args
6315      This function inserts the strings and/or characters ARGS into the
6316      current buffer, at point, moving point forward.  An error is
6317      signaled unless all ARGS are either strings or characters.  The
6318      value is `nil'.
6319
6320      This function is unlike the other insertion functions in that it
6321      relocates markers initially pointing at the insertion point, to
6322      point after the inserted text.
6323
6324  - Function: insert-string string &optional buffer
6325      This function inserts STRING into BUFFER before point.  BUFFER
6326      defaults to the current buffer if omitted.  This function is
6327      chiefly useful if you want to insert a string in a buffer other
6328      than the current one (otherwise you could just use `insert').
6329
6330  - Function: insert-char character &optional count ignored buffer
6331      This function inserts COUNT instances of CHARACTER into BUFFER
6332      before point.  COUNT must be a number, and CHARACTER must be a
6333      character.
6334
6335      If optional argument BUFFER is `nil', the current buffer is
6336      assumed. (In FSF Emacs, the third argument is called INHERIT and
6337      refers to text properties.  In XEmacs, it is always ignored.)
6338
6339      This function always returns `nil'.
6340
6341  - Function: insert-buffer-substring from-buffer-or-name &optional
6342           start end
6343      This function inserts a portion of buffer FROM-BUFFER-OR-NAME
6344      (which must already exist) into the current buffer before point.
6345      The text inserted is the region from START and END.  (These
6346      arguments default to the beginning and end of the accessible
6347      portion of that buffer.)  This function returns `nil'.
6348
6349      In this example, the form is executed with buffer `bar' as the
6350      current buffer.  We assume that buffer `bar' is initially empty.
6351
6352           ---------- Buffer: foo ----------
6353           We hold these truths to be self-evident, that all
6354           ---------- Buffer: foo ----------
6355           
6356           (insert-buffer-substring "foo" 1 20)
6357                => nil
6358           
6359           ---------- Buffer: bar ----------
6360           We hold these truth-!-
6361           ---------- Buffer: bar ----------
6362
6363 \1f
6364 File: lispref.info,  Node: Commands for Insertion,  Next: Deletion,  Prev: Insertion,  Up: Text
6365
6366 User-Level Insertion Commands
6367 =============================
6368
6369 This section describes higher-level commands for inserting text,
6370 commands intended primarily for the user but useful also in Lisp
6371 programs.
6372
6373  - Command: insert-buffer from-buffer-or-name
6374      This command inserts the entire contents of FROM-BUFFER-OR-NAME
6375      (which must exist) into the current buffer after point.  It leaves
6376      the mark after the inserted text.  The value is `nil'.
6377
6378  - Command: self-insert-command count
6379      This command inserts the last character typed; it does so COUNT
6380      times, before point, and returns `nil'.  Most printing characters
6381      are bound to this command.  In routine use, `self-insert-command'
6382      is the most frequently called function in XEmacs, but programs
6383      rarely use it except to install it on a keymap.
6384
6385      In an interactive call, COUNT is the numeric prefix argument.
6386
6387      This command calls `auto-fill-function' whenever that is non-`nil'
6388      and the character inserted is a space or a newline (*note Auto
6389      Filling::).
6390
6391      This command performs abbrev expansion if Abbrev mode is enabled
6392      and the inserted character does not have word-constituent syntax.
6393      (*Note Abbrevs::, and *Note Syntax Class Table::.)
6394
6395      This is also responsible for calling `blink-paren-function' when
6396      the inserted character has close parenthesis syntax (*note
6397      Blinking::).
6398
6399  - Command: newline &optional count
6400      This command inserts newlines into the current buffer before point.
6401      If COUNT is supplied, that many newline characters are inserted.
6402
6403      This function calls `auto-fill-function' if the current column
6404      number is greater than the value of `fill-column' and COUNT is
6405      `nil'.  Typically what `auto-fill-function' does is insert a
6406      newline; thus, the overall result in this case is to insert two
6407      newlines at different places: one at point, and another earlier in
6408      the line.  `newline' does not auto-fill if COUNT is non-`nil'.
6409
6410      This command indents to the left margin if that is not zero.
6411      *Note Margins::.
6412
6413      The value returned is `nil'.  In an interactive call, COUNT is the
6414      numeric prefix argument.
6415
6416  - Command: split-line
6417      This command splits the current line, moving the portion of the
6418      line after point down vertically so that it is on the next line
6419      directly below where it was before.  Whitespace is inserted as
6420      needed at the beginning of the lower line, using the `indent-to'
6421      function.  `split-line' returns the position of point.
6422
6423      Programs hardly ever use this function.
6424
6425  - Variable: overwrite-mode
6426      This variable controls whether overwrite mode is in effect: a
6427      non-`nil' value enables the mode.  It is automatically made
6428      buffer-local when set in any fashion.
6429
6430 \1f
6431 File: lispref.info,  Node: Deletion,  Next: User-Level Deletion,  Prev: Commands for Insertion,  Up: Text
6432
6433 Deleting Text
6434 =============
6435
6436 Deletion means removing part of the text in a buffer, without saving it
6437 in the kill ring (*note The Kill Ring::).  Deleted text can't be
6438 yanked, but can be reinserted using the undo mechanism (*note Undo::).
6439 Some deletion functions do save text in the kill ring in some special
6440 cases.
6441
6442    All of the deletion functions operate on the current buffer, and all
6443 return a value of `nil'.
6444
6445  - Command: erase-buffer &optional buffer
6446      This function deletes the entire text of BUFFER, leaving it empty.
6447      If the buffer is read-only, it signals a `buffer-read-only'
6448      error.  Otherwise, it deletes the text without asking for any
6449      confirmation.  It returns `nil'.  BUFFER defaults to the current
6450      buffer if omitted.
6451
6452      Normally, deleting a large amount of text from a buffer inhibits
6453      further auto-saving of that buffer "because it has shrunk".
6454      However, `erase-buffer' does not do this, the idea being that the
6455      future text is not really related to the former text, and its size
6456      should not be compared with that of the former text.
6457
6458  - Command: delete-region start end &optional buffer
6459      This command deletes the text in BUFFER in the region defined by
6460      START and END.  The value is `nil'.  If optional argument BUFFER
6461      is `nil', the current buffer is assumed.
6462
6463  - Command: delete-char &optional count killp
6464      This command deletes COUNT characters directly after point, or
6465      before point if COUNT is negative.  COUNT defaults to `1'.  If
6466      KILLP is non-`nil', then it saves the deleted characters in the
6467      kill ring.
6468
6469      In an interactive call, COUNT is the numeric prefix argument, and
6470      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
6471      argument is supplied, the text is saved in the kill ring.  If no
6472      prefix argument is supplied, then one character is deleted, but
6473      not saved in the kill ring.
6474
6475      The value returned is always `nil'.
6476
6477  - Command: delete-backward-char &optional count killp
6478      This command deletes COUNT characters directly before point, or
6479      after point if COUNT is negative.  COUNT defaults to 1.  If KILLP
6480      is non-`nil', then it saves the deleted characters in the kill
6481      ring.
6482
6483      In an interactive call, COUNT is the numeric prefix argument, and
6484      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
6485      argument is supplied, the text is saved in the kill ring.  If no
6486      prefix argument is supplied, then one character is deleted, but
6487      not saved in the kill ring.
6488
6489      The value returned is always `nil'.
6490
6491  - Command: backward-delete-char-untabify count &optional killp
6492      This command deletes COUNT characters backward, changing tabs into
6493      spaces.  When the next character to be deleted is a tab, it is
6494      first replaced with the proper number of spaces to preserve
6495      alignment and then one of those spaces is deleted instead of the
6496      tab.  If KILLP is non-`nil', then the command saves the deleted
6497      characters in the kill ring.
6498
6499      Conversion of tabs to spaces happens only if COUNT is positive.
6500      If it is negative, exactly -COUNT characters after point are
6501      deleted.
6502
6503      In an interactive call, COUNT is the numeric prefix argument, and
6504      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
6505      argument is supplied, the text is saved in the kill ring.  If no
6506      prefix argument is supplied, then one character is deleted, but
6507      not saved in the kill ring.
6508
6509      The value returned is always `nil'.
6510
6511 \1f
6512 File: lispref.info,  Node: User-Level Deletion,  Next: The Kill Ring,  Prev: Deletion,  Up: Text
6513
6514 User-Level Deletion Commands
6515 ============================
6516
6517 This section describes higher-level commands for deleting text,
6518 commands intended primarily for the user but useful also in Lisp
6519 programs.
6520
6521  - Command: delete-horizontal-space
6522      This function deletes all spaces and tabs around point.  It returns
6523      `nil'.
6524
6525      In the following examples, we call `delete-horizontal-space' four
6526      times, once on each line, with point between the second and third
6527      characters on the line each time.
6528
6529           ---------- Buffer: foo ----------
6530           I -!-thought
6531           I -!-     thought
6532           We-!- thought
6533           Yo-!-u thought
6534           ---------- Buffer: foo ----------
6535           
6536           (delete-horizontal-space)   ; Four times.
6537                => nil
6538           
6539           ---------- Buffer: foo ----------
6540           Ithought
6541           Ithought
6542           Wethought
6543           You thought
6544           ---------- Buffer: foo ----------
6545
6546  - Command: delete-indentation &optional join-following-p
6547      This function joins the line point is on to the previous line,
6548      deleting any whitespace at the join and in some cases replacing it
6549      with one space.  If JOIN-FOLLOWING-P is non-`nil',
6550      `delete-indentation' joins this line to the following line
6551      instead.  The value is `nil'.
6552
6553      If there is a fill prefix, and the second of the lines being joined
6554      starts with the prefix, then `delete-indentation' deletes the fill
6555      prefix before joining the lines.  *Note Margins::.
6556
6557      In the example below, point is located on the line starting
6558      `events', and it makes no difference if there are trailing spaces
6559      in the preceding line.
6560
6561           ---------- Buffer: foo ----------
6562           When in the course of human
6563           -!-    events, it becomes necessary
6564           ---------- Buffer: foo ----------
6565           
6566           (delete-indentation)
6567                => nil
6568           
6569           ---------- Buffer: foo ----------
6570           When in the course of human-!- events, it becomes necessary
6571           ---------- Buffer: foo ----------
6572
6573      After the lines are joined, the function `fixup-whitespace' is
6574      responsible for deciding whether to leave a space at the junction.
6575
6576  - Command: fixup-whitespace
6577      This function replaces all the white space surrounding point with
6578      either one space or no space, according to the context.  It
6579      returns `nil'.
6580
6581      At the beginning or end of a line, the appropriate amount of space
6582      is none.  Before a character with close parenthesis syntax, or
6583      after a character with open parenthesis or expression-prefix
6584      syntax, no space is also appropriate.  Otherwise, one space is
6585      appropriate.  *Note Syntax Class Table::.
6586
6587      In the example below, `fixup-whitespace' is called the first time
6588      with point before the word `spaces' in the first line.  For the
6589      second invocation, point is directly after the `('.
6590
6591           ---------- Buffer: foo ----------
6592           This has too many     -!-spaces
6593           This has too many spaces at the start of (-!-   this list)
6594           ---------- Buffer: foo ----------
6595           
6596           (fixup-whitespace)
6597                => nil
6598           (fixup-whitespace)
6599                => nil
6600           
6601           ---------- Buffer: foo ----------
6602           This has too many spaces
6603           This has too many spaces at the start of (this list)
6604           ---------- Buffer: foo ----------
6605
6606  - Command: just-one-space
6607      This command replaces any spaces and tabs around point with a
6608      single space.  It returns `nil'.
6609
6610  - Command: delete-blank-lines
6611      This function deletes blank lines surrounding point.  If point is
6612      on a blank line with one or more blank lines before or after it,
6613      then all but one of them are deleted.  If point is on an isolated
6614      blank line, then it is deleted.  If point is on a nonblank line,
6615      the command deletes all blank lines following it.
6616
6617      A blank line is defined as a line containing only tabs and spaces.
6618
6619      `delete-blank-lines' returns `nil'.
6620
6621 \1f
6622 File: lispref.info,  Node: The Kill Ring,  Next: Undo,  Prev: User-Level Deletion,  Up: Text
6623
6624 The Kill Ring
6625 =============
6626
6627 "Kill" functions delete text like the deletion functions, but save it
6628 so that the user can reinsert it by "yanking".  Most of these functions
6629 have `kill-' in their name.  By contrast, the functions whose names
6630 start with `delete-' normally do not save text for yanking (though they
6631 can still be undone); these are "deletion" functions.
6632
6633    Most of the kill commands are primarily for interactive use, and are
6634 not described here.  What we do describe are the functions provided for
6635 use in writing such commands.  You can use these functions to write
6636 commands for killing text.  When you need to delete text for internal
6637 purposes within a Lisp function, you should normally use deletion
6638 functions, so as not to disturb the kill ring contents.  *Note
6639 Deletion::.
6640
6641    Killed text is saved for later yanking in the "kill ring".  This is
6642 a list that holds a number of recent kills, not just the last text
6643 kill.  We call this a "ring" because yanking treats it as having
6644 elements in a cyclic order.  The list is kept in the variable
6645 `kill-ring', and can be operated on with the usual functions for lists;
6646 there are also specialized functions, described in this section, that
6647 treat it as a ring.
6648
6649    Some people think this use of the word "kill" is unfortunate, since
6650 it refers to operations that specifically _do not_ destroy the entities
6651 "killed".  This is in sharp contrast to ordinary life, in which death
6652 is permanent and "killed" entities do not come back to life.
6653 Therefore, other metaphors have been proposed.  For example, the term
6654 "cut ring" makes sense to people who, in pre-computer days, used
6655 scissors and paste to cut up and rearrange manuscripts.  However, it
6656 would be difficult to change the terminology now.
6657
6658 * Menu:
6659
6660 * Kill Ring Concepts::     What text looks like in the kill ring.
6661 * Kill Functions::         Functions that kill text.
6662 * Yank Commands::          Commands that access the kill ring.
6663 * Low-Level Kill Ring::    Functions and variables for kill ring access.
6664 * Internals of Kill Ring:: Variables that hold kill-ring data.
6665
6666 \1f
6667 File: lispref.info,  Node: Kill Ring Concepts,  Next: Kill Functions,  Up: The Kill Ring
6668
6669 Kill Ring Concepts
6670 ------------------
6671
6672 The kill ring records killed text as strings in a list, most recent
6673 first.  A short kill ring, for example, might look like this:
6674
6675      ("some text" "a different piece of text" "even older text")
6676
6677 When the list reaches `kill-ring-max' entries in length, adding a new
6678 entry automatically deletes the last entry.
6679
6680    When kill commands are interwoven with other commands, each kill
6681 command makes a new entry in the kill ring.  Multiple kill commands in
6682 succession build up a single entry in the kill ring, which would be
6683 yanked as a unit; the second and subsequent consecutive kill commands
6684 add text to the entry made by the first one.
6685
6686    For yanking, one entry in the kill ring is designated the "front" of
6687 the ring.  Some yank commands "rotate" the ring by designating a
6688 different element as the "front."  But this virtual rotation doesn't
6689 change the list itself--the most recent entry always comes first in the
6690 list.
6691
6692 \1f
6693 File: lispref.info,  Node: Kill Functions,  Next: Yank Commands,  Prev: Kill Ring Concepts,  Up: The Kill Ring
6694
6695 Functions for Killing
6696 ---------------------
6697
6698 `kill-region' is the usual subroutine for killing text.  Any command
6699 that calls this function is a "kill command" (and should probably have
6700 `kill' in its name).  `kill-region' puts the newly killed text in a new
6701 element at the beginning of the kill ring or adds it to the most recent
6702 element.  It uses the `last-command' variable to determine whether the
6703 previous command was a kill command, and if so appends the killed text
6704 to the most recent entry.
6705
6706  - Command: kill-region start end &optional verbose
6707      This function kills the text in the region defined by START and
6708      END.  The text is deleted but saved in the kill ring, along with
6709      its text properties.  The value is always `nil'.
6710
6711      In an interactive call, START and END are point and the mark.
6712
6713      If the buffer is read-only, `kill-region' modifies the kill ring
6714      just the same, then signals an error without modifying the buffer.
6715      This is convenient because it lets the user use all the kill
6716      commands to copy text into the kill ring from a read-only buffer.
6717
6718  - Command: copy-region-as-kill start end
6719      This command saves the region defined by START and END on the kill
6720      ring (including text properties), but does not delete the text
6721      from the buffer.  It returns `nil'.  It also indicates the extent
6722      of the text copied by moving the cursor momentarily, or by
6723      displaying a message in the echo area.
6724
6725      The command does not set `this-command' to `kill-region', so a
6726      subsequent kill command does not append to the same kill ring
6727      entry.
6728
6729      Don't call `copy-region-as-kill' in Lisp programs unless you aim to
6730      support Emacs 18.  For Emacs 19, it is better to use `kill-new' or
6731      `kill-append' instead.  *Note Low-Level Kill Ring::.
6732
6733 \1f
6734 File: lispref.info,  Node: Yank Commands,  Next: Low-Level Kill Ring,  Prev: Kill Functions,  Up: The Kill Ring
6735
6736 Functions for Yanking
6737 ---------------------
6738
6739 "Yanking" means reinserting an entry of previously killed text from the
6740 kill ring.  The text properties are copied too.
6741
6742  - Command: yank &optional arg
6743      This command inserts before point the text in the first entry in
6744      the kill ring.  It positions the mark at the beginning of that
6745      text, and point at the end.
6746
6747      If ARG is a list (which occurs interactively when the user types
6748      `C-u' with no digits), then `yank' inserts the text as described
6749      above, but puts point before the yanked text and puts the mark
6750      after it.
6751
6752      If ARG is a number, then `yank' inserts the ARGth most recently
6753      killed text--the ARGth element of the kill ring list.
6754
6755      `yank' does not alter the contents of the kill ring or rotate it.
6756      It returns `nil'.
6757
6758  - Command: yank-pop arg
6759      This command replaces the just-yanked entry from the kill ring
6760      with a different entry from the kill ring.
6761
6762      This is allowed only immediately after a `yank' or another
6763      `yank-pop'.  At such a time, the region contains text that was just
6764      inserted by yanking.  `yank-pop' deletes that text and inserts in
6765      its place a different piece of killed text.  It does not add the
6766      deleted text to the kill ring, since it is already in the kill
6767      ring somewhere.
6768
6769      If ARG is `nil', then the replacement text is the previous element
6770      of the kill ring.  If ARG is numeric, the replacement is the ARGth
6771      previous kill.  If ARG is negative, a more recent kill is the
6772      replacement.
6773
6774      The sequence of kills in the kill ring wraps around, so that after
6775      the oldest one comes the newest one, and before the newest one
6776      goes the oldest.
6777
6778      The value is always `nil'.
6779
6780 \1f
6781 File: lispref.info,  Node: Low-Level Kill Ring,  Next: Internals of Kill Ring,  Prev: Yank Commands,  Up: The Kill Ring
6782
6783 Low-Level Kill Ring
6784 -------------------
6785
6786 These functions and variables provide access to the kill ring at a lower
6787 level, but still convenient for use in Lisp programs.  They take care of
6788 interaction with X Window selections.  They do not exist in Emacs
6789 version 18.
6790
6791  - Function: current-kill count &optional do-not-move
6792      The function `current-kill' rotates the yanking pointer which
6793      designates the "front" of the kill ring by COUNT places (from newer
6794      kills to older ones), and returns the text at that place in the
6795      ring.
6796
6797      If the optional second argument DO-NOT-MOVE is non-`nil', then
6798      `current-kill' doesn't alter the yanking pointer; it just returns
6799      the COUNTth kill, counting from the current yanking pointer.
6800
6801      If COUNT is zero, indicating a request for the latest kill,
6802      `current-kill' calls the value of `interprogram-paste-function'
6803      (documented below) before consulting the kill ring.
6804
6805  - Function: kill-new string &optional replace
6806      This function makes the text STRING the latest entry in the kill
6807      ring, and sets `kill-ring-yank-pointer' to point to it.
6808
6809      Normally, STRING is added to the front of the kill ring as a new
6810      entry.  However, if optional argument REPLACE is non-`nil', the
6811      entry previously at the front of the kill ring is discarded, and
6812      STRING replaces it.
6813
6814      This function runs the functions on `kill-hooks', and also invokes
6815      the value of `interprogram-cut-function' (see below).
6816
6817  - Function: kill-append string before-p
6818      This function appends the text STRING to the first entry in the
6819      kill ring.  Normally STRING goes at the end of the entry, but if
6820      BEFORE-P is non-`nil', it goes at the beginning.  This function
6821      also invokes the value of `interprogram-cut-function' (see below).
6822
6823  - Variable: interprogram-paste-function
6824      This variable provides a way of transferring killed text from other
6825      programs, when you are using a window system.  Its value should be
6826      `nil' or a function of no arguments.
6827
6828      If the value is a function, `current-kill' calls it to get the
6829      "most recent kill".  If the function returns a non-`nil' value,
6830      then that value is used as the "most recent kill".  If it returns
6831      `nil', then the first element of `kill-ring' is used.
6832
6833      The normal use of this hook is to get the X server's primary
6834      selection as the most recent kill, even if the selection belongs
6835      to another X client.  *Note X Selections::.
6836
6837  - Variable: interprogram-cut-function
6838      This variable provides a way of communicating killed text to other
6839      programs, when you are using a window system.  Its value should be
6840      `nil' or a function of one argument.
6841
6842      If the value is a function, `kill-new' and `kill-append' call it
6843      with the new first element of the kill ring as an argument.
6844
6845      The normal use of this hook is to set the X server's primary
6846      selection to the newly killed text.
6847
6848 \1f
6849 File: lispref.info,  Node: Internals of Kill Ring,  Prev: Low-Level Kill Ring,  Up: The Kill Ring
6850
6851 Internals of the Kill Ring
6852 --------------------------
6853
6854 The variable `kill-ring' holds the kill ring contents, in the form of a
6855 list of strings.  The most recent kill is always at the front of the
6856 list.
6857
6858    The `kill-ring-yank-pointer' variable points to a link in the kill
6859 ring list, whose CAR is the text to yank next.  We say it identifies
6860 the "front" of the ring.  Moving `kill-ring-yank-pointer' to a
6861 different link is called "rotating the kill ring".  We call the kill
6862 ring a "ring" because the functions that move the yank pointer wrap
6863 around from the end of the list to the beginning, or vice-versa.
6864 Rotation of the kill ring is virtual; it does not change the value of
6865 `kill-ring'.
6866
6867    Both `kill-ring' and `kill-ring-yank-pointer' are Lisp variables
6868 whose values are normally lists.  The word "pointer" in the name of the
6869 `kill-ring-yank-pointer' indicates that the variable's purpose is to
6870 identify one element of the list for use by the next yank command.
6871
6872    The value of `kill-ring-yank-pointer' is always `eq' to one of the
6873 links in the kill ring list.  The element it identifies is the CAR of
6874 that link.  Kill commands, which change the kill ring, also set this
6875 variable to the value of `kill-ring'.  The effect is to rotate the ring
6876 so that the newly killed text is at the front.
6877
6878    Here is a diagram that shows the variable `kill-ring-yank-pointer'
6879 pointing to the second entry in the kill ring `("some text" "a
6880 different piece of text" "yet older text")'.
6881
6882      kill-ring       kill-ring-yank-pointer
6883        |               |
6884        |     ___ ___    --->  ___ ___      ___ ___
6885         --> |___|___|------> |___|___|--> |___|___|--> nil
6886               |                |            |
6887               |                |            |
6888               |                |             -->"yet older text"
6889               |                |
6890               |                 --> "a different piece of text"
6891               |
6892                --> "some text"
6893
6894 This state of affairs might occur after `C-y' (`yank') immediately
6895 followed by `M-y' (`yank-pop').
6896
6897  - Variable: kill-ring
6898      This variable holds the list of killed text sequences, most
6899      recently killed first.
6900
6901  - Variable: kill-ring-yank-pointer
6902      This variable's value indicates which element of the kill ring is
6903      at the "front" of the ring for yanking.  More precisely, the value
6904      is a tail of the value of `kill-ring', and its CAR is the kill
6905      string that `C-y' should yank.
6906
6907  - User Option: kill-ring-max
6908      The value of this variable is the maximum length to which the kill
6909      ring can grow, before elements are thrown away at the end.  The
6910      default value for `kill-ring-max' is 30.
6911
6912 \1f
6913 File: lispref.info,  Node: Undo,  Next: Maintaining Undo,  Prev: The Kill Ring,  Up: Text
6914
6915 Undo
6916 ====
6917
6918 Most buffers have an "undo list", which records all changes made to the
6919 buffer's text so that they can be undone.  (The buffers that don't have
6920 one are usually special-purpose buffers for which XEmacs assumes that
6921 undoing is not useful.)  All the primitives that modify the text in the
6922 buffer automatically add elements to the front of the undo list, which
6923 is in the variable `buffer-undo-list'.
6924
6925  - Variable: buffer-undo-list
6926      This variable's value is the undo list of the current buffer.  A
6927      value of `t' disables the recording of undo information.
6928
6929    Here are the kinds of elements an undo list can have:
6930
6931 `INTEGER'
6932      This kind of element records a previous value of point.  Ordinary
6933      cursor motion does not get any sort of undo record, but deletion
6934      commands use these entries to record where point was before the
6935      command.
6936
6937 `(START . END)'
6938      This kind of element indicates how to delete text that was
6939      inserted.  Upon insertion, the text occupied the range START-END
6940      in the buffer.
6941
6942 `(TEXT . POSITION)'
6943      This kind of element indicates how to reinsert text that was
6944      deleted.  The deleted text itself is the string TEXT.  The place to
6945      reinsert it is `(abs POSITION)'.
6946
6947 `(t HIGH . LOW)'
6948      This kind of element indicates that an unmodified buffer became
6949      modified.  The elements HIGH and LOW are two integers, each
6950      recording 16 bits of the visited file's modification time as of
6951      when it was previously visited or saved.  `primitive-undo' uses
6952      those values to determine whether to mark the buffer as unmodified
6953      once again; it does so only if the file's modification time
6954      matches those numbers.
6955
6956 `(nil PROPERTY VALUE START . END)'
6957      This kind of element records a change in a text property.  Here's
6958      how you might undo the change:
6959
6960           (put-text-property START END PROPERTY VALUE)
6961
6962 `POSITION'
6963      This element indicates where point was at an earlier time.
6964      Undoing this element sets point to POSITION.  Deletion normally
6965      creates an element of this kind as well as a reinsertion element.
6966
6967 `nil'
6968      This element is a boundary.  The elements between two boundaries
6969      are called a "change group"; normally, each change group
6970      corresponds to one keyboard command, and undo commands normally
6971      undo an entire group as a unit.
6972
6973  - Function: undo-boundary
6974      This function places a boundary element in the undo list.  The undo
6975      command stops at such a boundary, and successive undo commands undo
6976      to earlier and earlier boundaries.  This function returns `nil'.
6977
6978      The editor command loop automatically creates an undo boundary
6979      before each key sequence is executed.  Thus, each undo normally
6980      undoes the effects of one command.  Self-inserting input
6981      characters are an exception.  The command loop makes a boundary
6982      for the first such character; the next 19 consecutive
6983      self-inserting input characters do not make boundaries, and then
6984      the 20th does, and so on as long as self-inserting characters
6985      continue.
6986
6987      All buffer modifications add a boundary whenever the previous
6988      undoable change was made in some other buffer.  This way, a
6989      command that modifies several buffers makes a boundary in each
6990      buffer it changes.
6991
6992      Calling this function explicitly is useful for splitting the
6993      effects of a command into more than one unit.  For example,
6994      `query-replace' calls `undo-boundary' after each replacement, so
6995      that the user can undo individual replacements one by one.
6996
6997  - Function: primitive-undo count list
6998      This is the basic function for undoing elements of an undo list.
6999      It undoes the first COUNT elements of LIST, returning the rest of
7000      LIST.  You could write this function in Lisp, but it is convenient
7001      to have it in C.
7002
7003      `primitive-undo' adds elements to the buffer's undo list when it
7004      changes the buffer.  Undo commands avoid confusion by saving the
7005      undo list value at the beginning of a sequence of undo operations.
7006      Then the undo operations use and update the saved value.  The new
7007      elements added by undoing are not part of this saved value, so
7008      they don't interfere with continuing to undo.
7009