diff options
| author | Eli Zaretskii | 2025-05-24 12:56:30 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2025-05-24 12:56:30 +0300 |
| commit | 36afdd2f6f9f6bbb6bcc95ff2fb1e426c0bcdb3d (patch) | |
| tree | 0f639c4201a5d5a2dff6e8302968151bb1c02ae2 | |
| parent | d0c90bc9bfe8fedbff7f282086dc38458b1e0f9e (diff) | |
| download | emacs-36afdd2f6f9f6bbb6bcc95ff2fb1e426c0bcdb3d.tar.gz emacs-36afdd2f6f9f6bbb6bcc95ff2fb1e426c0bcdb3d.zip | |
Fix documentation of use-package's ':hook' keyword
* doc/misc/use-package.texi (Hooks): Document how to add several
functions to the same hook (bug#77609).
| -rw-r--r-- | doc/misc/use-package.texi | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/misc/use-package.texi b/doc/misc/use-package.texi index c14e7b77d23..69dd68d7f3a 100644 --- a/doc/misc/use-package.texi +++ b/doc/misc/use-package.texi | |||
| @@ -1191,8 +1191,7 @@ keybindings you've set using either the @code{:bind} keyword or the | |||
| 1191 | @cindex hooks | 1191 | @cindex hooks |
| 1192 | @findex :hook | 1192 | @findex :hook |
| 1193 | The @code{:hook} keyword allows adding functions to hooks. It takes | 1193 | The @code{:hook} keyword allows adding functions to hooks. It takes |
| 1194 | @c FIXME: The actual forms accepted by :hook are different, see below! | 1194 | one argument of the form @var{hooks}, specifying or more functions |
| 1195 | one argument of the form @var{hooks}, specifying one or more functions | ||
| 1196 | to add to one or more hooks. For the purposes of @code{:hook}, the | 1195 | to add to one or more hooks. For the purposes of @code{:hook}, the |
| 1197 | name of hook variables should always exclude the @samp{-hook} suffix. | 1196 | name of hook variables should always exclude the @samp{-hook} suffix. |
| 1198 | It is appended automatically for you, to save some typing. | 1197 | It is appended automatically for you, to save some typing. |
| @@ -1265,6 +1264,17 @@ applied, the following examples are all equivalent: | |||
| 1265 | @end group | 1264 | @end group |
| 1266 | @end lisp | 1265 | @end lisp |
| 1267 | 1266 | ||
| 1267 | To add more than one function to the same hook, add them separately, | ||
| 1268 | like this: | ||
| 1269 | |||
| 1270 | @lisp | ||
| 1271 | @group | ||
| 1272 | (use-package company | ||
| 1273 | :hook ((prog-mode . company-mode) | ||
| 1274 | (prog-mode . some-other-function))) | ||
| 1275 | @end group | ||
| 1276 | @end lisp | ||
| 1277 | |||
| 1268 | One common mistake when using @code{:hook} is to forget to omit the | 1278 | One common mistake when using @code{:hook} is to forget to omit the |
| 1269 | @samp{-hook} suffix, which, as already explained, is appended | 1279 | @samp{-hook} suffix, which, as already explained, is appended |
| 1270 | automatically. Therefore, the following will not work, as it attempts | 1280 | automatically. Therefore, the following will not work, as it attempts |