From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.help Subject: Re: Backup Blacklist Date: Tue, 2 Jan 2007 23:22:14 +0100 Message-ID: References: <45990274.5060103@gatech.edu> <459A0379.6000508@gatech.edu> <459AC940.6060505@gatech.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1167776594 29707 80.91.229.12 (2 Jan 2007 22:23:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 Jan 2007 22:23:14 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 02 23:23:11 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H1s2I-0001oY-Vw for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jan 2007 23:23:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H1s2I-0000yb-7G for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jan 2007 17:23:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H1s1R-0000Ps-Of for help-gnu-emacs@gnu.org; Tue, 02 Jan 2007 17:22:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H1s1Q-0000Ou-27 for help-gnu-emacs@gnu.org; Tue, 02 Jan 2007 17:22:17 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H1s1P-0000Oq-P9 for help-gnu-emacs@gnu.org; Tue, 02 Jan 2007 17:22:15 -0500 Original-Received: from [64.233.182.190] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H1s1P-0000Ba-Dg for help-gnu-emacs@gnu.org; Tue, 02 Jan 2007 17:22:15 -0500 Original-Received: by nf-out-0910.google.com with SMTP id h2so131410nfe for ; Tue, 02 Jan 2007 14:22:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WGMVacPwxNp9mosRnnXwbtx3Vqfuc72txJr3J0B/x801pVjhADkybFa7eIdZoLufh8zuJbZoVXD0gcraNQJbsfTXV688wVc8+7D3EkTBywZj5Uo0XBDDbk/jSs5A3K2kHsOXIE/IcSgmYGBtYvW6flJfPDcJ08XwyFXLM4KkTBY= Original-Received: by 10.82.113.6 with SMTP id l6mr1749181buc.1167776534462; Tue, 02 Jan 2007 14:22:14 -0800 (PST) Original-Received: by 10.82.147.2 with HTTP; Tue, 2 Jan 2007 14:22:14 -0800 (PST) Original-To: "Matthew Flaschen" In-Reply-To: <459AC940.6060505@gatech.edu> Content-Disposition: inline X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:40109 Archived-At: On 1/2/07, Matthew Flaschen 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