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

北战南征 提交于 2019-11-29 02:56:32

问题


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


回答1:


Add this to your .emacs:

(global-auto-revert-mode 1)


来源:https://stackoverflow.com/questions/2703296/emacs-often-switching-between-emacs-and-my-ides-editor-how-to-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!