When Emacs sees that a file is not under some kind of version control, it saves a copy of the file before editing it. By default, the copy is stored alongside the original, using the original file’s name with a tilda (~) appended. This tends to clutter up directories:[gist id=1208218 file=”backups”]
Today I change the configuration so that all such backup files will be written into ~/.emacs24.d/backups:
I also realized today that Emacs already defines a variable to keep track of the location of the user’s Emacs directory, called user-emacs-directory. So while I’m at it, I set that variable to be equal to my abg-emacs-init-file variable.[gist id=1208218 file=”init.el”]
To test it, I edit another file and save it. When I’m done, I see that the directory ~/.emacs24.d/backups has been created, and contains a backup file:[gist id=1208218 file=”backups-dir”]
As you can see, Emacs replaces all the slashes with “!” symbols when storing backups in a separate directory.