diff options
| author | Glenn Morris | 2012-02-04 12:59:54 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-02-04 12:59:54 -0800 |
| commit | c7291ad983d8494ff826b5c2eb4f5611b014de89 (patch) | |
| tree | f9723dd27feb3c73c8de6d746e1919dcd2409db9 | |
| parent | 3723ec07bf3a91a786ba4d5deba68f3d0eda2494 (diff) | |
| download | emacs-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/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 29 | ||||
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 23 |
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 @@ | |||
| 1 | 2012-02-04 Glenn Morris <rgm@gnu.org> | 1 | 2012-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 |
| 136 | similar to nested @code{around} advices (@pxref{Around-Advice}). | 136 | similar to nested @code{around} advices (@pxref{Around-Advice}). |
| 137 | 137 | ||
| 138 | Each hook function must accept an argument list consisting of a function | 138 | Each 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}. |
| 140 | The function @var{fun} passed to the very first hook function in | 140 | The 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 | 141 | called with arguments @var{args}, performs @var{body} (i.e., the default |
| 142 | @var{args}. The @var{fun} passed to each successive hook function is | 142 | operation). The @var{fun} passed to each successive hook function is |
| 143 | constructed from all the preceding hook functions (and @var{body}); if | 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 | 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 | 145 | @code{with-wrapper-hook} call would if the preceding hook functions were |
| 146 | the only ones in @var{hook}. | 146 | the only ones in @var{hook}. |
| 147 | 147 | ||
| 148 | In the function definition of the hook function, @var{fun} can be called | 148 | Each hook function may call its @var{fun} argument as many times as it |
| 149 | any number of times (including not calling it at all). This function | 149 | wishes, including never. In that case, such a hook function acts to |
| 150 | definition is then used to construct the @var{fun} passed to the next | 150 | replace the default definition altogether, and any preceding hook |
| 151 | hook function in @var{hook}, if any. The last or ``outermost'' | 151 | functions. Of course, a subsequent hook function may do the same thing. |
| 152 | @var{fun} is called once to produce the effect. | 152 | |
| 153 | Each hook function definition is used to construct the @var{fun} passed | ||
| 154 | to 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 | |||
| 157 | When might you want to use a wrapper hook? The function | ||
| 158 | @code{filter-buffer-substring} illustrates a common case. There is a | ||
| 159 | basic functionality, performed by @var{body}---in this case, to extract | ||
| 160 | a buffer-substring. Then any number of hook functions can act in | ||
| 161 | sequence to modify that string, before returning the final result. | ||
| 162 | A wrapper-hook also allows for a hook function to completely replace the | ||
| 163 | default 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 @@ | |||
| 1 | 2012-02-04 Glenn Morris <rgm@gnu.org> | 1 | 2012-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. | |||
| 1373 | Each hook function should accept an argument list consisting of a | 1373 | Each hook function should accept an argument list consisting of a |
| 1374 | function FUN, followed by the additional arguments in ARGS. | 1374 | function FUN, followed by the additional arguments in ARGS. |
| 1375 | 1375 | ||
| 1376 | The FUN passed to the first hook function in HOOK performs BODY, | 1376 | The first hook function in HOOK is passed a FUN that, if it is called |
| 1377 | if it is called with arguments ARGS. The FUN passed to each | 1377 | with arguments ARGS, performs BODY (i.e., the default operation). |
| 1378 | successive hook function is defined based on the preceding hook | 1378 | The FUN passed to each successive hook function is defined based |
| 1379 | functions; if called with arguments ARGS, it does what the | 1379 | on the preceding hook functions; if called with arguments ARGS, |
| 1380 | `with-wrapper-hook' call would do if the preceding hook functions | 1380 | it does what the `with-wrapper-hook' call would do if the |
| 1381 | were the only ones present in HOOK. | 1381 | preceding hook functions were the only ones present in HOOK. |
| 1382 | 1382 | ||
| 1383 | In the function definition of each hook function, FUN can be | 1383 | Each hook function may call its FUN argument as many times as it wishes, |
| 1384 | called any number of times (including not calling it at all). | 1384 | including never. In that case, such a hook function acts to replace |
| 1385 | That function definition is then used to construct the FUN passed | 1385 | the default definition altogether, and any preceding hook functions. |
| 1386 | Of course, a subsequent hook function may do the same thing. | ||
| 1387 | |||
| 1388 | Each hook function definition is used to construct the FUN passed | ||
| 1386 | to the next hook function, if any. The last (or \"outermost\") | 1389 | to the next hook function, if any. The last (or \"outermost\") |
| 1387 | FUN is then called once." | 1390 | FUN is then called once." |
| 1388 | (declare (indent 2) (debug (form sexp body))) | 1391 | (declare (indent 2) (debug (form sexp body))) |