5

When typing ls in my home directory, I amm greeted by a lot of this:

#%2Ascratch%2A#1399_po# #%2Ascratch%2A#14484YsZ# [...] 

I also have the following in my init.el

(defvar autosave-location (concat user-emacs-directory "data/autosave")) (setq auto-save-file-name-transforms `((".*" ,autosave-location t))) 

Why, then are the scratch autosaves not being sent to ~/.emacs.d/data/autosave and instead are being blasted around my file system? Ideally, I just want it to save to that folder, however if that can't be done, disabling autosave for *scratch* buffers entirely would suffice.

I believe this started with Emacs 24.4.

7
  • In your setup, is the *scratch* a file-visiting-buffer or a NON-file-visiting buffer? The default is the latter and thus is not subject to autosave. I like to kill the *scratch* when Emacs opens and prevent it from reappearing, and instead I use a custom file-visiting-buffer called .scratch. Whenever *scratch* would normally appear, I preempt it with a custom find-file /path/to/.scratch Commented Jan 26, 2015 at 19:21
  • It is not a file-visiting buffer (and I would rather it stay that way), which is why I'm confused. Commented Jan 26, 2015 at 19:24
  • Emacs does not, by default, autosave NON-file-visiting buffers. For example, a *Help* buffer does not get autosaved, nor does a *Backtrace* buffer. Commented Jan 26, 2015 at 19:25
  • Apparently, it will if you enable auto-save-mode in the buffer. Commented Jan 26, 2015 at 19:27
  • See also stackoverflow.com/questions/8849661/… Commented Jan 26, 2015 at 21:17

1 Answer 1

5

You'll notice that you're using a variable called auto-save-file-name-transforms. Since *scratch* has no filename, it falls back to autosaving in default-directory.

For the *scratch* buffer, or any other buffers like this with no filename, you can use:

(setq-local default-directory "~/.emacs.d/data/autosave") 

Edit: I see that you don't really care about autosaving scratch buffers. Can I ask how you enable auto-save-mode in your init? You should use:

 (setq-default auto-save-default t) 

And not something like a hook with (auto-save-mode 1), because the variable only enables it for file-visiting buffers, while a hook could potentially enable it for buffers where you don't want it.

1
  • Yes and yes. I suppose I'll just disable it entirely for *scratch* then. Commented Jan 26, 2015 at 19:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.