Sync up with r21-4-14-chise-0_21-22.
[chise/xemacs-chise.git] / info / lispref.info-30
1 This is ../info/lispref.info, produced by makeinfo version 4.0b from
2 lispref/lispref.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * Lispref: (lispref).           XEmacs Lisp Reference Manual.
7 END-INFO-DIR-ENTRY
8
9    Edition History:
10
11    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
12 Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
13 Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
14 XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
15 GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
16 Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
17 Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
18 Reference Manual (for 19.15 and 20.1, 20.2, 20.3) v3.2, April, May,
19 November 1997 XEmacs Lisp Reference Manual (for 21.0) v3.3, April 1998
20
21    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
22 Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
23 Copyright (C) 1995, 1996 Ben Wing.
24
25    Permission is granted to make and distribute verbatim copies of this
26 manual provided the copyright notice and this permission notice are
27 preserved on all copies.
28
29    Permission is granted to copy and distribute modified versions of
30 this manual under the conditions for verbatim copying, provided that the
31 entire resulting derived work is distributed under the terms of a
32 permission notice identical to this one.
33
34    Permission is granted to copy and distribute translations of this
35 manual into another language, under the above conditions for modified
36 versions, except that this permission notice may be stated in a
37 translation approved by the Foundation.
38
39    Permission is granted to copy and distribute modified versions of
40 this manual under the conditions for verbatim copying, provided also
41 that the section entitled "GNU General Public License" is included
42 exactly as in the original, and provided that the entire resulting
43 derived work is distributed under the terms of a permission notice
44 identical to this one.
45
46    Permission is granted to copy and distribute translations of this
47 manual into another language, under the above conditions for modified
48 versions, except that the section entitled "GNU General Public License"
49 may be included in a translation approved by the Free Software
50 Foundation instead of in the original English.
51
52 \1f
53 File: lispref.info,  Node: Insertion,  Next: Commands for Insertion,  Prev: Comparing Text,  Up: Text
54
55 Inserting Text
56 ==============
57
58    "Insertion" means adding new text to a buffer.  The inserted text
59 goes at point--between the character before point and the character
60 after point.
61
62    Insertion relocates markers that point at positions after the
63 insertion point, so that they stay with the surrounding text (*note
64 Markers::).  When a marker points at the place of insertion, insertion
65 normally doesn't relocate the marker, so that it points to the
66 beginning of the inserted text; however, certain special functions such
67 as `insert-before-markers' relocate such markers to point after the
68 inserted text.
69
70    Some insertion functions leave point before the inserted text, while
71 other functions leave it after.  We call the former insertion "after
72 point" and the latter insertion "before point".
73
74    If a string with non-`nil' extent data is inserted, the remembered
75 extents will also be inserted.  *Note Duplicable Extents::.
76
77    Insertion functions signal an error if the current buffer is
78 read-only.
79
80    These functions copy text characters from strings and buffers along
81 with their properties.  The inserted characters have exactly the same
82 properties as the characters they were copied from.  By contrast,
83 characters specified as separate arguments, not part of a string or
84 buffer, inherit their text properties from the neighboring text.
85
86  - Function: insert &rest args
87      This function inserts the strings and/or characters ARGS into the
88      current buffer, at point, moving point forward.  In other words, it
89      inserts the text before point.  An error is signaled unless all
90      ARGS are either strings or characters.  The value is `nil'.
91
92  - Function: insert-before-markers &rest args
93      This function inserts the strings and/or characters ARGS into the
94      current buffer, at point, moving point forward.  An error is
95      signaled unless all ARGS are either strings or characters.  The
96      value is `nil'.
97
98      This function is unlike the other insertion functions in that it
99      relocates markers initially pointing at the insertion point, to
100      point after the inserted text.
101
102  - Function: insert-string string &optional buffer
103      This function inserts STRING into BUFFER before point.  BUFFER
104      defaults to the current buffer if omitted.  This function is
105      chiefly useful if you want to insert a string in a buffer other
106      than the current one (otherwise you could just use `insert').
107
108  - Function: insert-char character &optional count ignored buffer
109      This function inserts COUNT instances of CHARACTER into BUFFER
110      before point.  COUNT must be a number, and CHARACTER must be a
111      character.
112
113      If optional argument BUFFER is `nil', the current buffer is
114      assumed. (In FSF Emacs, the third argument is called INHERIT and
115      refers to text properties.  In XEmacs, it is always ignored.)
116
117      This function always returns `nil'.
118
119  - Function: insert-buffer-substring from-buffer-or-name &optional
120           start end
121      This function inserts a portion of buffer FROM-BUFFER-OR-NAME
122      (which must already exist) into the current buffer before point.
123      The text inserted is the region from START and END.  (These
124      arguments default to the beginning and end of the accessible
125      portion of that buffer.)  This function returns `nil'.
126
127      In this example, the form is executed with buffer `bar' as the
128      current buffer.  We assume that buffer `bar' is initially empty.
129
130           ---------- Buffer: foo ----------
131           We hold these truths to be self-evident, that all
132           ---------- Buffer: foo ----------
133           
134           (insert-buffer-substring "foo" 1 20)
135                => nil
136           
137           ---------- Buffer: bar ----------
138           We hold these truth-!-
139           ---------- Buffer: bar ----------
140
141 \1f
142 File: lispref.info,  Node: Commands for Insertion,  Next: Deletion,  Prev: Insertion,  Up: Text
143
144 User-Level Insertion Commands
145 =============================
146
147    This section describes higher-level commands for inserting text,
148 commands intended primarily for the user but useful also in Lisp
149 programs.
150
151  - Command: insert-buffer from-buffer-or-name
152      This command inserts the entire contents of FROM-BUFFER-OR-NAME
153      (which must exist) into the current buffer after point.  It leaves
154      the mark after the inserted text.  The value is `nil'.
155
156  - Command: self-insert-command count
157      This command inserts the last character typed; it does so COUNT
158      times, before point, and returns `nil'.  Most printing characters
159      are bound to this command.  In routine use, `self-insert-command'
160      is the most frequently called function in XEmacs, but programs
161      rarely use it except to install it on a keymap.
162
163      In an interactive call, COUNT is the numeric prefix argument.
164
165      This command calls `auto-fill-function' whenever that is non-`nil'
166      and the character inserted is a space or a newline (*note Auto
167      Filling::).
168
169      This command performs abbrev expansion if Abbrev mode is enabled
170      and the inserted character does not have word-constituent syntax.
171      (*Note Abbrevs::, and *Note Syntax Class Table::.)
172
173      This is also responsible for calling `blink-paren-function' when
174      the inserted character has close parenthesis syntax (*note
175      Blinking::).
176
177  - Command: newline &optional count
178      This command inserts newlines into the current buffer before point.
179      If COUNT is supplied, that many newline characters are inserted.
180
181      This function calls `auto-fill-function' if the current column
182      number is greater than the value of `fill-column' and COUNT is
183      `nil'.  Typically what `auto-fill-function' does is insert a
184      newline; thus, the overall result in this case is to insert two
185      newlines at different places: one at point, and another earlier in
186      the line.  `newline' does not auto-fill if COUNT is non-`nil'.
187
188      This command indents to the left margin if that is not zero.
189      *Note Margins::.
190
191      The value returned is `nil'.  In an interactive call, COUNT is the
192      numeric prefix argument.
193
194  - Command: split-line
195      This command splits the current line, moving the portion of the
196      line after point down vertically so that it is on the next line
197      directly below where it was before.  Whitespace is inserted as
198      needed at the beginning of the lower line, using the `indent-to'
199      function.  `split-line' returns the position of point.
200
201      Programs hardly ever use this function.
202
203  - Variable: overwrite-mode
204      This variable controls whether overwrite mode is in effect: a
205      non-`nil' value enables the mode.  It is automatically made
206      buffer-local when set in any fashion.
207
208 \1f
209 File: lispref.info,  Node: Deletion,  Next: User-Level Deletion,  Prev: Commands for Insertion,  Up: Text
210
211 Deleting Text
212 =============
213
214    Deletion means removing part of the text in a buffer, without saving
215 it in the kill ring (*note The Kill Ring::).  Deleted text can't be
216 yanked, but can be reinserted using the undo mechanism (*note Undo::).
217 Some deletion functions do save text in the kill ring in some special
218 cases.
219
220    All of the deletion functions operate on the current buffer, and all
221 return a value of `nil'.
222
223  - Command: erase-buffer &optional buffer
224      This function deletes the entire text of BUFFER, leaving it empty.
225      If the buffer is read-only, it signals a `buffer-read-only'
226      error.  Otherwise, it deletes the text without asking for any
227      confirmation.  It returns `nil'.  BUFFER defaults to the current
228      buffer if omitted.
229
230      Normally, deleting a large amount of text from a buffer inhibits
231      further auto-saving of that buffer "because it has shrunk".
232      However, `erase-buffer' does not do this, the idea being that the
233      future text is not really related to the former text, and its size
234      should not be compared with that of the former text.
235
236  - Command: delete-region start end &optional buffer
237      This command deletes the text in BUFFER in the region defined by
238      START and END.  The value is `nil'.  If optional argument BUFFER
239      is `nil', the current buffer is assumed.
240
241  - Command: delete-char &optional count killp
242      This command deletes COUNT characters directly after point, or
243      before point if COUNT is negative.  COUNT defaults to `1'.  If
244      KILLP is non-`nil', then it saves the deleted characters in the
245      kill ring.
246
247      In an interactive call, COUNT is the numeric prefix argument, and
248      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
249      argument is supplied, the text is saved in the kill ring.  If no
250      prefix argument is supplied, then one character is deleted, but
251      not saved in the kill ring.
252
253      The value returned is always `nil'.
254
255  - Command: delete-backward-char &optional count killp
256      This command deletes COUNT characters directly before point, or
257      after point if COUNT is negative.  COUNT defaults to 1.  If KILLP
258      is non-`nil', then it saves the deleted characters in the kill
259      ring.
260
261      In an interactive call, COUNT is the numeric prefix argument, and
262      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
263      argument is supplied, the text is saved in the kill ring.  If no
264      prefix argument is supplied, then one character is deleted, but
265      not saved in the kill ring.
266
267      The value returned is always `nil'.
268
269  - Command: backward-delete-char-untabify count &optional killp
270      This command deletes COUNT characters backward, changing tabs into
271      spaces.  When the next character to be deleted is a tab, it is
272      first replaced with the proper number of spaces to preserve
273      alignment and then one of those spaces is deleted instead of the
274      tab.  If KILLP is non-`nil', then the command saves the deleted
275      characters in the kill ring.
276
277      Conversion of tabs to spaces happens only if COUNT is positive.
278      If it is negative, exactly -COUNT characters after point are
279      deleted.
280
281      In an interactive call, COUNT is the numeric prefix argument, and
282      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
283      argument is supplied, the text is saved in the kill ring.  If no
284      prefix argument is supplied, then one character is deleted, but
285      not saved in the kill ring.
286
287      The value returned is always `nil'.
288
289 \1f
290 File: lispref.info,  Node: User-Level Deletion,  Next: The Kill Ring,  Prev: Deletion,  Up: Text
291
292 User-Level Deletion Commands
293 ============================
294
295    This section describes higher-level commands for deleting text,
296 commands intended primarily for the user but useful also in Lisp
297 programs.
298
299  - Command: delete-horizontal-space
300      This function deletes all spaces and tabs around point.  It returns
301      `nil'.
302
303      In the following examples, we call `delete-horizontal-space' four
304      times, once on each line, with point between the second and third
305      characters on the line each time.
306
307           ---------- Buffer: foo ----------
308           I -!-thought
309           I -!-     thought
310           We-!- thought
311           Yo-!-u thought
312           ---------- Buffer: foo ----------
313           
314           (delete-horizontal-space)   ; Four times.
315                => nil
316           
317           ---------- Buffer: foo ----------
318           Ithought
319           Ithought
320           Wethought
321           You thought
322           ---------- Buffer: foo ----------
323
324  - Command: delete-indentation &optional join-following-p
325      This function joins the line point is on to the previous line,
326      deleting any whitespace at the join and in some cases replacing it
327      with one space.  If JOIN-FOLLOWING-P is non-`nil',
328      `delete-indentation' joins this line to the following line
329      instead.  The value is `nil'.
330
331      If there is a fill prefix, and the second of the lines being joined
332      starts with the prefix, then `delete-indentation' deletes the fill
333      prefix before joining the lines.  *Note Margins::.
334
335      In the example below, point is located on the line starting
336      `events', and it makes no difference if there are trailing spaces
337      in the preceding line.
338
339           ---------- Buffer: foo ----------
340           When in the course of human
341           -!-    events, it becomes necessary
342           ---------- Buffer: foo ----------
343           
344           (delete-indentation)
345                => nil
346           
347           ---------- Buffer: foo ----------
348           When in the course of human-!- events, it becomes necessary
349           ---------- Buffer: foo ----------
350
351      After the lines are joined, the function `fixup-whitespace' is
352      responsible for deciding whether to leave a space at the junction.
353
354  - Command: fixup-whitespace
355      This function replaces all the white space surrounding point with
356      either one space or no space, according to the context.  It
357      returns `nil'.
358
359      At the beginning or end of a line, the appropriate amount of space
360      is none.  Before a character with close parenthesis syntax, or
361      after a character with open parenthesis or expression-prefix
362      syntax, no space is also appropriate.  Otherwise, one space is
363      appropriate.  *Note Syntax Class Table::.
364
365      In the example below, `fixup-whitespace' is called the first time
366      with point before the word `spaces' in the first line.  For the
367      second invocation, point is directly after the `('.
368
369           ---------- Buffer: foo ----------
370           This has too many     -!-spaces
371           This has too many spaces at the start of (-!-   this list)
372           ---------- Buffer: foo ----------
373           
374           (fixup-whitespace)
375                => nil
376           (fixup-whitespace)
377                => nil
378           
379           ---------- Buffer: foo ----------
380           This has too many spaces
381           This has too many spaces at the start of (this list)
382           ---------- Buffer: foo ----------
383
384  - Command: just-one-space
385      This command replaces any spaces and tabs around point with a
386      single space.  It returns `nil'.
387
388  - Command: delete-blank-lines
389      This function deletes blank lines surrounding point.  If point is
390      on a blank line with one or more blank lines before or after it,
391      then all but one of them are deleted.  If point is on an isolated
392      blank line, then it is deleted.  If point is on a nonblank line,
393      the command deletes all blank lines following it.
394
395      A blank line is defined as a line containing only tabs and spaces.
396
397      `delete-blank-lines' returns `nil'.
398
399 \1f
400 File: lispref.info,  Node: The Kill Ring,  Next: Undo,  Prev: User-Level Deletion,  Up: Text
401
402 The Kill Ring
403 =============
404
405    "Kill" functions delete text like the deletion functions, but save
406 it so that the user can reinsert it by "yanking".  Most of these
407 functions have `kill-' in their name.  By contrast, the functions whose
408 names start with `delete-' normally do not save text for yanking
409 (though they can still be undone); these are "deletion" functions.
410
411    Most of the kill commands are primarily for interactive use, and are
412 not described here.  What we do describe are the functions provided for
413 use in writing such commands.  You can use these functions to write
414 commands for killing text.  When you need to delete text for internal
415 purposes within a Lisp function, you should normally use deletion
416 functions, so as not to disturb the kill ring contents.  *Note
417 Deletion::.
418
419    Killed text is saved for later yanking in the "kill ring".  This is
420 a list that holds a number of recent kills, not just the last text
421 kill.  We call this a "ring" because yanking treats it as having
422 elements in a cyclic order.  The list is kept in the variable
423 `kill-ring', and can be operated on with the usual functions for lists;
424 there are also specialized functions, described in this section, that
425 treat it as a ring.
426
427    Some people think this use of the word "kill" is unfortunate, since
428 it refers to operations that specifically _do not_ destroy the entities
429 "killed".  This is in sharp contrast to ordinary life, in which death
430 is permanent and "killed" entities do not come back to life.
431 Therefore, other metaphors have been proposed.  For example, the term
432 "cut ring" makes sense to people who, in pre-computer days, used
433 scissors and paste to cut up and rearrange manuscripts.  However, it
434 would be difficult to change the terminology now.
435
436 * Menu:
437
438 * Kill Ring Concepts::     What text looks like in the kill ring.
439 * Kill Functions::         Functions that kill text.
440 * Yank Commands::          Commands that access the kill ring.
441 * Low-Level Kill Ring::    Functions and variables for kill ring access.
442 * Internals of Kill Ring:: Variables that hold kill-ring data.
443
444 \1f
445 File: lispref.info,  Node: Kill Ring Concepts,  Next: Kill Functions,  Up: The Kill Ring
446
447 Kill Ring Concepts
448 ------------------
449
450    The kill ring records killed text as strings in a list, most recent
451 first.  A short kill ring, for example, might look like this:
452
453      ("some text" "a different piece of text" "even older text")
454
455 When the list reaches `kill-ring-max' entries in length, adding a new
456 entry automatically deletes the last entry.
457
458    When kill commands are interwoven with other commands, each kill
459 command makes a new entry in the kill ring.  Multiple kill commands in
460 succession build up a single entry in the kill ring, which would be
461 yanked as a unit; the second and subsequent consecutive kill commands
462 add text to the entry made by the first one.
463
464    For yanking, one entry in the kill ring is designated the "front" of
465 the ring.  Some yank commands "rotate" the ring by designating a
466 different element as the "front."  But this virtual rotation doesn't
467 change the list itself--the most recent entry always comes first in the
468 list.
469
470 \1f
471 File: lispref.info,  Node: Kill Functions,  Next: Yank Commands,  Prev: Kill Ring Concepts,  Up: The Kill Ring
472
473 Functions for Killing
474 ---------------------
475
476    `kill-region' is the usual subroutine for killing text.  Any command
477 that calls this function is a "kill command" (and should probably have
478 `kill' in its name).  `kill-region' puts the newly killed text in a new
479 element at the beginning of the kill ring or adds it to the most recent
480 element.  It uses the `last-command' variable to determine whether the
481 previous command was a kill command, and if so appends the killed text
482 to the most recent entry.
483
484  - Command: kill-region start end &optional verbose
485      This function kills the text in the region defined by START and
486      END.  The text is deleted but saved in the kill ring, along with
487      its text properties.  The value is always `nil'.
488
489      In an interactive call, START and END are point and the mark.
490
491      If the buffer is read-only, `kill-region' modifies the kill ring
492      just the same, then signals an error without modifying the buffer.
493      This is convenient because it lets the user use all the kill
494      commands to copy text into the kill ring from a read-only buffer.
495
496  - Command: copy-region-as-kill start end
497      This command saves the region defined by START and END on the kill
498      ring (including text properties), but does not delete the text
499      from the buffer.  It returns `nil'.  It also indicates the extent
500      of the text copied by moving the cursor momentarily, or by
501      displaying a message in the echo area.
502
503      The command does not set `this-command' to `kill-region', so a
504      subsequent kill command does not append to the same kill ring
505      entry.
506
507      Don't call `copy-region-as-kill' in Lisp programs unless you aim to
508      support Emacs 18.  For Emacs 19, it is better to use `kill-new' or
509      `kill-append' instead.  *Note Low-Level Kill Ring::.
510
511 \1f
512 File: lispref.info,  Node: Yank Commands,  Next: Low-Level Kill Ring,  Prev: Kill Functions,  Up: The Kill Ring
513
514 Functions for Yanking
515 ---------------------
516
517    "Yanking" means reinserting an entry of previously killed text from
518 the kill ring.  The text properties are copied too.
519
520  - Command: yank &optional arg
521      This command inserts before point the text in the first entry in
522      the kill ring.  It positions the mark at the beginning of that
523      text, and point at the end.
524
525      If ARG is a list (which occurs interactively when the user types
526      `C-u' with no digits), then `yank' inserts the text as described
527      above, but puts point before the yanked text and puts the mark
528      after it.
529
530      If ARG is a number, then `yank' inserts the ARGth most recently
531      killed text--the ARGth element of the kill ring list.
532
533      `yank' does not alter the contents of the kill ring or rotate it.
534      It returns `nil'.
535
536  - Command: yank-pop arg
537      This command replaces the just-yanked entry from the kill ring
538      with a different entry from the kill ring.
539
540      This is allowed only immediately after a `yank' or another
541      `yank-pop'.  At such a time, the region contains text that was just
542      inserted by yanking.  `yank-pop' deletes that text and inserts in
543      its place a different piece of killed text.  It does not add the
544      deleted text to the kill ring, since it is already in the kill
545      ring somewhere.
546
547      If ARG is `nil', then the replacement text is the previous element
548      of the kill ring.  If ARG is numeric, the replacement is the ARGth
549      previous kill.  If ARG is negative, a more recent kill is the
550      replacement.
551
552      The sequence of kills in the kill ring wraps around, so that after
553      the oldest one comes the newest one, and before the newest one
554      goes the oldest.
555
556      The value is always `nil'.
557
558 \1f
559 File: lispref.info,  Node: Low-Level Kill Ring,  Next: Internals of Kill Ring,  Prev: Yank Commands,  Up: The Kill Ring
560
561 Low-Level Kill Ring
562 -------------------
563
564    These functions and variables provide access to the kill ring at a
565 lower level, but still convenient for use in Lisp programs.  They take
566 care of interaction with X Window selections.  They do not exist in
567 Emacs version 18.
568
569  - Function: current-kill count &optional do-not-move
570      The function `current-kill' rotates the yanking pointer which
571      designates the "front" of the kill ring by COUNT places (from newer
572      kills to older ones), and returns the text at that place in the
573      ring.
574
575      If the optional second argument DO-NOT-MOVE is non-`nil', then
576      `current-kill' doesn't alter the yanking pointer; it just returns
577      the COUNTth kill, counting from the current yanking pointer.
578
579      If COUNT is zero, indicating a request for the latest kill,
580      `current-kill' calls the value of `interprogram-paste-function'
581      (documented below) before consulting the kill ring.
582
583  - Function: kill-new string &optional replace
584      This function makes the text STRING the latest entry in the kill
585      ring, and sets `kill-ring-yank-pointer' to point to it.
586
587      Normally, STRING is added to the front of the kill ring as a new
588      entry.  However, if optional argument REPLACE is non-`nil', the
589      entry previously at the front of the kill ring is discarded, and
590      STRING replaces it.
591
592      This function runs the functions on `kill-hooks', and also invokes
593      the value of `interprogram-cut-function' (see below).
594
595  - Function: kill-append string before-p
596      This function appends the text STRING to the first entry in the
597      kill ring.  Normally STRING goes at the end of the entry, but if
598      BEFORE-P is non-`nil', it goes at the beginning.  This function
599      also invokes the value of `interprogram-cut-function' (see below).
600
601  - Variable: interprogram-paste-function
602      This variable provides a way of transferring killed text from other
603      programs, when you are using a window system.  Its value should be
604      `nil' or a function of no arguments.
605
606      If the value is a function, `current-kill' calls it to get the
607      "most recent kill".  If the function returns a non-`nil' value,
608      then that value is used as the "most recent kill".  If it returns
609      `nil', then the first element of `kill-ring' is used.
610
611      The normal use of this hook is to get the X server's primary
612      selection as the most recent kill, even if the selection belongs
613      to another X client.  *Note X Selections::.
614
615  - Variable: interprogram-cut-function
616      This variable provides a way of communicating killed text to other
617      programs, when you are using a window system.  Its value should be
618      `nil' or a function of one argument.
619
620      If the value is a function, `kill-new' and `kill-append' call it
621      with the new first element of the kill ring as an argument.
622
623      The normal use of this hook is to set the X server's primary
624      selection to the newly killed text.
625
626 \1f
627 File: lispref.info,  Node: Internals of Kill Ring,  Prev: Low-Level Kill Ring,  Up: The Kill Ring
628
629 Internals of the Kill Ring
630 --------------------------
631
632    The variable `kill-ring' holds the kill ring contents, in the form
633 of a list of strings.  The most recent kill is always at the front of
634 the list.
635
636    The `kill-ring-yank-pointer' variable points to a link in the kill
637 ring list, whose CAR is the text to yank next.  We say it identifies
638 the "front" of the ring.  Moving `kill-ring-yank-pointer' to a
639 different link is called "rotating the kill ring".  We call the kill
640 ring a "ring" because the functions that move the yank pointer wrap
641 around from the end of the list to the beginning, or vice-versa.
642 Rotation of the kill ring is virtual; it does not change the value of
643 `kill-ring'.
644
645    Both `kill-ring' and `kill-ring-yank-pointer' are Lisp variables
646 whose values are normally lists.  The word "pointer" in the name of the
647 `kill-ring-yank-pointer' indicates that the variable's purpose is to
648 identify one element of the list for use by the next yank command.
649
650    The value of `kill-ring-yank-pointer' is always `eq' to one of the
651 links in the kill ring list.  The element it identifies is the CAR of
652 that link.  Kill commands, which change the kill ring, also set this
653 variable to the value of `kill-ring'.  The effect is to rotate the ring
654 so that the newly killed text is at the front.
655
656    Here is a diagram that shows the variable `kill-ring-yank-pointer'
657 pointing to the second entry in the kill ring `("some text" "a
658 different piece of text" "yet older text")'.
659
660      kill-ring       kill-ring-yank-pointer
661        |               |
662        |     ___ ___    --->  ___ ___      ___ ___
663         --> |___|___|------> |___|___|--> |___|___|--> nil
664               |                |            |
665               |                |            |
666               |                |             -->"yet older text"
667               |                |
668               |                 --> "a different piece of text"
669               |
670                --> "some text"
671
672 This state of affairs might occur after `C-y' (`yank') immediately
673 followed by `M-y' (`yank-pop').
674
675  - Variable: kill-ring
676      This variable holds the list of killed text sequences, most
677      recently killed first.
678
679  - Variable: kill-ring-yank-pointer
680      This variable's value indicates which element of the kill ring is
681      at the "front" of the ring for yanking.  More precisely, the value
682      is a tail of the value of `kill-ring', and its CAR is the kill
683      string that `C-y' should yank.
684
685  - User Option: kill-ring-max
686      The value of this variable is the maximum length to which the kill
687      ring can grow, before elements are thrown away at the end.  The
688      default value for `kill-ring-max' is 30.
689
690 \1f
691 File: lispref.info,  Node: Undo,  Next: Maintaining Undo,  Prev: The Kill Ring,  Up: Text
692
693 Undo
694 ====
695
696    Most buffers have an "undo list", which records all changes made to
697 the buffer's text so that they can be undone.  (The buffers that don't
698 have one are usually special-purpose buffers for which XEmacs assumes
699 that undoing is not useful.)  All the primitives that modify the text
700 in the buffer automatically add elements to the front of the undo list,
701 which is in the variable `buffer-undo-list'.
702
703  - Variable: buffer-undo-list
704      This variable's value is the undo list of the current buffer.  A
705      value of `t' disables the recording of undo information.
706
707    Here are the kinds of elements an undo list can have:
708
709 `INTEGER'
710      This kind of element records a previous value of point.  Ordinary
711      cursor motion does not get any sort of undo record, but deletion
712      commands use these entries to record where point was before the
713      command.
714
715 `(START . END)'
716      This kind of element indicates how to delete text that was
717      inserted.  Upon insertion, the text occupied the range START-END
718      in the buffer.
719
720 `(TEXT . POSITION)'
721      This kind of element indicates how to reinsert text that was
722      deleted.  The deleted text itself is the string TEXT.  The place to
723      reinsert it is `(abs POSITION)'.
724
725 `(t HIGH . LOW)'
726      This kind of element indicates that an unmodified buffer became
727      modified.  The elements HIGH and LOW are two integers, each
728      recording 16 bits of the visited file's modification time as of
729      when it was previously visited or saved.  `primitive-undo' uses
730      those values to determine whether to mark the buffer as unmodified
731      once again; it does so only if the file's modification time
732      matches those numbers.
733
734 `(nil PROPERTY VALUE START . END)'
735      This kind of element records a change in a text property.  Here's
736      how you might undo the change:
737
738           (put-text-property START END PROPERTY VALUE)
739
740 `POSITION'
741      This element indicates where point was at an earlier time.
742      Undoing this element sets point to POSITION.  Deletion normally
743      creates an element of this kind as well as a reinsertion element.
744
745 `nil'
746      This element is a boundary.  The elements between two boundaries
747      are called a "change group"; normally, each change group
748      corresponds to one keyboard command, and undo commands normally
749      undo an entire group as a unit.
750
751  - Function: undo-boundary
752      This function places a boundary element in the undo list.  The undo
753      command stops at such a boundary, and successive undo commands undo
754      to earlier and earlier boundaries.  This function returns `nil'.
755
756      The editor command loop automatically creates an undo boundary
757      before each key sequence is executed.  Thus, each undo normally
758      undoes the effects of one command.  Self-inserting input
759      characters are an exception.  The command loop makes a boundary
760      for the first such character; the next 19 consecutive
761      self-inserting input characters do not make boundaries, and then
762      the 20th does, and so on as long as self-inserting characters
763      continue.
764
765      All buffer modifications add a boundary whenever the previous
766      undoable change was made in some other buffer.  This way, a
767      command that modifies several buffers makes a boundary in each
768      buffer it changes.
769
770      Calling this function explicitly is useful for splitting the
771      effects of a command into more than one unit.  For example,
772      `query-replace' calls `undo-boundary' after each replacement, so
773      that the user can undo individual replacements one by one.
774
775  - Function: primitive-undo count list
776      This is the basic function for undoing elements of an undo list.
777      It undoes the first COUNT elements of LIST, returning the rest of
778      LIST.  You could write this function in Lisp, but it is convenient
779      to have it in C.
780
781      `primitive-undo' adds elements to the buffer's undo list when it
782      changes the buffer.  Undo commands avoid confusion by saving the
783      undo list value at the beginning of a sequence of undo operations.
784      Then the undo operations use and update the saved value.  The new
785      elements added by undoing are not part of this saved value, so
786      they don't interfere with continuing to undo.
787
788 \1f
789 File: lispref.info,  Node: Maintaining Undo,  Next: Filling,  Prev: Undo,  Up: Text
790
791 Maintaining Undo Lists
792 ======================
793
794    This section describes how to enable and disable undo information for
795 a given buffer.  It also explains how the undo list is truncated
796 automatically so it doesn't get too big.
797
798    Recording of undo information in a newly created buffer is normally
799 enabled to start with; but if the buffer name starts with a space, the
800 undo recording is initially disabled.  You can explicitly enable or
801 disable undo recording with the following two functions, or by setting
802 `buffer-undo-list' yourself.
803
804  - Command: buffer-enable-undo &optional buffer-or-name
805      This command enables recording undo information for buffer
806      BUFFER-OR-NAME, so that subsequent changes can be undone.  If no
807      argument is supplied, then the current buffer is used.  This
808      function does nothing if undo recording is already enabled in the
809      buffer.  It returns `nil'.
810
811      In an interactive call, BUFFER-OR-NAME is the current buffer.  You
812      cannot specify any other buffer.
813
814  - Command: buffer-disable-undo &optional buffer
815  - Command: buffer-flush-undo &optional buffer
816      This function discards the undo list of BUFFER, and disables
817      further recording of undo information.  As a result, it is no
818      longer possible to undo either previous changes or any subsequent
819      changes.  If the undo list of BUFFER is already disabled, this
820      function has no effect.
821
822      This function returns `nil'.  It cannot be called interactively.
823
824      The name `buffer-flush-undo' is not considered obsolete, but the
825      preferred name `buffer-disable-undo' is new as of Emacs versions
826      19.
827
828    As editing continues, undo lists get longer and longer.  To prevent
829 them from using up all available memory space, garbage collection trims
830 them back to size limits you can set.  (For this purpose, the "size" of
831 an undo list measures the cons cells that make up the list, plus the
832 strings of deleted text.)  Two variables control the range of acceptable
833 sizes: `undo-limit' and `undo-strong-limit'.
834
835  - Variable: undo-limit
836      This is the soft limit for the acceptable size of an undo list.
837      The change group at which this size is exceeded is the last one
838      kept.
839
840  - Variable: undo-strong-limit
841      This is the upper limit for the acceptable size of an undo list.
842      The change group at which this size is exceeded is discarded
843      itself (along with all older change groups).  There is one
844      exception: the very latest change group is never discarded no
845      matter how big it is.
846
847 \1f
848 File: lispref.info,  Node: Filling,  Next: Margins,  Prev: Maintaining Undo,  Up: Text
849
850 Filling
851 =======
852
853    "Filling" means adjusting the lengths of lines (by moving the line
854 breaks) so that they are nearly (but no greater than) a specified
855 maximum width.  Additionally, lines can be "justified", which means
856 inserting spaces to make the left and/or right margins line up
857 precisely.  The width is controlled by the variable `fill-column'.  For
858 ease of reading, lines should be no longer than 70 or so columns.
859
860    You can use Auto Fill mode (*note Auto Filling::) to fill text
861 automatically as you insert it, but changes to existing text may leave
862 it improperly filled.  Then you must fill the text explicitly.
863
864    Most of the commands in this section return values that are not
865 meaningful.  All the functions that do filling take note of the current
866 left margin, current right margin, and current justification style
867 (*note Margins::).  If the current justification style is `none', the
868 filling functions don't actually do anything.
869
870    Several of the filling functions have an argument JUSTIFY.  If it is
871 non-`nil', that requests some kind of justification.  It can be `left',
872 `right', `full', or `center', to request a specific style of
873 justification.  If it is `t', that means to use the current
874 justification style for this part of the text (see
875 `current-justification', below).
876
877    When you call the filling functions interactively, using a prefix
878 argument implies the value `full' for JUSTIFY.
879
880  - Command: fill-paragraph justify
881      This command fills the paragraph at or after point.  If JUSTIFY is
882      non-`nil', each line is justified as well.  It uses the ordinary
883      paragraph motion commands to find paragraph boundaries.  *Note
884      Paragraphs: (xemacs)Paragraphs.
885
886  - Command: fill-region start end &optional justify
887      This command fills each of the paragraphs in the region from START
888      to END.  It justifies as well if JUSTIFY is non-`nil'.
889
890      The variable `paragraph-separate' controls how to distinguish
891      paragraphs.  *Note Standard Regexps::.
892
893  - Command: fill-individual-paragraphs start end &optional justify
894           mail-flag
895      This command fills each paragraph in the region according to its
896      individual fill prefix.  Thus, if the lines of a paragraph were
897      indented with spaces, the filled paragraph will remain indented in
898      the same fashion.
899
900      The first two arguments, START and END, are the beginning and end
901      of the region to be filled.  The third and fourth arguments,
902      JUSTIFY and MAIL-FLAG, are optional.  If JUSTIFY is non-`nil', the
903      paragraphs are justified as well as filled.  If MAIL-FLAG is
904      non-`nil', it means the function is operating on a mail message
905      and therefore should not fill the header lines.
906
907      Ordinarily, `fill-individual-paragraphs' regards each change in
908      indentation as starting a new paragraph.  If
909      `fill-individual-varying-indent' is non-`nil', then only separator
910      lines separate paragraphs.  That mode can handle indented
911      paragraphs with additional indentation on the first line.
912
913  - User Option: fill-individual-varying-indent
914      This variable alters the action of `fill-individual-paragraphs' as
915      described above.
916
917  - Command: fill-region-as-paragraph start end &optional justify
918      This command considers a region of text as a paragraph and fills
919      it.  If the region was made up of many paragraphs, the blank lines
920      between paragraphs are removed.  This function justifies as well
921      as filling when JUSTIFY is non-`nil'.
922
923      In an interactive call, any prefix argument requests justification.
924
925      In Adaptive Fill mode, which is enabled by default,
926      `fill-region-as-paragraph' on an indented paragraph when there is
927      no fill prefix uses the indentation of the second line of the
928      paragraph as the fill prefix.
929
930  - Command: justify-current-line how eop nosqueeze
931      This command inserts spaces between the words of the current line
932      so that the line ends exactly at `fill-column'.  It returns `nil'.
933
934      The argument HOW, if non-`nil' specifies explicitly the style of
935      justification.  It can be `left', `right', `full', `center', or
936      `none'.  If it is `t', that means to do follow specified
937      justification style (see `current-justification', below).  `nil'
938      means to do full justification.
939
940      If EOP is non-`nil', that means do left-justification when
941      `current-justification' specifies full justification.  This is used
942      for the last line of a paragraph; even if the paragraph as a whole
943      is fully justified, the last line should not be.
944
945      If NOSQUEEZE is non-`nil', that means do not change interior
946      whitespace.
947
948  - User Option: default-justification
949      This variable's value specifies the style of justification to use
950      for text that doesn't specify a style with a text property.  The
951      possible values are `left', `right', `full', `center', or `none'.
952      The default value is `left'.
953
954  - Function: current-justification
955      This function returns the proper justification style to use for
956      filling the text around point.
957
958  - Variable: fill-paragraph-function
959      This variable provides a way for major modes to override the
960      filling of paragraphs.  If the value is non-`nil',
961      `fill-paragraph' calls this function to do the work.  If the
962      function returns a non-`nil' value, `fill-paragraph' assumes the
963      job is done, and immediately returns that value.
964
965      The usual use of this feature is to fill comments in programming
966      language modes.  If the function needs to fill a paragraph in the
967      usual way, it can do so as follows:
968
969           (let ((fill-paragraph-function nil))
970             (fill-paragraph arg))
971
972  - Variable: use-hard-newlines
973      If this variable is non-`nil', the filling functions do not delete
974      newlines that have the `hard' text property.  These "hard
975      newlines" act as paragraph separators.
976
977 \1f
978 File: lispref.info,  Node: Margins,  Next: Auto Filling,  Prev: Filling,  Up: Text
979
980 Margins for Filling
981 ===================
982
983  - User Option: fill-prefix
984      This variable specifies a string of text that appears at the
985      beginning of normal text lines and should be disregarded when
986      filling them.  Any line that fails to start with the fill prefix
987      is considered the start of a paragraph; so is any line that starts
988      with the fill prefix followed by additional whitespace.  Lines
989      that start with the fill prefix but no additional whitespace are
990      ordinary text lines that can be filled together.  The resulting
991      filled lines also start with the fill prefix.
992
993      The fill prefix follows the left margin whitespace, if any.
994
995  - User Option: fill-column
996      This buffer-local variable specifies the maximum width of filled
997      lines.  Its value should be an integer, which is a number of
998      columns.  All the filling, justification and centering commands
999      are affected by this variable, including Auto Fill mode (*note
1000      Auto Filling::).
1001
1002      As a practical matter, if you are writing text for other people to
1003      read, you should set `fill-column' to no more than 70.  Otherwise
1004      the line will be too long for people to read comfortably, and this
1005      can make the text seem clumsy.
1006
1007  - Variable: default-fill-column
1008      The value of this variable is the default value for `fill-column'
1009      in buffers that do not override it.  This is the same as
1010      `(default-value 'fill-column)'.
1011
1012      The default value for `default-fill-column' is 70.
1013
1014  - Command: set-left-margin from to margin
1015      This sets the `left-margin' property on the text from FROM to TO
1016      to the value MARGIN.  If Auto Fill mode is enabled, this command
1017      also refills the region to fit the new margin.
1018
1019  - Command: set-right-margin from to margin
1020      This sets the `right-margin' property on the text from FROM to TO
1021      to the value MARGIN.  If Auto Fill mode is enabled, this command
1022      also refills the region to fit the new margin.
1023
1024  - Function: current-left-margin
1025      This function returns the proper left margin value to use for
1026      filling the text around point.  The value is the sum of the
1027      `left-margin' property of the character at the start of the
1028      current line (or zero if none), and the value of the variable
1029      `left-margin'.
1030
1031  - Function: current-fill-column
1032      This function returns the proper fill column value to use for
1033      filling the text around point.  The value is the value of the
1034      `fill-column' variable, minus the value of the `right-margin'
1035      property of the character after point.
1036
1037  - Command: move-to-left-margin &optional n force
1038      This function moves point to the left margin of the current line.
1039      The column moved to is determined by calling the function
1040      `current-left-margin'.  If the argument N is non-`nil',
1041      `move-to-left-margin' moves forward N-1 lines first.
1042
1043      If FORCE is non-`nil', that says to fix the line's indentation if
1044      that doesn't match the left margin value.
1045
1046  - Function: delete-to-left-margin &optional from to
1047      This function removes left margin indentation from the text
1048      between FROM and TO.  The amount of indentation to delete is
1049      determined by calling `current-left-margin'.  In no case does this
1050      function delete non-whitespace.
1051
1052      The arguments FROM and TO are optional; the default is the whole
1053      buffer.
1054
1055  - Function: indent-to-left-margin
1056      This is the default `indent-line-function', used in Fundamental
1057      mode, Text mode, etc.  Its effect is to adjust the indentation at
1058      the beginning of the current line to the value specified by the
1059      variable `left-margin'.  This may involve either inserting or
1060      deleting whitespace.
1061
1062  - Variable: left-margin
1063      This variable specifies the base left margin column.  In
1064      Fundamental mode, <LFD> indents to this column.  This variable
1065      automatically becomes buffer-local when set in any fashion.
1066
1067 \1f
1068 File: lispref.info,  Node: Auto Filling,  Next: Sorting,  Prev: Margins,  Up: Text
1069
1070 Auto Filling
1071 ============
1072
1073    Auto Fill mode is a minor mode that fills lines automatically as text
1074 is inserted.  This section describes the hook used by Auto Fill mode.
1075 For a description of functions that you can call explicitly to fill and
1076 justify existing text, see *Note Filling::.
1077
1078    Auto Fill mode also enables the functions that change the margins and
1079 justification style to refill portions of the text.  *Note Margins::.
1080
1081  - Variable: auto-fill-function
1082      The value of this variable should be a function (of no arguments)
1083      to be called after self-inserting a space or a newline.  It may be
1084      `nil', in which case nothing special is done in that case.
1085
1086      The value of `auto-fill-function' is `do-auto-fill' when Auto-Fill
1087      mode is enabled.  That is a function whose sole purpose is to
1088      implement the usual strategy for breaking a line.
1089
1090           In older Emacs versions, this variable was named
1091           `auto-fill-hook', but since it is not called with the
1092           standard convention for hooks, it was renamed to
1093           `auto-fill-function' in version 19.
1094