From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: BRUCE INGALLS <bruce.ingalls@gmail.com>
Newsgroups: gmane.emacs.help
Subject: trashback
Date: Sun, 5 Feb 2006 19:03:46 -0500
Message-ID: <534d19de0602051603t345eddb9o382be4400fa9dafb@mail.gmail.com>
NNTP-Posting-Host: main.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: sea.gmane.org 1139184282 28080 80.91.229.2 (6 Feb 2006 00:04:42 GMT)
X-Complaints-To: usenet@sea.gmane.org
NNTP-Posting-Date: Mon, 6 Feb 2006 00:04:42 +0000 (UTC)
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 06 01:04:39 2006
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by ciao.gmane.org with esmtp (Exim 4.43)
	id 1F5try-0003jZ-Hd
	for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Feb 2006 01:04:39 +0100
Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1F5tvF-0002Rd-BE
	for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2006 19:08:01 -0500
Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1F5tuV-0002QM-Hv
	for help-gnu-emacs@gnu.org; Sun, 05 Feb 2006 19:07:15 -0500
Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1F5tuT-0002On-6j
	for help-gnu-emacs@gnu.org; Sun, 05 Feb 2006 19:07:14 -0500
Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1F5tuS-0002OM-G1
	for help-gnu-emacs@gnu.org; Sun, 05 Feb 2006 19:07:12 -0500
Original-Received: from [64.233.184.201] (helo=wproxy.gmail.com)
	by monty-python.gnu.org with esmtp (Exim 4.52) id 1F5ttu-0000og-SB
	for help-gnu-emacs@gnu.org; Sun, 05 Feb 2006 19:06:39 -0500
Original-Received: by wproxy.gmail.com with SMTP id i27so1048032wra
	for <help-gnu-emacs@gnu.org>; Sun, 05 Feb 2006 16:03:46 -0800 (PST)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com;
	h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
	b=GjSLGqxvicaoGf8JAnbMFHGoE7E54rhnoLsgnXPcgPHqs44aGQbCFhK4pd7lzbmE3mw7JDwzrlLFMPGu/LQBCIsA0eBM9G2Wcvgxs+o/ENiNEcBehzmyee1tu5PYaOBHub/jqSxcesLI6a2gtJBL0bGskaDhNY9Zsty5dvAWVe0=
Original-Received: by 10.54.112.10 with SMTP id k10mr5591909wrc;
	Sun, 05 Feb 2006 16:03:46 -0800 (PST)
Original-Received: by 10.54.71.1 with HTTP; Sun, 5 Feb 2006 16:03:46 -0800 (PST)
Original-To: help-gnu-emacs@gnu.org
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 <help-gnu-emacs.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=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:33020
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/33020>

It seems to me, that a good place to put emacs backups, is in your
Wastebasket directory, and let your Operating or Desktop System deal
with cleanup.
Frankly, if I need a backup for more than an hour, I'd turn to an
industrial strength system, such as Arch, Subversion, CVS or RCS.

The attached code had some testing on w32. I'm sure most of the other
directories are wrong. However, it should not require much work to be
useful. I do need some porting & testing help, however. I expect that
EmacsWiki is a good home, with an announcement on gnu.emacs.sources.
Perhaps the maintainer of backup-dir.el (or ebackup.el) would be
interested in adding this code, to make it the M-x customize default?

;;--- cut here ---

;;trashback.el: auto discovers local OS dependent waste-basket dir, to
;;consolidate & manage all your ~ backup files.

;;Version 2006-2-5 is a poorly tested pre-alpha proof of concept
;;Copyright 2006, Bruce Ingalls. See http://www.gnu.org/ for GPL3 license

;;Bugs: w32 assumes that Recycler dir was created by virtue of having been =
used
;;Cygnome or kde-cygwin will use the w32 Recycler. Likewise for Mac/Fink
;;Limited support for remote systems (Tramp,Ange-ftp,Efs)

;;Docs: http://www.emacswiki.org/cgi-bin/wiki/BackupDirectory
;;This is not part of Emacs, but will be part of http://emacro.sf.net/

(cond
 ((string-match "windows" (symbol-name system-type))
  (progn
    ;;Filter . & .. from w32 recycler directory
    (setq e-trashback
=09  (directory-files
=09   (concat (getenv "SystemDrive") "/Recycler/") 't "[^.].+$" 'nil))
    ;;Trim, until the first directory is our writable directory
    (while (not (file-accessible-directory-p (car e-trashback)))
      (setq e-trashback (delq (car e-trashback) e-trashback)))
   (setq e-trashback (car e-trashback))))

 ((or (string-match "Macintosh" (emacs-version))
      (string-match "macos" (emacs-version)))
  (progn
    (setq e-trashback (expand-file-name "~/.trash-wildguess/"))
    (message "Where is Mac's trash directory?")))

  ((file-exists-p (expand-file-name "~/.gnome/Desktop/Trash/"))
    (setq e-trashback (expand-file-name "~/.gnome/Desktop/Trash/")))

  ((file-exists-p (expand-file-name "~/.kde/Desktop/Trash"))
    (setq e-trashback (expand-file-name "~/.kde/Desktop/Trash/")))

;;Others? ~/WASTEBASKET perhaps?
;;Default to ~/.emacs-backup on unsupported systems
  (t (setq e-trashback (expand-file-name "~/.emacs-backup/")))
)


;;Set the results for backup-dir.el.
;;Set '.' current path for /ssh:... style tramp patterns
;;(require 'backup-dir)
(setq backup-directory-alist
      '(("^/[a-z]+:.+$" . ".")
=09("." . e-trashback)))