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.

Scott Weldon
  • 2,695
  • 1
  • 17
  • 31

1 Answers1

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)))))
tarsius
  • 25,298
  • 4
  • 69
  • 109
  • 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