(defun backup-current-file ()
"backs up a file with date embedded. e.g., '.emacs' is copied to '.emacs-2010-07-16'"
(let ((backupfilename (concat (buffer-file-name) "-" (format-time-string "%C%y-%m-%d" (current-time)))))
(message (concat "copying file " (buffer-file-name) " to " backupfilename) )
(copy-file (buffer-file-name) backupfilename)
Friday, July 16, 2010
Emacs lisp code to backup current buffer
I've upgraded to the latest emacs and doing a little cleanup work. Just wrote this tiny elisp method to backup a file and embed the current date in the new file name. I use this right before I start making major changes in a file not under version control to have a temp file to go back to when things go awry - and they always go awry.