Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are #file# and file~ and how can I get rid of them?

Tags:

unix

emacs

I originally had three files: makefile, readme.txt, and hashtable.c in my directory, where I am writing my code in emacs. I noticed that some new files: #hashtable.c#, #readme.txt#, hashtable.c~, and makefile~ have been created. I was wondering what these files were. Are these important, and if not, how do I tell emacs to stop making them? I'm also curious why readme.txt doesn't get a tilde file and makefile doesn't get a sharp file.

like image 923
Andrew Latham Avatar asked Aug 20 '12 03:08

Andrew Latham


2 Answers

The file with the ~ is a backup file that automatically gets created when you save a file. The #readme.txt# is the file being currently edited/in use (i.e., the autosave version). That will usually go away (unlike the ~ file) when you exit emacs normally (if it crashes or gets killed the # files may stay around).

You might find this page about emacs backup files of interest, and this SO question: How do I control how Emacs makes backup files?

You can prevent backup files from being created with this:

(setq make-backup-files nil) 
like image 86
Levon Avatar answered Oct 04 '22 07:10

Levon


I recommend installing no-littering. It automatically puts backup files (file~) in ~/.emacs.d/var/backup/. It doesn't do anything about autosaves (#file#), but there is a note about putting those files in a specified directory in the README:

(setq auto-save-file-name-transforms       `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) 

Neither of these things actually prevents Emacs from creating these files, but I'm assuming most people actually want these files (in case of a crash), but don't want them strewn all over the filesystem.

like image 43
jpkotta Avatar answered Oct 04 '22 07:10

jpkotta