My c-x c-s Muscles Are Getting Tired.
I've used some of the online office apps a bit, such as Google Docs, and I really like that you don't have to continually save your work. They take care of that for you. The blogger web interface that I'm using to type this entry does the same thing. A few people I work with are big Microsoft One Note fans, and it doesn't even have a save button.
I believe it's time for emacs to save my files for me. I have a c-x c-s twitch that I'd like to get rid of. I hunted around a bit, thinking that I couldn't have been the first emacs user to think of this, but I didn't have much luck. It turns out that Emacs does save your work for you automatically, but it's not quite what I'm looking for. It saves to separate back up files that you have to use special commands to recover information from, and it still bugs you about saving whenever you do things like compile or exit. Of course I want to save my work!
Is there really no good auto-save feature for emacs?
Comments
This solution is *terrible*, sorry.
I think there might be a way to check buffer-file-name and run the hook only then; I'll have to try. I'll tell you if I find a solution!
I'm trying this out for now (also posted on the wiki):
(defun save-buffer-if-visiting-file (&optional args)
"Save the current buffer only if it is visiting a file"
(interactive)
(if (buffer-file-name)
(save-buffer args)))
(add-hook 'auto-save-hook 'save-buffer-if-visiting-file)
Seems to do the trick so far.
I haven't tried the run-with-idle-timer suggested on the wiki. Seems like, since auto-save is already running on a timer that piggy-backing off of that is better. I could be wrong.
[It was "terrible" without the (if (buffer-file-name), where it would start prompting on scratch buffers, completion buffers, even the minibuffer. With your modification, it works well.]