jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.37k stars 260 forks source link

`:hook` forms not equivalent #1074

Open just-walk opened 4 months ago

just-walk commented 4 months ago

When adding julia-snail-mode to the julia-mode hook, different forms of the use-package syntax that should have "equivalent" behavior are in fact different. (https://www.gnu.org/software/emacs/manual/html_mono/use-package.html#Hooks)

This first form does what I would expect it to do.

(use-package julia-snail
  :ensure t
  :custom
  (julia-snail-terminal-type :eat)
  :hook (julia-mode . julia-snail-mode)
)

The variable julia-mode-hook then evaluates to (julia-snail-mode).

This second form shortens the hook declaration. By the documentation, this should append -mode to the package name and add it to the hook specified. In this case julia-snail-mode should be appended to julia-mode-hook.

(use-package julia-snail
  :ensure t
  :custom
  (julia-snail-terminal-type :eat)
  :hook julia-mode
)

Instead, variable julia-mode-hook evaluates to (julia-snail).

What's going on? Is this a bug in use-package, or am I misunderstanding the docs?

MerlinsGreatBeard commented 2 weeks ago

Saw a similar thing with symex-mode and emacs-lisp-mode where

 (use-package symex
    :ensure t
    :hook (emacs-lisp-mode . symex-mode))

→ emacs-lisp-mode-hook = (symex-mode)

but

   (use-package symex
    :ensure t
    :hook emacs-lisp-mode)

→ emacs-lisp-mode-hook = (symex symex-mode)