Emacs Reboot #5

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.

1 comment

  1. I’m doing roughly the same thing that you did — starting fresh with an empty init.el directory. I’m using el-get. So far I like it. I’m walking through the set of emacs pages you have done. You might see me pop up again here soon :-).

    One thought:

    backup-directory-alist is customizable so you could use the GUI to customize it or
    add the code manually to the customization list. All the init stuff is a bit mysterious
    to me so I try (perhaps too aggressively) to use customize if it is a custom var.

Leave a Reply to pedz Cancel reply

Your email address will not be published. Required fields are marked *