From: "Juanma Barranquero" <lekktu@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Backup Blacklist
Date: Tue, 2 Jan 2007 23:22:14 +0100 [thread overview]
Message-ID: <f7ccd24b0701021422y2d9c0e8dm4095051d324de240@mail.gmail.com> (raw)
In-Reply-To: <459AC940.6060505@gatech.edu>
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
next prev parent reply other threads:[~2007-01-02 22:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-01 12:45 Backup Blacklist Matthew Flaschen
2007-01-02 1:51 ` Juanma Barranquero
2007-01-02 7:02 ` Matthew Flaschen
2007-01-02 13:01 ` Juanma Barranquero
2007-01-02 21:06 ` Matthew Flaschen
2007-01-02 22:22 ` Juanma Barranquero [this message]
2007-01-03 1:13 ` Matthew Flaschen
2007-01-03 1:25 ` Juanma Barranquero
2007-01-03 5:48 ` Matthew Flaschen
2007-01-03 11:56 ` Juanma Barranquero
2007-01-03 12:30 ` Juanma Barranquero
2007-01-03 23:41 ` Juanma Barranquero
2007-01-04 7:18 ` Matthew Flaschen
2007-01-05 12:39 ` Juanma Barranquero
2007-01-25 1:15 ` Matthew Flaschen
2007-01-25 1:22 ` Juanma Barranquero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7ccd24b0701021422y2d9c0e8dm4095051d324de240@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).