我正在尝试从终端在 emacsclient 中打开两个文件,例如“hello.txt”和“world.txt”,我希望它们在两个不同的窗口中打开(如 emacs 中的这个词的含义)但在相同的框架。
我像这样调用 emacsclient:
emacsclient -nw hello.txt world.txt
当前发生的是单个 emacsclient 框架显示一个显示 hello.txt 的窗口。另一个文件被打开到一个不可见的缓冲区中。
如果我改为使用 emacs 而不是 emacsclient,我会得到预期的结果(即两个文件在同一框架内但在两个窗口中打开)。如何使 emacsclient 的行为与 emacs 相同?
我不是在寻求让 emacsclient 生成多个框架的方法,而是在寻求某种方法让 emacsclient 在同一框架内的拆分窗口中打开多个文件。
最佳答案
似乎您不能直接使用 emacsclient 和文件列表执行此操作
您可以通过将 lisp 传递给 emacsclient 来执行您想要的操作,但稍微有点麻烦,即可达到相同的效果,尽管它有点冗长
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")'
关于emacs - 如何让 emacsclient 在同一个 'window' 内的单独 'frame' 中打开每个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25092911/