bug#81643: 32.0.50; use-package :hook is not the same as :init add-hook
Lucas Jimenez via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the clarification! This was a mistake from my part due ignoring the :commands attribute (I totally missed it there) so the documentation is correct. The documentation doesn’t say they are the same! that was an invention of mine for miss reading it. > On 18-08-2026, at 16:49, John Wiegley <[email protected]> wrote: > >>>>>> Eli Zaretskii <[email protected] <mailto:[email protected]>> writes: > >> 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? > > These examples are indeed all equivalent, because the `:commands company-mode' > declaration in the last use-package block causes the deferred behavior. In the > two options reported in the e-mail I responded to, there wasn’t anything added > to ensure that both definitions used deferral. > > -- > John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F > http://newartisans.com <http://newartisans.com/> 60E1 46C4 BD1A 7AC1 4BA2