help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trashback


From: BRUCE INGALLS
Subject: trashback
Date: Sun, 5 Feb 2006 19:03:46 -0500

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
          (directory-files
           (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]+:.+$" . ".")
        ("." . e-trashback)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]