创建或重用现有的Emacs GUI框架 [英] Create or reuse existing Emacs GUI frame

查看:145
本文介绍了创建或重用现有的Emacs GUI框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设Emacs服务器正在运行,我想要 emacsclient< file> 创建一个新的框架(如 -c )当没有现有的帧或重用现有的帧时,有一个。换句话说,只有当没有现有的框架时,我才想要 -c 这是可能的吗?

解决方案

我用一套shell脚本解决了我的问题。



my_emacs

 #!/ bin / sh 
emacs24-x $ @ 1> / dev / null 2> / dev / null&

您可能需要将emacs24-x更改为指向您的X11 emacs的内容。



my_emacsclient

 #!/ bin / sh 
emacsclient $ @ 1> ; / dev / null 2> / dev / null || my_emacs

通过〜/ bin等将两个文件添加到PATH。



在我的.emacs中,我还添加了以下行

 加载服务器)
(除非(server-running-p)(server-start))

还可以更改一些环境变量并选择添加一个别名

  export ALTERNATE_EDITOR =my_emacs
export EDITOR = my_emacsclient -n
export SUDO_EDITOR =my_emacsclient
...
alias e =$ EDITOR

当您在shell中运行 e 时,应创建或重新使用现有的GUI框架。另外,运行 e< filename> 在一个帧中打开该文件;您还可以将其他标志(例如 -n )传递给 e



对于其他应用程序(例如您的文件管理器)中的相同行为,您还应该更改Emacs .desktop文件(对于我来说,这是 /usr/share/applications/emacs24.desktop )运行 my_emacs



更改 emacs 到 my_emacsclient 通过基于Debian的(?)发行版中的替代系统。


Assuming an Emacs server is running, I want emacsclient <file> to either create a new frame (like -c) when there is no existing frame or reuse an existing frame when there is one. In other words, I want the -c only when there is no existing frame. Is that possible?

解决方案

I solved my problem with a set of shell scripts.

my_emacs

#!/bin/sh
emacs24-x $@ 1> /dev/null 2> /dev/null &

You may need to change emacs24-x to something that points to your X11 emacs.

my_emacsclient

#!/bin/sh
emacsclient $@ 1> /dev/null 2> /dev/null || my_emacs

Add both files to you PATH via ~/bin or the like.

In my .emacs I also added the followings lines

(load "server")
(unless (server-running-p) (server-start))

Also change some environment variables and optionally add an alias

export ALTERNATE_EDITOR="my_emacs"
export EDITOR="my_emacsclient -n"
export SUDO_EDITOR="my_emacsclient"
...
alias e="$EDITOR"

When you run e in your shell it should create or resuse an existing GUI frame. Also, running e <filename> opens that file in a frame; you can also pass other flags like -n to e.

For the same behaviour in other applications (say your file manager), you should also change the Emacs .desktop file (for me that's /usr/share/applications/emacs24.desktop) to run my_emacs.

It might also be a good idea to change emacs to my_emacsclient via the alternatives system in Debian-based (?) distributions.

这篇关于创建或重用现有的Emacs GUI框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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