如何从命令行打开现有 emacs 进程中的文件?

bev*_*bev 19 command-line emacs

我有几个脚本可以启动与特定项目相关的所有应用程序和文件。但是,它会启动多个 emacs 实例,而不是简单地使当前的 emacs 打开请求的文件。我宁愿当前的 emacs 只是在新缓冲区中打开项目文本文件。

任何想法我怎么能做到这一点?

gee*_*aur 24

M-x server-start在 Emacs 会话中,然后用于emacsclient -n file1 file2 ...将文件添加到现有 Emacs。您可能还想使用其他选项,例如-c在新窗口(框架)中打开文件。


ctr*_*lor 7

放入(server-start)你的.emacs档案。

将此添加到 ~/.bashrc

alias myedit='emacsclient --alternate-editor="" --no-wait $*' #quotes intentionaly left blank
Run Code Online (Sandbox Code Playgroud)

然后myedit用作您的编辑器。您将不得不使用该-c选项来打开一个窗口。

所以你可以这样做:

myedit -c a-file
run-script #that uses myedit
Run Code Online (Sandbox Code Playgroud)

或者

run-script #that uses myedit
myedit -c
Run Code Online (Sandbox Code Playgroud)