I want to save all open buffers to the relevant files (not an autosave file) at some regular interval (between 5 and 1 minutes).

This seemed like it was the correct solution:

; In ~/.emacs file make following changes.

(require 'auto-save-buffers)
(run-with-idle-timer 5 t 'auto-save-buffers) 

But eval-region on this code gives the following error message: eval-region: Cannot open load file: no such file or directory, auto-save-buffers. I run emacs 24.4.

Is the auto-save-buffers functionality no longer available? Is there some other way to do what I want? Is it actually the right tool for saving to the file I have opened rather than a separate autosave file?

I have seen auto-save-buffers-enhanced in the list of available packages (ie. M-x list-packages) and using that instead of auto-save-buffers might be an option, but I'd prefer a solution that only requires things that come with emacs by default.

1 Answer 1


I'm not actually sure what auto-save-buffers is/was; I can't see a reference to it (nor to it being removed).

However if I understand the question correctly, you could do this by ditching the require, and then replacing 'auto-save-buffers with (lambda () (save-some-buffers t)) in the timer call:

(run-with-idle-timer 5 t (lambda () (save-some-buffers t)))

See C-hf save-some-buffers RET for details.

Also, while it's probably obvious from the name run-with-idle-timer, note that your code doesn't do something "every N seconds". It triggers whenever Emacs has been idle for N seconds, and requires an intervening period of not-idle-ness before it can trigger again. In this case I imagine you're entirely happy with that behaviour, however.

  • Yes, this looks really good, but there is a problem with using it on my system: I'm using the GUI version of emacs in OSX and I get the native looking osx gui popup menu giving me the choice of wether I want to save this buffer, save all buffers, view changes etc. after five seconds, is there some way to override all interactive menus and just save the file?
    – Var87
    Commented Apr 19, 2015 at 14:15
  • 1
    That's weird... that argument to save-some-buffers means "don't ask". I can't replicate the problem (but also not using OSX). Which version of Emacs are you running?
    – phils
    Commented Apr 19, 2015 at 22:23
  • 24.4 (when I do M-x save-some-buffers I get the interactive cli menu in the bottom, by the way) ... this is about aquamacs but may be relevant: stackoverflow.com/questions/15254414/…
    – Var87
    Commented Apr 20, 2015 at 20:49
  • 1
    Well yes, you certainly will get that prompt (by default) if you call the command interactively via M-x or C-x s. You can bypass that by using a prefix argument: C-u. None of that is relevant to my answer, though, where we're calling the function directly in elisp with that argument pre-set. Did you actually try the code?
    – phils
    Commented Apr 20, 2015 at 22:40
  • Whoops, sorry about that. I did put some code in my .emacs, but I didn't do it correctly. Thanks for your solution, works perfectly now!
    – Var87
    Commented Apr 21, 2015 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.