bug#81643: 32.0.50; use-package :hook is not the same as :init add-hook

Björn Lindqvist <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <CALG+76cAVPkv3Ni3J7+F4XAx_wdPZ_2VwqT2ZPN3PeLFKb8hzw@mail.gmail.com>
Den tis 18 aug. 2026 kl 13:41 skrev Eli Zaretskii <[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:

I think the problem is with the first two examples in section 4.3. Specifically:

    :init (add-hook 'c-ts-mode-hook #'my/c-ts-mode-hook)

cannot be simplified to:

    :hook (c-ts-mode . my/c-ts-mode-hook)

It must be:

    :hook ('c-ts-mode . #'my/c-ts-mode-hook)

So I need to quote both the prefix of c-ts-mode-hook and the name of
the hook function.

I think the documentation is very confusing. For example:

    (use-package company
    :commands company-mode
    :init
    (add-hook 'prog-mode-hook #'company-mode))

Why is the hook function named company-mode?


-- 
mvh/best regards Björn Lindqvist
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.