gnu emacs backup files I use [GNU Emacs](http://gnu.org/software/emacs/), and I love it. However, one annoyance is that it scatters autosave files (_#foo#_) and backup files (_foo~_) all over the filesystem. So, I finally got fed up with this, and figured out how to keep them all in one place. Here's the [elisp](http://gnu.org/software/emacs/emacs-lisp-intro/html_node/index.html) (GNU Emacs only) that I put in [my .emacs](dotfiles/.emacs): ;; Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs.d/. (custom-set-variables '(auto-save-file-name-transforms '((".*" "~/.emacs.d/autosaves/\\1" t))) '(backup-directory-alist '((".*" . "~/.emacs.d/backups/")))) ;; create the autosave dir if necessary, since emacs won't. (make-directory "~/.emacs.d/autosaves/" t) ...and, courtesy of [Amit Patel](http://www-cs-students.stanford.edu/~amitp/), here's the elisp for XEmacs. ;;; Auto-save ;;; Load the auto-save.el package, which lets you put all of your autosave ;;; files in one place, instead of scattering them around the file system. ;;; M-x recover-all-files or M-x recover-file to get them back (defvar temp-directory (concat "/tmp/" (user-login-name))) (make-directory temp-directory t) ; One of the main issues for me is that my home directory is ; NFS mounted. By setting all the autosave directories in /tmp, ; things run much quicker (setq auto-save-directory (concat temp-directory "/autosave") auto-save-hash-directory (concat temp-directory "/autosave-hash") auto-save-directory-fallback "/tmp/" auto-save-list-file-prefix (concat temp-directory "/autosave-") auto-save-hash-p nil auto-save-timeout 100 auto-save-interval 300) (make-directory auto-save-directory t) (require 'auto-save) ;;; Put backups in another directory. With the directory-info ;;; variable, you can control which files get backed up where. (require 'backup-dir) (setq bkup-backup-directory-info \`( (t ,(concat temp-directory "/backups") ok-create full-path) )) (setq make-backup-files t) (setq backup-by-copying t) (setq backup-by-copying-when-mismatch t) (setq backup-by-copying-when-linked t) (setq version-control t) (setq-default delete-old-versions t)