aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-02-04 12:59:54 -0800
committerGlenn Morris2012-02-04 12:59:54 -0800
commitc7291ad983d8494ff826b5c2eb4f5611b014de89 (patch)
treef9723dd27feb3c73c8de6d746e1919dcd2409db9
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.
-rw-r--r--doc/lispref/ChangeLog2
-rw-r--r--doc/lispref/modes.texi29
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/subr.el23
4 files changed, 37 insertions, 19 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
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 89ce0f67408..2d618c6454c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12012-02-04 Glenn Morris <rgm@gnu.org> 12012-02-04 Glenn Morris <rgm@gnu.org>
2 2
3 * subr.el (with-wrapper-hook): Doc fixes.
4
3 * simple.el (filter-buffer-substring-functions) 5 * simple.el (filter-buffer-substring-functions)
4 (buffer-substring-filters, filter-buffer-substring): Doc fixes. 6 (buffer-substring-filters, filter-buffer-substring): Doc fixes.
5 7
diff --git a/lisp/subr.el b/lisp/subr.el
index 36bca654208..e735fd9577d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1373,16 +1373,19 @@ around the preceding ones, like a set of nested `around' advices.
1373Each hook function should accept an argument list consisting of a 1373Each hook function should accept an argument list consisting of a
1374function FUN, followed by the additional arguments in ARGS. 1374function FUN, followed by the additional arguments in ARGS.
1375 1375
1376The FUN passed to the first hook function in HOOK performs BODY, 1376The first hook function in HOOK is passed a FUN that, if it is called
1377if it is called with arguments ARGS. The FUN passed to each 1377with arguments ARGS, performs BODY (i.e., the default operation).
1378successive hook function is defined based on the preceding hook 1378The FUN passed to each successive hook function is defined based
1379functions; if called with arguments ARGS, it does what the 1379on the preceding hook functions; if called with arguments ARGS,
1380`with-wrapper-hook' call would do if the preceding hook functions 1380it does what the `with-wrapper-hook' call would do if the
1381were the only ones present in HOOK. 1381preceding hook functions were the only ones present in HOOK.
1382 1382
1383In the function definition of each hook function, FUN can be 1383Each hook function may call its FUN argument as many times as it wishes,
1384called any number of times (including not calling it at all). 1384including never. In that case, such a hook function acts to replace
1385That function definition is then used to construct the FUN passed 1385the default definition altogether, and any preceding hook functions.
1386Of course, a subsequent hook function may do the same thing.
1387
1388Each hook function definition is used to construct the FUN passed
1386to the next hook function, if any. The last (or \"outermost\") 1389to the next hook function, if any. The last (or \"outermost\")
1387FUN is then called once." 1390FUN is then called once."
1388 (declare (indent 2) (debug (form sexp body))) 1391 (declare (indent 2) (debug (form sexp body)))