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.

Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30

2 Answers2

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).

Kyle Meyer
  • 6,914
  • 26
  • 22
  • 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. – Mathieu Marques May 06 '17 at 00:21
  • 1
    It wasn't officially obsolete because I forgot to mark it, but I've done it now: https://github.com/magit/magit/commit/a277432e806af89c3bdd6046721c4db948443120 – npostavs May 06 '17 at 03:13
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.

Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30