2

I am rewriting my Emacs config file to fully use use-package and organize code. Currently, I have

(use-package magit
  :custom
  (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))

;; Flyspell
(add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)

It works but things are splited and they could be together. When I am writing commit messages, flyspell is activated and I can easily see grammar mistakes.

I tried to bring everything together in one s-expression with:

;; Magit configuration
(use-package magit
  :custom
  (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
  :hook ((git-commit-setup-hook . git-commit-turn-on-flyspell)))

Unfortunately, it does not work. How can I fix this?

Thanks.

1
  • 1
    I suggest setting use-package-hook-name-suffix to nil for a very simple reason: that way you can still put the cursor on top of any symbol that corresponds to a hook and inspect it with C-h o.
    – aadcg
    Commented Apr 19, 2022 at 9:08

1 Answer 1

2

Here is from the README of use-package

When using :hook omit the "-hook" suffix if you specify the hook explicitly, as this is appended by default. For example the following code will not work as it attempts to add to the prog-mode-hook-hook which does not exist:

;; DOES NOT WORK
(use-package ace-jump-mode
  :hook (prog-mode-hook . ace-jump-mode))

If you do not like this behaviour, set use-package-hook-name-suffix to nil. By default the value of this variable is "-hook".

1
  • It works now, thanks. Following your suggestion, I just did a minor tweak: (use-package magit :custom (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1) :hook ((git-commit-setup . git-commit-turn-on-flyspell))) Commented Apr 20, 2022 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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