Friday, January 7, 2011

Hardly anything ruins a glorious day of coding like fat-fingering the commit message late at night as you doze off, and then pushing it out for the world to see. To prevent that, I have equipped my Emacs configuration with a few little tools now.

First, I found the git-commit-mode, a special mode for Git commit messages. This helps you format the commit messages according to convention, and will use ugly colors if, for example, you write lines that are too long or you do not keep the second line blank. It also allows the use of things like M-q without shredding the whole file template.

Second, I integrated on-the-fly spell checking into the git-commit-mode. It won't stop you from writing nonsense, but it will catch the silly mistakes.

The last line is handy if you have save-place on by default. When you make a new commit, it would then normally place the cursor where a previously edited commit message was finished, because to the save-place functionality, it looks as though it's the same file.

If you can find a way to incorporate your toggle-save-place trick in a way that won't break things for people not using save-places, I'd be happy to integrate that so you can get rid of that mode hook.

Also, turning on flyspell-mode is one of the things I want to happen automatically for git-commit-mode as well. But also there's tons of other cases where I want flyspell-mode depending on the mode of the buffer I'm editing, or any other condition. In order to not write mode hooks for every single mode I'm using and hardcode things in there, I've written espect.el. You might want to give that a try as well :-)