My init file includes

(setq global-auto-revert-mode t)

and I can confirm it's true with C-h v. But I still have to manually revert all my files with revert-buffer whenever I change git branches. I even get as far as trying to save and getting the "file changed on disk" prompt. Any suggestions for how to debug this?

  • 1
    Try putting this in your init instead: (global-auto-revert-mode 1) Commented Apr 27, 2015 at 17:38
  • @kaushalmodi no luck (I would have been really surprised)
    – djechlin
    Commented Apr 27, 2015 at 17:45
  • Could it be a matter with auto-revert-interval? I use it and it works for me, excepting files over tramp. Commented Apr 27, 2015 at 17:55
  • Looks like a bug that crept in in 24.5 and 25.0. @SwarnenduBiswas are you on emacs 24.4? Commented Apr 27, 2015 at 17:58
  • @djechlin I verified using emacs -Q sessions that auto revert mode does not work on emacs 24.5 and 25.0 but works fine on 24.4. What version are you on? Commented Apr 27, 2015 at 17:59

3 Answers 3


A minor mode is not enabled/disabled by setting a variable. The minor mode variable should be used to check the "mode enabled" status, not to set the mode state. If its value is t, the minor mode is on, else the mode is off.

See the below snippets to see how to control any minor mode. Replace MINOR-MODE-NAME with the actual minor mode name you are dealing with (global-auto-revert-name as is the case in the question).

Enabling a minor mode

Using elisp


;; or

Based on a hook activation


Disabling a minor mode

Using elisp


;; or

Based on a hook activation

(add-hook 'SOME-HOOK (lambda () (MINOR-MODE-NAME -1)))

Toggling a minor mode



Using a key binding

(global-set-key (kbd "<KEY>") #'MINOR-MODE-NAME)

Using elisp (non-interactively)



  • I've run into some modes where you have to pass t or nil instead of numbers. Commented Sep 28, 2016 at 18:13
  • @JosephGarvin It might be worthwhile to find out which those modes are.. and may be file a bug report to fix that inconsistency if in fact they are defined as minor modes? Commented Sep 28, 2016 at 18:20
  • The answer is very abstract. I don't know how to use it. Commented Mar 3, 2019 at 16:57
  • @ctrl-alt-delor What's the minor mode you're trying to control that led you to this answer? Commented Mar 5, 2019 at 12:42
  • The one in the question. (global-auto-revert-mode) Commented Mar 6, 2019 at 8:11

You don't set the variable using setq, you call the function:

  • I'm wondering how that is different from (global-auto-revert-mode 1). Also if you are adding this to your init, you shouldn't even need that argument. Just (global-auto-revert-mode) should suffice. Check out Xah's blog post for more info. Commented Apr 27, 2015 at 18:57
  • As with any mode defined using define-global-minor-mode, the only valid values are numbers, nil, and toggle. The fact that t works is only due to the fact that prefix-numeric-value doesn't choke on it and treats it like 1. Commented Apr 27, 2015 at 20:57
  • @Lindydancer Yeah, I'd like djechlin to clarify why passing 1 as argument did not work. Commented Apr 27, 2015 at 21:14
  • @kaushalmodi I was still setq-ing - I thought you were just changing t to a 1, I overlooked the change from setq to calling the function.
    – djechlin
    Commented Apr 27, 2015 at 21:26
  • @djechlin Thanks for clarifying. But for the sake of clarify and consistency, it is recommended to pass it an arg 1 or nothing if you want to enable that minor mode from elisp in your init. Commented Apr 27, 2015 at 21:31

auto-revert only works for buffers which are not modified. So at least for the "trying to save and getting the file changed on disk prompt" the behavior you describe is normal.

  • I opened the same file simultaneously in an emacs 25.0 instance and emacs 24.4 instance (both with -Q option) and did M-x global-auto-revert-mode in both. From terminal when I echoed some string ( echo 1234 >> somefile.txt) to that file, only the emacs 24.4 buffer auto-reverted. Commented Apr 27, 2015 at 18:04
  • Then please M-x report-emacs-bug.
    – Stefan
    Commented Apr 27, 2015 at 18:08
  • Done! bug # 20441 Commented Apr 27, 2015 at 18:19
  • The "bug" got resolved by itself.. was probably an issue with glib on my system. Commented May 8, 2015 at 13:04

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.