OS X 上的 Emacs 23 - 使用多个实例还是 emacsclient?
我想知道是否有人对在 OS X 上设置 emacs 23 有任何建议。我已经使用 Linux/Windows 一段时间了,我只会打开许多 emacs 实例,它们是独立的 - 例如,我可以在不同的框架中有两个单独的文件,每个文件都运行自己的 R、Python 和/或 shell。 我认为这是令人皱眉的(?) - 但它使每个脚本文件的工作目录保持独立,这是我喜欢的。
我知道在 .emacs 文件中设置(服务器启动)有一些优势,并且调用“emacsclient”而不是“Emacs”现在是首选方式(?)。 我发现这个线程有助于通过 Applescript 实现这一点: Emacs 23、OS X、multi-tty 和 emacsclient
但是我想知道这是否是唯一的方法 - 当我在 OS X 上打开两个 emacs 实例时,它给了我错误:
** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x3803, name = 'org.gnu.Emacs.ServiceProvider'
但打开一个新框架允许我编辑文件。 我知道对于 OS X 上的 vim 有一个叫做“mvim”的东西,它允许启动多个 vim 实例,但是 emacs 有类似的东西吗? 很抱歉这个冗长的问题 - 总之,我想这些是我想征求您的专业知识的问题:
(1)“emacsclient”是专家的方式吗? (2) 如果不一定,有没有办法让 emacs 23 的多个实例(不仅仅是框架)在 OS X 上运行?
谢谢!
I wonder if anyone has any recommendations as to setup of emacs 23 on OS X. I have been using Linux/Windows for a while and there, I would just open many instances of emacs and they were self-contained - for instance, I could have two separate files in separate frames, each with their own R, Python, and/or shell running. I think this is frowned upon(?) - but it kept the working directory for each script file separate, which I loved.
I understand there is some advantage to setting (server-start) in my .emacs file and calling 'emacsclient' rather than 'Emacs' is now the preferred way(?). I found this thread which facilitates this to occur through an Applescript:
Emacs 23, OS X, multi-tty and emacsclient
But I wonder if this the only way to go about it - when I open two emacs instances on OS X it gives me the error:
** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x3803, name = 'org.gnu.Emacs.ServiceProvider'
but opens a new frame allows me to edit files. I understand that for vim on OS X there is something called 'mvim' which allows multiple instances of vim to be launched, but is there something similar for emacs? Sorry for the long-winded question - in summary, I guess these are the questions for which I would like to solicit your expertise:
(1) Is 'emacsclient' the way of the experts, and
(2) if not necessarily, is there a way to get multiple instances of emacs 23 (not just frames) running on OS X?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您想要 emacs 的多个实例(而不是框架),请在终端提示符下使用以下命令:
If you want multiple instances (and not frames) of emacs use the following at the terminal prompt:
让我间接回答你的问题。
如您所知,
emacsclient< /code>
提供一项服务,允许用户在现有 Emacs 中打开来自 Emacs 外部的文档。 这是专家的“方法”吗? 取决于专家。 我是 Emacs 的重度用户,但从不使用
emacsclient
。 为什么? 因为我从一开始就没有离开 Emacs。 我运行的所有 shell 都在 Emacs 内(使用自制的 screen 包),我读到Emacs 中的邮件等。我从来没有理由在命令行中输入emacsclient
。您的使用模型似乎是您更喜欢运行多个 Emacsen,这样可以更轻松地跟踪一起使用的进程和文件。 这是有道理的。 如果您愿意,您可以在一个 Emacs 中完成这一切,但这可能需要对您的使用模型进行一些更改,或者进行一些自定义以帮助管理多个解释器/shell/任何您喜欢的内容。
因此,如果您喜欢运行多个 Emacs 实例,那么请务必继续这样做。
关于第二个问题,似乎有
.emacs 中的 (server-start)
引起了问题 - 可能是因为两个 Emacsen 尝试使用同一端口时发生冲突。 查看文档以启动服务器,也许可以从 .emacs 中删除该行,然后使用--daemon
命令行选项启动服务器一次。然后,在命令行中,您可以选择是否要启动新的 emacs(通过输入
emacs
)或连接到您启动的服务器(通过输入emacsclient
)。Let me answer your questions indirectly.
As you know,
emacsclient
provides a service, allowing users to open documents from outside Emacs in an existing Emacs. Is this "the way" of the experts? Depends on the expert. I'm a heavy user of Emacs, but never useemacsclient
. Why? Because I never leave Emacs in the first place. All the shells I run are inside Emacs (using a home-brewed screen package), I read mail in Emacs, etc. There's never a reason for me to typeemacsclient
at a command line.Your usage model seems to be that you prefer having multiple Emacsen running, making it easier to keep track of which processes and files are being used together. And that makes sense. You could do it all in one Emacs if you wish, but it might take some changes in your usage model, or some customizations to help manage multiple interpreters/shells/whatever to your liking.
So, if you like multiple instances of Emacs running, then by all means, continue doing so.
Regarding the second question, it appears as though having
(server-start)
in your .emacs is causing problems - likely because there's a conflict with two Emacsen trying to use the same port. Check out the documentation for starting the server, and perhaps remove that line from your .emacs, and instead start the server once by using the--daemon
command line option.Then, at the command line, you have the choice of whether you want to start a new emacs (by typing
emacs
) or connect to the server you started (by typingemacsclient
).下面是一个简单的 shell 脚本,它将启动一个单独的实例,打开 Emacs 窗口并为其提供焦点:
注意:
识别要激活的框架,但上面的脚本正确
对我来说。
Here's a simple shell script that will start a separate instance, raise the Emacs window and give it focus:
Notes:
identify the frame to activate, but the above script does the right
thing for me.
我在 .emacs 中使用类似的内容,仅在服务器尚未运行时调用服务器启动:
然后对我的 .zshrc 进行一些更改,以便我可以从 shell 中无意识地运行
ec
作为我的编辑器命令:I use something like this in my .emacs to only call server-start if the server isn't already running:
Then a couple of changes to my .zshrc so that I can mindlessly run
ec
as my editor command from the shell:我创建了这个 shell 脚本,它允许您同时打开多个 emacs 实例。
要安装,只需将
emacs-ide
脚本复制到/usr/local/bin/
或$PATH
上的任何目录。您可以运行具有多个文件或目录的多个 Emacs 实例,如下所示:
该脚本还设置窗口的名称以匹配正在编辑的目录(项目)或文件。
I have created this shell script, which will allow you to open multiple emacs instances simultaneously.
To install, just copy the
emacs-ide
script to/usr/local/bin/
or any directory on your$PATH
.You can run multiple Emacs instances with multiple files or directories, as such:
The script also sets the name of the window to match the directory (project) or file being edited.
我使用
失败,并弹出“Emacs 意外退出”。 (OS X Yosemite 10.10.3、Emacs 24.3.1 x86_64-apple-darwin)
作为解决方法,我安装了 Aquamacs 和 Emacs,因此至少可以运行两个副本。
Using
failed for me with a popup "Emacs quit unexpectedly." (OS X Yosemite 10.10.3, Emacs 24.3.1 x86_64-apple-darwin)
As a workaround, I installed Aquamacs as well as Emacs, so at least I can have two copies running.