home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-25 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  48.3 KB  |  1,212 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.  
  7.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26. 
  27. File: elisp,  Node: Regexp Search,  Next: Replacement,  Prev: Regular Expressions,  Up: Searching and Matching
  28.  
  29. Regular Expression Searching
  30. ============================
  31.  
  32.    In GNU Emacs, you can search for the next match for a regexp either
  33. incrementally or not.  Incremental search commands are described in the
  34. `The GNU Emacs Manual'.  *Note Regular Expression Search: (emacs)Regexp
  35. Search.  Here we describe only the search functions useful in programs.
  36. The principal one is `re-search-forward'.
  37.  
  38.  - Command: re-search-forward REGEXP &optional LIMIT NOERROR REPEAT
  39.      This function searches forward in the current buffer for a string
  40.      of text that is matched by the regular expression REGEXP.  The
  41.      function skips over any amount of text that is not matched by
  42.      REGEXP, and leaves point at the end of the first string found that
  43.      does match.
  44.  
  45.      If the search is successful (i.e., if text matching REGEXP is
  46.      found), then point moves to the end of that text, and the function
  47.      returns the new value of point.
  48.  
  49.      What happens when the search fails depends on the value of
  50.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  51.      signaled.  If NOERROR is `t', `re-search-forward' does nothing and
  52.      returns `nil'.  If NOERROR is neither `nil' nor `t', then
  53.      `re-search-forward' moves point to LIMIT (or the end of the
  54.      buffer) and returns `nil'.
  55.  
  56.      If LIMIT is non-`nil' (it must be a position in the current
  57.      buffer), then it is the upper bound to the search.  No match
  58.      extending after that position is accepted.
  59.  
  60.      If REPEAT is supplied (it must be a positive number), then the
  61.      search is repeated that many times (each time starting at the end
  62.      of the previous time's match).  The call succeeds if all these
  63.      searches succeeded, and point is left at the end of the match
  64.      found by the last search.  Otherwise the search fails.
  65.  
  66.      In the following example, point is initially located directly
  67.      before the `T'.  After evaluating the form, point is located at
  68.      the end of that line (between the `t' of `hat' and before the
  69.      newline).
  70.  
  71.           ---------- Buffer: foo ----------
  72.           I read "-!-The cat in the hat
  73.           comes back" twice.
  74.           ---------- Buffer: foo ----------
  75.           
  76.           (re-search-forward "[a-z]+" nil t 5)
  77.                => t
  78.           
  79.           ---------- Buffer: foo ----------
  80.           I read "The cat in the hat-!-
  81.           comes back" twice.
  82.           ---------- Buffer: foo ----------
  83.  
  84.  - Command: re-search-backward REGEXP &optional LIMIT NOERROR REPEAT
  85.      This function searches backward in the current buffer for a string
  86.      of text that is matched by the regular expression REGEXP, leaving
  87.      point at the beginning of the first text found.
  88.  
  89.      This function is analogous to `re-search-forward', but they are
  90.      not simple mirror images.  `re-search-forward' finds the match
  91.      whose beginning is as close as possible.  If `re-search-backward'
  92.      were a perfect mirror image, it would find the match whose end is
  93.      as close as possible.  However, in fact it finds the match whose
  94.      beginning is as close as possible.  The reason is that matching a
  95.      regular expression at a given spot always works from beginning to
  96.      end, and is done at a specified beginning position.  Thus, true
  97.      mirror-image behavior would require a special feature for matching
  98.      regexps from end to beginning.
  99.  
  100.  - Function: string-match REGEXP STRING &optional START
  101.      This function returns the index of the start of the first match for
  102.      the regular expression REGEXP in STRING, or `nil' if there is no
  103.      match.  If START is non-`nil', the search starts at that index in
  104.      STRING.
  105.  
  106.      For example,
  107.  
  108.           (string-match
  109.            "quick" "The quick brown fox jumped quickly.")
  110.                => 4
  111.           (string-match
  112.            "quick" "The quick brown fox jumped quickly." 8)
  113.                => 27
  114.  
  115.      The index of the first character of the string is 0, the index of
  116.      the second character is 1, and so on.
  117.  
  118.      After this function returns, the index of the first character
  119.      beyond the match is available as `(match-end 0)'.  *Note Match
  120.      Data::.
  121.  
  122.           (string-match
  123.            "quick" "The quick brown fox jumped quickly." 8)
  124.                => 27
  125.           
  126.           (match-end 0)
  127.                => 32
  128.  
  129.      The `match-beginning' and `match-end' functions are described
  130.      together; see *Note Match Data::.
  131.  
  132.  - Function: looking-at REGEXP
  133.      This function determines whether the text in the current buffer
  134.      directly following point matches the regular expression REGEXP.
  135.      "Directly following" means precisely that: the search is
  136.      "anchored" and it must succeed starting with the first character
  137.      following point.  The result is `t' if so, `nil' otherwise.
  138.  
  139.      This function does not move point, but it updates the match data,
  140.      which you can access using `match-beginning' or `match-end'.
  141.      *Note Match Data::.
  142.  
  143.      In this example, point is located directly before the `T'.  If it
  144.      were anywhere else, the result would be `nil'.
  145.  
  146.           ---------- Buffer: foo ----------
  147.           I read "-!-The cat in the hat
  148.           comes back" twice.
  149.           ---------- Buffer: foo ----------
  150.           
  151.           (looking-at "The cat in the hat$")
  152.                => t
  153.  
  154. 
  155. File: elisp,  Node: Replacement,  Next: Match Data,  Prev: Regexp Search,  Up: Searching and Matching
  156.  
  157. Replacement
  158. ===========
  159.  
  160.  - Function: perform-replace FROM-STRING REPLACEMENTS QUERY-FLAG
  161.           REGEXP-FLAG DELIMITED-FLAG &optional REPEAT-COUNT MAP
  162.      This function is the guts of `query-replace' and related commands.
  163.      It searches for occurrences of FROM-STRING and replaces some or
  164.      all of them.  If QUERY-FLAG is `nil', it replaces all occurrences;
  165.      otherwise, it asks the user what to do about each one.
  166.  
  167.      If REGEXP-FLAG is non-`nil', then FROM-STRING is considered a
  168.      regular expression; otherwise, it must match literally.  If
  169.      DELIMITED-FLAG is non-`nil', then only replacements surrounded by
  170.      word boundaries are considered.
  171.  
  172.      The argument REPLACEMENTS specifies what to replace occurrences
  173.      with.  If it is a string, that string is used.  It can also be a
  174.      list of strings, to be used in cyclic order.
  175.  
  176.      If REPEAT-COUNT is non-`nil', it should be an integer, the number
  177.      of occurrences to consider.  In this case, `perform-replace'
  178.      returns after considering that many occurrences.
  179.  
  180.      Normally, the keymap `query-replace-map' defines the possible user
  181.      responses.  The argument MAP, if non-`nil', is a keymap to use
  182.      instead of `query-replace-map'.
  183.  
  184.  - Variable: query-replace-map
  185.      This variable holds a special keymap that defines the valid user
  186.      responses for `query-replace' and related functions, as well as
  187.      `y-or-n-p' and `map-y-or-n-p'.  It is special in two ways:
  188.  
  189.         * The "key bindings" are not commands, just symbols that are
  190.           meaningful to the functions that use this map.
  191.  
  192.         * Prefix keys are not supported; each key binding must be for a
  193.           single event key sequence.  This is because the functions
  194.           don't use read key sequence to get the input; instead, they
  195.           read a single event and look it up "by hand."
  196.  
  197.    Here are the meaningful "bindings" for `query-replace-map'.  Several
  198. of them are meaningful only for `query-replace' and friends.
  199.  
  200. `act'
  201.      Do take the action.  The action being considered--in other words,
  202.      "yes."
  203.  
  204. `skip'
  205.      Do not take action for this question--in other words, "no."
  206.  
  207. `exit'
  208.      Answer this question "no," and don't ask any more.
  209.  
  210. `act-and-exit'
  211.      Answer this question "yes," and don't ask any more.
  212.  
  213. `act-and-show'
  214.      Answer this question "yes," but show the results--don't advance
  215.      yet.
  216.  
  217. `automatic'
  218.      Answer this question and all subsequent questions in the series
  219.      with "yes," without further user interaction.
  220.  
  221. `backup'
  222.      Move back to the previous place that a question was asked about.
  223.  
  224. `edit'
  225.      Enter a recursive edit to deal with this item--instead of any
  226.      other answer.
  227.  
  228. `delete-and-edit'
  229.      Delete the text being considered, then enter a recursive edit to
  230.      replace it.
  231.  
  232. `recenter'
  233.      Redisplay and center the window, then ask the same question again.
  234.  
  235. `quit'
  236.      Perform a quit right away.  Only the `y-or-n-p' functions use this
  237.      answer.
  238.  
  239. `help'
  240.      Display some help, then ask again.
  241.  
  242. 
  243. File: elisp,  Node: Match Data,  Next: Standard Regexps,  Prev: Replacement,  Up: Searching and Matching
  244.  
  245. The Match Data
  246. ==============
  247.  
  248.    Emacs keeps track of the positions of the start and end of segments
  249. of text found during a regular expression search.  This means, for
  250. example, that you can search for a complex pattern, such as a date in
  251. an Rmail message, and extract parts of it.
  252.  
  253.    Because the match data normally describe the most recent search only,
  254. you must be careful not to do another search inadvertently between the
  255. search you wish to refer back to and the use of the match data.  If you
  256. can't avoid another intervening search, you must save and restore the
  257. match data around it, to prevent it from being overwritten.
  258.  
  259. * Menu:
  260.  
  261. * Simple Match Data::     Accessing single items of match data,
  262.                 such as where a particular subexpression started.
  263. * Replacing Match::      Replacing a substring that was matched.
  264. * Entire Match Data::     Accessing the entire match data at once, as a list.
  265. * Saving Match Data::     Saving and restoring the match data.
  266.  
  267. 
  268. File: elisp,  Node: Simple Match Data,  Next: Replacing Match,  Up: Match Data
  269.  
  270. Simple Match Data Access
  271. ------------------------
  272.  
  273.    This section explains how to use the match data to find the starting
  274. point or ending point of the text that was matched by a particular
  275. search, or by a particular parenthetical subexpression of a regular
  276. expression.
  277.  
  278.  - Function: match-beginning COUNT
  279.      This function returns the position of the start of text matched by
  280.      the last regular expression searched for.  COUNT, a number,
  281.      specifies a subexpression whose start position is the value.  If
  282.      COUNT is zero, then the value is the position of the text matched
  283.      by the whole regexp.  If COUNT is greater than zero, then the
  284.      value is the position of the beginning of the text matched by the
  285.      COUNTth subexpression, regardless of whether it was used in the
  286.      final match.
  287.  
  288.      Subexpressions of a regular expression are those expressions
  289.      grouped inside of parentheses, `\(...\)'.  The COUNTth
  290.      subexpression is found by counting occurrences of `\(' from the
  291.      beginning of the whole regular expression.  The first
  292.      subexpression is numbered 1, the second 2, and so on.
  293.  
  294.      The value is `nil' for a parenthetical grouping inside of a `\|'
  295.      alternative that wasn't used in the match.
  296.  
  297.      The `match-end' function is similar to the `match-beginning'
  298.      function except that it returns the position of the end of the
  299.      matched text.
  300.  
  301.      Here is an example, with a comment showing the numbers of the
  302.      positions in the text:
  303.  
  304.           (string-match
  305.            "\\(qu\\)\\(ick\\)" "The quick fox jumped quickly.")
  306.                => 4            ;^^^^^^^^^^
  307.                                ;0123456789
  308.  
  309.           (match-beginning 1)               ; The beginning of the match
  310.                => 4                         ;   with `qu' is at index 4.
  311.  
  312.           (match-beginning 2)               ; The beginning of the match
  313.                => 6                         ;   with `ick' is at index 6.
  314.  
  315.           (match-end 1)                     ; The end of the match
  316.                => 6                         ;   with `qu' is at index 6.
  317.           
  318.           (match-end 2)                     ; The end of the match
  319.                => 9                         ;   with `ick' is at index 9.
  320.  
  321.      Here is another example.  Before the form is evaluated, point is
  322.      located at the beginning of the line.  After evaluating the search
  323.      form, point is located on the line between the space and the word
  324.      `in'.  The beginning of the entire match is at the 9th character
  325.      of the buffer (`T'), and the beginning of the match for the first
  326.      subexpression is at the 13th character (`c').
  327.  
  328.           (list
  329.             (re-search-forward "The \\(cat \\)")
  330.             (match-beginning 0)
  331.             (match-beginning 1))
  332.               => (t 9 13)
  333.           
  334.           ---------- Buffer: foo ----------
  335.           I read "The cat -!-in the hat comes back" twice.
  336.                   ^   ^
  337.                   9  13
  338.           ---------- Buffer: foo ----------
  339.  
  340.      (Note that in this case, the index returned is a buffer position;
  341.      the first character of the buffer counts as 1.)
  342.  
  343.  - Function: match-end COUNT
  344.      This function returns the position of the end of text matched by
  345.      the last regular expression searched for.  This function is
  346.      otherwise similar to `match-beginning'.
  347.  
  348. 
  349. File: elisp,  Node: Replacing Match,  Next: Entire Match Data,  Prev: Simple Match Data,  Up: Match Data
  350.  
  351. Replacing the Text That Matched
  352. -------------------------------
  353.  
  354.  - Function: replace-match REPLACEMENT &optional FIXEDCASE LITERAL
  355.      This function replaces the text matched by the last search with
  356.      REPLACEMENT.
  357.  
  358.      If FIXEDCASE is non-`nil', then the case of the replacement text
  359.      is not changed; otherwise, the replacement text is converted to a
  360.      different case depending upon the capitalization of the text to be
  361.      replaced.  If the original text is all upper case, the replacement
  362.      text is converted to upper case, except when all of the words in
  363.      the original text are only one character long.  In that event, the
  364.      replacement text is capitalized.  If *all* of the words in the
  365.      original text are capitalized, then all of the words in the
  366.      replacement text are capitalized.
  367.  
  368.      If LITERAL is non-`nil', then REPLACEMENT is inserted exactly as
  369.      it is, the only alterations being case changes as needed.  If it
  370.      is `nil' (the default), then the character `\' is treated
  371.      specially.  If a `\' appears in REPLACEMENT, then it must be part
  372.      of one of the following sequences:
  373.  
  374.     `\&'
  375.           `\&' stands for the entire text being replaced.
  376.  
  377.     `\N'
  378.           `\N' stands for the Nth subexpression in the original regexp.
  379.           Subexpressions are those expressions grouped inside of
  380.           `\(...\)'.  N is a digit.
  381.  
  382.     `\\'
  383.           `\\' stands for a single `\' in the replacement text.
  384.  
  385.      `replace-match' leaves point at the end of the replacement text,
  386.      and returns `t'.
  387.  
  388. 
  389. File: elisp,  Node: Entire Match Data,  Next: Saving Match Data,  Prev: Replacing Match,  Up: Match Data
  390.  
  391. Accessing the Entire Match Data
  392. -------------------------------
  393.  
  394.    The functions `match-data' and `store-match-data' let you read or
  395. write the entire match data, all at once.
  396.  
  397.  - Function: match-data
  398.      This function returns a new list containing all the information on
  399.      what text the last search matched.  Element zero is the position
  400.      of the beginning of the match for the whole expression; element
  401.      one is the position of the end of the match for the expression.
  402.      The next two elements are the positions of the beginning and end
  403.      of the match for the first subexpression.  In general, element
  404.      number 2N corresponds to `(match-beginning N)'; and element number
  405.      2N + 1 corresponds to `(match-end N)'.
  406.  
  407.      All the elements are markers or `nil' if matching was done on a
  408.      buffer, and all are integers or `nil' if matching was done on a
  409.      string with `string-match'.  (In Emacs 18 and earlier versions,
  410.      markers were used even for matching on a string, except in the case
  411.      of the integer 0.)
  412.  
  413.      As always, there must be no possibility of intervening searches
  414.      between the call to a search function and the call to `match-data'
  415.      that is intended to access the match-data for that search.
  416.  
  417.           (match-data)
  418.                =>  (#<marker at 9 in foo>
  419.                     #<marker at 17 in foo>
  420.                     #<marker at 13 in foo>
  421.                     #<marker at 17 in foo>)
  422.  
  423.  - Function: store-match-data MATCH-LIST
  424.      This function sets the match data from the elements of MATCH-LIST,
  425.      which should be a list that was the value of a previous call to
  426.      `match-data'.
  427.  
  428.      If MATCH-LIST refers to a buffer that doesn't exist, you don't get
  429.      an error; that sets the match data in a meaningless but harmless
  430.      way.
  431.  
  432. 
  433. File: elisp,  Node: Saving Match Data,  Prev: Entire Match Data,  Up: Match Data
  434.  
  435. Saving and Restoring the Match Data
  436. -----------------------------------
  437.  
  438.    All asynchronous process functions (filters and sentinels) and
  439. functions that use `recursive-edit' should save and restore the match
  440. data if they do a search or if they let the user type arbitrary
  441. commands.  Saving the match data is useful in other cases as
  442. well--whenever you want to access the match data resulting from an
  443. earlier search, notwithstanding another intervening search.
  444.  
  445.    This example shows the problem that can arise if you fail to attend
  446. to this requirement:
  447.  
  448.      (re-search-forward "The \\(cat \\)")
  449.           => 48
  450.      (foo)                   ; Perhaps `foo' does
  451.                              ;   more searching.
  452.      (match-end 0)
  453.           => 61              ; Unexpected result---not 48!
  454.  
  455.    In Emacs versions 19 and later, you can save and restore the match
  456. data with `save-match-data':
  457.  
  458.  - Special Form: save-match-data BODY...
  459.      This special form executes BODY, saving and restoring the match
  460.      data around it.  This is useful if you wish to do a search without
  461.      altering the match data that resulted from an earlier search.
  462.  
  463.    You can use `store-match-data' together with `match-data' to imitate
  464. the effect of the special form `save-match-data'.  This is useful for
  465. writing code that can run in Emacs 18.  Here is how:
  466.  
  467.      (let ((data (match-data)))
  468.        (unwind-protect
  469.            ...   ; May change the original match data.
  470.          (store-match-data data)))
  471.  
  472. 
  473. File: elisp,  Node: Standard Regexps,  Next: Searching and Case,  Prev: Match Data,  Up: Searching and Matching
  474.  
  475. Standard Regular Expressions Used in Editing
  476. ============================================
  477.  
  478.    Here are the regular expressions standardly used in editing:
  479.  
  480.  - Variable: page-delimiter
  481.      This is the regexp describing line-beginnings that separate pages.
  482.      The default value is `"^\014"' (i.e., `"^^L"' or `"^\C-l"').
  483.  
  484.  - Variable: paragraph-separate
  485.      This is the regular expression for recognizing the beginning of a
  486.      line that separates paragraphs.  (If you change this, you may have
  487.      to change `paragraph-start' also.)  The default value is `"^[
  488.      \t\f]*$"', which is a line that consists entirely of spaces, tabs,
  489.      and form feeds.
  490.  
  491.  - Variable: paragraph-start
  492.      This is the regular expression for recognizing the beginning of a
  493.      line that starts *or* separates paragraphs.  The default value is
  494.      `"^[ \t\n\f]"', which matches a line starting with a space, tab,
  495.      newline, or form feed.
  496.  
  497.  - Variable: sentence-end
  498.      This is the regular expression describing the end of a sentence.
  499.      (All paragraph boundaries also end sentences, regardless.)  The
  500.      default value is:
  501.  
  502.           "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*"
  503.  
  504.      This means a period, question mark or exclamation mark, followed
  505.      by a closing brace, followed by tabs, spaces or new lines.
  506.  
  507.      For a detailed explanation of this regular expression, see *Note
  508.      Regexp Example::.
  509.  
  510. 
  511. File: elisp,  Node: Searching and Case,  Prev: Standard Regexps,  Up: Searching and Matching
  512.  
  513. Searching and Case
  514. ==================
  515.  
  516.    By default, searches in Emacs ignore the case of the text they are
  517. searching through; if you specify searching for `FOO', then `Foo' or
  518. `foo' is also considered a match.  Regexps, and in particular character
  519. sets, are included: thus, `[aB]' would match `a' or `A' or `b' or `B'.
  520.  
  521.    If you do not want this feature, set the variable `case-fold-search'
  522. to `nil'.  Then all letters must match exactly, including case.  This
  523. is a per-buffer-local variable; altering the variable affects only the
  524. current buffer.  (*Note Intro to Buffer-Local::.)  Alternatively, you
  525. may change the value of `default-case-fold-search', which is the
  526. default value of `case-fold-search' for buffers that do not override it.
  527.  
  528.  - User Option: case-replace
  529.      This variable determines whether `query-replace' should preserve
  530.      case in replacements.  If the variable is `nil', then case need
  531.      not be preserved.
  532.  
  533.  - User Option: case-fold-search
  534.      This buffer-local variable determines whether searches should
  535.      ignore case.  If the variable is `nil' they do not ignore case;
  536.      otherwise they do ignore case.
  537.  
  538.  - Variable: default-case-fold-search
  539.      The value of this variable is the default value for
  540.      `case-fold-search' in buffers that do not override it.  This is the
  541.      same as `(default-value 'case-fold-search)'.
  542.  
  543. 
  544. File: elisp,  Node: Syntax Tables,  Next: Abbrevs,  Prev: Searching and Matching,  Up: Top
  545.  
  546. Syntax Tables
  547. *************
  548.  
  549.    A "syntax table" provides Emacs with the information that determines
  550. the syntactic use of each character in a buffer.  This information is
  551. used by the parsing commands, the complex movement commands, and others
  552. to determine where words, symbols, and other syntactic constructs begin
  553. and end.  The current syntax table controls the meaning of the word
  554. motion functions (*note Word Motion::.) and the list motion functions
  555. (*note List Motion::.) as well as the functions in this chapter.
  556.  
  557.    A syntax table is a vector of 256 elements; it contains one entry for
  558. each of the 256 ASCII characters of an 8-bit byte.  Each element is an
  559. integer that encodes the syntax of the character in question.
  560.  
  561.    Syntax tables are used only for moving across text, not for the GNU
  562. Emacs Lisp reader.  GNU Emacs Lisp uses built-in syntactic rules when
  563. reading Lisp expressions, and these rules cannot be changed.
  564.  
  565.    Each buffer has its own major mode, and each major mode has its own
  566. idea of the syntactic class of various characters.  For example, in Lisp
  567. mode, the character `;' begins a comment, but in C mode, it terminates
  568. a statement.  To support these variations, Emacs makes the choice of
  569. syntax table local to each buffer.  Typically, each major mode has its
  570. own syntax table and installs that table in each buffer which uses that
  571. mode.  Changing this table alters the syntax in all those buffers as
  572. well as in any buffers subsequently put in that mode.  Occasionally
  573. several similar modes share one syntax table.  *Note Example Major
  574. Modes::, for an example of how to set up a syntax table.
  575.  
  576.  - Function: syntax-table-p OBJECT
  577.      This function returns `t' if OBJECT is a vector of length 256
  578.      elements.  This means that the vector may be a syntax table.
  579.      However, according to this test, any vector of length 256 is
  580.      considered to be a syntax table, no matter what its contents.
  581.  
  582. * Menu:
  583.  
  584. * Syntax Descriptors::       How characters are classified.
  585. * Syntax Table Functions::   How to create, examine and alter syntax tables.
  586. * Motion and Syntax::         Moving over characters with certain syntaxes.
  587. * Parsing Expressions::      Parsing balanced expressions
  588.                                 using the syntax table.
  589. * Standard Syntax Tables::   Syntax tables used by various major modes.
  590. * Syntax Table Internals::   How syntax table information is stored.
  591.  
  592. 
  593. File: elisp,  Node: Syntax Descriptors,  Next: Syntax Table Functions,  Up: Syntax Tables
  594.  
  595. Syntax Descriptors
  596. ==================
  597.  
  598.    This section describes the syntax classes and flags that denote the
  599. syntax of a character, and how they are represented as a "syntax
  600. descriptor", which is a Lisp string that you pass to
  601. `modify-syntax-entry' to specify the desired syntax.
  602.  
  603.    Emacs defines twelve "syntax classes".  Each syntax table puts each
  604. character into one class.  There is no necessary relationship between
  605. the class of a character in one syntax table and its class in any other
  606. table.
  607.  
  608.    Each class is designated by a mnemonic character which serves as the
  609. name of the class when you need to specify a class.  Usually the
  610. designator character is one which is frequently put in that class;
  611. however, its meaning as a designator is unvarying and independent of how
  612. it is actually classified.
  613.  
  614.    A syntax descriptor is a Lisp string which specifies a syntax class,
  615. a matching character (unused except for parenthesis classes) and flags.
  616. The first character is the designator for a syntax class.  The second
  617. character is the character to match; if it is unused, put a space there.
  618. Then come the characters for any desired flags.  If no matching
  619. character or flags are needed, one character is sufficient.
  620.  
  621.    Thus, the descriptor for the character `*' in C mode is `. 23'
  622. (i.e., punctuation, matching character slot unused, second character of
  623. a comment-starter, first character of an comment-ender), and the entry
  624. for `/' is `. 14' (i.e., punctuation, matching character slot unused,
  625. first character of a comment-starter, second character of a
  626. comment-ender).
  627.  
  628. * Menu:
  629.  
  630. * Syntax Class Table::      Table of syntax classes.
  631. * Syntax Flags::            Additional flags each character can have.
  632.  
  633. 
  634. File: elisp,  Node: Syntax Class Table,  Next: Syntax Flags,  Up: Syntax Descriptors
  635.  
  636. Table of Syntax Classes
  637. -----------------------
  638.  
  639.    Here is a summary of the classes, the characters that stand for them,
  640. their meanings, and examples of their use.
  641.  
  642.  - Syntax class: whitespace character
  643.      "Whitespace characters" (designated with ` ' or `-') separate
  644.      symbols and words from each other.  Typically, whitespace
  645.      characters have no other syntactic use, and multiple whitespace
  646.      characters are syntactically equivalent to a single one.  Space,
  647.      tab, newline and formfeed are almost always considered whitespace.
  648.  
  649.  - Syntax class: word constituent
  650.      "Word constituents" (designated with `w') are parts of normal
  651.      English words and are typically used in variable and command names
  652.      in programs.  All upper and lower case letters and the digits are
  653.      typically word constituents.
  654.  
  655.  - Syntax class: symbol constituent
  656.      "Symbol constituents" (designated with `_') are the extra
  657.      characters that are used in variable and command names along with
  658.      word constituents.  For example, the symbol constituents class is
  659.      used in Lisp mode to indicate that certain characters may be part
  660.      of symbol names even though they are not part of English words.
  661.      These characters are `$&*+-_<>'.  In standard C, the only
  662.      non-word-constituent character that is valid in symbols is
  663.      underscore (`_').
  664.  
  665.  - Syntax class: punctuation character
  666.      "Punctuation characters" (`.') are those characters that are used
  667.      as punctuation in English, or are used in some way in a programming
  668.      language to separate symbols from one another.  Most programming
  669.      language modes, including Emacs Lisp mode, have no characters in
  670.      this class since the few characters that are not symbol or word
  671.      constituents all have other uses.
  672.  
  673.  - Syntax class: open parenthesis character
  674.  - Syntax class: close parenthesis character
  675.      Open and close "parenthesis characters" are characters used in
  676.      dissimilar pairs to surround sentences or expressions.  Such a
  677.      grouping is begun with an open parenthesis character and
  678.      terminated with a close.  Each open parenthesis character matches
  679.      a particular close parenthesis character, and vice versa.
  680.      Normally, Emacs indicates momentarily the matching open
  681.      parenthesis when you insert a close parenthesis.  *Note Blinking::.
  682.  
  683.      The class of open parentheses is designated with `(', and that of
  684.      close parentheses with `)'.
  685.  
  686.      In English text, and in C code, the parenthesis pairs are `()',
  687.      `[]', and `{}'.  In Emacs Lisp, the delimiters for lists and
  688.      vectors (`()' and `[]') are classified as parenthesis characters.
  689.  
  690.  - Syntax class: string quote
  691.      "String quote characters" (designated with `"') is used to delimit
  692.      string constants in many languages, including Lisp and C.  The
  693.      same string quote character appears at the beginning and the end
  694.      of a string.  Such quoted strings do not nest.
  695.  
  696.      The parsing facilities of Emacs consider a string as a single
  697.      token.  The usual syntactic meanings of the characters in the
  698.      string are suppressed.
  699.  
  700.      The Lisp modes have two string quote characters: double-quote (`"')
  701.      and vertical bar (`|').  `|' is not used in Emacs Lisp, but it is
  702.      used in Common Lisp.  C also has two string quote characters:
  703.      double-quote for strings, and single-quote (`'') for character
  704.      constants.
  705.  
  706.      English text has no string quote characters because English is not
  707.      a programming language.  Although quotation marks are used in
  708.      English, we do not want them to turn off the usual syntactic
  709.      properties of other characters in the quotation.
  710.  
  711.  - Syntax class: escape
  712.      An "escape character" (designated with `\') starts an escape
  713.      sequence such as is used in C string and character constants.  The
  714.      character `\' belongs to this class in both C and Lisp.  (In C, it
  715.      is used thus only inside strings, but it turns out to cause no
  716.      trouble to treat it this way throughout C code.)
  717.  
  718.      Characters in this class count as part of words if
  719.      `words-include-escapes' is non-`nil'.  *Note Word Motion::.
  720.  
  721.  - Syntax class: character quote
  722.      A "character quote character" (designated with `/') quotes the
  723.      following character so that it loses its normal syntactic meaning.
  724.      This differs from an escape character in that only the character
  725.      immediately following is ever affected.
  726.  
  727.      Characters in this class count as part of words if
  728.      `words-include-escapes' is non-`nil'.  *Note Word Motion::.
  729.  
  730.      This class is not currently used in any standard Emacs modes.
  731.  
  732.  - Syntax class: paired delimiter
  733.      "Paired delimiter characters" (designated with `$') are like
  734.      string quote characters except that the syntactic properties of the
  735.      characters between the delimiters are not suppressed.  Only TeX
  736.      mode uses a paired identical delimiter presently--the `$' that
  737.      begins and ends math mode.
  738.  
  739.  - Syntax class: expression prefix
  740.      An "expression prefix operator" (designated with `'') is used for
  741.      syntactic operators that are part of an expression if they appear
  742.      next to one but are not part of an adjoining symbol.  These
  743.      characters in Lisp include the apostrophe, `'' (used for quoting),
  744.      the comma, `,' (used in macros), and `#' (used in the read syntax
  745.      for certain data types).
  746.  
  747.  - Syntax class: comment starter
  748.  - Syntax class: comment ender
  749.      The "comment starter" and "comment ender" characters are used in
  750.      different languages to delimit comments.  These classes are
  751.      designated with `<' and `>', respectively.
  752.  
  753.      English text has no comment characters.  In Lisp, the semicolon
  754.      (`;') starts a comment and a newline or formfeed ends one.
  755.  
  756. 
  757. File: elisp,  Node: Syntax Flags,  Prev: Syntax Class Table,  Up: Syntax Descriptors
  758.  
  759. Syntax Flags
  760. ------------
  761.  
  762.    In addition to the classes, entries for characters in a syntax table
  763. can include flags.  There are six possible flags, represented by the
  764. characters `1', `2', `3', `4', `b' and `p'.
  765.  
  766.    All the flags except `p' are used to describe multi-character
  767. comment delimiters.  The digit flags indicate that a character can
  768. *also* be part of a comment sequence, in addition to the syntactic
  769. properties associated with its character class.  The flags are
  770. independent of the class and each other for the sake of characters such
  771. as `*' in C mode, which is a punctuation character, *and* the second
  772. character of a start-of-comment sequence (`/*'), *and* the first
  773. character of an end-of-comment sequence (`*/').
  774.  
  775.    The flags for a character C are:
  776.  
  777.    * `1' means C is the start of a two-character comment start sequence.
  778.  
  779.    * `2' means C is the second character of such a sequence.
  780.  
  781.    * `3' means C is the start of a two-character comment end sequence.
  782.  
  783.    * `4' means C is the second character of such a sequence.
  784.  
  785.    * `b' means that C as a comment delimiter belongs to the alternative
  786.      "b" comment style.
  787.  
  788.      Emacs can now supports two comment styles simultaneously.  (This
  789.      is for the sake of C++.)  More specifically, it can recognize two
  790.      different comment-start sequences.  Both must share the same first
  791.      character; only the second character may differ.  Mark the second
  792.      character of the "b"-style comment start sequence with the `b'
  793.      flag.
  794.  
  795.      The two styles of comment can have different comment-end
  796.      sequences.  A comment-end sequence (one or two characters) applies
  797.      to the "b" style if its first character has the `b' flag set;
  798.      otherwise, it applies to the "a" style.
  799.  
  800.      The appropriate comment syntax settings for C++ are as follows:
  801.  
  802.     `/'
  803.           `124b'
  804.  
  805.     `*'
  806.           `23'
  807.  
  808.     newline
  809.           `>b'
  810.  
  811.      Thus `/*' is a comment-start sequence for "a" style, `//' is a
  812.      comment-start sequence for "b" style, `*/' is a comment-end
  813.      sequence for "a" style, and newline is a comment-end sequence for
  814.      "b" style.
  815.  
  816.    * `p' identifies an additional "prefix character" for Lisp syntax.
  817.      These characters are treated as whitespace when they appear between
  818.      expressions.  When they appear within an expression, they are
  819.      handled according to their usual syntax codes.
  820.  
  821.      The function `backward-prefix-chars' moves back over these
  822.      characters, as well as over characters whose primary syntax class
  823.      is prefix (`'').
  824.  
  825. 
  826. File: elisp,  Node: Syntax Table Functions,  Next: Motion and Syntax,  Prev: Syntax Descriptors,  Up: Syntax Tables
  827.  
  828. Syntax Table Functions
  829. ======================
  830.  
  831.    In this section we describe functions for creating, accessing and
  832. altering syntax tables.
  833.  
  834.  - Function: make-syntax-table &optional TABLE
  835.      This function constructs a copy of TABLE and returns it.  If TABLE
  836.      is not supplied (or is `nil'), it returns a copy of the current
  837.      syntax table.  Otherwise, an error is signaled if TABLE is not a
  838.      syntax table.
  839.  
  840.  - Function: copy-syntax-table &optional TABLE
  841.      This function is identical to `make-syntax-table'.
  842.  
  843.  - Command: modify-syntax-entry CHAR SYNTAX-DESCRIPTOR &optional TABLE
  844.      This function sets the syntax entry for CHAR according to
  845.      SYNTAX-DESCRIPTOR.  The syntax is changed only for TABLE, which
  846.      defaults to the current buffer's syntax table, and not in any
  847.      other syntax table.  The argument SYNTAX-DESCRIPTOR specifies the
  848.      desired syntax; this is a string beginning with a class designator
  849.      character, and optionally containing a matching character and
  850.      flags as well.  *Note Syntax Descriptors::.
  851.  
  852.      This function always returns `nil'.  The old syntax information in
  853.      the table for this character is discarded.
  854.  
  855.      An error is signaled if the first character of the syntax
  856.      descriptor is not one of the twelve syntax class designator
  857.      characters.  An error is also signaled if CHAR is not a character.
  858.  
  859.      Examples:
  860.  
  861.           ;; Put the space character in class whitespace.
  862.           (modify-syntax-entry ?\  " ")
  863.                => nil
  864.           
  865.           ;; Make `$' an open parenthesis character,
  866.           ;;   with `^' as its matching close.
  867.           (modify-syntax-entry ?$ "(^")
  868.                => nil
  869.           
  870.           ;; Make `^' a close parenthesis character,
  871.           ;;   with `$' as its matching open.
  872.           (modify-syntax-entry ?^ ")$")
  873.                => nil
  874.           
  875.           ;; Make `/' a punctuation character,
  876.           ;;   the first character of a start-comment sequence,
  877.           ;;   and the second character of an end-comment sequence.
  878.           ;;   This is used in C mode.
  879.           (modify-syntax-entry ?/ ".13")
  880.                => nil
  881.  
  882.  - Function: char-syntax CHARACTER
  883.      This function returns the syntax class of CHARACTER, represented
  884.      by its mnemonic designator character.  This *only* returns the
  885.      class, not any matching parenthesis or flags.
  886.  
  887.      An error is signaled if CHAR is not a character.
  888.  
  889.      The first example shows that the syntax class of space is
  890.      whitespace (represented by a space).  The second example shows
  891.      that the syntax of `/' is punctuation in C-mode.  This does not
  892.      show the fact that it is also a comment sequence character.  The
  893.      third example shows that open parenthesis is in the class of open
  894.      parentheses.  This does not show the fact that it has a matching
  895.      character, `)'.
  896.  
  897.           (char-to-string (char-syntax ?\ ))
  898.                => " "
  899.           
  900.           (char-to-string (char-syntax ?/))
  901.                => "."
  902.           
  903.           (char-to-string (char-syntax ?\())
  904.                => "("
  905.  
  906.  - Function: set-syntax-table TABLE
  907.      This function makes TABLE the syntax table for the current buffer.
  908.      It returns TABLE.
  909.  
  910.  - Function: syntax-table
  911.      This function returns the current syntax table, which is the table
  912.      for the current buffer.
  913.  
  914. 
  915. File: elisp,  Node: Motion and Syntax,  Next: Parsing Expressions,  Prev: Syntax Table Functions,  Up: Syntax Tables
  916.  
  917. Motion and Syntax
  918. =================
  919.  
  920.    This section describes functions for moving across characters in
  921. certain syntax classes.  None of these functions exists in Emacs
  922. version 18 or earlier.
  923.  
  924.  - Function: skip-syntax-forward SYNTAXES &optional LIMIT
  925.      This function moves point forward across characters whose syntax
  926.      classes are mentioned in SYNTAXES.  It stops when it encounters
  927.      the end of the buffer, or position LIM (if specified), or a
  928.      character it is not supposed to skip.
  929.  
  930.      The return value is the distance traveled, which is a nonnegative
  931.      integer.
  932.  
  933.  - Function: skip-syntax-backward SYNTAXES &optional LIMIT
  934.      This function moves point backward across characters whose syntax
  935.      classes are mentioned in SYNTAXES.  It stops when it encounters
  936.      the beginning of the buffer, or position LIM (if specified), or a
  937.      character it is not supposed to skip.
  938.  
  939.      The return value indicates the distance traveled.  It is an
  940.      integer that is zero or less.
  941.  
  942.  - Function: backward-prefix-chars
  943.      This function moves point backward over any number of chars with
  944.      expression prefix syntax.  This includes both characters in the
  945.      expression prefix syntax class, and characters with the `p' flag.
  946.  
  947. 
  948. File: elisp,  Node: Parsing Expressions,  Next: Standard Syntax Tables,  Prev: Motion and Syntax,  Up: Syntax Tables
  949.  
  950. Parsing Balanced Expressions
  951. ============================
  952.  
  953.    Here are several functions for parsing and scanning balanced
  954. expressions.  The syntax table controls the interpretation of
  955. characters, so these functions can be used for Lisp expressions when in
  956. Lisp mode and for C expressions when in C mode.  *Note List Motion::,
  957. for convenient higher-level functions for moving over balanced
  958. expressions.
  959.  
  960.  - Function: parse-partial-sexp START LIMIT &optional TARGET-DEPTH
  961.           STOP-BEFORE STATE STOP-COMMENT
  962.      This function parses an expression in the current buffer starting
  963.      at START, not scanning past LIMIT.  Parsing stops at LIMIT or when
  964.      certain criteria described below are met; point is set to the
  965.      location where parsing stops.  The value returned is a description
  966.      of the status of the parse at the point where it stops.
  967.  
  968.      Normally, START is assumed to be the top level of an expression to
  969.      be parsed, such as the beginning of a function definition.
  970.      Alternatively, you might wish to resume parsing in the middle of an
  971.      expression.  To do this, you must provide a STATE argument that
  972.      describes the initial status of parsing.  If STATE is omitted (or
  973.      `nil'), parsing assumes that START is the beginning of a new parse
  974.      at level 0.
  975.  
  976.      If the third argument TARGET-DEPTH is non-`nil', parsing stops if
  977.      the depth in parentheses becomes equal to TARGET-DEPTH.  The depth
  978.      starts at 0, or at whatever is given in STATE.
  979.  
  980.      If the fourth argument STOP-BEFORE is non-`nil', parsing stops
  981.      when it comes to any character that starts a sexp.  If
  982.      STOP-COMMENT is non-`nil', parsing stops when it comes to the
  983.      start of a comment.
  984.  
  985.      The fifth argument STATE is a seven-element list of the same form
  986.      as the value of this function, described below.  The return value
  987.      of one call may be used to initialize the state of the parse on
  988.      another call to `parse-partial-sexp'.
  989.  
  990.      The result is a list of seven elements describing the final state
  991.      of the parse:
  992.  
  993.        0. The depth in parentheses, starting at 0.
  994.  
  995.        1. The character position of the start of the innermost
  996.           containing parenthetical grouping; `nil' if none.
  997.  
  998.        2. The character position of the start of the last complete
  999.           subexpression terminated; `nil' if none.
  1000.  
  1001.        3. Non-`nil' if inside a string.  (It is the character that will
  1002.           terminate the string.)
  1003.  
  1004.        4. `t' if inside a comment.
  1005.  
  1006.        5. `t' if point is just after a quote character.
  1007.  
  1008.        6. The minimum parenthesis depth encountered during this scan.
  1009.  
  1010.      Elements 1, 4, 5, and 6 are significant in the argument STATE.
  1011.  
  1012.      This function is used to determine how to indent lines in programs
  1013.      written in languages that have nested parentheses.
  1014.  
  1015.  - Function: scan-lists FROM COUNT DEPTH
  1016.      This function scans forward COUNT balanced parenthetical groupings
  1017.      from character number FROM.  It returns the character number of
  1018.      the position thus found.
  1019.  
  1020.      If DEPTH is nonzero, parenthesis depth counting begins from that
  1021.      value.  The only candidates for stopping are places where the
  1022.      depth in parentheses becomes zero; `scan-lists' counts COUNT such
  1023.      places and then stops.  Thus, a positive value for DEPTH means go
  1024.      out levels of parenthesis.
  1025.  
  1026.      Comments are ignored if `parse-sexp-ignore-comments' is non-`nil'.
  1027.  
  1028.      If the beginning or end of the buffer (or its accessible portion)
  1029.      is reached and the depth is not zero, an error is signaled.  If
  1030.      the depth is zero but the count is not used up, `nil' is returned.
  1031.  
  1032.  - Function: scan-sexps FROM COUNT
  1033.      Scan from character number FROM by COUNT balanced expressions.  It
  1034.      returns the character number of the position thus found.
  1035.  
  1036.      Comments are ignored if `parse-sexp-ignore-comments' is non-`nil'.
  1037.  
  1038.      If the beginning or end of (the accessible part of) the buffer is
  1039.      reached in the middle of a parenthetical grouping, an error is
  1040.      signaled.  If the beginning or end is reached between groupings but
  1041.      before count is used up, `nil' is returned.
  1042.  
  1043.  - Variable: parse-sexp-ignore-comments
  1044.      If the value is non-`nil', then comments are treated as whitespace
  1045.      by the functions in this section and by `forward-sexp'.
  1046.  
  1047.      In older Emacs versions, this feature worked only when the comment
  1048.      terminator is something like `*/', and appears only to end a
  1049.      comment.  In languages where newlines terminate comments, it was
  1050.      necessary make this variable `nil', since not every newline is the
  1051.      end of a comment.  This limitation no longer exists.
  1052.  
  1053.    You can use `forward-comment' to move forward or backward over one
  1054. comment or several comments.
  1055.  
  1056.  - Function: forward-comment COUNT
  1057.      This function moves point forward across COUNT comments (backward,
  1058.      if COUNT is negative).  If it finds anything other than a comment
  1059.      or whitespace, it stops, leaving point at the place where it
  1060.      stopped.  It also stops after satisfying COUNT.
  1061.  
  1062.    To move forward over all comments and whitespace following point, use
  1063. `(forward-comment (buffer-size))'.  `(buffer-size)' is a good argument
  1064. to use, because the number of comments to skip cannot exceed that many.
  1065.  
  1066. 
  1067. File: elisp,  Node: Standard Syntax Tables,  Next: Syntax Table Internals,  Prev: Parsing Expressions,  Up: Syntax Tables
  1068.  
  1069. Some Standard Syntax Tables
  1070. ===========================
  1071.  
  1072.    Each of the major modes in Emacs has its own syntax table.  Here are
  1073. several of them:
  1074.  
  1075.  - Function: standard-syntax-table
  1076.      This function returns the standard syntax table, which is the
  1077.      syntax table used in Fundamental mode.
  1078.  
  1079.  - Variable: text-mode-syntax-table
  1080.      The value of this variable is the syntax table used in Text mode.
  1081.  
  1082.  - Variable: c-mode-syntax-table
  1083.      The value of this variable is the syntax table in use in C-mode
  1084.      buffers.
  1085.  
  1086.  - Variable: emacs-lisp-mode-syntax-table
  1087.      The value of this variable is the syntax table used in Emacs Lisp
  1088.      mode by editing commands.  (It has no effect on the Lisp `read'
  1089.      function.)
  1090.  
  1091. 
  1092. File: elisp,  Node: Syntax Table Internals,  Prev: Standard Syntax Tables,  Up: Syntax Tables
  1093.  
  1094. Syntax Table Internals
  1095. ======================
  1096.  
  1097.    Each element of a syntax table is an integer that translates into the
  1098. full meaning of the entry: class, possible matching character, and
  1099. flags.  However, it is not common for a programmer to work with the
  1100. entries directly in this form since the Lisp-level syntax table
  1101. functions usually work with syntax descriptors (*note Syntax
  1102. Descriptors::.).
  1103.  
  1104.    The low 8 bits of each element of a syntax table indicates the
  1105. syntax class.
  1106.  
  1107. Integer
  1108.      Class
  1109.  
  1110. 0
  1111.      whitespace
  1112.  
  1113. 1
  1114.      punctuation
  1115.  
  1116. 2
  1117.      word
  1118.  
  1119. 3
  1120.      symbol
  1121.  
  1122. 4
  1123.      open parenthesis
  1124.  
  1125. 5
  1126.      close parenthesis
  1127.  
  1128. 6
  1129.      expression prefix
  1130.  
  1131. 7
  1132.      string quote
  1133.  
  1134. 8
  1135.      paired delimiter
  1136.  
  1137. 9
  1138.      escape
  1139.  
  1140. 10
  1141.      character quote
  1142.  
  1143. 11
  1144.      comment-start
  1145.  
  1146. 12
  1147.      comment-end
  1148.  
  1149.    The next 8 bits are the matching opposite parenthesis (if the
  1150. character has parenthesis syntax); otherwise, they are not meaningful.
  1151. The next 6 bits are the flags.
  1152.  
  1153. 
  1154. File: elisp,  Node: Abbrevs,  Next: Processes,  Prev: Syntax Tables,  Up: Top
  1155.  
  1156. Abbrevs And Abbrev Expansion
  1157. ****************************
  1158.  
  1159.    An abbreviation or "abbrev" is a string of characters that may be
  1160. expanded to a longer string.  The user can insert the abbrev string and
  1161. find it replaced automatically with the expansion of the abbrev.  This
  1162. saves typing.
  1163.  
  1164.    The set of abbrevs currently in effect is recorded in an "abbrev
  1165. table".  Each buffer has a local abbrev table, but normally all buffers
  1166. in the same major mode share one abbrev table.  There is also a global
  1167. abbrev table.  Normally both are used.
  1168.  
  1169.    An abbrev table is represented as an obarray containing a symbol for
  1170. each abbreviation.  The symbol's name is the abbreviation.  Its value is
  1171. the expansion; its function definition is the hook; its property list
  1172. cell contains the use count, the number of times the abbreviation has
  1173. been expanded.  Because these symbols are not interned in the usual
  1174. obarray, they will never appear as the result of reading a Lisp
  1175. expression; in fact, they will never be used except by the code that
  1176. handles abbrevs.  Therefore, it is safe to use them in an extremely
  1177. nonstandard way.  *Note Creating Symbols::.
  1178.  
  1179.    For the user-level commands for abbrevs, see *Note Abbrev Mode:
  1180. (emacs)Abbrevs.
  1181.  
  1182. * Menu:
  1183.  
  1184. * Abbrev Mode::                 Setting up Emacs for abbreviation.
  1185. * Tables: Abbrev Tables.        Creating and working with abbrev tables.
  1186. * Defining Abbrevs::            Specifying abbreviations and their expansions.
  1187. * Files: Abbrev Files.          Saving abbrevs in files.
  1188. * Expansion: Abbrev Expansion.  Controlling expansion; expansion subroutines.
  1189. * Standard Abbrev Tables::      Abbrev tables used by various major modes.
  1190.  
  1191. 
  1192. File: elisp,  Node: Abbrev Mode,  Next: Abbrev Tables,  Prev: Abbrevs,  Up: Abbrevs
  1193.  
  1194. Setting Up Abbrev Mode
  1195. ======================
  1196.  
  1197.    Abbrev mode is a minor mode controlled by the value of the variable
  1198. `abbrev-mode'.
  1199.  
  1200.  - Variable: abbrev-mode
  1201.      A non-`nil' value of this variable turns on the automatic expansion
  1202.      of abbrevs when their abbreviations are inserted into a buffer.
  1203.      If the value is `nil', abbrevs may be defined, but they are not
  1204.      expanded automatically.
  1205.  
  1206.      This variable automatically becomes local when set in any fashion.
  1207.  
  1208.  - Variable: default-abbrev-mode
  1209.      This is the value `abbrev-mode' for buffers that do not override
  1210.      it.  This is the same as `(default-value 'abbrev-mode)'.
  1211.  
  1212.