home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / elisp.i18 (.txt) < prev    next >
GNU Info File  |  1993-06-14  |  52KB  |  898 lines

  1. This is Info file elisp, produced by Makeinfo-1.47 from the input file
  2. elisp.texi.
  3.    This file documents GNU Emacs Lisp.
  4.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 18.
  6.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  7. Cambridge, MA 02139 USA
  8.    Copyright (C) 1990 Free Software Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20. File: elisp,  Node: Deletion,  Next: User-Level Deletion,  Prev: Commands for Insertion,  Up: Text
  21. Deletion of Text
  22. ================
  23.    All of the deletion functions operate on the current buffer, and all
  24. return a value of `nil'.  In addition to these functions, you can also
  25. delete text using the "kill" functions that save it in the kill ring
  26. for the user; some of these functions save text in the kill ring in
  27. some cases but not in the usual case.  *Note The Kill Ring::.
  28.  -- Function: erase-buffer
  29.      This function deletes the entire text of the current buffer,
  30.      leaving it empty.  If the buffer is read-only, it signals a
  31.      `buffer-read-only' error.  Otherwise the text is deleted with no
  32.      confirmation required. The value is always `nil'.
  33.      As a safety measure, this function is not interactively callable.
  34.  -- Command: delete-region START END
  35.      This function deletes the text in the current buffer in the region
  36.      defined by START and END.  The value is `nil'.
  37.  -- Command: delete-char COUNT &optional KILLP
  38.      This function deletes COUNT characters directly after point, or
  39.      before point if COUNT is negative.  If KILLP is non-`nil', then it
  40.      saves the deleted characters in the kill ring.
  41.      In an interactive call, COUNT is the numeric prefix argument, and
  42.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  43.      argument is supplied, the text is saved in the kill ring.  If no
  44.      prefix argument is supplied, then one character is deleted, but
  45.      not saved in the kill ring.
  46.      The value returned is always `nil'.
  47.  -- Command: delete-backward-char COUNT &optional KILLP
  48.      This function deletes COUNT characters directly before point, or
  49.      after point if COUNT is negative.  If KILLP is non-`nil', then it
  50.      saves the deleted characters in the kill ring.
  51.      In an interactive call, COUNT is the numeric prefix argument, and
  52.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  53.      argument is supplied, the text is saved in the kill ring.  If no
  54.      prefix argument is supplied, then one character is deleted, but
  55.      not saved in the kill ring.
  56.      The value returned is always `nil'.
  57.  -- Command: backward-delete-char-untabify COUNT &optional KILLP
  58.      This function deletes COUNT characters backward, changing tabs
  59.      into spaces.  When the next character to be deleted is a tab, it is
  60.      first replaced with the proper number of spaces to preserve
  61.      alignment and then one of those spaces is deleted instead of the
  62.      tab.  If KILLP is non-`nil', then the command saves the deleted
  63.      characters in the kill ring.
  64.      If COUNT is negative, then tabs are not changed to spaces, and the
  65.      characters are deleted by calling `delete-backward-char' with
  66.      COUNT.
  67.      In an interactive call, COUNT is the numeric prefix argument, and
  68.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  69.      argument is supplied, the text is saved in the kill ring.  If no
  70.      prefix argument is supplied, then one character is deleted, but
  71.      not saved in the kill ring.
  72.      The value returned is always `nil'.
  73. File: elisp,  Node: User-Level Deletion,  Next: The Kill Ring,  Prev: Deletion,  Up: Text
  74. User-Level Deletion Commands
  75. ============================
  76.    This section describes higher-level commands for deleting text,
  77. commands intended primarily for the user but useful also in Lisp
  78. programs.
  79.  -- Command: delete-horizontal-space
  80.      This function deletes all spaces and tabs around point.  It returns
  81.      `nil'.
  82.      In the following examples, assume that `delete-horizontal-space' is
  83.      called four times, once on each line, with point between the
  84.      second and third characters on the line.
  85.           ---------- Buffer: foo ----------
  86.           I -!-thought
  87.           I -!-     thought
  88.           We-!- thought
  89.           Yo-!-u thought
  90.           ---------- Buffer: foo ----------
  91.           
  92.           (delete-horizontal-space)   ; Four times.
  93.                => nil
  94.           
  95.           ---------- Buffer: foo ----------
  96.           Ithought
  97.           Ithought
  98.           Wethought
  99.           You thought
  100.           ---------- Buffer: foo ----------
  101.  -- Command: delete-indentation &optional JOIN-FOLLOWING-P
  102.      This function joins the line point is on to the previous line,
  103.      deleting any whitespace at the join and in some cases replacing it
  104.      with one space.  If JOIN-FOLLOWING-P is non-`nil',
  105.      `delete-indentation' joins this line to following line instead.
  106.      The value is `nil'.
  107.      In the example below, point is located on the line starting
  108.      `events', and it makes no difference if there are trailing spaces
  109.      in the preceding line.
  110.           ---------- Buffer: foo ----------
  111.           When in the course of human
  112.           -!-    events, it becomes necessary
  113.           ---------- Buffer: foo ----------
  114.           
  115.           (delete-indentation)
  116.                => nil
  117.           
  118.           ---------- Buffer: foo ----------
  119.           When in the course of human-!- events, it becomes necessary
  120.           ---------- Buffer: foo ----------
  121.      After the lines are joined, the function `fixup-whitespace' is
  122.      responsible for deciding whether to leave a space at the junction.
  123.  -- Function: fixup-whitespace
  124.      This function replaces white space between the objects on either
  125.      side of point with either one space or no space as appropriate. 
  126.      It returns `nil'.
  127.      The appropriate amount of space is none at the beginning or end of
  128.      the line.  Otherwise, it is one space except when point is before a
  129.      character with close parenthesis syntax or after a character with
  130.      open parenthesis or expression-prefix syntax.  *Note Syntax Class
  131.      Table::.
  132.      In the example below, point is at the beginning of the second line
  133.      when `fixup-whitespace' is called the first time.  It is located
  134.      directly after the `(' for the second invocation.
  135.           ---------- Buffer: foo ----------
  136.           This has too many spaces
  137.           -!-     at the front of this line
  138.           This has too many spaces at the start of (-!-   this list)
  139.           ---------- Buffer: foo ----------
  140.           
  141.           (fixup-whitespace)
  142.                => nil
  143.           (fixup-whitespace)
  144.                => nil
  145.           
  146.           ---------- Buffer: foo ----------
  147.           This has too many spaces
  148.           at the front of this line
  149.           This has too many spaces at the start of (this list)
  150.           ---------- Buffer: foo ----------
  151.  -- Command: just-one-space
  152.      This command replaces any spaces and tabs around point with a
  153.      single space.  It returns `nil'.
  154.  -- Command: delete-blank-lines
  155.      This function deletes blank lines surrounding point.  If point is
  156.      on a blank line with one or more blank lines before or after it,
  157.      then all but one of them are deleted.  If point is on an isolated
  158.      blank line, then it is deleted.  If point is on a nonblank line,
  159.      the command deletes all blank lines following it.
  160.      A blank line is defined as a line containing only tabs and spaces.
  161.      `delete-blank-lines' returns `nil'.
  162. File: elisp,  Node: The Kill Ring,  Next: Undo,  Prev: User-Level Deletion,  Up: Text
  163. The Kill Ring
  164. =============
  165.    "Kill" functions delete text like the deletion functions, but save
  166. it so that the user can reinsert it by "yanking".  Most of these
  167. functions have `kill-' in their name.  By contrast, the functions whose
  168. names start with `delete-' normally do not save text for yanking
  169. (though they can still be undone); these are "deletion" functions.
  170.    Most of the kill commands are primarily for interactive use, and are
  171. not described here.  What we do describe are the functions provided for
  172. use in writing such commands.  When deleting text for internal purposes
  173. within a Lisp function, you should normally use deletion functions, so
  174. as not to disturb the kill ring contents.  *Note Deletion::.
  175.    Emacs saves the last several batches of killed text in a list.  We
  176. call it the "kill ring" because, in yanking, the elements are
  177. considered to be in a cyclic order.  The list is kept in the variable
  178. `kill-ring', and can be operated on with the usual functions for lists;
  179. there are also specialized functions, described in this section, which
  180. treat it as a ring.
  181.    Some people think use of the word "kill" in Emacs is unfortunate,
  182. since it refers to processes which specifically *do not* destroy the
  183. entities "killed".  This is in sharp contrast to ordinary life, in
  184. which death is permanent and "killed" entities do not come back to
  185. life.  Therefore, other metaphors have been proposed.  For example, the
  186. term "cut ring" makes sense to people who, in pre-computer days, used
  187. scissors and paste to cut up and rearrange manuscripts.  However, it
  188. would be difficult to change now.
  189. * Menu:
  190. * Data in Kill Ring::   What text looks like in the kill ring.
  191. * Kill Functions::      Functions that kill text.
  192. * Yank Commands::       Commands that access the kill ring.
  193. * Kill Ring Internals:: Variables that hold kill-ring data.
  194. File: elisp,  Node: Data in Kill Ring,  Next: Kill Functions,  Prev: The Kill Ring,  Up: The Kill Ring
  195. Data Structures in the Kill Ring
  196. --------------------------------
  197.    Killed text is kept as strings in a list.  A short kill ring, for
  198. example, might look like this:
  199.      ("some text" "a different piece of text" "yet more text")
  200.    Functions that push more text into the list make the text in question
  201. into a string (using `buffer-substring'), add the string to the front
  202. of the list, and then look at the length of the list.  If the length is
  203. longer than the value of `kill-ring-max', the last entry in the list is
  204. dropped off when the new entry is put on.
  205.    The `kill-ring-yank-pointer' global variable points to the kill ring
  206. entry that a "yank" function will copy.  Several functions move this
  207. pointer from one entry to another, and a user can thereby specify which
  208. entry to copy.
  209.    Here is a diagram that shows the variable `kill-ring-yank-pointer'
  210. pointing to the second entry in the kill ring `("some text" "a
  211. different piece of text" "yet more text")'.
  212.      kill-ring       kill-ring-yank-pointer
  213.        |               |
  214.        |     ___ ___    --->  ___ ___      ___ ___
  215.         --> |___|___|------> |___|___|--> |___|___|--> nil
  216.               |                |            |
  217.               |                |            |
  218.               |                |             -->"yet more text"
  219.               |                |
  220.               |                 --> "a different piece of text"
  221.               |
  222.                --> "some text"
  223. (This circumstance occurs after `C-y' (`yank') is immediately followed
  224. by `M-y' (`yank-pop').)
  225.    Both `kill-ring' and `kill-ring-yank-pointer' are Lisp variables
  226. whose values are normally lists.  The word "pointer" in the name of the
  227. `kill-ring-yank-pointer' indicates that the variable's purpose is to
  228. identify one element of the list that will be used by default by the
  229. next yank command.  The value of `kill-ring-yank-pointer' is always
  230. `eq' to one of the links in the kill ring list.  The element it
  231. identifies is the CAR of that link.
  232.    Moving `kill-ring-yank-pointer' to a different link is called
  233. "rotating the kill ring".  The functions that do this treat the kill
  234. ring (which is a list) as ring; that is to say, a change that would
  235. otherwise move the pointer past the end of the list (which would be
  236. useless) instead moves the pointer to the first link on the list.
  237. Likewise, moving back from the first link goes to the last one.
  238.    `kill-region' is the primitive method of killing text.  Any command
  239. that calls this function is a "kill command" (and should probably have
  240. the word "kill" in its name).  `kill-region' puts the newly killed text
  241. in a new element at the beginning of the `kill-ring' list, and then
  242. sets `kill-ring-yank-pointer' to point to the first link of the list,
  243. which contains the first element. Consequently, the next `yank' command
  244. will yank the text just killed.  In this situation, `kill-ring' and
  245. `kill-ring-yank-pointer' are `eq' to each other.
  246.    When kill commands are interwoven with other commands, the killed
  247. portions of text are put into separate entries in the kill ring.  But
  248. when two or more kill commands are executed in sequence, the text killed
  249. by the second (or third, etc.) kill command is appended to the text
  250. killed by the first command so as to make one entry in the kill ring.
  251. The `kill-region' function uses the `last-command' variable to keep
  252. track of whether the previous was a kill command, and in such cases
  253. appends the killed text to the most recent entry.
  254. File: elisp,  Node: Kill Functions,  Next: Yank Commands,  Prev: Data in Kill Ring,  Up: The Kill Ring
  255. Functions for Killing
  256. ---------------------
  257.  -- Command: kill-region START END
  258.      This function kills the text in the region defined by START and
  259.      END.  The text is deleted but saved in the kill ring.  The value
  260.      is always `nil'.
  261.      In an interactive call, START and END are point and the mark.
  262.  -- Command: kill-line &optional COUNT
  263.      This function kills the rest of the line following point, not
  264.      including the newline.  If point is directly before a newline, or
  265.      if there is only whitespace between point and the newline, then it
  266.      kills the whitespace and newline.
  267.      If COUNT is supplied, then the command kills that many lines
  268.      (*including* the newline).  (This makes executing `(kill-line 2)'
  269.      different from executing `(kill-line)' twice.)  If COUNT is
  270.      negative, then `kill-line' kills lines backwards.
  271.      In an interactive call, COUNT is the raw prefix argument (which
  272.      then gets converted to a number if non-`nil').  The value is always
  273.      `nil'.
  274.  -- Command: zap-to-char COUNT CHARACTER
  275.      In Emacs version 18, this function kills the text from point up to
  276.      *but not including* the specified character.  Thus, if the cursor
  277.      is at the beginning of this sentence and the character is `s',
  278.      `Thu' is deleted.  If the argument is 2, `Thus, if the cur' is
  279.      deleted, up to but not including the `s' in `cursor'.
  280.      In Emacs version 19, this function will kill all text in the
  281.      region from point up to and including the next COUNT occurrences
  282.      of CHARACTER.  Thus, in the example shown in the previous
  283.      paragraph, the terminating `s' *will* be removed.
  284.      The version 18 implementation kills text to the end of the buffer
  285.      if the specified character is not found, but the version 19
  286.      implementation will simply signal an error.
  287.      The function scans backward from point if COUNT is negative.  The
  288.      value is always `nil'.
  289.  -- Command: copy-region-as-kill START END
  290.      This function saves the region defined by START and END on the
  291.      kill ring, but does not delete the text from the buffer.  It
  292.      returns `nil'.
  293.      In an interactive call, START and END are point and the mark.
  294. File: elisp,  Node: Yank Commands,  Next: Kill Ring Internals,  Prev: Kill Functions,  Up: The Kill Ring
  295. Functions for Yanking
  296. ---------------------
  297.  -- Command: yank &optional ARG
  298.      This function inserts the text in the first entry in the kill ring
  299.      directly before point.  After the yank, the mark is positioned at
  300.      the beginning and point is positioned after the end of the
  301.      inserted text.
  302.      If ARG is a list (which occurs interactively when the user types
  303.      `C-u' with no digits), then `yank' inserts the text as described
  304.      above, but puts point before the yanked text and puts the mark
  305.      after it.  If ARG is a number, then `yank' inserts the ARGth most
  306.      recently killed text.
  307.      `yank' does not alter the contents of the kill ring or rotate it.
  308.      It returns `nil'.
  309.  -- Command: yank-pop ARG
  310.      This function replaces the just-yanked text with another batch of
  311.      killed text--another element of the kill ring.
  312.      This command is allowed only immediately after a `yank' or a
  313.      `yank-pop'.  At such a time, the region contains text that was just
  314.      inserted by the previous `yank'.  `yank-pop' deletes that text and
  315.      inserts in its place a different stretch of killed text.  The text
  316.      that is deleted is not inserted into the kill ring, since it is
  317.      already in the kill ring somewhere.
  318.      If ARG is `nil', then the existing region contents are replaced
  319.      with the previous element of the kill ring.  If ARG is numeric,
  320.      then the ARG'TH previous kill is the replacement.  If ARG is
  321.      negative, a more recent kill is the replacement.
  322.      The sequence of kills in the kill ring wraps around, so that after
  323.      the oldest one comes the newest one, and before the newest one
  324.      goes the oldest.
  325.      The value is always `nil'.
  326. File: elisp,  Node: Kill Ring Internals,  Prev: Yank Commands,  Up: The Kill Ring
  327. Internals of the Kill Ring
  328. --------------------------
  329.    This section describes the lower levels of the kill ring.
  330.  -- Variable: kill-ring
  331.      List of killed text sequences, most recently killed first.
  332.  -- Variable: kill-ring-yank-pointer
  333.      This variable's value indicates which element of the kill ring is
  334.      the "front" of the ring.  More precisely, the value is a sublist
  335.      of the value of `kill-ring', and its CAR is the kill string at the
  336.      front of the ring.  Rotating the ring works by changing
  337.      `kill-ring-yank-pointer', and does not actually change the value of
  338.      `kill-ring'.
  339.      Commands which do change the kill ring also copy the new kill ring
  340.      value into this variable.  The effect is to rotate the ring so
  341.      that the newly killed text is at front.
  342.  -- Command: rotate-yank-pointer COUNT
  343.      This function rotates the kill ring COUNT positions, which means
  344.      setting `kill-ring-yank-pointer' to some other link in the kill
  345.      ring list.  It returns the new value of `kill-ring-yank-pointer'.
  346.  -- User Option: kill-ring-max
  347.      The value of this variable is the maximum length to which the kill
  348.      ring can grow, before elements are thrown away on a first-in,
  349.      first-out basis.  The default value for `kill-ring-max' is 30.
  350. File: elisp,  Node: Undo,  Next: Filling,  Prev: The Kill Ring,  Up: Text
  351.    Most buffers have an "undo stack" which records all changes made to
  352. the buffer's text so that they can be undone.  (In general, all buffers
  353. have undo stacks except special-purpose buffers for which Emacs assumes
  354. that undoing is not useful.)  The size of an undo stack is limited, so
  355. large changes or a large number of changes cannot be undone.
  356.    Undoing an old change is itself a change, and is added to the undo
  357. stack.  However, you are not limited to undoing just the single most
  358. recent change; you can keep undoing older and older changes, even as the
  359. undo's themselves are being added to the stack.
  360.  -- Command: undo &optional ARG
  361.      This is a user-level command to undo some previous changes.  It
  362.      uses `undo-more' and `undo-start'.  By repeating this command you
  363.      can undo earlier and earlier changes, until the information in the
  364.      undo stack is used up.  A numeric argument serves as a repeat
  365.      count. The value is unpredictable.
  366.  -- Function: undo-boundary
  367.      This function places a boundary between units of undo.  The undo
  368.      command stops at such a boundary, and successive undo commands
  369.      will undo to earlier and earlier boundaries.  The return value is
  370.      `nil'.
  371.      The editor command loop automatically creates an undo boundary
  372.      between keystroke commands.  Thus, each undo normally undoes the
  373.      effects of one command.  Calling this function explicitly is
  374.      useful for splitting the effects of a command into more than one
  375.      unit.  For example, `query-replace' calls this function after each
  376.      replacement so that the user can undo individual replacements one
  377.      by one.
  378.  -- Function: undo-more COUNT
  379.      This function is used to undo COUNT additional units of undo. It
  380.      is not safe if the buffer has been changed in any fashion other
  381.      than undo since the last call to `undo-start'.  Multiple calls to
  382.      `undo-more' have a cumulative effect, undoing farther back in time.
  383.      The return value is `nil'.
  384.  -- Function: undo-start
  385.      This function prepares to undo one or more units of undo describing
  386.      the most recent changes to the current buffer.  It does not
  387.      actually undo anything (or change the buffer at all); only
  388.      `undo-more' does that.  It returns `nil'.
  389.      One use of this function is to break a sequence of undo's, so a
  390.      subsequent call to `undo-more' will undo the recent run of undoing,
  391.      rather than extend it into the past.
  392.      The command `undo' calls `undo-start' whenever the previous
  393.      command was not an `undo'.
  394.  -- Command: buffer-enable-undo &optional BUFFER-OR-NAME
  395.      This function assigns an undo stack for buffer BUFFER-OR-NAME, so
  396.      that subsequent changes can be undone.  If no argument is supplied,
  397.      then the current buffer is used.  If the buffer already has an undo
  398.      stack, nothing is changed.  This function returns `nil'.
  399.      In an interactive call, BUFFER-OR-NAME is the current buffer. You
  400.      cannot specify any other buffer.
  401.  -- Function: buffer-flush-undo BUFFER
  402.      This function deassigns the undo stack of the buffer BUFFER, so
  403.      that it will not take up space.  As a result, it is no longer
  404.      possible to undo either previous changes or any subsequent changes.
  405.      If the buffer already has no undo stack, then this function has no
  406.      effect.
  407.      This function returns `nil'.  It cannot be called interactively.
  408. File: elisp,  Node: Filling,  Next: Auto Filling,  Prev: Undo,  Up: Text
  409. Filling
  410. =======
  411.    "Filling" means adjusting the lengths of lines (by moving words
  412. between them) so that they are nearly (but no greater than) a specified
  413. maximum width.  Additionally, lines can be "justified", which means
  414. that spaces are inserted between words to make the line exactly the
  415. specified width.  The width is controlled by the variable
  416. `fill-column'.  For ease of reading, lines should be no longer than 70
  417. or so columns.
  418.    You can use Auto Fill mode (*note Auto Filling::.) to fill text
  419. automatically as you insert it, but changes to existing text may leave
  420. it improperly filled.  Then you must fill the text explicitly.
  421.    Most of the functions in this section return values that are not
  422. meaningful.
  423.  -- Command: fill-paragraph JUSTIFY-FLAG
  424.      This function fills the paragraph at or after point.  If
  425.      JUSTIFY-FLAG is non-`nil', each line is justified as well.
  426.  -- Command: fill-region START END &optional JUSTIFY-FLAG
  427.      This function fills each of the paragraphs in the region from
  428.      start to end.  It justifies as well if JUSTIFY-FLAG is non-`nil'. 
  429.      (In an interactive call, this is true if there is a prefix
  430.      argument.)
  431.      The variable `paragraph-separate' controls how to distinguish
  432.      paragraphs.
  433.  -- Command: fill-individual-paragraphs START END &optional
  434.           JUSTIFY-FLAG MAIL-FLAG
  435.      This function fills each paragraph in the region according to its
  436.      individual fill prefix.  Thus, if the lines of a paragraph are
  437.      indented with spaces, the filled paragraph will continue to be
  438.      indented in the same fashion.
  439.      The first two arguments, START and END, are the beginning and end
  440.      of the region that will be filled.  The third and fourth
  441.      arguments, JUSTIFY-FLAG and MAIL-FLAG, are optional.  If
  442.      JUSTIFY-FLAG is non-`nil', the paragraphs are justified as well as
  443.      filled.  If MAIL-FLAG is non-`nil', the function is told that it
  444.      is operating on a mail message and therefore should not fill the
  445.      header lines.
  446.  -- Command: fill-region-as-paragraph START END &optional JUSTIFY-FLAG
  447.      This function considers a region of text as a paragraph and fills
  448.      it. If the region was made up of many paragraphs, the blank lines
  449.      between paragraphs are removed.  This function justifies as well
  450.      as filling when JUSTIFY-FLAG is non-`nil'.  In an interactive
  451.      call, any prefix argument requests justification.
  452.  -- Command: justify-current-line
  453.      This function inserts spaces between the words of the current line
  454.      so that the line ends exactly at `fill-column'.  It returns `nil'.
  455.  -- User Option: fill-column
  456.      This buffer-local variable specifies the maximum width of filled
  457.      lines.  Its value should be an integer, which is a number of
  458.      columns. All the filling, justification and centering commands are
  459.      affected by this variable, including Auto Fill mode (*note Auto
  460.      Filling::.).
  461.      As a practical matter, if you are writing text for other people to
  462.      read, you should set `fill-column' to no more than 70.  Otherwise
  463.      the line will be too long for people to read comfortably, and this
  464.      can make the text seem clumsy.
  465.  -- Variable: default-fill-column
  466.      The value of this variable is the default value for `fill-column'
  467.      in buffers that do not override it.  This is the same as
  468.      `(default-value 'fill-column)'.
  469.      The default value for `default-fill-column' is 70.
  470. File: elisp,  Node: Auto Filling,  Next: Sorting,  Prev: Filling,  Up: Text
  471. Auto Filling
  472. ============
  473.    "Filling" breaks text into lines that are no more than a specified
  474. number of columns wide.  Filled lines end between words, and therefore
  475. may have to be shorter than the maximum width.
  476.    Auto Fill mode is a minor mode in which Emacs fills lines
  477. automatically as text as inserted.  This section describes the hook and
  478. the two variables used by Auto Fill mode.  For a description of
  479. functions that you can call manually to fill and justify text, see
  480. *Note Filling::.
  481.  -- Variable: auto-fill-hook
  482.      The value of this variable should be a function (of no arguments)
  483.      to be called after self-inserting a space at a column beyond
  484.      `fill-column'.  It may be `nil', in which case nothing special is
  485.      done.
  486.      The default value for `auto-fill-hook' is `do-auto-fill', a
  487.      function whose sole purpose is to implement the usual strategy for
  488.      breaking a line.
  489.      Since `auto-fill-hook' is not called by the `run-hooks' function,
  490.      it will be renamed `auto-fill-function' in Version 19.
  491. File: elisp,  Node: Sorting,  Next: Indentation,  Prev: Auto Filling,  Up: Text
  492. Sorting Text
  493. ============
  494.    The sorting commands described in this section all rearrange text in
  495. a buffer.  This is in contrast to the function `sort', which rearranges
  496. the order of the elements of a list (*note Rearrangement::.). The
  497. values returned by these commands are not meaningful.
  498.  -- Command: sort-regexp-fields REVERSE RECORD-REGEXP KEY-REGEXP START
  499.           END
  500.      This command sorts the region between START and END alphabetically
  501.      as specified by RECORD-REGEXP and KEY-REGEXP. If REVERSE is a
  502.      negative integer, then sorting is in reverse order.
  503.      Alphabetical sorting means that two sort keys are compared by
  504.      comparing the first characters of each, the second characters of
  505.      each, and so on.  If a mismatch is found, it means that the sort
  506.      keys are unequal; the sort key whose character is less at the
  507.      point of first mismatch is the lesser sort key.  The individual
  508.      characters are compared according to their numerical values. 
  509.      Since Emacs uses the ASCII character set, the ordering in that set
  510.      determines alphabetical order.
  511.      The value of the RECORD-REGEXP argument specifies the textual
  512.      units or "records" that should be sorted.  At the end of each
  513.      record, a search is done for this regular expression, and the text
  514.      that matches it is the next record.  For example, the regular
  515.      expression `^.+$', which matches lines with at least one character
  516.      besides a newline, would make each such line into a sort record. 
  517.      *Note Regular Expressions::, for a description of the syntax and
  518.      meaning of regular expressions.
  519.      The value of the KEY-REGEXP argument specifies what part of each
  520.      record is to be compared against the other records.  The
  521.      KEY-REGEXP could match the whole record, or only a part.  In the
  522.      latter case, the rest of the record has no effect on the sorted
  523.      order of records, but it is carried along when the record moves to
  524.      its new position.
  525.      The KEY-REGEXP argument can refer to the text matched by a
  526.      subexpression of RECORD-REGEXP, or it can be a regular expression
  527.      on its own.
  528.      If KEY-REGEXP is:
  529.     `\DIGIT'
  530.           then the text matched by the DIGITth `\(...\)' parenthesis
  531.           grouping in RECORD-REGEXP is used for sorting.
  532.     `\&'
  533.           then the whole record is used for sorting.
  534.     a regular expression
  535.           then the function searches for a match for the regular
  536.           expression within the record.  If such a match is found, it
  537.           is used for sorting.  If a match for KEY-REGEXP is not found
  538.           within a record then that record is ignored, which means its
  539.           position in the buffer is not changed.  (The other records
  540.           may move around it.)
  541.      For example, if you plan to sort all the lines in the region by the
  542.      first word on each line starting with the letter `f', you should
  543.      set RECORD-REGEXP to `^.*$' and set KEY-REGEXP to `\<f\w*\>'.  The
  544.      resulting expression looks like this:
  545.           (sort-regexp-fields nil "^.*$" "\\<f\\w*\\>"
  546.                               (region-beginning)
  547.                               (region-end))
  548.      If you call `sort-regexp-fields' interactively, you are prompted
  549.      for RECORD-REGEXP and KEY-REGEXP in the minibuffer.
  550.  -- Command: sort-subr REVERSE NEXTRECFUN ENDRECFUN &optional
  551.           STARTKEYFUN ENDKEYFUN
  552.      This command is the general text sorting routine that divides a
  553.      buffer into records and sorts them.  The functions `sort-lines',
  554.      `sort-paragraphs', `sort-pages', `sort-fields',
  555.      `sort-regexp-fields' and `sort-numeric-fields' all use `sort-subr'.
  556.      To understand how `sort-subr' works, consider the whole accessible
  557.      portion of the buffer as being divided into disjoint pieces called
  558.      "sort records".  A portion of each sort record (perhaps all of it)
  559.      is designated as the sort key.  The records are rearranged in the
  560.      buffer in order by their sort keys.  The records may or may not be
  561.      contiguous.
  562.      Usually, the records are rearranged in order of ascending sort key.
  563.      If the first argument to the `sort-subr' function, REVERSE, is
  564.      non-`nil', the sort records are rearranged in order of descending
  565.      sort key.
  566.      The next four arguments to `sort-subr' are functions that are
  567.      called to move point across a sort record.  They are called many
  568.      times from within `sort-subr'.
  569.        1. NEXTRECFUN is called with point at the end of a record.  This
  570.           function moves point to the start of the next record.  The
  571.           first record is assumed to start at the position of point
  572.           when `sort-subr' is called.  (Therefore, you should usually
  573.           move point to the beginning of the buffer before calling
  574.           `sort-subr'.)
  575.        2. ENDRECFUN is called with point within a record.  It moves
  576.           point to the end of the record.
  577.        3. STARTKEYFUN is called to move point from the start of a
  578.           record to the start of the sort key.  This argument is
  579.           optional.  If supplied, the function should either return a
  580.           non-`nil' value to be used as the sort key, or return `nil'
  581.           to indicate that the sort key is in the buffer starting at
  582.           point.  In the latter case, and ENDKEYFUN will be called to
  583.           find the end of the sort key.
  584.        4. ENDKEYFUN is called to move point from the start of the sort
  585.           key to the end of the sort key.  This argument is optional. 
  586.           If STARTKEYFUN returns `nil' and this argument is omitted (or
  587.           `nil'), then the sort key extends to the end of the record. 
  588.           There is no need for ENDKEYFUN if STARTKEYFUN returns a
  589.           non-`nil' value.
  590.      As an example of `sort-subr', here is the complete function
  591.      definition for `sort-lines':
  592.           (defun sort-lines (reverse beg end)
  593.             "Sort lines in region alphabetically; arg means reverse order.
  594.           Called from a program, there are three arguments:
  595.           REVERSE (non-nil means reverse order),
  596.           and BEG and END (the region to sort)."
  597.             (interactive "P\nr")
  598.             (save-restriction
  599.               (narrow-to-region beg end)
  600.               (goto-char (point-min))
  601.               (sort-subr reverse 'forward-line 'end-of-line)))
  602.      Here `forward-line' moves point to the start of the next record,
  603.      and `end-of-line' moves point to the end of record.  We do not pass
  604.      the arguments STARTKEYFUN and ENDKEYFUN, because the entire record
  605.      is used as the sort key.
  606.      The `sort-paragraphs' function is very much the same, except that
  607.      its `sort-subr' call looks like this:
  608.           (sort-subr reverse
  609.                      (function (lambda () (skip-chars-forward "\n \t\f")))
  610.                      'forward-paragraph)))
  611.  -- Command: sort-lines REVERSE START END
  612.      This command sorts lines in the region between START and END
  613.      alphabetically.  If REVERSE is non-`nil', the sort is in reverse
  614.      order.
  615.  -- Command: sort-paragraphs REVERSE START END
  616.      This command sorts paragraphs in the region between START and END
  617.      alphabetically.  If REVERSE is non-`nil', the sort is in reverse
  618.      order.
  619.  -- Command: sort-pages REVERSE START END
  620.      This command sorts pages in the region between START and END
  621.      alphabetically.  If REVERSE is non-`nil', the sort is in reverse
  622.      order.
  623.  -- Command: sort-fields FIELD START END
  624.      This command sorts lines in the region between START and END,
  625.      comparing them alphabetically by the FIELDth field of each line. 
  626.      Fields are separated by whitespace and numbered starting from 1. 
  627.      If FIELD is negative, sorting is by the -FIELDth field from the
  628.      end of the line.  This command is useful for sorting tables.
  629.  -- Command: sort-numeric-fields FIELD START END
  630.      This command sorts lines in the region between START and END,
  631.      comparing them numerically by the FIELDth field of each line. 
  632.      Fields are separated by whitespace and numbered starting from 1. 
  633.      The specified field must contain a number in each line of the
  634.      region.  If FIELD is negative, sorting is by the -FIELDth field
  635.      from the end of the line.  This command is useful for sorting
  636.      tables.
  637.  -- Command: sort-columns REVERSE &optional BEG END
  638.      This command sorts the lines in the region between BEG and END,
  639.      comparing them alphabetically by a certain range of columns. For
  640.      the purpose of this command, the region includes the entire line
  641.      that point is in and the entire line containing END.  The column
  642.      positions of BEG and END bound the range of columns to sort on.
  643.      If REVERSE is non-`nil', the sort is in reverse order.
  644.      One unusual thing about this command is that the entire line
  645.      containing point, and the entire line containing the mark, are
  646.      included in the region sorted.
  647.      Note that `sort-columns' uses the `sort' utility program, and so
  648.      cannot work properly on text containing tab characters.  Use `M-x
  649.      `untabify'' to convert tabs to spaces before sorting.  The
  650.      `sort-columns' function doesn't work in VMS, because the subprocess
  651.      facilities are lacking.
  652. File: elisp,  Node: Indentation,  Next: Columns,  Prev: Sorting,  Up: Text
  653. Indentation
  654. ===========
  655.    The indentation functions are used to examine, move to, and change
  656. whitespace that is at the beginning of a line.  Some of the functions
  657. can also change whitespace elsewhere on a line.  Indentation always
  658. counts from zero at the left margin.
  659. * Menu:
  660. * Primitive Indent::      Functions used to count and insert indentation.
  661. * Mode-Specific Indent::  Customize indentation for different modes.
  662. * Region Indent::         Indent all the lines in a region.
  663. * Relative Indent::       Indent the current line based on previous lines.
  664. * Indent Tabs::           Adjustable, typewriter-like tab stops.
  665. * Motion by Indent::      Move to first non-blank character.
  666. File: elisp,  Node: Primitive Indent,  Next: Mode-Specific Indent,  Prev: Indentation,  Up: Indentation
  667. Indentation Primitives
  668. ----------------------
  669.    This section describes the primitive functions used to count and
  670. insert indentation.  The functions in the following sections use these
  671. primitives.
  672.  -- Function: current-indentation
  673.      This function returns the indentation of the current line, which is
  674.      the horizontal position of the first nonblank character.  If the
  675.      contents are entirely blank, then this is the horizontal position
  676.      of the end of the line.
  677.  -- Command: indent-to COLUMN &optional MINIMUM
  678.      This function indents from point with tabs and spaces until COLUMN
  679.      is reached.  If MINIMUM is specified and non-`nil', then at least
  680.      that many spaces are inserted even if this requires going beyond
  681.      COLUMN.  The value is the column at which the inserted indentation
  682.      ends.
  683.  -- User Option: indent-tabs-mode
  684.      If this variable is non-`nil', indentation functions can insert
  685.      tabs as well as spaces.  Otherwise, they insert only spaces. 
  686.      Setting this variable automatically makes it local to the current
  687.      buffer.
  688. File: elisp,  Node: Mode-Specific Indent,  Next: Region Indent,  Prev: Primitive Indent,  Up: Indentation
  689. Indentation Controlled by Major Mode
  690. ------------------------------------
  691.    An important function of each major mode is to customize the TAB key
  692. to indent properly for the language being edited.  This section
  693. describes the mechanism of the TAB key and how to control it. The
  694. functions in this section return unpredictable values.
  695.  -- Variable: indent-line-function
  696.      This variable's value is the function to be used by TAB (and
  697.      various commands) to indent the current line.  The command
  698.      `indent-according-to-mode' does no more than call this function.
  699.      In Lisp mode, the value is the symbol `lisp-indent-line'; in C
  700.      mode, `c-indent-line'; in Fortran mode, `fortran-indent-line'. In
  701.      Fundamental mode, Text mode, and many other modes with no standard
  702.      for indentation, the value is `indent-to-left-margin' (which is the
  703.      default value).
  704.  -- Command: indent-according-to-mode
  705.      This command calls the function in `indent-line-function' to
  706.      indent the current line in a way appropriate for the current major
  707.      mode.
  708.  -- Command: indent-for-tab-command
  709.      This command calls the function in `indent-line-function' to
  710.      indent the current line, except that if that function is
  711.      `indent-to-left-margin', `insert-tab' is called instead.
  712.  -- Variable: left-margin
  713.      This variable is the column to which the default
  714.      `indent-line-function' will indent.  (That function is
  715.      `indent-to-left-margin'.)  In Fundamental mode, LFD indents to
  716.      this column.  This variable automatically becomes buffer-local when
  717.      set in any fashion.
  718.  -- Function: indent-to-left-margin
  719.      This is the default `indent-line-function', used in Fundamental
  720.      mode, Text mode, etc.  Its effect is to adjust the indentation at
  721.      the beginning of the current line to the value specified by the
  722.      variable `left-margin'.  This may involve either inserting or
  723.      deleting whitespace.
  724.  -- Command: newline-and-indent
  725.      This function inserts a newline, then indents the new line (the one
  726.      following the newline just inserted) according to the major mode.
  727.      Indentation is done using the current `indent-line-function'.  In
  728.      programming language modes, this is the same thing TAB does, but
  729.      in some text modes, where TAB inserts a tab, `newline-and-indent'
  730.      indents to the column specified by `left-margin'.
  731.  -- Command: reindent-then-newline-and-indent
  732.      This command reindents the current line, inserts a newline at
  733.      point, and then reindents the new line (the one following the
  734.      newline just inserted).
  735.      Indentation of both lines is done according to the current major
  736.      mode; this means that the current value of `indent-line-function'
  737.      is called.  In programming language modes, this is the same thing
  738.      TAB does, but in some text modes, where TAB inserts a tab,
  739.      `reindent-then-newline-and-indent' indents to the column specified
  740.      by `left-margin'.
  741. File: elisp,  Node: Region Indent,  Next: Relative Indent,  Prev: Mode-Specific Indent,  Up: Indentation
  742. Indenting an Entire Region
  743. --------------------------
  744.    This section describes commands which indent all the lines in the
  745. region.  They return unpredictable values.
  746.  -- Command: indent-region START END TO-COLUMN
  747.      This command indents each nonblank line starting between START
  748.      (inclusive) and END (exclusive).  If TO-COLUMN is `nil',
  749.      `indent-region' indents each nonblank line by calling the current
  750.      mode's indentation function, the value of `indent-line-function'.
  751.      If TO-COLUMN is non-`nil', it should be an integer specifying the
  752.      number of columns of indentation; then this function gives each
  753.      line exactly that much indentation, by either adding or deleting
  754.      whitespace.
  755.  -- Variable: indent-region-function
  756.      The value of this variable is a function that can be used by
  757.      `indent-region' as a short cut.  You should design the function so
  758.      that it will produce the same results as indenting the lines of the
  759.      region one by one (but presumably faster).
  760.      If the value is `nil', there is no short cut, and `indent-region'
  761.      actually works line by line.
  762.      A short cut function is useful in modes such as C mode and Lisp
  763.      mode, where the `indent-line-function' must scan from the
  764.      beginning of the function: applying it to each line would be
  765.      quadratic in time.  The short cut can update the scan information
  766.      as it moves through the lines indenting them; this takes linear
  767.      time.  If indenting a line individually is fast, there is no need
  768.      for a short cut.
  769.      `indent-region' with a non-`nil' argument has a different
  770.      definition and does not use this variable.
  771.  -- Command: indent-rigidly START END COUNT
  772.      This command indents all lines starting between START (inclusive)
  773.      and END (exclusive) sideways by `count' columns. This "preserves
  774.      the shape" of the affected region, moving it as a rigid unit. 
  775.      Consequently, this command is useful not only for indenting
  776.      regions of unindented text, but also for indenting regions of
  777.      formatted code.
  778.      For example, if COUNT is 3, this command adds 3 columns of
  779.      indentation to each of the lines beginning in the region specified.
  780.      In Mail mode, `C-c C-y' (`mail-yank-original') uses
  781.      `indent-rigidly' to indent the text copied from the message being
  782.      replied to.
  783. File: elisp,  Node: Relative Indent,  Next: Indent Tabs,  Prev: Region Indent,  Up: Indentation
  784. Indentation Relative to Previous Lines
  785. --------------------------------------
  786.    This section describes two commands which indent the current line
  787. based on the contents of previous lines.
  788.  -- Command: indent-relative &optional UNINDENTED-OK
  789.      This function inserts whitespace at point, extending to the same
  790.      column as the next "indent point" of the previous nonblank line. 
  791.      An indent point is a non-whitespace character following
  792.      whitespace.  The next indent point is the first one at a column
  793.      greater than the current column of point.  For example, if point
  794.      is underneath and to the left of the first non-blank character of
  795.      a line of text, it moves to that column by inserting whitespace.
  796.      If the previous nonblank line has no next indent point (i.e., none
  797.      at a great enough column position), this function either does
  798.      nothing (if UNINDENTED-OK is non-`nil') or calls `tab-to-tab-stop'.
  799.      Thus, if point is underneath and to the right of the last column
  800.      of a short line of text, this function moves point to the next tab
  801.      stop by inserting whitespace.
  802.      This command returns an unpredictable value.
  803.      In the following example, point is at the beginning of the second
  804.      line:
  805.                       This line is indented twelve spaces.
  806.           -!-The quick brown fox jumped over the lazy dog.
  807.      Evaluation of the expression `(indent-relative nil)' produces the
  808.      following:
  809.                       This line is indented twelve spaces.
  810.                       -!-The quick brown fox jumped over the lazy dog.
  811.      In this example, point is between the `m' and `p' of `jumped':
  812.                       This line is indented twelve spaces.
  813.           The quick brown fox jum-!-ped over the lazy dog.
  814.      Evaluation of the expression `(indent-relative nil)' produces the
  815.      following:
  816.                       This line is indented twelve spaces.
  817.           The quick brown fox jum  -!-ped over the lazy dog.
  818.  -- Command: indent-relative-maybe
  819.      This command indents the current line like the previous nonblank
  820.      line. The function consists of a call to `indent-relative' with a
  821.      non-`nil' value passed to the UNINDENTED-OK optional argument. 
  822.      The value is unpredictable.
  823.      If the previous line has no indentation, the current line is given
  824.      no indentation (any existing indentation is deleted); if the
  825.      previous nonblank line has no indent points beyond the column at
  826.      which point starts, nothing is changed.
  827. File: elisp,  Node: Indent Tabs,  Next: Motion by Indent,  Prev: Relative Indent,  Up: Indentation
  828. Adjustable "Tab Stops"
  829. ----------------------
  830.    This section explains the mechanism for user-specified "tab stops"
  831. and the mechanisms which use and set them.  The name "tab stops" is
  832. used because the feature is similar to that of the tab stops on a
  833. typewriter.  The feature works by inserting an appropriate number of
  834. spaces and tab characters to reach the designated position, like the
  835. other indentation functions; it does not affect the display of tab
  836. characters in the buffer (*note Control Char Display::.).  Note that the
  837. TAB character as input uses this tab stop feature only in a few major
  838. modes, such as Text mode.
  839.  -- Function: tab-to-tab-stop
  840.      This function inserts spaces or tabs up to the next tab stop column
  841.      defined by `tab-stop-list'.  It searches the list for an element
  842.      greater than the current column number, and uses that element as
  843.      the column to indent to.  If no such element is found, then
  844.      nothing is done.
  845.  -- User Option: tab-stop-list
  846.      This variable is the list of tab stop columns used by
  847.      `tab-to-tab-stops'.  The elements should be integers in increasing
  848.      order.  The tab stop columns need not be evenly spaced.
  849.      Use `M-x edit-tab-stops' to edit the location of tab stops
  850.      interactively.
  851. File: elisp,  Node: Motion by Indent,  Prev: Indent Tabs,  Up: Indentation
  852. Indentation-Based Motion Commands
  853. ---------------------------------
  854.    These commands, primarily for interactive use, act based on the
  855. indentation in the text.
  856.  -- Command: back-to-indentation
  857.      This command moves point to the first non-whitespace character in
  858.      the current line (which is the line in which point is located). 
  859.      It returns `nil'.
  860.  -- Command: backward-to-indentation ARG
  861.      This command moves point backward ARG lines and then to the first
  862.      nonblank character on that line.  It returns `nil'.
  863.  -- Command: forward-to-indentation ARG
  864.      This command moves point forward ARG lines and then to the first
  865.      nonblank character on that line.  It returns `nil'.
  866. File: elisp,  Node: Columns,  Next: Case Changes,  Prev: Indentation,  Up: Text
  867. Counting Columns
  868. ================
  869.    The column functions convert between a character position (counting
  870. characters from the beginning of the buffer) and a column position
  871. (counting screen characters from the beginning of a line).
  872.    Column number computations ignore the width of the window and the
  873. amount of horizontal scrolling.  Consequently, a column value can be
  874. arbitrarily high.  The first (or leftmost) column is numbered 0.
  875.    A character counts according to the number of columns it occupies on
  876. the screen.  This means control characters count as occupying 2 or 4
  877. columns, depending upon the value of `ctl-arrow', and tabs count as
  878. occupying a number of columns that depends on the value of `tab-width'
  879. and on the column where the tab begins.  *Note Control Char Display::.
  880.  -- Function: current-column
  881.      This function returns the horizontal position of point, measured in
  882.      columns, counting from 0 at the left margin.  The column count is
  883.      calculated by adding together the widths of all the displayed
  884.      representations of the characters between the start of the current
  885.      line and point.
  886.      For a more complicated example of the use of `current-column', see
  887.      the description of `count-lines' in *Note Text Lines::.
  888.  -- Function: move-to-column COLUMN
  889.      This function moves point to COLUMN in the current line.  The
  890.      calculation of COLUMN takes into account the widths of all the
  891.      displayed representations of the characters between the start of
  892.      the line and point.
  893.      If the argument COLUMN is greater than the column position of the
  894.      end of the line, point moves to the end of the line.  If COLUMN is
  895.      negative, point moves to the beginning of the line.  An error is
  896.      signaled if COLUMN is not an integer.
  897.      The return value is the column number actually moved to.
  898.