aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2025-05-24 12:56:30 +0300
committerEli Zaretskii2025-05-24 12:56:30 +0300
commit36afdd2f6f9f6bbb6bcc95ff2fb1e426c0bcdb3d (patch)
tree0f639c4201a5d5a2dff6e8302968151bb1c02ae2
parentd0c90bc9bfe8fedbff7f282086dc38458b1e0f9e (diff)
downloademacs-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.texi14
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
1193The @code{:hook} keyword allows adding functions to hooks. It takes 1193The @code{:hook} keyword allows adding functions to hooks. It takes
1194@c FIXME: The actual forms accepted by :hook are different, see below! 1194one argument of the form @var{hooks}, specifying or more functions
1195one argument of the form @var{hooks}, specifying one or more functions
1196to add to one or more hooks. For the purposes of @code{:hook}, the 1195to add to one or more hooks. For the purposes of @code{:hook}, the
1197name of hook variables should always exclude the @samp{-hook} suffix. 1196name of hook variables should always exclude the @samp{-hook} suffix.
1198It is appended automatically for you, to save some typing. 1197It 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
1267To add more than one function to the same hook, add them separately,
1268like 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
1268One common mistake when using @code{:hook} is to forget to omit the 1278One 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
1270automatically. Therefore, the following will not work, as it attempts 1280automatically. Therefore, the following will not work, as it attempts