use-package icon indicating copy to clipboard operation
use-package copied to clipboard

:hook does not defer if on expansion it contains a lambda?

Open doolio opened this issue 6 years ago • 2 comments

The following use-package declaration does not get deferred as I would expect using the :hook keyword but perhaps this is a misunderstanding on my part.

(use-package yaml-mode
  :ensure t
  :hook (yaml-mode . (lambda () (run-hooks 'prog-mode-hook))))

If instead I explicitly include the :defer keyword as follows it does get deferred as desired.

(use-package yaml-mode
  :ensure t
  :hook (yaml-mode . (lambda () (run-hooks 'prog-mode-hook)))
  :defer t)

In the first case I believe it does not get deferred because of the use of the lambda. The use-package-deferring-keywords docstring states "... :hook ... only imply deferred loading if they reference actual function symbols that can be autoloaded from the module." Is that the case here? Thanks for your time.

doolio avatar Apr 05 '18 18:04 doolio

same issue here.

tshu-w avatar Aug 12 '20 02:08 tshu-w

I can reproduce this on the latest version of use-package. It seems like a bug to me.

skangas avatar Dec 08 '22 01:12 skangas