4

I have a file (my org-mode todo list) that I keep in sync across my machines, and I often leave it open in Emacs. Thus, I placed the following in my .dir-locals.el in the same folder as this file:

((org-mode . ((auto-revert-mode . 1))))

I know it has taken effect, because my modeline shows ARev, among others.

However, the file never auto-reverts. Even if I have been away from my machine all day, making changes on another machine and syncing them, I don't see the changes. The sync was successful though, because as soon as I try to type in that buffer, I see

<me>.org changed on disk; really edit the buffer? (y, n, r or C-h) 

I can hit r at that point to revert the buffer, but I would rather just have that happen automatically.

Why is my file not being auto-reverted? What can I do to determine the cause of this problem?

I am running Emacs 24.4, and I have seen this behavior both on Windows 8 and on Debian Jessie.

Edit: Forgot to check this originally, but the problem doesn't happen when I run emacs -Q. This means that it is caused by something in my init file.

Edit 2: The problem only occurs when using the .dirs-locals file. If I open a file, do M-x auto-revert-mode, and edit it elsewhere, it reverts automatically, even using my full init file.

Edit 3: I was mistaken: The problem does occur when running emacs -Q if I use the .dirs-locals.el posted above. So it is not a problem with my init file.

  • 1
    "What can I do to determine the cause of this problem?" Start by running emacs -q and see if that still happens. – Malabarba Jan 10 '15 at 1:39
  • Right, duh. *facepalm* I'll report back when I've done so. – Scott Weldon Jan 10 '15 at 1:56
  • This problem does not happen with emacs -Q. Looks like I have some binary searching to do... – Scott Weldon Jan 13 '15 at 16:29
  • Correction: the problem does happen with emacs -Q. See updated question. – Scott Weldon Jan 18 '15 at 0:03
  • Shouldn't it be t instead of 1 as value for the mode? – wasamasa Jan 18 '15 at 8:02
2

To enable a minor-mode you have to use the eval keyword as explained in Specifying File Variables

To enable or disable a minor mode in a local variables list, use the eval keyword with a Lisp expression that runs the mode command.

While that isn't explicitly mentioned in Per-Directory Local Variables it does apply here to - after all directory variables are just a convenient way of specifying file-local variables.

((org-mode . ((eval . (auto-revert-mode 1)))))
  • Thanks! I guess I either didn't read the instructions close enough, or the instructions I found were faulty. (I can't seem to find them again to confirm which.) – Scott Weldon Jan 18 '15 at 16:32

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.