Emacs as commit message editor
Avoiding tedious startup time
If you use Emacs for writing commit messages, you'll want to get to an open buffer as quickly as possible. Rather than launching a whole new Emacs process, you can connect to an existing one.
See http://www.emacswiki.org/cgi-bin/wiki/EmacsClient for more information.
Avoiding unsightly backup files
By default, Emacs will create backup files for any file that you edit and save. If you use Emacs for writing commit messages, Emacs will create backups of the temporary files that Bazaar creates to store the messages. These backups will lie around in your working tree, cluttering things up.
Here are three ways to avoid the mess. Any of them will work. The first two add exceptions preventing emacs from making backups of commit messages, and the third moves all of your backups to a central place, so you never get backups of any file in your tree.
(defun starts-with-p (string1 string2)
(string= (substring string1 0 (min (length string1) (length
string2))) string2))
(defun dont-backup-commit-files-p (filename)
(let ((filename-part (file-name-nondirectory filename)))
(if (or (starts-with-p filename-part "svn-commit")
(starts-with-p filename-part "bzr_log"))
nil
(normal-backup-enable-predicate filename))))
(setq backup-enable-predicate 'dont-backup-commit-files-p)OR
;;; ........................................................ variables ...
(defconst my-backup-file-exclude
"svn-commit\\|bzr_log"
"*Files to exclude. Regexp to check filename part only.")
(defconst my-backup-path-exclude
nil
"*Files to exclude. Regexp to check full path; including filename.")
;;; ............................................................. code ...
(defun my-normal-backup-exclude (path)
"Check PATH against `my-backup-file-exclude' and `my-backup-path-exclude'."
(and (stringp path)
(or (and (stringp my-backup-file-exclude)
(string-match
my-backup-file-exclude
(file-name-nondirectory path)))
(and (stringp my-backup-path-exclude)
(string-match
my-backup-path-exclude
path)))))
(defun my-normal-backup-enable-predicate (path)
"Do not backup files matching
`my-backup-file-exclude' or `my-backup-path-exclude'."
(if (my-normal-backup-exclude path)
nil
(normal-backup-enable-predicate path)))
(setq backup-enable-predicate 'my-normal-backup-enable-predicate)or finally, putting all backups in one directory. Make sure it exists.
;; create a backup file directory (defun make-backup-file-name (file) (concat "~/.emacs.d/backups/" (file-name-nondirectory file) "~"))
Mode for commit buffers
It is good that there is not hard line breaks in commit messages (except for ending paragraphs) as the window width may be different depending on the tool used to view them (console, bzr viz, bzr qlog). In order for your text to be nonetheless well displayed in Emacs, you can add the following to your ~/.emacs
(add-to-list 'auto-mode-alist '("/bzr_log\\." . longlines-mode))