1

I'm attempting to set the following hook using use-package, but it's not getting applied.

Normal elisp:

(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

Using use-package:

(use-package org-bullets
  :ensure t
  :after org-plus-contrib
  :hook (org-mode . (lambda () (org-bullets-mode 1))))

Its value is:

(flyspell-mode org-eldoc-load #f(compiled-function
                 ()
                 #<bytecode 0xbdabad>)
           #f(compiled-function
          ()
          #<bytecode 0x4fd045>)
           org-babel-result-hide-spec org-babel-hide-all-hashes)

What's the correct way to do this with use-package :hook?

1

You need remove :after org-plus-contrib, it's preventing your :hook ... from running.


By the way, consider replacing

(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

with

(add-hook 'org-mode-hook 'org-bullets-mode)

unless you really need support Emacs 23 or older versions (see also https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS.24#L3303). With use-package, you can use

(use-package org-bullets
  :ensure t
  :hook (org-mode . org-bullets-mode))
  • Thanks for the pointer to the new link. Why is the :after preventing the :hook? I want the :after to express the fact that org-bullets needs the org package to be installed. – retrodev Sep 10 '18 at 17:05
  • 1
    @retrodev That :after means (with-eval-after-load 'org-plus-contrib (add-hook ...)), however, there is no such feature org-plus-contrib at all, thus add-hook will never run. Besides, add-hook will always work even if the hook is void for now, see (info "(elisp) Setting Hooks") if you don't understand. Besides, you should understand why you need :after in the first place. – xuchunyang Sep 10 '18 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.