From ed38fc0d8bcc966ed55b6ccea1014b37b2fb14e1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 24 May 2025 12:56:30 +0300 Subject: [PATCH] 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). (cherry picked from commit 36afdd2f6f9f6bbb6bcc95ff2fb1e426c0bcdb3d) --- doc/misc/use-package.texi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/misc/use-package.texi b/doc/misc/use-package.texi index 582cc9ab226..dd70a7d33a1 100644 --- a/doc/misc/use-package.texi +++ b/doc/misc/use-package.texi @@ -1210,8 +1210,7 @@ keybindings you've set using either the @code{:bind} keyword or the @cindex hooks @findex :hook The @code{:hook} keyword allows adding functions to hooks. It takes -@c FIXME: The actual forms accepted by :hook are different, see below! -one argument of the form @var{hooks}, specifying one or more functions +one argument of the form @var{hooks}, specifying or more functions to add to one or more hooks. For the purposes of @code{:hook}, the name of hook variables should always exclude the @samp{-hook} suffix. It is appended automatically for you, to save some typing. @@ -1284,6 +1283,17 @@ applied, the following examples are all equivalent: @end group @end lisp +To add more than one function to the same hook, add them separately, +like this: + +@lisp +@group +(use-package company + :hook ((prog-mode . company-mode) + (prog-mode . some-other-function))) +@end group +@end lisp + One common mistake when using @code{:hook} is to forget to omit the @samp{-hook} suffix, which, as already explained, is appended automatically. Therefore, the following will not work, as it attempts -- 2.39.5