Here’s a really trivial Emacs major mode for editing Git and Mercurial commit messages: commit-msg-mode.el. It works in basically the same way as the Vim mode, highlighting the summary line, help text, etc.
To use it, put it on your load-path and add the following to your .emacs:
(autoload 'commit-msg-mode "commit-msg-mode" "Major mode for editing commit messages." t) (add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . commit-msg-mode)) (add-to-list 'auto-mode-alist '("hg-editor-.*$" . commit-msg-mode))
If you’re anything like me you’ll appreciate having your commit message spell-checked which you can do with:
(add-hook 'commit-msg-mode-hook (lambda () (flyspell-mode t)))
I found that I needed to put (font-lock-fontify-buffer) into the definition of the mode function just after setting the font-lock-defaults variable in order to have the nice colouring on the faces done when the buffer was brought up.
June 7, 2011 @ 4:14 am
Thanks, I’ve added that. I guess I didn’t need it because I have global-font-lock-mode on?
June 7, 2011 @ 6:48 am