aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorGlenn Morris2012-02-04 12:59:54 -0800
committerGlenn Morris2012-02-04 12:59:54 -0800
commitc7291ad983d8494ff826b5c2eb4f5611b014de89 (patch)
treef9723dd27feb3c73c8de6d746e1919dcd2409db9 /doc
parent3723ec07bf3a91a786ba4d5deba68f3d0eda2494 (diff)
downloademacs-c7291ad983d8494ff826b5c2eb4f5611b014de89.tar.gz
emacs-c7291ad983d8494ff826b5c2eb4f5611b014de89.zip
with-wrapper-hook doc clarifications
* doc/lispref/modes.texi (Running Hooks): Try to clarify with-wrapper-hook. * lisp/subr.el (with-wrapper-hook): Doc fixes.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog2
-rw-r--r--doc/lispref/modes.texi29
2 files changed, 22 insertions, 9 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index ddc459cc50e..54dbdb9c9b2 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,7 @@
12012-02-04 Glenn Morris <rgm@gnu.org> 12012-02-04 Glenn Morris <rgm@gnu.org>
2 2
3 * modes.texi (Running Hooks): Try to clarify with-wrapper-hook.
4
3 * text.texi (Buffer Contents): 5 * text.texi (Buffer Contents):
4 Update filter-buffer-substring description. 6 Update filter-buffer-substring description.
5 7
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 0eda905f82f..638ab89e37f 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -135,21 +135,32 @@ This macro runs the abnormal hook @code{hook} as a series of nested
135``wrapper functions'' around the @var{body} forms. The effect is 135``wrapper functions'' around the @var{body} forms. The effect is
136similar to nested @code{around} advices (@pxref{Around-Advice}). 136similar to nested @code{around} advices (@pxref{Around-Advice}).
137 137
138Each hook function must accept an argument list consisting of a function 138Each hook function should accept an argument list consisting of a function
139@var{fun}, followed by the additional arguments listed in @var{args}. 139@var{fun}, followed by the additional arguments listed in @var{args}.
140The function @var{fun} passed to the very first hook function in 140The first hook function is passed a function @var{fun} that, if it is
141@var{hook} does the same as @var{body}, if it is called with arguments 141called with arguments @var{args}, performs @var{body} (i.e., the default
142@var{args}. The @var{fun} passed to each successive hook function is 142operation). The @var{fun} passed to each successive hook function is
143constructed from all the preceding hook functions (and @var{body}); if 143constructed from all the preceding hook functions (and @var{body}); if
144this @var{fun} is called with arguments @var{args}, it does what the 144this @var{fun} is called with arguments @var{args}, it does what the
145@code{with-wrapper-hook} call would if the preceding hook functions were 145@code{with-wrapper-hook} call would if the preceding hook functions were
146the only ones in @var{hook}. 146the only ones in @var{hook}.
147 147
148In the function definition of the hook function, @var{fun} can be called 148Each hook function may call its @var{fun} argument as many times as it
149any number of times (including not calling it at all). This function 149wishes, including never. In that case, such a hook function acts to
150definition is then used to construct the @var{fun} passed to the next 150replace the default definition altogether, and any preceding hook
151hook function in @var{hook}, if any. The last or ``outermost'' 151functions. Of course, a subsequent hook function may do the same thing.
152@var{fun} is called once to produce the effect. 152
153Each hook function definition is used to construct the @var{fun} passed
154to the next hook function in @var{hook}, if any. The last or
155``outermost'' @var{fun} is called once to produce the overall effect.
156
157When might you want to use a wrapper hook? The function
158@code{filter-buffer-substring} illustrates a common case. There is a
159basic functionality, performed by @var{body}---in this case, to extract
160a buffer-substring. Then any number of hook functions can act in
161sequence to modify that string, before returning the final result.
162A wrapper-hook also allows for a hook function to completely replace the
163default definition (by not calling @var{fun}).
153@end defmac 164@end defmac
154 165
155@node Setting Hooks 166@node Setting Hooks