本文介绍了如果在最后一个打开的框架内,Emacs C-x C-c将覆盖save-buffers-kill-terminal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了 emacs -daemon 来登录到Gnome,并使用与.cpp和.py文件相关联的 emacsclient ,以便我们在Eclipse中使用emacs在Eclipse中选择时用作这些文件的默认编辑器。这样我就可以得到一个很好的工作流程,结合了emacs的编辑功能和Eclipse的项目/构建管理和调试工具。



Anyhoo ...我想防止C-C C关闭我正在编辑的Emacs框架,如果它是唯一的Emacs框架在任何给定的时刻保持可见。



有没有一种查询守护程序Emacs进程的方法,以便找出有多少帧被打开,并覆盖默认的Cx Cc行为来做什么(if只有1帧剩余),从而确保始终至少有一个可见框架始终打开?



实现此行为的一些elisp可以添加对我的.emacs将是伟大的。

奖励积分:¬)
我有将vi,emacs等映射到emacsclient -c的别名,所以我总是得到emacs框架来来去往。进一步的改进将是Eclipse将文件直接发送到特定框架,例如第一帧用emacsclient -c打开。

解决方案

在emacs客户端内, save-buffers-kill-terminal 只能调用 server-save-buffers-kill-terminal ,所以你可能希望安装一个建议来不影响非客户端帧。 frame-list 函数cal用于内省当前存在的帧。它显然总是包含守护进程本身的一个条目,然后为每个开放框架包含一个条目。

 (defadvice server-save-缓冲区杀死终端(在dont-kill-last-client-frame激活周围)
(当(< 2(length(frame-list)))
ad-do-it))


I have setup emacs -daemon to run on login to Gnome and associated emacsclient with .cpp and .py files that I work with in Eclipse in order that emacs is used as my default editor for these files when selected within Eclipse. This way I can get a good work flow combining the editing capabilities of emacs and the project/build management and debugging facilities of Eclipse.

Anyhoo... I want to prevent C-x C-c from closing the Emacs frame I am currently editing in if it is the only Emacs frame remaining visible at any given moment.

Is there a way of querying the daemon Emacs process in order to find out how many frames are open and override the default C-x C-c behaviour to do nothing (if only 1 frame remaining) thereby ensuring there is always at least one visible frame open at all times?

Some elisp that implements this behaviour and that can be added to my .emacs would be great.

Bonus Points :¬) I have aliases that map vi, emacs etc... to "emacsclient -c", so I get emacs frames coming and going all the time in general. A further enhancement would be for Eclipse to send files that I want to edit directly to a specific frame e.g. the 1st frame opened with emacsclient -c.

解决方案

Within emacs-clients, save-buffers-kill-terminal only calls server-save-buffers-kill-terminal, so you might want to install an advice onto that to not affect non-client frames. The frame-list function cal be used to introspect the currently existing frames. It apparently always includes one entry for the daemon process itself, and then one for each open frame.

(defadvice server-save-buffers-kill-terminal (around dont-kill-last-client-frame activate)
  (when (< 2 (length (frame-list)))
    ad-do-it))

这篇关于如果在最后一个打开的框架内,Emacs C-x C-c将覆盖save-buffers-kill-terminal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:12