Emacs as commit message editor
Jari Aalto
jari.aalto at cante.net
Mon Apr 30 09:59:48 BST 2007
"Jonathan Lange" <jml at mumak.net> writes:
> Hello all,
>
> I use emacs to write my commit messages, and thought I'd share a small
> hack I came up with over the weekend.
>
> The big problem with using emacs as a commit editor (apart from the
> memory footprint) is that it leaves bzr_log.FOO~ files lying around
> after the commit. If this bugs you, you can add the following code to
> your .emacs file:
>
> (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)
>
Nice. Here is another version. You can make the regexps as tight or
loose as needed (I left out the ^ anchor).
Jari
;;; ........................................................ 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)
More information about the bazaar
mailing list