Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: Often switching between Emacs and my IDE's editor, how to automatically 'synch' the files?

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).

like image 603
SyntaxT3rr0r Avatar asked Apr 24 '10 05:04

SyntaxT3rr0r


1 Answers

Add this to your .emacs:

(global-auto-revert-mode 1)
like image 71
Michael Mrozek Avatar answered Nov 19 '22 09:11

Michael Mrozek