4

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

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 按预期工作。您对可能发生的事情有任何想法吗?

非常感谢!-斯蒂芬

4

4 回答 4

5

您确定您使用的是正确的“emacsclient”二进制文件吗?你会想要/Applications/Emacs.app/Contents/MacOS/bin/emacsclient,默认情况下它不会在你的路径中。如果您只是从命令行调用 bare emacsclient,您将从emacsclientApple 发布的 Emacs 22.1 中获得。

如果你运行emacsclient --version并得到这个:

$ emacsclient --version
emacsclient 22.1

你没有得到正确的。

于 2009-08-14T09:39:41.520 回答
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 Client.app 图标替换 Emacs.app

http://www.cubiclemuses.com/cm/articles/2009/07/30/emacs-23-for-os-x/

但是 (1) 守护进程似乎没有加载我的许多 .emacs 自定义项,并且 (2) 当我退出 Emacs Client 时,它会完全退出 Emacs 并生成错误......

所以我的解决方案是使用上面定义的 bash 别名;将行 (server-start) 添加到我的 .emacs 文件中,并将 Emacs.app 图标添加到我的 OS X 扩展坞,以便我可以使用该图标或其中一个别名来启动 emacs 并打开新文件在运行的实例中,我还可以在 Emacs 中使用上面的别名或 Cx Cf(或 Cx b)。

于 2009-08-26T11:13:17.347 回答
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截至本文发布之时,它会推送。

于 2009-08-24T20:17:51.493 回答
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 框架......

希望这可以帮助。

于 2009-10-09T16:14:24.653 回答