Article View: gnu.emacs.help
Article #2208Re: backup file creation
From: Lawrence R. Dodd
Date: Tue, 26 Jan 1993 10:57
Date: Tue, 26 Jan 1993 10:57
44 lines
2506 bytes
2506 bytes
>>>>> "Henry" == Henry Minsky <hqm@ai.mit.edu> writes:
Henry> How can I get emacs to create a new backup file after every buffer
Henry> save, rather than just the first time a file is edited?
yes that is right.
I get around it by sticking this in my .emacs. Is there an easier way to do
this? I did this so long ago that the comments are probably wrong but I know
that it works. I would appreciate it if someone would tell me if there is an
easier/slicker way to do this.
Larry
----------
;;; This next function unconditionally makes the previous file version into a
;;; backup file. Why you ask? Well, the way the save-buffer works by default
;;; as follows: you visit file GAR, you modify the file, you save the buffer,
;;; it renames the original file GAR to GAR followed by a ~1~ and saves the
;;; contents of the buffer in GAR. Thus, the previous version of GAR is saved
;;; in GAR.~1~. Now, the next time you save this buffer the contents of the
;;; buffer are saved in GAR again but nothing is done to GAR.~1~. Note, that
;;; the intermediate file is lost. When editing a file I want to have a
;;; backup file created everytime I type C-x C-s and then after all the
;;; editing is done I can clean up all the intermediate files. This is
;;; possible by binding the following defun to C-x C-s and by using numbered
;;; backup files.
;;; assign defun to C-x C-s
(define-key global-map "\C-x\C-s" 'save-buffer-always-create-backup)
(defun save-buffer-always-create-backup ()
"Saves the current buffer and unconditionally makes the previous version
into a backup file. This is done by passing C-u C-u C-u or 4*4*4=64 as an
argument to the save-buffer command."
(interactive)
(if version-control ; if version-control is non-nil (t or never)
(save-buffer 64) ; then make previous version into a backup file
(save-buffer 1) ; else normal save-buffer is performed
))
----------
Technical Details
Message-ID:
<DODD.93Jan26105720@mycenae.cchem.berkeley.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!agate.berkeley.edu!doddReferences:
<9301230326.AA06071@transit>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!agate.berkeley.edu!dodd From: dodd@mycenae.cchem.berkeley.edu (Lawrence R. Dodd) Newsgroups: gnu.emacs.help Subject: Re: backup file creation Date: 26 Jan 93 10:57:20 Organization: Dept of Chemical Engineering, Polytechnic Univ, NY, USA Lines: 44 Distribution: world Message-ID: <DODD.93Jan26105720@mycenae.cchem.berkeley.edu> References: <9301230326.AA06071@transit> NNTP-Posting-Host: mycenae.cchem.berkeley.edu In-reply-to: hqm@ai.mit.edu's message of 25 Jan 1993 19:57:42 -0500