guile-snarf configuration
[bpt/emacs.git] / doc / lispref / abbrevs.texi
index ada58c1..73a3f5f 100644 (file)
@@ -1,8 +1,9 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1994, 1999, 2001-2012 Free Software Foundation, Inc.
+@c Copyright (C) 1990-1994, 1999, 2001-2014 Free Software Foundation,
+@c Inc.
 @c See the file elisp.texi for copying conditions.
-@node Abbrevs, Processes, Syntax Tables, Top
+@node Abbrevs
 @chapter Abbrevs and Abbrev Expansion
 @cindex abbrev
 @c  @cindex abbrev table  Redundant with "abbrev".
@@ -56,7 +57,7 @@ expanded in the buffer.  For the user-level commands for abbrevs, see
                                 Which properties have which effect.
 @end menu
 
-@node Abbrev Tables, Defining Abbrevs, Abbrevs, Abbrevs
+@node Abbrev Tables
 @section Abbrev Tables
 
   This section describes how to create and manipulate abbrev tables.
@@ -123,8 +124,7 @@ the system abbrevs.  (The mode or package using @var{name} is supposed
 to add these to @var{name} separately.)
 @end defun
 
-@node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs
-@comment  node-name,  next,  previous,  up
+@node Defining Abbrevs
 @section Defining Abbrevs
 
   @code{define-abbrev} is the low-level basic function for defining an
@@ -133,7 +133,7 @@ abbrev in an abbrev table.
   When a major mode defines a system abbrev, it should call
 @code{define-abbrev} and specify @code{t} for the @code{:system}
 property.  Be aware that any saved non-``system'' abbrevs are restored
-at startup, i.e. before some major modes are loaded.  Therefore, major
+at startup, i.e., before some major modes are loaded.  Therefore, major
 modes should not assume that their abbrev tables are empty when they
 are first loaded.
 
@@ -179,7 +179,7 @@ behavior of the functions in this section; it is examined by their
 callers.
 @end defopt
 
-@node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs
+@node Abbrev Files
 @section Saving Abbrevs in Files
 
   A file of saved abbrev definitions is actually a file of Lisp code.
@@ -230,8 +230,7 @@ define the same abbrevs.  If @var{filename} is @code{nil} or omitted,
 @code{abbrev-file-name} is used.  This function returns @code{nil}.
 @end deffn
 
-@node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs
-@comment  node-name,  next,  previous,  up
+@node Abbrev Expansion
 @section Looking Up and Expanding Abbreviations
 
   Abbrevs are usually expanded by certain interactive commands,
@@ -258,13 +257,16 @@ as in @code{abbrev-symbol}.
 
 @deffn Command expand-abbrev
 This command expands the abbrev before point, if any.  If point does not
-follow an abbrev, this command does nothing.  The command returns the
-abbrev symbol if it did expansion, @code{nil} otherwise.
-
-If the abbrev symbol has a hook function that is a symbol whose
-@code{no-self-insert} property is non-@code{nil}, and if the hook
-function returns @code{nil} as its value, then @code{expand-abbrev}
-returns @code{nil} even though expansion did occur.
+follow an abbrev, this command does nothing.  To do the expansion, it
+calls the function that is the value of the @code{abbrev-expand-function}
+variable, with no arguments, and returns whatever that function does.
+
+The default expansion function returns the abbrev symbol if it did
+expansion, and @code{nil} otherwise.  If the abbrev symbol has a hook
+function that is a symbol whose @code{no-self-insert} property is
+non-@code{nil}, and if the hook function returns @code{nil} as its
+value, then the default expansion function returns @code{nil},
+even though expansion did occur.
 @end deffn
 
 @defun abbrev-insert abbrev &optional name start end
@@ -332,24 +334,21 @@ has already been unexpanded.  This contains information left by
 @code{expand-abbrev} for the sake of the @code{unexpand-abbrev} command.
 @end defvar
 
-@defvar abbrev-expand-functions
-This is a wrapper hook (@pxref{Running Hooks}) run around the
-@code{expand-abbrev} function.  Each function on this hook is called
-with a single argument: a function that performs the normal abbrev
-expansion.  The hook function can hence do anything it wants before
-and after performing the expansion.  It can also choose not to call
-its argument, thus overriding the default behavior; or it may even
-call it several times.  The function should return the abbrev symbol
-if expansion took place.
+@defvar abbrev-expand-function
+The value of this variable is a function that @code{expand-abbrev}
+will call with no arguments to do the expansion.  The function can do
+anything it wants before and after performing the expansion.
+It should return the abbrev symbol if expansion took place.
 @end defvar
 
   The following sample code shows a simple use of
-@code{abbrev-expand-functions}.  It assumes that @code{foo-mode} is a
+@code{abbrev-expand-function}.  It assumes that @code{foo-mode} is a
 mode for editing certain files in which lines that start with @samp{#}
 are comments.  You want to use Text mode abbrevs for those lines.  The
 regular local abbrev table, @code{foo-mode-abbrev-table} is
 appropriate for all other lines.  @xref{Standard Abbrev Tables}, for the
 definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}.
+@xref{Advising Functions}, for details of @code{add-function}.
 
 @smallexample
 (defun foo-mode-abbrev-expand-function (expand)
@@ -362,13 +361,11 @@ definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}.
 
 (add-hook 'foo-mode-hook
           #'(lambda ()
-              (add-hook 'abbrev-expand-functions
-                        'foo-mode-abbrev-expand-function
-                        nil t)))
+              (add-function :around (local 'abbrev-expand-function)
+                            #'foo-mode-abbrev-expand-function)))
 @end smallexample
 
-@node Standard Abbrev Tables, Abbrev Properties, Abbrev Expansion, Abbrevs
-@comment  node-name,  next,  previous,  up
+@node Standard Abbrev Tables
 @section Standard Abbrev Tables
 
   Here we list the variables that hold the abbrev tables for the
@@ -410,7 +407,7 @@ of the local abbrev table used in Emacs Lisp mode.  @xref{Abbrev Table
 Properties}.
 @end defvar
 
-@node Abbrev Properties, Abbrev Table Properties, Standard Abbrev Tables, Abbrevs
+@node Abbrev Properties
 @section Abbrev Properties
 
 Abbrevs have properties, some of which influence the way they work.
@@ -450,7 +447,7 @@ same pattern of capitalization.  It also disables the code that
 modifies the capitalization of the expansion.
 @end table
 
-@node Abbrev Table Properties,  , Abbrev Properties, Abbrevs
+@node Abbrev Table Properties
 @section Abbrev Table Properties
 
 Like abbrevs, abbrev tables have properties, some of which influence