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

hook: Add check for -mode suffix automatically

Open floli opened this issue 6 years ago • 3 comments

Hello, the code

(use-package org-bullets
  :ensure t
  :hook (org-mode . org-bullets-mode))

works just fine. However, I expected

(use-package org-bullets
  :ensure t
  :hook org-mode)

fails with

(org-bullets org-ref-org-menu #[0 "ÀÁÂÃÄ$‡" [add-hook change-major-mode-hook org-show-block-all append local] 5] #[0 "ÀÁÂÃÄ$‡" [add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes org-bullets-mode visual-line-mode)

So it seems, that use-package expects the activation function to be called exactly like the mode and does not try to append -mode to it.

Wouldn't it be wise to try for org-bullets-mode in this case?

Or am I mistaken on that?

floli avatar Apr 20 '18 11:04 floli

I came here to say the same thing. The majority of modes don’t include the word “mode” in package name.

CeleritasCelery avatar Apr 27 '18 23:04 CeleritasCelery

I came across the general.el package which provides the :ghook keyword. It is smart enough to infer the -mode for the function name but can’t infer the -hook for the hook name. Go figure 😕

CeleritasCelery avatar May 06 '18 05:05 CeleritasCelery

I came across the general.el package which provides the :ghook keyword. It is smart enough to infer the -mode for the function name but can’t infer the -hook for the hook name. Go figure confused

It was an intentional design decision. If someone really wants it, I can make the shorthand opt-in.

noctuid avatar May 06 '22 14:05 noctuid