Emacs:经常在 Emacs 和我的 IDE 编辑器之间切换,如何自动“同步"文件? [英] Emacs: Often switching between Emacs and my IDE's editor, how to automatically 'synch' the files?

查看:20
本文介绍了Emacs:经常在 Emacs 和我的 IDE 编辑器之间切换,如何自动“同步"文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常需要对一些文件执行一些 Emacs 魔法,我需要在我的 IDE (IntelliJ IDEA) 和 Emacs 之间来回切换.

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.

当在 Emacs 下进行更改时(以及在我保存文件之后)并且我回到 IntelliJ 时,更改会立即出现(如果我没记错的话,我将 IntelliJ 配置为 "总是在修改时重新加载文件在磁盘上检测到 或类似的东西).我什至不需要重新加载:只要 IntelliJ IDEA 获得焦点,它就会立即重新加载文件(因此我可以立即访问我从 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).

到目前为止,非常好.

然而,相反",它还不起作用.

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

我可以配置 Emacs 以便每次更改磁盘上的文件时都会重新加载它吗?

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

或者制作 Emacs,每次获得焦点"时,验证当前打开的任何文件是否已在磁盘上被修改?

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

我知道我可以在 Emacs 下开始修改缓冲区,它会立即警告它已被修改,但我宁愿让它立即执行(例如,如果我使用我的 IDE 进行一些大的更改,当我回到 Emacs,我看到的可能根本不再是文件包含的内容,而且有点奇怪).

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

推荐答案

将此添加到您的 .emacs:

(global-auto-revert-mode 1)

这篇关于Emacs:经常在 Emacs 和我的 IDE 编辑器之间切换,如何自动“同步"文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆