Emacs 23,emacsclient参数是什么?

4
我最近在OS X Leopard上安装了Emacs 23,并尝试使用Emacs服务器。我已经尝试过两种方法:(1)将(server-start)放入我的.emacs文件中,以及(2)在终端上运行emacs --daemon(在单独的试验中;不同时进行)。无论哪种情况,在我已经打开一个emacs frame并尝试使用emacsclient -t、-tty或-nw在OS X终端中打开另一个文件时,该文件总是在现有的frame中打开而不是像描述中一样在终端中打开:

http://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html

http://emacs-fu.blogspot.com/2009/02/emacs-daemon.html

然而,emacsclient -c按预期工作。您有任何想法可能发生了什么?

非常感谢!-Stephen


当您使用“emacs -Q”启动主emacs,然后在其中执行(server-start),然后运行“emacsclient -nw”时会发生什么? - Yoo
感谢您的回复!但是同样的事情,emacsclient -nw somefile会在emacs -Q创建的相同框架中打开somefile... - hatmatrix
你或许可以在emacs-devel@gnu.org邮件列表中得到答案,或者通过Emacs M-x report-emacs-bug提交Bug。 - Trey Jackson
4个回答

5
感谢大家的建议和回复 - 我认为我的解决方案是在我的 .bash_profile 文件中添加以下内容:
## --- emacs ---
alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs'

## --- emacs client ---
## adapted from http://philipweaver.blogspot.com/2009/08/emacs-23.html

# start a windowed frame
alias ec="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n -c -a /Applications/Emacs.app/Contents/MacOS/Emacs"

# start a terminal frame
alias em="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -t -a /Applications/Emacs.app/Contents/MacOS/Emacs -nw"

# do not start a new frame
alias ea="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n -a /Applications/Emacs.app/Contents/MacOS/Emacs"

我尝试使用emacs --daemon,并按照这里建议的方法,将Emacs.app替换为Emacs Client.app图标。但是,(1)守护程序似乎没有加载我的许多.emacs自定义和(2)当我退出Emacs Client时,它会退出整个Emacs并生成错误...
因此,我的解决方案是使用上面定义的bash别名;在我的.emacs文件中添加(server-start)行,并将Emacs.app图标添加到我的OS X dock中,以便我可以使用图标或别名之一启动emacs,并在运行实例中打开新文件我也可以使用上面的别名或Emacs中的C-x C-f(或C-x b)。

5
你确定你使用的是正确的 'emacsclient' 二进制文件吗?你需要使用 /Applications/Emacs.app/Contents/MacOS/bin/emacsclient,默认情况下它不会在你的路径中。如果你只从命令行调用裸的 emacsclient,你会得到 Apple 发布的 Emacs 22.1 中的 emacsclient
如果你运行 emacsclient --version 命令并得到以下结果:
$ emacsclient --version
emacsclient 22.1

你没有得到正确的那个。

谢谢...我得到了emacsclient 23.1,所以这似乎不是问题的原因。 - hatmatrix

2
如果您安装了二进制文件Emacs.app,您应该使用包中的可执行文件。例如:
$ /Applications/Emacs.app/Contents/MacOS/Emacs -nw

包内还有一个bin目录:

$ cd /Applications/Emacs.app/Contents/MacOS/bin
$ ls -la
total 1488
drwxr-xr-x@ 19 ayman   admin     646 Aug 16 02:33 .
drwxr-xr-x@  5 ayman   admin     170 Aug 16 02:33 ..
-rwxr-xr-x@  1 ayman   admin   39704 Aug 16 02:33 b2m
-rwxr-xr-x@  1 ayman   admin  236412 Aug 16 02:33 ctags
lrwxr-xr-x   1 ayman   admin      18 Aug 24 12:54 cvtmail -> ../libexec/cvtmail
lrwxr-xr-x   1 ayman   admin      21 Aug 24 12:54 digest-doc -> ../libexec/digest-doc
-rwxr-xr-x@  1 ayman   admin  122124 Aug 16 02:33 ebrowse
-rwxr-xr-x@  1 ayman   admin   72188 Aug 16 02:33 emacsclient
-rwxr-xr-x@  1 ayman   admin  232344 Aug 16 02:33 etags
lrwxr-xr-x   1 ayman   admin      19 Aug 24 12:54 fakemail -> ../libexec/fakemail
-rwxr-xr-x@  1 ayman   admin    7288 Aug 16 02:26 grep-changelog
lrwxr-xr-x   1 ayman   admin      15 Aug 24 12:54 hexl -> ../libexec/hexl
lrwxr-xr-x   1 ayman   admin      19 Aug 24 12:54 movemail -> ../libexec/movemail
lrwxr-xr-x   1 ayman   admin      18 Aug 24 12:54 profile -> ../libexec/profile
-rwxr-xr-x@  1 ayman   admin    3977 Aug 16 02:26 rcs-checkin
lrwxr-xr-x   1 ayman   admin      18 Aug 24 12:54 rcs2log -> ../libexec/rcs2log
lrwxr-xr-x   1 ayman   admin      21 Aug 24 12:54 sorted-doc -> ../libexec/sorted-doc
lrwxr-xr-x   1 ayman   admin      28 Aug 24 12:54 update-game-score -> ../libexec/update-game-score
lrwxr-xr-x   1 ayman   admin      17 Aug 24 12:54 vcdiff -> ../libexec/vcdiff
$ 

如果您正在使用命令行,可以使用MacPort更新终端版本:

$ sudo port install emacs-app

在此发布时,它将emacs-app@23.0.0_NS-9.0rc3_1推送出去。


谢谢。我已经通过bash启动文件中的别名命令将“emacs”和“emacsclient”映射到Emacs.app二进制文件。我不想在我的机器上有重复的emacs副本,但这可能是打开多个emacs实例的方法... - hatmatrix

1

我不经常在OS X上使用emacs,但我已经开始在启动/窗口管理器启动时只是启动emacs --daemon,并使进程在后台运行。这不是一个选项吗?

我在我的*shrc文件中使用以下别名:

EDITOR='emacsclient -t'
alias e='emacsclient -n'
alias ew='emacsclient -c -n'
alias et='emacsclient -t'

虽然我必须承认,我大多数时候都是通过我的窗口管理器中的绑定来生成emacs框架(您可以考虑类似QuickKeys或Quicksliver的东西),触发:emacsclient -c -nemacs -n -e'(make-remember-frame)',这将触发一个新的org-remember框架...

希望这有所帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接