2

I have tried:

(add-hook 'git-commit-mode-hook '(lambda ()
                                   (setq fill-column 72)
                                   (turn-on-auto-fill)))
  1. In both cases, auto-fill-mode is not active in the COMMIT_EDITMSG buffer unless I manually turn it on with M-x auto-fill-mode RET.
  2. Even when auto-fill-mode is turned on, I can still type past the 72nd character on the same line.

Also, correct me if I'm wrong but it seems both git-commit-fill-column and git-commit-turn-on-auto-fill are deprecated.

2 Answers 2

1

I had comment-auto-fill-only-comments set to t. Since Magit commit buffer supports comments, it won't auto-fill.

(use-package git-commit
  :ensure nil
  :preface
  (defun me/git-commit-set-fill-column ()
    (setq-local comment-auto-fill-only-comments nil)
    (setq fill-column 72))
  :config
  (advice-add 'git-commit-turn-on-auto-fill :before #'me/git-commit-set-fill-column))

Edit: Created 2 issues on the subject: #3067 and #3068.

1

As far as I know, neither git-commit-fill-column nor git-commit-turn-on-auto-fill is deprecated, although the docstring of git-commit-fill-column suggests that you use fill-column directly. (Before Magit 2.9.0, a buffer-local value for fill-column was reset to git-commit-fill-column.)

git-commit-turn-on-auto-fill is still included in the default value of git-commit-setup-hook, so Auto Fill mode should be enabled by default.

I've justed tested the extreme example of

(add-hook 'git-commit-mode-hook (lambda () (setq fill-column 20)))

with emacs -Q, and it appears to work as expected (i.e., Auto Fill mode is on with a fill-column of 20).

2
  • This is the second strange thing that I come accross without being able to pinpoint the origin, the first one being no color applied to faces in ERC. Time to bissect I suppose... Thanks for the clarifications though. Commented May 6, 2017 at 0:21
  • 1
    It wasn't officially obsolete because I forgot to mark it, but I've done it now: github.com/magit/magit/commit/…
    – npostavs
    Commented May 6, 2017 at 3:13

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.