创建或重用现有的Emacs GUI框架 [英] Create or reuse existing Emacs GUI frame
问题描述
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屋!