home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / elisp.i18 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  50.7 KB  |  1,162 lines

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