chiark / gitweb /
emacs: Don't back up boring files like commit messages.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 24 Apr 2008 15:53:00 +0000 (16:53 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 24 Apr 2008 15:53:00 +0000 (16:53 +0100)
dot-emacs.el
emacs

index 7ced7797d3994530cab13ef7613e4224c09659bf..1b1a71cf80f4127afdda5dd5e63d0e71b895b40e 100644 (file)
@@ -609,6 +609,26 @@ (make-face 'mdw-punct-face)
 (defvar mdw-number-face 'mdw-number-face "Face to use for numbers")
 (make-face 'mdw-number-face)
 
+;; --- Backup file handling ---
+
+(defvar mdw-backup-disable-regexps nil
+  "*List of regular expressions: if a file name matches any of these then the
+file is not backed up.")
+
+(defun mdw-backup-enable-predicate (name)
+  "[mdw]'s default backup predicate: allows a backup if the
+standard predicate would allow it, and it doesn't match any of
+the regular expressions in `mdw-backup-disable-regexps'."
+  (and (normal-backup-enable-predicate name)
+       (let ((answer t) (list mdw-backup-disable-regexps))
+        (save-match-data
+          (while list
+            (if (string-match (car list) name)
+                (setq answer nil))
+            (setq list (cdr list)))
+          answer))))
+(setq backup-enable-predicate 'mdw-backup-enable-predicate)
+
 ;;;----- General fontification ----------------------------------------------
 
 (defun mdw-set-fonts (frame faces)
diff --git a/emacs b/emacs
index 100d87213cdde539a5c7a956fb8a19b9065d089b..f0ac5809550622c68e1ece54f128c337347ec671 100644 (file)
--- a/emacs
+++ b/emacs
 (setq backup-by-copying-when-linked t)
 (setq backup-by-copying-when-mismatch t)
 
+(setq mdw-backup-disable-regexps
+      '("/\\.git/COMMIT_EDITMSG$"
+       "/\\.stgit\\(-edit\\.txt\\|msg\\.txt\\|\\.msg\\)$"))
+
 ;; --- Calculator fiddling ---
 
 (setq calc-settings-file "~/.emacs-calc")