This does not answer your question as posed, so feel free to ignore or downvote.
I doubt that you really want Emacs to save all buffers to disk, including all of the internal, normally invisible buffers. Why would you want that?
It's not about the disk space. It's about the noise. Do you really want to dig stuff out of a directory where your important files might be mixed in with such stuff? Or do you want to fish for the occasional pearl in a temp directory (whose purpose is to stash noise)?
Buffers that have names like *...*
(not starting with a space char) are typically output-only (e.g., *info*
) or for temporary interaction (e.g. *scratch*
). For such buffers, my recommendation would be to leave things as they are. You can always save any such buffer on demand, using C-x C-w
, if you really need to.
Which brings me to what I suspect is your real use case: "buffer[s] for taking notes, etc.". The answer here is to use C-x C-f
instead of C-x b
. IOW, yes, visit them as file buffers. If you never save the buffer there is no file created - except an autosave file, which is probably just what you want and need.
When you visit a buffer as a file buffer, you automatically control which major mode is used by default (using auto-mode-alist
). This is just as important for note-taking as it is for programming code.
In particular, I would suggest that if you use *scratch*
for temporary Lisp interaction, you might reconsider. Many users (including me) have found that it helps to instead use C-x C-f foo.el
(or whatever other *.el
file name). One reason is that you get autosave files for free (and backup files, if you save the buffer). Another reason is that you get Emacs-Lisp mode instead of Lisp interaction mode. A third reason is that yes, you might well want to save your "temporary" work. And as you say, disk space is cheap.
What about #4 conflicting with what I said in #1? You don't want to mix files of temporary scribbles with important files, and you don't want to fish the occasional pearl out of a directory of temp files. The answer here is that it's up to you to organize things so that this effect is minimized. Working with such scratch files in a particular directory can help, as can using a naming convention (esp. a prefix) that helps you distinguish such files.
Another thing that can help: Dired. You can use ~
and #
to mark backup and autosave files for deletion (then x
to delete them). And if you use a naming convention for your presumably temporary, scratch files then you can use %
or similar to mark all of them for deletion. You can even execute a function periodically to clean out such files. And you can easily rename any that you really want to keep longer.
So my advice is to perhaps reconsider how you're interacting with such temporary, note-taking buffers. Consider using file buffers, which get autosaved. In sum, use C-x C-f foobarbaz.txt RET
(or .el
or whatever) instead of C-x b foobarbaz RET
.
save-some-buffers
has an option for non-file-visiting buffers -- perhaps you can marry that with a timer and a custom function, whichsave-some-buffers
accepts as an argument -- see the doc-string. There is probably already something that does this -- e.g., Google"save-some-buffers" auto save
etc.; and, see the functionauto-save-mode
insimple.el
for some ideas. My recollection is that auto-save-buffers-enhanced may have done something like this: github.com/kentaro/auto-save-buffers-enhanced/blob/master/…deft
package.