diff options
| author | Chong Yidong | 2011-10-26 08:47:58 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-10-26 08:47:58 +0800 |
| commit | 60754666a5512445c13a7e11b66bb0394a96d5ea (patch) | |
| tree | ddbc3c83e01997a13933b4f2414b86d318eed131 | |
| parent | b1f6fa2666442e27ae8ac3439fd1891c94fe36bc (diff) | |
| download | emacs-60754666a5512445c13a7e11b66bb0394a96d5ea.tar.gz emacs-60754666a5512445c13a7e11b66bb0394a96d5ea.zip | |
* doc/emacs/modes.texi (Running Hooks): Document with-wrapper-hook.
| -rw-r--r-- | doc/lispref/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 54 |
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 @@ | |||
| 1 | 2011-10-26 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * modes.texi (Running Hooks): Document with-wrapper-hook. | ||
| 4 | |||
| 1 | 2011-10-18 Chong Yidong <cyd@gnu.org> | 5 | 2011-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 |
| 88 | and the other functions below to run particular hooks. | 88 | used to run a normal hook. We also document the functions for running |
| 89 | various kinds of abnormal hooks. | ||
| 89 | 90 | ||
| 90 | @defun run-hooks &rest hookvars | 91 | @defun run-hooks &rest hookvars |
| 91 | This function takes one or more normal hook variable names as | 92 | This 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 |
| 111 | This function is the way to run an abnormal hook and always call all | 112 | This function runs an abnormal hook by calling all the hook functions in |
| 112 | of the hook functions. It calls each of the hook functions one by | 113 | @var{hook}, passing each one the arguments @var{args}. |
| 113 | one, 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 |
| 117 | This function is the way to run an abnormal hook until one of the hook | 117 | This function runs an abnormal hook by calling each hook function in |
| 118 | functions fails. It calls each of the hook functions, passing each of | 118 | turn, stopping if one of them ``fails'' by returning @code{nil}. Each |
| 119 | them the arguments @var{args}, until some hook function returns | 119 | hook function is passed the arguments @var{args}. If this function |
| 120 | @code{nil}. It then stops and returns @code{nil}. If none of the | 120 | stops because one of the hook functions fails, it returns @code{nil}; |
| 121 | hook functions return @code{nil}, it returns a non-@code{nil} value. | 121 | otherwise 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 |
| 125 | This function is the way to run an abnormal hook until a hook function | 125 | This function runs an abnormal hook by calling each hook function, |
| 126 | succeeds. It calls each of the hook functions, passing each of them | 126 | stopping if one of them ``succeeds'' by returning a non-@code{nil} |
| 127 | the arguments @var{args}, until some hook function returns | 127 | value. Each hook function is passed the arguments @var{args}. If this |
| 128 | non-@code{nil}. Then it stops, and returns whatever was returned by | 128 | function stops because one of the hook functions returns a |
| 129 | the last hook function that was called. If all hook functions return | 129 | non-@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 | ||
| 134 | This macro runs the abnormal hook @code{hook} as a series of nested | ||
| 135 | ``wrapper functions'' around the @var{body} forms. The effect is | ||
| 136 | similar to nested @code{around} advices (@pxref{Around-Advice}). | ||
| 137 | |||
| 138 | Each hook function must accept an argument list consisting of a function | ||
| 139 | @var{fun}, followed by the additional arguments listed in @var{args}. | ||
| 140 | The 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 | ||
| 143 | constructed from all the preceding hook functions (and @var{body}); if | ||
| 144 | this @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 | ||
| 146 | the only ones in @var{hook}. | ||
| 147 | |||
| 148 | In the function definition of the hook function, @var{fun} can be called | ||
| 149 | any number of times (including not calling it at all). This function | ||
| 150 | definition is then used to construct the @var{fun} passed to the next | ||
| 151 | hook 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 | ||