Skip to content

Instantly share code, notes, and snippets.

@scottwb
Created March 5, 2012 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwb/1980413 to your computer and use it in GitHub Desktop.
Save scottwb/1980413 to your computer and use it in GitHub Desktop.
Make emacs store *~ backups files all in a single directory.
;;; Move the backup *~ files into a single backups directory instead of
;;; littering the filesystem with them. Also version the backups and only
;;; keep a finite number of backup versions.
;;;
;;; Read more, and get the required backup-dir.el here:
;;; http://www.emacswiki.org/emacs/BackupDirectory
;;;
(require 'backup-dir)
(make-variable-buffer-local 'backup-inhibited)
(setq bkup-backup-directory-info
'((t "~/.emacs.d/backups" ok-create full-path prepend-name)))
(setq delete-old-versions t
kept-old-versions 1
kept-new-versions 3
version-control t)
(defun make-backup-file-name (FILE)
(let ((dirname (concat "~/.emacs.d/backups"
(format-time-string "%y/%m/%d/"))))
(if (not (file-exists-p dirname))
(make-directory dirname t))
(concat dirname (file-name-nondirectory FILE))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment