Thread View: gnu.emacs.help
2 messages
2 total messages
Started by Henry Minsky
Tue, 26 Jan 1993 00:57
backup file creation
Author: Henry Minsky
Date: Tue, 26 Jan 1993 00:57
Date: Tue, 26 Jan 1993 00:57
2 lines
562 bytes
562 bytes
How can I get emacs to create a new backup file after every buffer save, rather than just the first time a file is edited?
Re: backup file creation
Author: 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
))
----------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads