1

I've noticed that emacs is leaving behind files in the directories of files I've edited with it. The files are named the same as the original, except the filename is preceeded and succeeded with a # character. For example, something like #file.c#, for example (if the original file was named file.c ).

I've already disabled lockfiles and changed the default directory backup files are saved to in my init.el script, like so:

(setq create-lockfiles nil)
(setq backup-directory-alist `(("." . "~/.saves")))

So I'm wondering why these files are generated, what their purpose is, and if there's a way I can supress them/change where they are saved to.

1

The Emacs manual (C-h r) is your friend for such a question. Use i in the manual to look something up in the index. For example, i auto save lets you get to node Auto Save, and the first item in the menu there takes you to node Auto-Save Files.

There you get a complete description of what these files are, what they are for, how to recognize them, how to manage them, etc.

Similarly, for backup files. i backup file (or i backup-directory-alist) takes you to node Backup Files, which tells you all you'll want to know about backup files. In particular, there, you can see that backup files are different, in name and purpose, from auto-save files.

Same thing for lock files: i lock file (or i create-lockfiles) takes you to node Interlocking. There, you can see that lock files are different, in name and purpose, from auto-save files.

If, after taking a look at these doc pages, you have a more specific question about these files, please pose that (separately).

| improve this answer | |
  • It looks like the manual is missing an index entry for # pointing to the Auto Save Files node. I # does get you to .#, lock file names [Concept Index] however, which might explain the original confusion. Although I see that the first hit actually is very useful here, so i # would get you there right away. It's just not at all obvious from its # (Dired) [Key Index]: Flagging Many Files title that it's going to be relevant. – phils Jan 24 at 0:32
  • @phils that's correct. I did check the emacs manual before posting this question. – TheDarkHoarse Jan 24 at 0:38
  • This has now been fixed for Emacs 27 (see bug 39259). – phils Jan 24 at 9:51
  • @phils That was fast! I submitted the bug just yesterday. – TheDarkHoarse Jan 24 at 19:33
1

As mentioned by Drew, the files in question are auto-save files, which are distinct from backup files. Unfortunately for some reason, there is no index entry for # pointing to Auto Save Files in the emacs manual, hence my confusion.

My solution was simply to also change the location auto-save files are saved to, namely a hidden directory in my home directory named .saves, by adding the following line to my configuration file:

(setq auto-save-file-name-transforms `((".*" "~/.saves" t)))
| improve this answer | |
  • (FYI, you can accept your answer.) – Drew Jan 24 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.