bug#81643: 32.0.50; use-package :hook is not the same as :init add-hook
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
> From: John Wiegley <[email protected]> > Cc: Lucas Jimenez <[email protected]>, [email protected] > Date: Tue, 18 Aug 2026 00:43:00 -0700 > > The original reporter is correct: If the manual implies that `:hook' is the > same as using `add-hook' in a `:init' block, then it should be correctly to > say that this depends on whether (1) the nature of the use-package macro > causes auto-deferral to happen, and (2) there is code in a `:config' block > that would thusly be deferred. > > Maybe it’s best to just drop this statement from the manual. There's no such statement in the manual. It is a conjecture, probably from the following excerpt: You can also provide a list of hooks. When multiple hooks should be applied, the following examples are all equivalent: (use-package company :hook (prog-mode text-mode)) (use-package company :hook ((prog-mode text-mode) . company-mode)) (use-package company :hook ((prog-mode . company-mode) (text-mode . company-mode))) (use-package company :commands company-mode :init (add-hook 'prog-mode-hook #'company-mode) (add-hook 'text-mode-hook #'company-mode)) Are the examples incorrect?