ant2009
ant2009

Reputation: 22486

emacs why do I have hashes at the ends of my file names i.e. #test.c#

I am using emacs 22.2.1 on Ubuntu 9.04.

Every time I open a file and work on it, and then when I list the files in the directory in the terminal I see hashes at the ends of each file.

i.e.

#test.c#
#test.h#

Why is this and how can I remove them?

Many thanks for any advice,

Upvotes: 18

Views: 9131

Answers (6)

dotancohen
dotancohen

Reputation: 31471

Instead of removing these autosave files, I recommend placing them in a hidden directory. They are cheap insurance against data loss.

On Emacs 28 running on Ubuntu linux, I have the following lines in my ~/.emacs config file:

(setq auto-save-file-name-transforms `((".", "~/.emacs-saves" t)))

Additionally, I use this to move the backup files (Those that look like filename~) as well:

(setq backup-directory-alist `(("." . "~/.emacs-saves")))
(setq backup-by-copying t)

Note that you might have a different config file location, this is perfectly fine. If you find ~/.emacs does not exist, then try ~/.emacs.el, ~/.emacs.d/init.el, or ~/.config/emacs/init.el.

Upvotes: 1

Pascal Cuoq
Pascal Cuoq

Reputation: 80276

You have encountered the feature named "autosave". It saves modified buffers that have not been saved by the user for a while.

I have seen people disable it or change the location of the autosaved buffers to a temporary directory. You can also get more info there, for instance.

Upvotes: 3

Puppe
Puppe

Reputation: 5125

It's a recovery file that emacs creates when you haven't saved your file in a while (but only if it contains unsaved text). As soon as you save your file the recover file is removed. If emacs should crash before you can save, the file can be recovered with M-x recover-file.

Upvotes: 1

Penang
Penang

Reputation: 1305

Emacs performs a timely backup so you can always have the changes you've made (minus the last 5 minutes of your work) in case of a crash. You can remove it by this command from your working directory rm #*

Upvotes: 2

weismat
weismat

Reputation: 7411

These are autosave files.
Have a look at this link to change the files to be in a different directory. Have a look at this

Upvotes: 5

user181548
user181548

Reputation:

It's a backup (autosave) file. Emacs should remove them when it finishes editing the file, unless it dies or you kill it without saving the files. It's better not to remove these files since if you do, you cannot recover if Emacs should crash for some reason. When you start Emacs again you can recover the file with M-x recover-this-file to recover it from the backup.

Upvotes: 23

Related Questions