2

Problem

When the file underlying buffer foo is changed, Emacs shows Reverting buffer 'foo'. in the echo area.

The problem is that it will do this even when I'm working in the minibuffer, and the message will simply overlay whatever I have there, making seeing what I'm working on impossible.

Question

Is there any way to change this behavior?

Steps to reproduce the behavior

  1. Outside of emacs, create a file: echo test > foo
  2. emacs -Q
  3. M-: (global-auto-revert-mode)
  4. M-: (find-file "foo")
  5. M-x switch-to-buffer *scratch*
  6. M-x to open the minibuffer, and keep it open.
  7. Outside of Emacs, append something to the file: echo bar >> foo

At this point you should see the message in the minibuffer saying Reverting buffer 'foo'.

2

I think you could add something like this to your initialization:

(advice-add
 'auto-revert-handler
 :around (lambda (orig-fun &rest args)
           (let ((auto-revert-verbose (not (minibufferp (window-buffer)))))
              (apply orig-fun args))))

Based on https://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Misc.html#Minibuffer-Misc, you can check whether the current buffer is a minibuffer by calling the minibufferp function as you enter the auto-revert-handler function to decide whether to temporarily set auto-revert-verbose to nil.

  • In my post above I've just added detailed instructions on how to reproduce this issue. After activating (global-auto-revert-mode) (step 3) I've eval'ed your advice and I'm still getting the same message even while having the minibuffer open with M-x. – izkon Dec 21 '18 at 2:57
  • 1
    Thanks for the detailed repro instructions. I was able to reproduce it and have updated my answer above to avoid the message. Even though the doc for minibufferp says it uses the current buffer if no argument is sent, I needed to pass it the result of (window-buffer) – Gina White Dec 21 '18 at 16:37
1

You most probably have set the global autorevert mode on using this form:

(global-auto-revert-mode)

You can stop it sending messages to minibuffer by setting

(setq auto-revert-verbose nil)

Set it back to t if and when you would like to be notified again.

  • But I don't want to turn it off wholesale. I want to turn it off only when I'm working in the minibuffer, and I might get in to the minibuffer from all sorts of different commands. How would I deactivate the notification only when I'm working in the minibuffer? – izkon Dec 20 '18 at 10:39

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.