0
votes

I'm wondering if there's a way to have emacs turn on auto-fill-mode when it's launched by git during a commit? I've looked at the command line options and perhaps I could use --load, or something like that to start with auto-fill-mode, but I suspect there's a better way? Also, git is set to use emacs -nw at the moment and open in the terminal.

2

2 Answers

1
votes

Here's what Magit's git-commit-mode does:

(add-to-list 'auto-mode-alist
             '("/\\(?:COMMIT\\|NOTES\\|TAG\\|PULLREQ\\)_EDITMSG\\'"
               . git-commit-mode))

Of course, you may simply want to simply install the entire package instead of reinvent the wheel.

0
votes

There might be several ways to do this (of course ;-). One way might have been to add a hook for Fundamental Mode which checked the directory of the commit message file and if it was in .git/ then tack on auto-fill-mode. But it turns out Fundamental Mode doesn't have any hooks because it is the barest of modes.

The next idea might be to add a function to any startup hooks. Which lead me to Emacs Startup Summary. I didn't test any of these, so I can't recommend the best hook to use, or if they will even work, and what might be better would be to:

Instead use add-to-list 'auto-mode-alist with the full commit message file name COMMIT_EDITMSG and hook fundamental-mode to the opening of that file.