aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-10-26 08:47:58 +0800
committerChong Yidong2011-10-26 08:47:58 +0800
commit60754666a5512445c13a7e11b66bb0394a96d5ea (patch)
treeddbc3c83e01997a13933b4f2414b86d318eed131
parentb1f6fa2666442e27ae8ac3439fd1891c94fe36bc (diff)
downloademacs-60754666a5512445c13a7e11b66bb0394a96d5ea.tar.gz
emacs-60754666a5512445c13a7e11b66bb0394a96d5ea.zip
* doc/emacs/modes.texi (Running Hooks): Document with-wrapper-hook.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/modes.texi54
2 files changed, 42 insertions, 16 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 490280dae29..acc334ea000 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12011-10-26 Chong Yidong <cyd@gnu.org>
2
3 * modes.texi (Running Hooks): Document with-wrapper-hook.
4
12011-10-18 Chong Yidong <cyd@gnu.org> 52011-10-18 Chong Yidong <cyd@gnu.org>
2 6
3 * display.texi (Glyphless Chars): New node. 7 * display.texi (Glyphless Chars): New node.
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index eb81ebc4acb..9d652901e53 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -84,8 +84,9 @@ its value is just a single function, not a list of functions.
84@node Running Hooks 84@node Running Hooks
85@subsection Running Hooks 85@subsection Running Hooks
86 86
87 At the appropriate times, Emacs uses the @code{run-hooks} function 87 In this section, we document the @code{run-hooks} function, which is
88and the other functions below to run particular hooks. 88used to run a normal hook. We also document the functions for running
89various kinds of abnormal hooks.
89 90
90@defun run-hooks &rest hookvars 91@defun run-hooks &rest hookvars
91This function takes one or more normal hook variable names as 92This function takes one or more normal hook variable names as
@@ -108,28 +109,49 @@ be run as well.
108@end defun 109@end defun
109 110
110@defun run-hook-with-args hook &rest args 111@defun run-hook-with-args hook &rest args
111This function is the way to run an abnormal hook and always call all 112This function runs an abnormal hook by calling all the hook functions in
112of the hook functions. It calls each of the hook functions one by 113@var{hook}, passing each one the arguments @var{args}.
113one, passing each of them the arguments @var{args}.
114@end defun 114@end defun
115 115
116@defun run-hook-with-args-until-failure hook &rest args 116@defun run-hook-with-args-until-failure hook &rest args
117This function is the way to run an abnormal hook until one of the hook 117This function runs an abnormal hook by calling each hook function in
118functions fails. It calls each of the hook functions, passing each of 118turn, stopping if one of them ``fails'' by returning @code{nil}. Each
119them the arguments @var{args}, until some hook function returns 119hook function is passed the arguments @var{args}. If this function
120@code{nil}. It then stops and returns @code{nil}. If none of the 120stops because one of the hook functions fails, it returns @code{nil};
121hook functions return @code{nil}, it returns a non-@code{nil} value. 121otherwise it returns a non-@code{nil} value.
122@end defun 122@end defun
123 123
124@defun run-hook-with-args-until-success hook &rest args 124@defun run-hook-with-args-until-success hook &rest args
125This function is the way to run an abnormal hook until a hook function 125This function runs an abnormal hook by calling each hook function,
126succeeds. It calls each of the hook functions, passing each of them 126stopping if one of them ``succeeds'' by returning a non-@code{nil}
127the arguments @var{args}, until some hook function returns 127value. Each hook function is passed the arguments @var{args}. If this
128non-@code{nil}. Then it stops, and returns whatever was returned by 128function stops because one of the hook functions returns a
129the last hook function that was called. If all hook functions return 129non-@code{nil} value, it returns that value; otherwise it returns
130@code{nil}, it returns @code{nil} as well. 130@code{nil}.
131@end defun 131@end defun
132 132
133@defmac with-wrapper-hook hook args &rest body
134This macro runs the abnormal hook @code{hook} as a series of nested
135``wrapper functions'' around the @var{body} forms. The effect is
136similar to nested @code{around} advices (@pxref{Around-Advice}).
137
138Each hook function must accept an argument list consisting of a function
139@var{fun}, followed by the additional arguments listed in @var{args}.
140The function @var{fun} passed to the very first hook function in
141@var{hook} does the same as @var{body}, if it is called with arguments
142@var{args}. The @var{fun} passed to each successive hook function is
143constructed from all the preceding hook functions (and @var{body}); if
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
146the only ones in @var{hook}.
147
148In the function definition of the hook function, @var{fun} can be called
149any number of times (including not calling it at all). This function
150definition is then used to construct the @var{fun} passed to the next
151hook function in @var{hook}, if any. The last or ``outermost''
152@var{fun} is called once to produce the effect.
153@end defmac
154
133@node Setting Hooks 155@node Setting Hooks
134@subsection Setting Hooks 156@subsection Setting Hooks
135 157