如何为emacsclient提供命令行选项?

9

我使用以下命令启动emacsclient:

emacsclient -a "" -c

这将打开与emacs守护程序连接的一个框架,并在守护程序未启动时启动它。非常好,这很有效。

然而,我喜欢最大化我的emacs框架。对于emacs,我会使用“-mm”选项。然而,这在emacsclient中不起作用。我该如何解决?

(似乎我可以通过添加像这样的shell文件来使某些内容正常工作:emacsclient -a "myshell.sh" -c,其中shell文件是:emacs -mm,但我无法使其正常工作 - 服务器无法保持运行状态。)


我不确定这是否可能,但是这些设置可以在您的.emacs或.Xressources中定义。请参见此问题 - Daimrod
3个回答

16

emacsclient -c -a "" -F "((fullscreen . maximized))" 非常方便!谢谢! - Nick

3
假设您想要全屏运行emacsclient,这也是我的情况。
使用“man emacsclient”命令可以查看emacsclient有“-F”选项。
-F, --frame-parameters=ALIST
       set the parameters of a newly-created frame.

在 Emacs 手册中,也就是一个 info 文件中,(emacs) emacsclient Options 这一章节有更多信息。特别是对于这个问题,(elisp) Size Parameters 提到了 fullscreen 参数。要运行全屏的 emacsclient,你需要提供一个 alist,其中一个元素是 (fullscreen . fullboth),像这样:
emacsclient -c -F "((fullscreen . fullboth))"

2

emacsclient提供了--eval(简称-e)命令行选项,用于执行任意的Emacs Lisp代码,因此您可以像这样从命令行访问文件并调用suspend-frame

emacsclient -a "" -c --eval "(progn (find-file \"/tmp/my-file\") (suspend-frame))"

您可以将此代码放入脚本中,例如:
#!/bin/bash
emacsclient -a "" -c --eval "(progn (find-file \"$1\") (suspend-frame))"

1
好的,但那不是问题的关键...问题是如何运行像“-mm”这样的命令行选项。 - Paul Biggar
Emacs是开源的,因此修改emacsclient.c以创建自己的版本的emacsclient接受-mm应该相当简单。 - Luke Girvin

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