[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Backup Blacklist
From: |
Juanma Barranquero |
Subject: |
Re: Backup Blacklist |
Date: |
Tue, 2 Jan 2007 23:22:14 +0100 |
On 1/2/07, Matthew Flaschen <matthew.flaschen@gatech.edu> wrote:
Changing the default directory to the empty string fixed that.
Hmm, I don't think that's correct. Try with this (it has a couple
small bug fixes):
(require 'cl)
(require 'regexp-opt)
;; Set this to t or nil if you don't want the default.
;; It is used in my-backup-enable-predicate
(defvar my-backup-case-fold case-fold-search)
(defun my-exclude-from-backup (&rest files)
"Exclude from backup all filenames in FILES.
They must be absolute paths.
Other files are passed to `normal-backup-enable-predicate',
so is still possible for them to be excluded anyway."
(let ((excluded (get 'my-exclude-from-backup :files)))
(mapc #'(lambda (file)
(unless (file-name-absolute-p file)
(error "%s is not an absolute filename" file))
(pushnew (expand-file-name file) excluded :test #'equal))
files)
(put 'my-exclude-from-backup :files excluded)
(put 'my-exclude-from-backup
:regexp (concat "^" (regexp-opt excluded) "$"))))
(defun my-backup-enable-predicate (file)
"Alternate `backup-enable-predicate' function that excludes from
backups those files registered with `my-exclude-from-backup'."
(let ((regexp (get 'my-exclude-from-backup :regexp)))
(if (and regexp
(let ((case-fold-search my-backup-case-fold))
(string-match regexp (expand-file-name file))))
nil
(normal-backup-enable-predicate file))))
(defun my-exclude-file-from-backup (&optional file)
(interactive (list (read-file-name "File to exclude: " nil nil t
(file-name-nondirectory buffer-file-name))))
(my-exclude-from-backup file))
(setq backup-enable-predicate 'my-backup-enable-predicate)
However, this also excludes other files containing the full path. Thus,
for exampled, if I excluded:
/data/Documents/cool.c
It will also exclude
/data/Documents/cool.cpp
Try now.
(my-backup-enable-predicate "/data/Documents/cool.c")
should return nil, and
(my-backup-enable-predicate "/data/Documents/cool.cpp")
should return t.
/L/e/k/t/u
- Backup Blacklist, Matthew Flaschen, 2007/01/01
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/01
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/02
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/02
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/02
- Re: Backup Blacklist,
Juanma Barranquero <=
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/02
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/02
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/03
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/03
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/03
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/03
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/04
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/05
- Re: Backup Blacklist, Matthew Flaschen, 2007/01/24
- Re: Backup Blacklist, Juanma Barranquero, 2007/01/24