home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / emacs / help / 5512 < prev    next >
Encoding:
Text File  |  1993-01-27  |  2.4 KB  |  58 lines

  1. Path: sparky!uunet!stanford.edu!agate!agate.berkeley.edu!dodd
  2. From: dodd@mycenae.cchem.berkeley.edu (Lawrence R. Dodd)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: backup file creation
  5. Date: 26 Jan 93 10:57:20
  6. Organization: Dept of Chemical Engineering, Polytechnic Univ, NY, USA
  7. Lines: 44
  8. Distribution: world
  9. Message-ID: <DODD.93Jan26105720@mycenae.cchem.berkeley.edu>
  10. References: <9301230326.AA06071@transit>
  11. NNTP-Posting-Host: mycenae.cchem.berkeley.edu
  12. In-reply-to: hqm@ai.mit.edu's message of 25 Jan 1993 19:57:42 -0500
  13.  
  14.  
  15.  
  16. >>>>> "Henry" == Henry Minsky <hqm@ai.mit.edu> writes:
  17.  
  18.   Henry> How can I get emacs to create a new backup file after every buffer
  19.   Henry> save, rather than just the first time a file is edited? 
  20.  
  21. yes that is right.
  22.  
  23. I get around it by sticking this in my .emacs.  Is there an easier way to do
  24. this?  I did this so long ago that the comments are probably wrong but I know
  25. that it works.  I would appreciate it if someone would tell me if there is an
  26. easier/slicker way to do this.
  27.  
  28. Larry
  29.  
  30. ----------
  31. ;;; This next function unconditionally makes the previous file version into a
  32. ;;; backup file.  Why you ask?  Well, the way the save-buffer works by default
  33. ;;; as follows: you visit file GAR, you modify the file, you save the buffer,
  34. ;;; it renames the original file GAR to GAR followed by a ~1~ and saves the
  35. ;;; contents of the buffer in GAR.  Thus, the previous version of GAR is saved
  36. ;;; in GAR.~1~. Now, the next time you save this buffer the contents of the
  37. ;;; buffer are saved in GAR again but nothing is done to GAR.~1~.  Note, that
  38. ;;; the intermediate file is lost.  When editing a file I want to have a
  39. ;;; backup file created everytime I type C-x C-s and then after all the
  40. ;;; editing is done I can clean up all the intermediate files.  This is
  41. ;;; possible by binding the following defun to C-x C-s and by using numbered
  42. ;;; backup files.
  43.  
  44. ;;; assign defun to C-x C-s
  45.  
  46. (define-key global-map "\C-x\C-s" 'save-buffer-always-create-backup)
  47.  
  48. (defun save-buffer-always-create-backup ()
  49.   "Saves the current buffer and unconditionally makes the previous version
  50. into a backup file. This is done by passing C-u C-u C-u or 4*4*4=64 as an
  51. argument to the save-buffer command."
  52.   (interactive)
  53.   (if version-control   ; if version-control is non-nil (t or never)
  54.       (save-buffer 64)  ; then make previous version into a backup file
  55.     (save-buffer 1)     ; else normal save-buffer is performed
  56.     ))
  57. ----------
  58.