如何在 Emacs 中失去焦点时自动保存文件
是否可以配置Emacs,以便在emacs窗口丢失时保存所有文件 重点?
Is it possible to configure Emacs, so that it saves all files when the emacs window loses
focus?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我向 Gnu Emacs 24.4 添加了焦点钩子。
它们被称为
focus-in-hook
和focus-out-hook
。您可以添加
到 .emacs 文件中,它应该在失去焦点时保存所有文件。
I added focus hooks to Gnu Emacs 24.4.
They are called
focus-in-hook
andfocus-out-hook
.You can add
to your .emacs file and it should save all files on loss of focus.
我使用这个,只有当 emacs 在 X 下运行时它才会工作(就像在 ubuntu 中一样)。
I use this, it will only work if emacs is running under X (like it probably would in something like ubuntu).
不确定这是否是您想要的。
来自: http://www.dribin.org/dave /blog/archives/2003/09/10/emacs/
编辑:它似乎只在 XEmacs 中工作
Not sure if this is what you want.
From: http://www.dribin.org/dave/blog/archives/2003/09/10/emacs/
EDIT: It only seems to work in XEmacs
在这种情况下,不要切换到浏览器应用程序,而是命令 Emacs 加载浏览器应用程序(
Cc Cv
或Mx browser-url-of-buffer
)。 使用此方法,您可以编写自己的函数来保存缓冲区,然后启动浏览器,例如:并将其挂钩到方便的绑定。
或者,您仍然可以使用
html-autoview-mode
,每次保存缓冲区时,都会自动将文件加载到您喜欢的浏览器中。In that case, instead of switching to the browser application, order Emacs to load the browser application (
C-c C-v
orM-x browse-url-of-buffer
). With this method, you can write your own function that saves the buffer and then brings the browser up, like:And hook it to a convenient binding.
Or you can still use the
html-autoview-mode
that each time you saves the buffer, automatically loads the file into your favorite browser.您可以使用“自动保存间隔”来保存您输入的每 n 个字符。 我的设置为 100。那么大约每 2-3 行代码吧?
这并没有回答你原来的问题; 这只是实现类似目标的一种方法。
You can use `auto-save-interval' to save every n characters you type. Mine is set to 100. So about every 2-3 lines of code, maybe?
This doesn't answer your original question; it's just a way to achieve something similar.