🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.emacs
Article #8339

Re: how to change backup file names?

#8339
From: Mike Coffin
Date: Thu, 19 Jan 1989 15:55
51 lines
2360 bytes
From article <2926@uvacs.cs.Virginia.EDU>, by pausch@uvacs.cs.Virginia.EDU (Randy Pausch):
> Is there any way to change the way GNUemacs names backup files?

Yes.  Change the function find-backup-file-name to do whatever you
want.  I prefer to prepend a "." on the front so that ls doesn't show
backups, so the following is in my .emacs file:

------------------------------------------------------------------------
;;; changed from original to put `.' before name of backup version
(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."
  (if (eq version-control 'never)
      (list (concat 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 (concat fn "~"))
	(cons 
	 (concat (file-name-directory fn)
		 "."
		 (file-name-nondirectory fn)
		 ".~"
		 (int-to-string (1+ high-water-mark)) "~")
	 (if (> number-to-delete 0)
	     (mapcar 
	      (function (lambda (n)
			  (concat 
			   (file-name-directory fn)
			   "."
			   (file-name-nondirectory fn)
			   ".~" (int-to-string n) "~")))
	      (let ((v (nthcdr kept-old-versions versions)))
		(rplacd (nthcdr (1- number-to-delete) v) ())
		v))))))))
-- 
Mike Coffin				mike@arizona.edu
Univ. of Ariz. Dept. of Comp. Sci.	{allegra,cmcl2}!arizona!mike
Tucson, AZ  85721			(602)621-2858
Technical Details
Message-ID: <8776@megaron.arizona.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!agate!bionet!ig!arizona!mike
References: <2926@uvacs.cs.Virginia.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!agate!bionet!ig!arizona!mike
From: mike@arizona.edu (Mike Coffin)
Newsgroups: comp.emacs
Subject: Re: how to change backup file names?
Message-ID: <8776@megaron.arizona.edu>
Date: 19 Jan 89 15:55:57 GMT
References: <2926@uvacs.cs.Virginia.EDU>
Organization: U of Arizona CS Dept, Tucson
Lines: 51