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 02:51:00 +0100 Message-ID: References: <45990274.5060103@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 1167702684 23351 80.91.229.12 (2 Jan 2007 01:51:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 Jan 2007 01:51:24 +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 02:51:21 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 1H1Yo9-0008D0-D1 for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jan 2007 02:51:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H1Yo8-0006YO-Pv for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jan 2007 20:51:16 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H1Ynu-0006Xv-U1 for help-gnu-emacs@gnu.org; Mon, 01 Jan 2007 20:51:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H1Ynt-0006XX-OY for help-gnu-emacs@gnu.org; Mon, 01 Jan 2007 20:51:02 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H1Ynt-0006XT-IY for help-gnu-emacs@gnu.org; Mon, 01 Jan 2007 20:51:01 -0500 Original-Received: from [64.233.182.187] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H1Ynt-0001mU-5L for help-gnu-emacs@gnu.org; Mon, 01 Jan 2007 20:51:01 -0500 Original-Received: by nf-out-0910.google.com with SMTP id d4so6815131nfe for ; Mon, 01 Jan 2007 17:51:00 -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=uDEMR8GOAulyuge8oLhSkAkbCGvOBirurWigCLyl2u00DxeXGVZr8XH1FR+qXOPf2Ruu1Cg7/AaFYXCEB5lqbow12O0ZnwTRmDE4oVqbG0STqpyD606FSGqp28PhHMvNfCwbJ2Yhw70DQLrv165Mi6Us5qK66dqXUmdpLh6+Fiw= Original-Received: by 10.82.167.5 with SMTP id p5mr1826347bue.1167702660278; Mon, 01 Jan 2007 17:51:00 -0800 (PST) Original-Received: by 10.82.147.2 with HTTP; Mon, 1 Jan 2007 17:51:00 -0800 (PST) Original-To: "Matthew Flaschen" In-Reply-To: <45990274.5060103@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:40092 Archived-At: On 1/1/07, Matthew Flaschen wrote: > Does anyone know a good way to maintain a blacklist of files that will > never be backed up by emacs? If I understand correctly what you're asking for, I use something similar to the following on my .emacs: (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 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 file))) nil (normal-backup-enable-predicate file)))) (setq backup-enable-predicate 'my-backup-enable-predicate) ;; and now, you can exclude files from backup with: (my-exclude-from-backup "/this/file" "/that/other/file") /L/e/k/t/u