5
(setq revert-without-query '(".*"))

With this extra line in .emacs file, i have configured emacs to revert buffers without any prompt. It doesn't prompt for clean buffers but when the buffer has unsaved changes, it prompts for confirmation.

So, how to use revert-buffer with absolutely no prompts (no matter if buffer is clean (or) dirty)?

  • What's your question? With no question posed, it risks being closed... – Drew Mar 27 '15 at 16:39
  • changed!!!!!!!! – Madhavan Mar 27 '15 at 16:45
  • OK. The answer is (revert-buffer t t). – Drew Mar 27 '15 at 16:45
  • (setq revert-without-query '(".*")) manual says, this line must turn off the prompts, but it didn't? are we giving wrong params to the variable? – Madhavan Mar 27 '15 at 16:47
  • 1
    revert-without-query determines which buffers will be reverted without querying, It does not turn off querying. More precisely, it reverts the file without querying if the file has changed on disk and you have not edited the buffer. If you have edited the buffer then it has no effect. – Drew Mar 27 '15 at 17:12
7

Not sure what you're asking. But FWIW, I use this, and I bind it to <f5>:

(defun revert-buffer-no-confirm ()
  "Revert buffer without confirmation."
  (interactive) (revert-buffer t t))

Note that you probably do not want to redefine or advise revert-buffer. You probably want to change the behavior only for interactive calls (there are plenty of Lisp calls to revert-buffer, and you don't want to affect their behavior).

That's why I define a separate command, which I use when I want to revert without being prompted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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