10

I very often need to do some Emacs magic on some files and I need to go back and forth between my IDE (IntelliJ IDEA) and Emacs.

When a change is made under Emacs (and after I've saved the file) and I go back to IntelliJ the change appears immediately (if I recall correctly I configured IntelliJ to "always reload file when a modification is detected on disk" or something like that). I don't even need to reload: as soon as IntelliJ IDEA gains focus, it instantly reloads the file (and I hence have immediately access to the modifications I made from Emacs).

So far, so very good.

However "the other way round", it doesn't work yet.

Can I configure Emacs so that everytime a file is changed on disk it reloads it?

Or make Emacs, everytime it "gains focus", verify if any file currently opened has been modified on disk?

I know I can start modifying the buffer under Emacs and it shall instantly warn that it has been modified, but I'd rather have it do it immediately (for example if I used my IDE to do some big change, when I come back to Emacs what I see may not be at all anymore what the file contains and it's a bit weird).

SyntaxT3rr0r
  • 27,745
  • 21
  • 87
  • 120

1 Answers1

17

Add this to your .emacs:

(global-auto-revert-mode 1)
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
  • @Michael Mrozek: Works flawlessly, thanks a lot... Btw I tried Googling before formulating my question my Google-fu ain't not always strong : ) – SyntaxT3rr0r Apr 24 '10 at 16:55
  • 1
    For those who want less of a "blanket" approach - You may want to `(add-hook 'c-mode-hook 'turn-on-auto-revert-mode)` or etc, for whatever modes you use. – Cheeso Apr 26 '10 at 19:23