如何让emacsclient在一个单独的窗口中打开每个文件'在相同的框架内#39;

时间:2014-08-02 07:50:26

标签: emacs emacsclient

我正在尝试从终端打开两个文件,在 emacsclient 中说'hello.txt'和'world.txt',我想让它们在两个不同的 windows <中打开/ em>(如emacs意义上的那个词)但在同一个框架中

我像这样调用 emacsclient

emacsclient -nw hello.txt world.txt

目前发生的是单个 emacsclient 框架显示单个窗口,其中显示hello.txt。另一个文件打开到一个不可见的缓冲区。

如果我改为使用 emacs 而不是 emacsclient ,我会得到预期的结果(即两个文件在同一帧内打开但在两个窗口中打开)。如何使emacsclient的行为与emacs相同?

我不是想要让 emacsclient 生成多个框架的方法,而是我想要一些方法让 emacsclient 在分割窗口内打开多个文件相同的框架。

3 个答案:

答案 0 :(得分:2)

您似乎无法使用emacsclient和文件列表直接执行此操作

通过将lisp传递给emacsclient来做你想做的事情你可以达到同样的效果,有点像kludge,虽然它有点冗长

emacsclient -t -e '(progn (find-file "file1")(find-file-other-window "file2"))' 

你或许可以包装这是一个小shell脚本ec2files.sh,它接受​​两个参数并将它们插入到那个lisp表单中。

或者写一个你在emacs init中加载的defun,它接受2个文件参数并打开它们。

(defun example-split-window-2-files (f1 f2) 
  (find-file f1)
  (find-file-other-window f2))

然后从emacsclient -e

调用它
emacsclient -t -e '(example-split-window-2-files "file1" "file2")'

答案 1 :(得分:2)

变量server-window是您想要查看的内容。您可以将此变量设置为选择要打开的窗口的函数。

我在emacs配置中有以下内容:

(setq server-window 'pop-to-buffer)

这确保了当您打开(单个)文件时,它会使用另一个窗口(必要时创建它)来显示该文件。您需要找到或编写一个函数来传递给服务器窗口,该窗口将继续为您创建新窗口以显示文件。

答案 2 :(得分:0)

第37.1节&#34;调用emacs 24.3.1手册中的“emacsclient&#39;&#34;”说:

  

你也可以强迫emacsclient' to open a new frame on a graphical display, or on a text terminal, using the - c&#39;和`-t&#39;选项。