1
submitted 11 months ago by usuario1986@alien.top to c/emacs@communick.news

Hi.

Still learning Emacs but happy with it so far. One thing i'm trying to find out is this. I'm OK with Emacs creating recovery files from which i can, well, recover my work after emacs is closed. However, if I save my files, I have no need for these #filename# or filename~ files that populate my folders. Is there a way to make emacs keep creating these recovery files, but deleting them if I *save* my actual files?

top 6 comments
sorted by: hot top controversial new old
[-] sandbox_actual@alien.top 1 points 11 months ago

First, for making sure the autosave files—the ones prefixed and suffixed by "#"—are cleaned up, ensure that delete-auto-save-files is non-nil (the default) and, if using Emacs 28 or later, set kill-buffer-delete-auto-save-files to non-nil (that would normally be t). As for the backup files ending in "~", those are created on saving a modified file by default and their creation is disabled by setting make-backup-files to a non-nil value.

All of this can be achieved, assuming you're using Emacs 28 or later, by adding

;; Disable backup files.
(setf make-backup-files nil)
;; Prompt to delete autosaves when killing buffers.
(setf kill-buffer-delete-auto-save-files t)

to your init file.

[-] vecksagos@alien.top 1 points 11 months ago

there is some ways to solve this, one is not creating this kind of files, not recommended, another way is changing the path are this is saved, setting `backup-directory-alist` and `auto-save-file-name-transforms` you can change where this files is stored, you can also use no-litterring to this.

[-] LeonardoZarkli@alien.top 1 points 11 months ago

use save-visited-file-mode (possibly, I'm using phone

[-] 7890yuiop@alien.top 1 points 11 months ago

Autosaves aren't needed once you've saved -- but emacs should already be removing them when you save your changes.

Backups are very specifically protecting you from the situation where the thing you saved was wrong. If you think that's useless, you haven't understood the purpose.

[-] SnooPets20@alien.top 1 points 11 months ago

That's what git is for, or just having undo-tree from which the file can be reverted to a previous state.

I tried to keep auto-saves and backup files in their own separate directory, since they always litter my projects which is annoying, but they just won't listen, I have to disable them.

[-] 7890yuiop@alien.top 1 points 11 months ago

That's what git is for

Even for files which are being tracked in version control, I don't agree that VCS always replaces backups. In some cases, yes; but backups are to protect me from data loss, and I want that protection in more situations than VCS gives me.

or just having undo-tree

I assume you mean "with a persistent undo record", which is another form of backup file, so sure -- whichever kind(s) of backup you prefer. Personally I believe I'd still want regular backups even if I used that -- if I can't trivially grep or compare old versions, I'd feel I'm missing a capability.

I tried to keep auto-saves and backup files in their own separate directory, since they always litter my projects which is annoying, but they just won't listen, I have to disable them.

I keep all backups in a separate directory, and I do not experience your problem, so that sounds to me like a fixable config issue.

this post was submitted on 20 Oct 2023
1 points (100.0% liked)

Emacs

310 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS