home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!airgun!airgun.wg.waii.com!jct
- From: jct@se33.wg2.waii.com (Jim Thompson)
- Newsgroups: comp.emacs
- Subject: Re: How do I send file~ to the wastebasket directory?
- Message-ID: <JCT.92Aug21185207@se33.wg2.waii.com>
- Date: 21 Aug 92 22:52:07 GMT
- References: <1992Aug20.192848.4860@fzi.de>
- Sender: news@airgun.wg.waii.com
- Followup-To: comp.emacs
- Organization: Western Geophysical Exploration Products
- Lines: 59
- Nntp-Posting-Host: se33.wg2.waii.com
- In-reply-to: schreib@fzi.de's message of 20 Aug 92 19:28:48 GMT
-
- In article <1992Aug20.192848.4860@fzi.de> schreib@fzi.de (Hartmut Schreiber) writes:
-
- > Is there a way to tell emacs, to create all ~-files in a special
- > directory "wastebasket", which I can delete from time to time?
-
- Here's some code I wrote to place backup files into "./EmacsBackups",
- if it exists, or "." otherwise. I'm not sure why I overrode
- find-backup-file-name instead of make-backup-file-name; this code is
- old and I was quite the Elisp novice when I wrote it (but it still
- does the job).
-
- (defun backup-name-base (file)
- "Create the non-numeric backup file name for FILE.
- This is a separate function so you can redefine it for customization."
- (setq fdir (file-name-directory file))
- (setq fname (file-name-nondirectory file))
- (setq fbackupdir "EmacsBackups/")
-
- (if (file-directory-p (concat fdir fbackupdir))
- (concat fdir fbackupdir fname)
- file))
-
- (defun find-backup-file-name (fn)
- "Find a file name for a backup file, and suggestions for deletions.
- Value is a list whose car is the name for the backup file
- and whose cdr is a list of old versions to consider deleting now.
- Mangled from the original version in files.el."
-
- (setq fn (backup-name-base fn))
-
- (if (eq version-control 'never)
- (list (make-backup-file-name fn))
- (let* ((base-versions (concat (file-name-nondirectory fn) ".~"))
- (bv-length (length base-versions))
- (possibilities (file-name-all-completions
- base-versions
- (file-name-directory fn)))
- (versions (sort (mapcar 'backup-extract-version possibilities)
- '<))
- (high-water-mark (apply 'max (cons 0 versions)))
- (deserve-versions-p
- (or version-control
- (> high-water-mark 0)))
- (number-to-delete (- (length versions)
- kept-old-versions kept-new-versions -1)))
- (if (not deserve-versions-p)
- (list (make-backup-file-name fn))
- (cons (concat fn ".~" (int-to-string (1+ high-water-mark)) "~")
- (if (> number-to-delete 0)
- (mapcar (function (lambda (n)
- (concat fn ".~" (int-to-string n) "~")))
- (let ((v (nthcdr kept-old-versions versions)))
- (rplacd (nthcdr (1- number-to-delete) v) ())
- v))))))))
- --
- _ Jim Thompson | Wanted:
- _| ~- thompson@wg2.waii.com | Nick Park's "Grand Day Out"
- \, _} Western Geophysical | on VHS-format videotape
- \( Houston, Texas | Email me if you know where I can buy it.
-