home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / elisp.i19 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  50.9 KB  |  1,187 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: Case Changes,  Next: Substitution,  Prev: Columns,  Up: Text
  30.  
  31. Case Changes
  32. ============
  33.  
  34.    The case change commands described here work on text in the current
  35. buffer.  *Note Character Case::, for case conversion commands that work
  36. on strings and characters.
  37.  
  38.  -- Command: capitalize-region START END
  39.      This function capitalizes all words in the region defined by START
  40.      and END.  To capitalize means to convert each word's first
  41.      character to upper case and convert the rest of each word to lower
  42.      case.  The function returns `nil'.
  43.  
  44.      If one end of the region is in the middle of a word, the part of
  45.      the word within the region is treated as an entire word.
  46.  
  47.      When `capitalize-region' is called interactively, START and END
  48.      are point and the mark, with the smallest first.
  49.  
  50.           ---------- Buffer: foo ----------
  51.           This is the contents of the 5th foo.
  52.           ---------- Buffer: foo ----------
  53.           
  54.           (capitalize-region 1 44)
  55.           => nil
  56.           
  57.           ---------- Buffer: foo ----------
  58.           This Is The Contents Of The 5th Foo.
  59.           ---------- Buffer: foo ----------
  60.  
  61.  -- Command: downcase-region START END
  62.      This function converts all of the letters in the region defined by
  63.      START and END to lower case.  The function returns `nil'.
  64.  
  65.      When `downcase-region' is called interactively, START and END are
  66.      point and the mark, with the smallest first.
  67.  
  68.  -- Command: upcase-region START END
  69.      This function converts all of the letters in the region defined by
  70.      START and END to upper case.  The function returns `nil'.
  71.  
  72.      When `upcase-region' is called interactively, START and END are
  73.      point and the mark, with the smallest first.
  74.  
  75.  -- Command: capitalize-word COUNT
  76.      This function capitalizes COUNT words after point, moving point
  77.      over as it does.  To capitalize means to convert each word's first
  78.      character to upper case and convert the rest of each word to lower
  79.      case. If COUNT is negative, the function capitalizes the -COUNT
  80.      previous words but does not move point.  The value is `nil'.
  81.  
  82.      If point is in the middle of a word, the part of word the before
  83.      point (if moving forward) or after point (if operating backward)
  84.      is ignored. The rest is treated as an entire word.
  85.  
  86.      When `capitalize-word' is called interactively, COUNT is set to
  87.      the numeric prefix argument.
  88.  
  89.  -- Command: downcase-word COUNT
  90.      This function converts the COUNT words after point to all lower
  91.      case, moving point over as it does.  If COUNT is negative, it
  92.      converts the -COUNT previous words but does not move point. The
  93.      value is `nil'.
  94.  
  95.      When `downcase-word' is called interactively, COUNT is set to the
  96.      numeric prefix argument.
  97.  
  98.  -- Command: upcase-word COUNT
  99.      This function converts the COUNT words after point to all upper
  100.      case, moving point over as it does.  If COUNT is negative, it
  101.      converts the -COUNT previous words but does not move point. The
  102.      value is `nil'.
  103.  
  104.      When `upcase-word' is called interactively, COUNT is set to the
  105.      numeric prefix argument.
  106.  
  107. 
  108. File: elisp,  Node: Substitution,  Next: Underlining,  Prev: Case Changes,  Up: Text
  109.  
  110. Substituting for a Character Code
  111. =================================
  112.  
  113.    The following function replaces characters within a specified region
  114. based on their character code.
  115.  
  116.  -- Function: subst-char-in-region START END OLD-CHAR NEW-CHAR
  117.           &optional NOUNDO
  118.      This function replaces all occurrences of the character OLD-CHAR
  119.      with the character NEW-CHAR in the region of the current buffer
  120.      defined by START and END.
  121.  
  122.      If NOUNDO is non-`nil', then `subst-char-in-region' does not
  123.      record the change for undo and does not mark the buffer as
  124.      modified.  This feature is useful for changes which are not
  125.      considered significant, such as when Outline mode changes visible
  126.      lines to invisible lines and vice versa.
  127.  
  128.      `subst-char-in-region' does not move point and returns `nil'.
  129.  
  130.           ---------- Buffer: foo ----------
  131.           This is the contents of the buffer before.
  132.           ---------- Buffer: foo ----------
  133.           
  134.           (subst-char-in-region 1 20 ?i ?X)
  135.                => nil
  136.           
  137.           ---------- Buffer: foo ----------
  138.           ThXs Xs the contents of the buffer before.
  139.           ---------- Buffer: foo ----------
  140.  
  141. 
  142. File: elisp,  Node: Underlining,  Next: Registers,  Prev: Substitution,  Up: Text
  143.  
  144. Underlining
  145. ===========
  146.  
  147.    The underlining commands are somewhat obsolete.  The
  148. `underline-region' function actually inserts `_^H' before each
  149. appropriate character in the region.  This command provides a minimal
  150. text formatting feature that might work on your printer; however, we
  151. recommend instead that you use more powerful text formatting facilities,
  152. such as Texinfo.
  153.  
  154.  -- Command: underline-region START END
  155.      This function underlines all nonblank characters in the region
  156.      defined by START and END.  That is, an underscore character and a
  157.      backspace character are inserted just before each non-whitespace
  158.      character in the region.  The backspace characters are intended to
  159.      cause overstriking, but in Emacs they display as either `\010' or
  160.      `^H', depending on the setting of `ctl-arrow'.  There is no way to
  161.      see the effect of the overstriking within Emacs.  The value is
  162.      `nil'.
  163.  
  164.  -- Command: ununderline-region START END
  165.      This function removes all underlining (overstruck underscores) in
  166.      the region defined by START and END.  The value is `nil'.
  167.  
  168. 
  169. File: elisp,  Node: Registers,  Prev: Underlining,  Up: Text
  170.  
  171. Registers
  172. =========
  173.  
  174.    A register is a sort of variable used in Emacs editing that can hold
  175. a marker, a string, or a rectangle.  Each register is named by a single
  176. character.  All characters, including control and meta characters (but
  177. with the exception of `C-g'), can be used to name registers.  Thus,
  178. there are 255 possible registers.  A register is designated in Emacs
  179. Lisp by a character which is its name.
  180.  
  181.    The functions in this section return unpredictable values unless
  182. otherwise stated.
  183.  
  184.  -- Variable: register-alist
  185.      This variable is an alist of elements of the form `(NAME .
  186.      CONTENTS)'.  Normally, there is one element for each Emacs
  187.      register that has been used.
  188.  
  189.      The object NAME is a character (an integer) identifying the
  190.      register.  The object CONTENTS is a string, marker, or list
  191.      representing the register contents.  A string represents text
  192.      stored in the register.  A marker represents a position.  A list
  193.      represents a rectangle; its elements are strings, one per line of
  194.      the rectangle.
  195.  
  196.  -- Command: view-register REG
  197.      This command displays what is contained in register REG.
  198.  
  199.  -- Function: get-register REG
  200.      This function returns the contents of the register REG, or `nil'
  201.      if it has no contents.
  202.  
  203.  -- Function: set-register REG VALUE
  204.      This function sets the contents of register REG to VALUE. A
  205.      register can be set to any value, but the other register functions
  206.      expect only strings, markers, and lists.
  207.  
  208.  -- Command: point-to-register REG
  209.      This command stores both the current location of point and the
  210.      current buffer in register REG as a marker.
  211.  
  212.  -- Command: register-to-point REG
  213.      This command moves point to the position stored in register REG.
  214.      Since both the buffer and the location within the buffer are
  215.      stored by the `point-to-register' function, this command can
  216.      switch you to another buffer.
  217.  
  218.      If the register does not contain a saved position (a marker), then
  219.      an error is signaled.
  220.  
  221.  -- Command: insert-register REG &optional BEFOREP
  222.      This command inserts contents of register REG into the current
  223.      buffer.
  224.  
  225.      Normally, this command puts point before the inserted text, and the
  226.      mark after it.  However, if the optional second argument BEFOREP
  227.      is non-`nil', it puts the mark before and point after. You can
  228.      pass a non-`nil' second argument BEFOREP to this function
  229.      interactively by supplying any prefix argument.
  230.  
  231.      If the register contains a rectangle, then the rectangle is
  232.      inserted with its upper left corner at point.  This means that
  233.      text is inserted in the current line and underneath it on
  234.      successive lines.
  235.  
  236.      If the register contains something other than saved text (a
  237.      string) or a rectangle (a list), currently useless things happen. 
  238.      This may be changed in the future.
  239.  
  240.  -- Command: copy-to-register REG START END &optional DELETE-FLAG
  241.      This command copies the region from START to END into register
  242.      REG.  If DELETE-FLAG is non-`nil', it deletes the region from the
  243.      buffer after copying it into the register.
  244.  
  245.  -- Command: prepend-to-register REG START END &optional DELETE-FLAG
  246.      This command prepends the region from START to END into register
  247.      REG.  If DELETE-FLAG is non-`nil', it deletes the region from the
  248.      buffer after copying it to the register.
  249.  
  250.  -- Command: append-to-register REG START END &optional DELETE-FLAG
  251.      This command appends the region from START to END to the text
  252.      already in register REG.  If DELETE-FLAG is non-`nil', it deletes
  253.      the region from the buffer after copying it to the register.
  254.  
  255.  -- Command: copy-rectangle-to-register REG START END &optional
  256.           DELETE-FLAG
  257.      This command copies a rectangular region from START to END into
  258.      register REG.  If DELETE-FLAG is non-`nil', it deletes the region
  259.      from the buffer after copying it to the register.
  260.  
  261. 
  262. File: elisp,  Node: Searching and Matching,  Next: Syntax Tables,  Prev: Text,  Up: Top
  263.  
  264. Searching and Matching
  265. **********************
  266.  
  267.    GNU Emacs provides two ways to search through a buffer for specified
  268. text: exact string searches and regular expression searches.  After a
  269. regular expression search, you can identify the text matched by parts of
  270. the regular expression by examining the "match data".
  271.  
  272. * Menu:
  273.  
  274. * String Search::         Search for an exact match.
  275. * Regular Expressions::   Describing classes of strings.
  276. * Regexp Search::         Searching for a match for a regexp.
  277. * Match Data::            Finding out which part of the text matched
  278.                             various parts of a regexp, after regexp search.
  279. * Saving Match Data::     Saving and restoring this information.
  280. * Standard Regexps::      Useful regexps for finding sentences, pages,...
  281. * Searching and Case::    Case-independent or case-significant searching.
  282.  
  283. 
  284. File: elisp,  Node: String Search,  Next: Regular Expressions,  Prev: Searching and Matching,  Up: Searching and Matching
  285.  
  286. Searching for Strings
  287. =====================
  288.  
  289.    These are the primitive functions for searching through the text in a
  290. buffer.  They are meant for use in programs, but you may call them
  291. interactively.  If you do so, they prompt for the search string; LIMIT
  292. and NOERROR are set to `nil', and REPEAT is set to 1.
  293.  
  294.  -- Command: search-forward STRING &optional LIMIT NOERROR REPEAT
  295.      This function searches forward from point for an exact match for
  296.      STRING.  It sets point to the end of the occurrence found, and
  297.      returns `t'.  If no match is found, the value and side effects
  298.      depend on NOERROR.
  299.  
  300.      In the following example, point is positioned at the beginning of
  301.      the line.  Then `(search-forward "fox")' is evaluated in the
  302.      minibuffer and point is left after the last letter of `fox':
  303.  
  304.           ---------- Buffer: foo ----------
  305.           -!-The quick brown fox jumped over the lazy dog.
  306.           ---------- Buffer: foo ----------
  307.           
  308.           (search-forward "fox")
  309.                => t
  310.           
  311.           ---------- Buffer: foo ----------
  312.           The quick brown fox-!- jumped over the lazy dog.
  313.           ---------- Buffer: foo ----------
  314.  
  315.      If LIMIT is non-`nil', then it is the upper bound to the search. 
  316.      (It must be a position in the current buffer.)  No match extending
  317.      after that position is accepted.
  318.  
  319.      What happens when the search fails depends on the value of
  320.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  321.      signaled.  If NOERROR is `t', `search-forward' returns `nil' and
  322.      doesn't signal an error.  If NOERROR is neither `nil' nor `t',
  323.      then `search-forward' moves point to LIMIT and returns `nil'.
  324.  
  325.      If REPEAT is non-`nil', then the search is repeated that many
  326.      times.  Point is positioned at the end of the last match.
  327.  
  328.  -- Command: search-backward STRING &optional LIMIT NOERROR REPEAT
  329.      This function searches backward from point for STRING.  It is just
  330.      like `search-forward' except that it searches backwards and leaves
  331.      point at the beginning of the match.
  332.  
  333.  -- Command: word-search-forward STRING &optional LIMIT NOERROR REPEAT
  334.      This function searches forward from point for a "word" match for
  335.      STRING.  It sets point to the end of the occurrence found, and
  336.      returns `t'.
  337.  
  338.      A word search differs from a simple string search in that a word
  339.      search *requires* that the words it searches for are present as
  340.      entire words (searching for the word `ball' will not match the word
  341.      `balls'), and punctuation and spacing are ignored (searching for
  342.      `ball boy' will match `ball.  Boy!').
  343.  
  344.      In this example, point is first placed at the beginning of the
  345.      buffer; the search leaves it between the `y' and the `!'.
  346.  
  347.           ---------- Buffer: foo ----------
  348.           -!-He said "Please!  Find
  349.           the ball boy!"
  350.           ---------- Buffer: foo ----------
  351.           
  352.           (word-search-forward "Please find the ball, boy.")
  353.                => t
  354.           
  355.           ---------- Buffer: foo ----------
  356.           He said "Please!  Find
  357.           the ball boy-!-!"
  358.           ---------- Buffer: foo ----------
  359.  
  360.      If LIMIT is non-`nil' (it must be a position in the current
  361.      buffer), then it is the upper bound to the search.  The match
  362.      found must not extend after that position.
  363.  
  364.      If NOERROR is `t', then `word-search-forward' returns `nil' when a
  365.      search fails, instead of signaling an error.  If NOERROR is
  366.      neither `nil' nor `t', then `word-search-forward' moves point to
  367.      LIMIT and returns `nil'.
  368.  
  369.      If REPEAT is non-`nil', then the search is repeated that many
  370.      times.  Point is positioned at the end of the last match.
  371.  
  372.  -- Command: word-search-backward STRING &optional LIMIT NOERROR REPEAT
  373.      This function searches backward from point for a word match to
  374.      STRING.  This function is just like `word-search-forward' except
  375.      that it searches backward and normally leaves point at the
  376.      beginning of the match.
  377.  
  378. 
  379. File: elisp,  Node: Regular Expressions,  Next: Regexp Search,  Prev: String Search,  Up: Searching and Matching
  380.  
  381. Regular Expressions
  382. ===================
  383.  
  384.    A "regular expression" ("regexp", for short) is a pattern that
  385. denotes a (possibly infinite) set of strings.  Searching for matches for
  386. a regexp is a very powerful operation.  This section explains how to
  387. write regexps; the following section says how to search for them.
  388.  
  389. * Menu:
  390.  
  391. * Syntax of Regexps::       Rules for writing regular expressions.
  392. * Regexp Example::          Illustrates regular expression syntax.
  393.  
  394. 
  395. File: elisp,  Node: Syntax of Regexps,  Next: Regexp Example,  Prev: Regular Expressions,  Up: Regular Expressions
  396.  
  397. Syntax of Regular Expressions
  398. -----------------------------
  399.  
  400.    Regular expressions have a syntax in which a few characters are
  401. special constructs and the rest are "ordinary".  An ordinary character
  402. is a simple regular expression which matches that character and nothing
  403. else. The special characters are `$', `^', `.', `*', `+', `?', `[', `]'
  404. and `\'; no new special characters will be defined in the future.  Any
  405. other character appearing in a regular expression is ordinary, unless a
  406. `\' precedes it.
  407.  
  408.    For example, `f' is not a special character, so it is ordinary, and
  409. therefore `f' is a regular expression that matches the string `f' and
  410. no other string.  (It does *not* match the string `ff'.)  Likewise, `o'
  411. is a regular expression that matches only `o'.
  412.  
  413.    Any two regular expressions A and B can be concatenated.  The result
  414. is a regular expression which matches a string if A matches some amount
  415. of the beginning of that string and B matches the rest of the string.
  416.  
  417.    As a simple example, we can concatenate the regular expressions `f'
  418. and `o' to get the regular expression `fo', which matches only the
  419. string `fo'.  Still trivial.  To do something more powerful, you need
  420. to use one of the special characters.  Here is a list of them:
  421.  
  422. `. (Period)'
  423.      is a special character that matches any single character except a
  424.      newline. Using concatenation, we can make regular expressions like
  425.      `a.b' which matches any three-character string which begins with
  426.      `a' and ends with `b'.
  427.  
  428. `*'
  429.      is not a construct by itself; it is a suffix that means the
  430.      preceding regular expression is to be repeated as many times as
  431.      possible.  In `fo*', the `*' applies to the `o', so `fo*' matches
  432.      one `f' followed by any number of `o's.  The case of zero `o's is
  433.      allowed: `fo*' does match `f'.
  434.  
  435.      `*' always applies to the *smallest* possible preceding
  436.      expression.  Thus, `fo*' has a repeating `o', not a repeating `fo'.
  437.  
  438.      The matcher processes a `*' construct by matching, immediately, as
  439.      many repetitions as can be found.  Then it continues with the rest
  440.      of the pattern.  If that fails, backtracking occurs, discarding
  441.      some of the matches of the `*'-modified construct in case that
  442.      makes it possible to match the rest of the pattern.  For example,
  443.      matching `ca*ar' against the string `caaar', the `a*' first tries
  444.      to match all three `a's; but the rest of the pattern is `ar' and
  445.      there is only `r' left to match, so this try fails. The next
  446.      alternative is for `a*' to match only two `a's. With this choice,
  447.      the rest of the regexp matches successfully.
  448.  
  449. `+'
  450.      is a suffix character similar to `*' except that it must match the
  451.      preceding expression at least once.  So, for example, `ca+r' will
  452.      match the strings `car' and `caaaar' but not the string `cr',
  453.      whereas `ca*r' would match all three strings.
  454.  
  455. `?'
  456.      is a suffix character similar to `*' except that it can match the
  457.      preceding expression either once or not at all.  For example,
  458.      `ca?r' will match `car' or `cr'; nothing else.
  459.  
  460. `[ ... ]'
  461.      `[' begins a "character set", which is terminated by a `]'.  In
  462.      the simplest case, the characters between the two form the set. 
  463.      Thus, `[ad]' matches either one `a' or one `d', and `[ad]*'
  464.      matches any string composed of just `a's and `d's (including the
  465.      empty string), from which it follows that `c[ad]*r' matches `cr',
  466.      `car', `cdr', `caddaar', etc.
  467.  
  468.      Character ranges can also be included in a character set, by
  469.      writing two characters with a `-' between them.  Thus, `[a-z]'
  470.      matches any lower case letter.  Ranges may be intermixed freely
  471.      with individual characters, as in `[a-z$%.]', which matches any
  472.      lower case letter or `$', `%' or a period.
  473.  
  474.      Note that the usual special characters are not special any more
  475.      inside a character set.  A completely different set of special
  476.      characters exists inside character sets: `]', `-' and `^'.
  477.  
  478.      To include a `]' in a character set, make it the first character.
  479.      For example, `[]a]' matches `]' or `a'.  To include a `-', write
  480.      `---', which is a range containing only `-', or write `-' as the
  481.      first character in the range.
  482.  
  483.      To include `^', make it other than the first character in the set.
  484.  
  485. `[^ ... ]'
  486.      `[^' begins a "complement character set", which matches any
  487.      character except the ones specified.  Thus, `[^a-z0-9A-Z]' matches
  488.      all characters *except* letters and digits.
  489.  
  490.      `^' is not special in a character set unless it is the first
  491.      character.  The character following the `^' is treated as if it
  492.      were first (thus, `-' and `]' are not special there).
  493.  
  494.      Note that a complement character set can match a newline, unless
  495.      newline is mentioned as one of the characters not to match.
  496.  
  497. `^'
  498.      is a special character that matches the empty string, but only at
  499.      the beginning of a line in the text being matched.  Otherwise it
  500.      fails to match anything.  Thus, `^foo' matches a `foo' which occurs
  501.      at the beginning of a line.
  502.  
  503.      When matching a string, `^' matches at the beginning of the string
  504.      or after a newline character `\n'.
  505.  
  506. `$'
  507.      is similar to `^' but matches only at the end of a line.  Thus,
  508.      `x+$' matches a string of one `x' or more at the end of a line.
  509.  
  510.      When matching a string, `$' matches at the end of the string or
  511.      before a newline character `\n'.
  512.  
  513. `\'
  514.      has two functions: it quotes the special characters (including
  515.      `\'), and it introduces additional special constructs.
  516.  
  517.      Because `\' quotes special characters, `\$' is a regular
  518.      expression which matches only `$', and `\[' is a regular
  519.      expression which matches only `[', and so on.
  520.  
  521.      Note that `\' also has special meaning in the read syntax of Lisp
  522.      strings (*note String Type::.), and must be quoted with `\'.  For
  523.      example, the regular expression that matches the `\' character is
  524.      `\\'.  To write a Lisp string that contains `\\', Lisp syntax
  525.      requires you to quote each `\' with another `\'.  Therefore, the
  526.      read syntax for this string is `"\\\\"'.
  527.  
  528.    *Note:* for historical compatibility, special characters are treated
  529. as ordinary ones if they are in contexts where their special meanings
  530. make no sense.  For example, `*foo' treats `*' as ordinary since there
  531. is no preceding expression on which the `*' can act.  It is poor
  532. practice to depend on this behavior; better to quote the special
  533. character anyway, regardless of where it appears.
  534.  
  535.    For the most part, `\' followed by any character matches only that
  536. character.  However, there are several exceptions: characters which,
  537. when preceded by `\', are special constructs.  Such characters are
  538. always ordinary when encountered on their own.  Here is a table of `\'
  539. constructs:
  540.  
  541. `\|'
  542.      specifies an alternative. Two regular expressions A and B with
  543.      `\|' in between form an expression that matches anything that
  544.      either A or B matches.
  545.  
  546.      Thus, `foo\|bar' matches either `foo' or `bar' but no other string.
  547.  
  548.      `\|' applies to the largest possible surrounding expressions. 
  549.      Only a surrounding `\( ... \)' grouping can limit the grouping
  550.      power of `\|'.
  551.  
  552.      Full backtracking capability exists to handle multiple uses of
  553.      `\|'.
  554.  
  555. `\( ... \)'
  556.      is a grouping construct that serves three purposes:
  557.  
  558.        1. To enclose a set of `\|' alternatives for other operations.
  559.           Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.
  560.  
  561.        2. To enclose a complicated expression for a suffix character
  562.           such as `*' to operate on.  Thus, `ba\(na\)*' matches
  563.           `bananana', etc., with any (zero or more) number of `na'
  564.           strings.
  565.  
  566.        3. To record a matched substring for future reference.
  567.  
  568.      This last application is not a consequence of the idea of a
  569.      parenthetical grouping; it is a separate feature which happens to
  570.      be assigned as a second meaning to the same `\( ... \)' construct
  571.      because there is no conflict in practice between the two meanings.
  572.      Here is an explanation of this feature:
  573.  
  574. `\DIGIT'
  575.      after the end of a `\( ... \)' construct, the matcher remembers the
  576.      beginning and end of the text matched by that construct.  Then,
  577.      later on in the regular expression, you can use `\' followed by
  578.      DIGIT to mean "match the same text matched the DIGITth time by the
  579.      `\( ... \)' construct."
  580.  
  581.      The strings matching the first nine `\( ... \)' constructs
  582.      appearing in a regular expression are assigned numbers 1 through 9
  583.      in the order that the open parentheses appear in the regular
  584.      expression. `\1' through `\9' can be used to refer to the text
  585.      matched by the corresponding `\( ... \)' construct.
  586.  
  587.      For example, `\(.*\)\1' matches any newline-free string that is
  588.      composed of two identical halves.  The `\(.*\)' matches the first
  589.      half, which may be anything, but the `\1' that follows must match
  590.      the same exact text.
  591.  
  592. `\`'
  593.      matches the empty string, provided it is at the beginning of the
  594.      buffer.
  595.  
  596. `\''
  597.      matches the empty string, provided it is at the end of the buffer.
  598.  
  599. `\b'
  600.      matches the empty string, provided it is at the beginning or end
  601.      of a word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
  602.      separate word.  `\bballs?\b' matches `ball' or `balls' as a
  603.      separate word.
  604.  
  605. `\B'
  606.      matches the empty string, provided it is *not* at the beginning or
  607.      end of a word.
  608.  
  609. `\<'
  610.      matches the empty string, provided it is at the beginning of a
  611.      word.
  612.  
  613. `\>'
  614.      matches the empty string, provided it is at the end of a word.
  615.  
  616. `\w'
  617.      matches any word-constituent character.  The editor syntax table
  618.      determines which characters these are.  *Note Syntax Tables::.
  619.  
  620. `\W'
  621.      matches any character that is not a word-constituent.
  622.  
  623. `\sCODE'
  624.      matches any character whose syntax is CODE.  Here CODE is a
  625.      character which represents a syntax code: thus, `w' for word
  626.      constituent, `-' for whitespace, `(' for open parenthesis, etc. 
  627.      *Note Syntax Tables::, for a list of the codes.
  628.  
  629. `\SCODE'
  630.      matches any character whose syntax is not CODE.
  631.  
  632.    Not every string is a valid regular expression.  For example, any
  633. string with unbalanced square brackets is invalid, and so is a string
  634. that ends with a single `\'.  If an invalid regular expression is
  635. passed to any of the search functions, an `invalid-regexp' error is
  636. signaled.
  637.  
  638.  -- Function: regexp-quote STRING
  639.      This function returns a regular expression string which matches
  640.      exactly STRING and nothing else.  This allows you to request an
  641.      exact string match when calling a function that wants a regular
  642.      expression.
  643.  
  644.           (regexp-quote "^The cat$")
  645.                => "\\^The cat\\$"
  646.  
  647.      One use of `regexp-quote' is to combine an exact string match with
  648.      context described as a regular expression.  For example, this
  649.      searches for the string which is the value of `string', surrounded
  650.      by whitespace:
  651.  
  652.           (re-search-forward (concat "\\s " (regexp-quote string) "\\s "))
  653.  
  654. 
  655. File: elisp,  Node: Regexp Example,  Prev: Syntax of Regexps,  Up: Regular Expressions
  656.  
  657. Complex Regexp Example
  658. ----------------------
  659.  
  660.    Here is a complicated regexp, used by Emacs to recognize the end of a
  661. sentence together with any whitespace that follows.  It is the value of
  662. the variable `sentence-end'.
  663.  
  664.    First, we show the regexp as a string in Lisp syntax to enable you to
  665. distinguish the spaces from the tab characters.  The string constant
  666. begins and ends with a double-quote.  `\"' stands for a double-quote as
  667. part of the string, `\\' for a backslash as part of the string, `\t'
  668. for a tab and `\n' for a newline.
  669.  
  670.      "[.?!][]\"')}]*\\($\\|\t\\|  \\)[ \t\n]*"
  671.  
  672.    In contrast, if you evaluate the variable `sentence-end', you will
  673. see the following:
  674.  
  675.      sentence-end
  676.      =>
  677.      "[.?!][]\"')}]*\\($\\|  \\|  \\)[
  678.      ]*"
  679.  
  680. In this case, the tab and carriage return are the actual characters.
  681.  
  682.    This regular expression contains four parts in succession and can be
  683. deciphered as follows:
  684.  
  685. `[.?!]'
  686.      The first part of the pattern consists of three characters, a
  687.      period, a question mark and an exclamation mark, within square
  688.      brackets.  The match must begin with one of these three characters.
  689.  
  690. `[]\"')}]*'
  691.      The second part of the pattern matches any closing braces and
  692.      quotation marks, zero or more of them, that may follow the period,
  693.      question mark or exclamation mark.  The `\"' is Lisp syntax for a
  694.      double-quote in a string.  The `*' at the end indicates that the
  695.      immediately preceding regular expression (a character set, in this
  696.      case) may be repeated zero or more times.
  697.  
  698. `\\($\\|\t\\|  \\)'
  699.      The third part of the pattern matches the whitespace that follows
  700.      the end of a sentence: the end of a line, or a tab, or two spaces.
  701.       The double backslashes are needed to prevent Emacs from reading
  702.      the parentheses and vertical bars as part of the search pattern;
  703.      the parentheses are used to mark the group and the vertical bars
  704.      are used to indicated that the patterns to either side of them are
  705.      alternatives. The dollar sign is used to match the end of a line. 
  706.      The tab character is written using `\t' and the two spaces are
  707.      written as themselves.
  708.  
  709. `[ \t\n]*'
  710.      Finally, the last part of the pattern indicates that the end of
  711.      the line or the whitespace following the period, question mark or
  712.      exclamation mark may, but need not, be followed by additional
  713.      whitespace.
  714.  
  715. 
  716. File: elisp,  Node: Regexp Search,  Next: Match Data,  Prev: Regular Expressions,  Up: Searching and Matching
  717.  
  718. Regular Expression Searching
  719. ============================
  720.  
  721.    In GNU Emacs, you can search for the next match for a regexp either
  722. incrementally or not.  Incremental search commands are described in the
  723. `The GNU Emacs Manual'.  *Note Regular Expression Search: (emacs)Regexp
  724. Search.  Here we describe only the search functions useful in programs.
  725.  The principal is `re-search-forward'.
  726.  
  727.  -- Command: re-search-forward REGEXP &optional LIMIT NOERROR REPEAT
  728.      This function searches forward in the current buffer for a string
  729.      of text that is matched by the regular expression REGEXP.  The
  730.      function skips over any amount of text that is not matched by
  731.      REGEXP, and leaves point at the end of the first string found that
  732.      does match.
  733.  
  734.      If the search is successful (i.e., if text matching REGEXP is
  735.      found), then point is left at the end of that text, and the
  736.      function returns `t'.
  737.  
  738.      What happens when the search fails depends on the value of
  739.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  740.      signaled.  If NOERROR is `t', `re-search-forward' returns `nil'
  741.      and doesn't signal an error. If NOERROR is neither `nil' nor `t',
  742.      then `search-forward' moves point to LIMIT and returns `nil'.
  743.  
  744.      If LIMIT is non-`nil' (it must be a position in the current
  745.      buffer), then it is the upper bound to the search.  No match
  746.      extending after that position is accepted.
  747.  
  748.      If REPEAT is supplied (it must be a positive number), then the
  749.      search is repeated that many times (each time starting at the end
  750.      of the previous time's match).  The call succeeds if all these
  751.      searches succeeded, and point is left at the end of the match
  752.      found by the last search.  Otherwise the search fails.
  753.  
  754.      In the following example, point is initially located directly
  755.      before the `T'.  After evaluating the form, point is located at
  756.      the end of that line (between the `t' of `hat' and before the
  757.      newline).
  758.  
  759.           ---------- Buffer: foo ----------
  760.           I read "-!-The cat in the hat
  761.           comes back" twice.
  762.           ---------- Buffer: foo ----------
  763.           
  764.           (re-search-forward "[a-z]+" nil t 5)
  765.                => t
  766.           
  767.           ---------- Buffer: foo ----------
  768.           I read "The cat in the hat-!-
  769.           comes back" twice.
  770.           ---------- Buffer: foo ----------
  771.  
  772.  -- Command: re-search-backward REGEXP &optional LIMIT NOERROR REPEAT
  773.      This function searches backward in the current buffer for a string
  774.      of text that is matched by the regular expression REGEXP, leaving
  775.      point at the beginning of the first text found.
  776.  
  777.      This function is analogous to `re-search-forward', but they are
  778.      not simple mirror images.  `re-search-forward' finds the match
  779.      whose beginning is as close as possible.  If `re-search-backward'
  780.      were a perfect mirror image, it would find the match whose end is
  781.      as close as possible.  However, in fact it finds the match whose
  782.      beginning is as close as possible.  The reason is that matching a
  783.      regular expression at a given spot always works from beginning to
  784.      end, and is done at a specified beginning position.  Thus, true
  785.      mirror-image behavior would require a special feature for matching
  786.      regexps from end to beginning.
  787.  
  788.  -- Function: string-match REGEXP STRING &optional START
  789.      This function returns the index of the start of the first match for
  790.      the regular expression REGEXP in STRING, or `nil' if there is no
  791.      match.  If START is non-`nil', the search starts at that index in
  792.      STRING.
  793.  
  794.      For example,
  795.  
  796.           (string-match "quick" "The quick brown fox jumped quickly.")
  797.                => 4
  798.           (string-match "quick" "The quick brown fox jumped quickly." 8)
  799.                => 27
  800.  
  801.      The index of the first character of the string is 0, the index of
  802.      the second character is 1, and so on.
  803.  
  804.      After this function returns, the index of the first character
  805.      beyond the match is available as `(match-end 0)'.  *Note Match
  806.      Data::.
  807.  
  808.           (string-match "quick" "The quick brown fox jumped quickly." 8)
  809.                => 27
  810.           
  811.           (match-end 0)
  812.                => 32
  813.  
  814.      The `match-end' function is described along with
  815.      `match-beginning'; see *Note Match Data::.
  816.  
  817.  -- Function: looking-at REGEXP
  818.      This function determines whether the text in the current buffer
  819.      directly following point matches the regular expression REGEXP. 
  820.      "Directly following" means precisely that: the search is
  821.      "anchored" and it must succeed starting with the first character
  822.      following point.  The result is `t' if so, `nil' otherwise.
  823.  
  824.      Point is not moved, but the match data is updated and can be used
  825.      with `match-beginning' or `match-end'.  *Note Match Data::.
  826.  
  827.      In this example, point is located directly before the `T'.  If it
  828.      were anywhere else, the result would be `nil'.
  829.  
  830.           ---------- Buffer: foo ----------
  831.           I read "-!-The cat in the hat
  832.           comes back" twice.
  833.           ---------- Buffer: foo ----------
  834.           (looking-at "The cat in the hat$")
  835.                => t
  836.  
  837. 
  838. File: elisp,  Node: Match Data,  Next: Saving Match Data,  Prev: Regexp Search,  Up: Searching and Matching
  839.  
  840. The Match Data
  841. ==============
  842.  
  843.    Emacs keeps track of the positions of the start and end of segments
  844. of text found during a regular expression search.  This means, for
  845. example, that you can search for a complex pattern, such as a date in
  846. an Rmail message, and extract parts of it.
  847.  
  848.  -- Function: match-beginning COUNT
  849.      This function returns the position of the start of text matched by
  850.      the last regular expression searched for.  COUNT, a number,
  851.      specifies a subexpression whose start position is the value.  If
  852.      COUNT is zero, then the value is the position of the text matched
  853.      by the whole regexp.  If COUNT is greater than zero, then the
  854.      value is the position of the beginning of the text matched by the
  855.      COUNTth subexpression, regardless of whether it was used in the
  856.      final match.
  857.  
  858.      Subexpressions of a regular expression are those expressions
  859.      grouped inside of parentheses, `\(...\)'.  The COUNTth
  860.      subexpression is found by counting occurrences of `\(' from the
  861.      beginning of the whole regular expression.  The first
  862.      subexpression is numbered 1, the second 2, and so on.
  863.  
  864.      The `match-end' function is similar to the `match-beginning'
  865.      function except that it returns the position of the end of the
  866.      matched text.
  867.  
  868.      Here is an example, with a comment showing the numbers of the
  869.      positions in the text:
  870.  
  871.           (string-match "\\(qu\\)\\(ick\\)" "The quick fox jumped quickly.")
  872.                => 4                         ;^^^^^^^^^^
  873.                                             ;0123456789
  874.           
  875.           (match-beginning 1)               ; The beginning of the match
  876.                => 4                         ; with `qu' is at index 4.
  877.           
  878.           (match-beginning 2)               ; The beginning of the match
  879.                => 6                         ; with `ick' is at index 6.
  880.           
  881.           (match-end 1)                     ; The end of the match
  882.                => 6                         ; with `qu' is at index 6.
  883.           
  884.           (match-end 2)                     ; The end of the match
  885.                => 9                         ; with `ick' is at index 9.
  886.  
  887.      Here is another example.  Before the form is evaluated, point is
  888.      located at the beginning of the line.  After evaluating the search
  889.      form, point is located on the line between the space and the word
  890.      `in'.  The beginning of the entire match is at the 9th character
  891.      of the buffer (`T'), and the beginning of the match for the first
  892.      subexpression is at the 13th character (`c').
  893.  
  894.           (list
  895.             (re-search-forward "The \\(cat \\)")
  896.             (match-beginning 0)
  897.             (match-beginning 1))
  898.           => (t 9 13)
  899.           
  900.           ---------- Buffer: foo ----------
  901.           I read "The cat -!-in the hat comes back" twice.
  902.                   ^   ^
  903.                   9  13
  904.           ---------- Buffer: foo ----------
  905.  
  906.      (Note that in this case, the index returned is a buffer position;
  907.      the first character of the buffer counts as 1.)
  908.  
  909.      It is essential that `match-beginning' be called after the search
  910.      desired, but before any other searches are performed.
  911.      `match-beginning' may not give the desired results if any other
  912.      Lisp programs are executed between the search and it, since they
  913.      may do other searches.  This example shows misuse of
  914.      `match-beginning'.
  915.  
  916.           (re-search-forward "The \\(cat \\)")
  917.                => t
  918.           (foo)                   ; Perhaps `foo' does more regexp searching.
  919.           (match-beginning 0)
  920.                => 61              ; Unexpected result!
  921.  
  922.      See the discussion of `store-match-data' for an example of how to
  923.      save and restore the match data around a search.
  924.  
  925.  -- Function: match-end COUNT
  926.      This function returns the position of the end of text matched by
  927.      the last regular expression searched for.  This function is
  928.      otherwise similar to `match-beginning'.
  929.  
  930.  -- Function: replace-match REPLACEMENT &optional FIXEDCASE LITERAL
  931.      This function replaces the text matched by the last search with
  932.      REPLACEMENT.
  933.  
  934.      If FIXEDCASE is non-`nil', then the case of the replacement text
  935.      is not changed; otherwise, the replacement text is converted to a
  936.      different case depending upon the capitalization of the text to be
  937.      replaced.  If the original text is all upper case, the replacement
  938.      text is converted to upper case, except when all of the words in
  939.      the original text are only one character long.  In that event, the
  940.      replacement text is capitalized.  If *all* of the words in the
  941.      original text are capitalized, then all of the words in the
  942.      replacement text are capitalized.
  943.  
  944.      If LITERAL is non-`nil', then REPLACEMENT is inserted exactly as
  945.      it is, the only alterations being case changes as needed. If it is
  946.      `nil' (the default), then the character `\' is treated specially. 
  947.      If a `\' appears in REPLACEMENT, then it must be part of one of
  948.      the following sequences:
  949.  
  950.     `\&'
  951.           `\&' stands for the entire text being replaced.
  952.  
  953.     `\N'
  954.           `\N' stands for the Nth subexpression in the original regexp.
  955.            Subexpressions are those expressions grouped inside of
  956.           `\(...\)'.  N is a digit.
  957.  
  958.     `\\'
  959.           `\\' stands for a single `\' in the replacement text.
  960.  
  961.      `replace-match' leaves point at the end of the replacement text,
  962.      and returns `t'.
  963.  
  964. 
  965. File: elisp,  Node: Saving Match Data,  Next: Standard Regexps,  Prev: Match Data,  Up: Searching and Matching
  966.  
  967. Saving and Restoring the Match Data
  968. ===================================
  969.  
  970.  -- Function: match-data
  971.      This function returns a new list containing all the information on
  972.      what text the last search matched.  Element zero is the position
  973.      of the beginning of the match for the whole expression; element
  974.      one is the position of the end of the match for the expression. 
  975.      The next two elements are the positions of the beginning and end
  976.      of the match for the first subexpression.  In general, element
  977.      number 2N corresponds to `(match-beginning N)'; and element number
  978.      2N + 1 corresponds to `(match-end N)'.
  979.  
  980.      All the elements are markers, or the integer 0 for a match at the
  981.      beginning of a string (with `string-match'), or `nil' if there was
  982.      no match for that subexpression.  As with other functions that get
  983.      information about a search, there must be no possibility of
  984.      intervening searches between the call to a search function and the
  985.      call to `match-data' that is intended to save the match-data for
  986.      that search.
  987.  
  988.           (match-data)
  989.                =>  (#<marker at 9 in foo> #<marker at 17 in foo>
  990.                     #<marker at 13 in foo> #<marker at 17 in foo>)
  991.  
  992.      In version 19, all elements will be markers or `nil' if matching
  993.      was done on a buffer, and all will be integers or `nil' if matching
  994.      was done on a string with `string-match'.
  995.  
  996.  -- Function: store-match-data MATCH-LIST
  997.      This function sets the match data within Emacs Lisp from the
  998.      elements of MATCH-LIST, which should be a list created by a
  999.      previous call to `match-data'.
  1000.  
  1001.      `store-match-data' may be used together with `match-data' to
  1002.      perform a search without changing the `match-data'.  This is useful
  1003.      when such searches occur in subroutines whose callers may not
  1004.      expect searches to go on.  Here is how:
  1005.  
  1006.           (let ((data (match-data)))
  1007.             (unwind-protect
  1008.                 ... ; May change the original match data.
  1009.               (store-match-data data)))
  1010.  
  1011.      All asynchronous process functions (filters and sentinels) and some
  1012.      modes that use `recursive-edit' should save and restore the match
  1013.      data if they do a search or if they let the user type arbitrary
  1014.      commands.
  1015.  
  1016.      Here is a function which will restore the match data if the buffer
  1017.      associated with it still exists.
  1018.  
  1019.           (defun restore-match-data (data)
  1020.             "Restore the match data DATA unless the buffer is missing."
  1021.             (catch 'foo
  1022.               (let ((d data))
  1023.                 (while d
  1024.                   (and (car d)
  1025.                        (null (marker-buffer (car d)))
  1026.                        ;; match-data buffer is deleted.
  1027.                        (throw 'foo nil))
  1028.                   (setq d (cdr d)))
  1029.                 (store-match-data data))))
  1030.  
  1031. 
  1032. File: elisp,  Node: Standard Regexps,  Next: Searching and Case,  Prev: Saving Match Data,  Up: Searching and Matching
  1033.  
  1034. Standard Regular Expressions Used in Editing
  1035. ============================================
  1036.  
  1037.  -- Variable: page-delimiter
  1038.      This is the regexp describing line-beginnings that separate pages.
  1039.       The default value is `"^\014"' (i.e., `"^^L"' or `"^\C-l"').
  1040.  
  1041.  -- Variable: paragraph-separate
  1042.      This is the regular expression for recognizing the beginning of a
  1043.      line that separates paragraphs.  (If you change this, you may have
  1044.      to change `paragraph-start' also.)  The default value is `"^[
  1045.      \t\f]*$"', which is a line that consists entirely of spaces, tabs,
  1046.      and form feeds.
  1047.  
  1048.  -- Variable: paragraph-start
  1049.      This is the regular expression for recognizing the beginning of a
  1050.      line that starts *or* separates paragraphs.  The default value is
  1051.      `"^[ \t\n\f]"', which matches a line starting with a space, tab,
  1052.      newline, or form feed.
  1053.  
  1054.  -- Variable: sentence-end
  1055.      This is the regular expression describing the end of a sentence. 
  1056.      (All paragraph boundaries also end sentences, regardless.)  The
  1057.      default value is:
  1058.  
  1059.           "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*"
  1060.  
  1061.      This means a period, question mark or exclamation mark, followed
  1062.      by a closing brace, followed by tabs, spaces or new lines.
  1063.  
  1064.      For a detailed explanation of this regular expression, see *Note
  1065.      Regexp Example::.
  1066.  
  1067. 
  1068. File: elisp,  Node: Searching and Case,  Prev: Standard Regexps,  Up: Searching and Matching
  1069.  
  1070. Searching and Case
  1071. ==================
  1072.  
  1073.    By default, searches in Emacs ignore the case of the text they are
  1074. searching through; if you specify searching for `FOO', then `Foo' or
  1075. `foo' is also considered a match.  Regexps, and in particular character
  1076. sets, are included: thus, `[aB]' would match `a' or `A' or `b' or `B'.
  1077.  
  1078.    If you do not want this feature, set the variable `case-fold-search'
  1079. to `nil'.  Then all letters must match exactly, including case.  This
  1080. is a per-buffer-local variable; altering the variable affects only the
  1081. current buffer.  (*Note Intro to Buffer-Local::.)  Alternatively, you
  1082. may change the value of `default-case-fold-search', which is the
  1083. default value of `case-fold-search' for buffers that do not override it.
  1084.  
  1085.  -- User Option: case-replace
  1086.      This variable determines whether `query-replace' should preserve
  1087.      case in replacements.  If the variable is `nil', then case need
  1088.      not be preserved.
  1089.  
  1090.  -- User Option: case-fold-search
  1091.      This buffer-local variable determines whether searches should
  1092.      ignore case.  If the variable is `nil' they do not ignore case;
  1093.      otherwise they do ignore case.
  1094.  
  1095.  -- Variable: default-case-fold-search
  1096.      The value of this variable is the default value for
  1097.      `case-fold-search' in buffers that do not override it.  This is the
  1098.      same as `(default-value 'case-fold-search)'.
  1099.  
  1100. 
  1101. File: elisp,  Node: Syntax Tables,  Next: Abbrevs,  Prev: Searching and Matching,  Up: Top
  1102.  
  1103. Syntax Tables
  1104. *************
  1105.  
  1106.    A "syntax table" provides Emacs with the information that determines
  1107. the syntactic use of each character in a buffer.  This information is
  1108. used by the parsing commands, the complex movement commands, and others
  1109. to determine where words, symbols, and other syntactic constructs begin
  1110. and end.
  1111.  
  1112.    A syntax table is a vector of 256 elements; it contains one entry for
  1113. each of the 256 ASCII characters of an 8-bit byte.  Each element is an
  1114. integer that encodes the syntax of the character in question.
  1115.  
  1116.    Syntax tables are used only for moving across text, not for the GNU
  1117. Emacs Lisp reader.  GNU Emacs Lisp uses built-in syntactic rules when
  1118. reading Lisp expressions, and these rules cannot be changed.
  1119.  
  1120.    Each buffer has its own major mode, and each major mode has its own
  1121. idea of the syntactic class of various characters.  For example, in Lisp
  1122. mode, the character `;' begins a comment, but in C mode, it terminates
  1123. a statement.  To support these variations, Emacs makes the choice of
  1124. syntax table local to the each buffer.  Typically, each major mode has
  1125. its own syntax table and installs that table in each buffer which uses
  1126. that mode.  Changing this table alters the syntax in all those buffers
  1127. as well as in any buffers subsequently put in that mode. Occasionally
  1128. several similar modes share one syntax table. *Note Example Major
  1129. Modes::, for an example of how to set up a syntax table.
  1130.  
  1131.  -- Function: syntax-table-p OBJECT
  1132.      This function returns `t' if OBJECT is a vector of length 256
  1133.      elements.  This means that the vector may be a syntax table.
  1134.      However, according to this test, any vector of length 256 is
  1135.      considered to be a syntax table, no matter what its contents.
  1136.  
  1137. * Menu:
  1138.  
  1139. * Syntax Descriptors::       How characters are classified.
  1140. * Syntax Table Functions::   How to create, examine and alter syntax tables.
  1141. * Parsing Expressions::      Parsing balanced expressions
  1142.                                 using the syntax table.
  1143. * Standard Syntax Tables::   Syntax tables used by various major modes.
  1144. * Syntax Table Internals::   How syntax table information is stored.
  1145.  
  1146. 
  1147. File: elisp,  Node: Syntax Descriptors,  Next: Syntax Table Functions,  Prev: Syntax Tables,  Up: Syntax Tables
  1148.  
  1149. Syntax Descriptors
  1150. ==================
  1151.  
  1152.    This section describes the syntax classes and flags that denote the
  1153. syntax of a character, and how they are represented as a "syntax
  1154. descriptor", which is a Lisp string that you pass to
  1155. `modify-syntax-entry' to specify the desired syntax.
  1156.  
  1157.    Emacs defines twelve "syntax classes".  Each syntax table contains a
  1158. mapping that puts each character into one class.  There is no necessary
  1159. relationship between the class of a character in one syntax table and
  1160. its class in any other table.
  1161.  
  1162.    Each class is designated by a mnemonic character which serves as the
  1163. name of the class when you need to specify a class.  Usually the
  1164. designator character is one which is frequently put in that class;
  1165. however, its meaning as a designator is unvarying and independent of how
  1166. it is actually classified.
  1167.  
  1168.    A syntax descriptor is a Lisp string which specifies a syntax class,
  1169. a matching character (unused except for parenthesis classes) and flags.
  1170. The first character is the designator for a syntax class.  The second
  1171. character is the character to match; if it is unused, put a space there.
  1172. Then come the characters for any desired flags.  If no matching
  1173. character or flags are needed, one character is sufficient.
  1174.  
  1175.    Thus, the descriptor for the character `*' in C mode is `. 23'
  1176. (i.e., punctuation, matching character slot unused, second character of
  1177. a comment-starter, first character of an comment-ender), and the entry
  1178. for `/' is `. 14' (i.e., punctuation, matching character slot unused,
  1179. first character of a comment-starter, second character of a
  1180. comment-ender).
  1181.  
  1182. * Menu:
  1183.  
  1184. * Syntax Class Table::      Table of syntax classes.
  1185. * Syntax Flags::            Additional flags each character can have.
  1186.  
  1187.