bash 在 emacs 终端中打开 emacs 缓冲区中的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12523345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:20:33  来源:igfitidea点击:

open a file in an emacs buffer while in emacs terminal

bashemacs

提问by alittleboy

Suppose I am in terminal in Emacs (M-x term), and I list the following files in current directory:

假设我在 Emacs 的终端中(Mx 术语),并且我在当前目录中列出了以下文件:

text_code.R

text_code.R

Now I am in bash-3.2$ (terminal) and hope to open this .R file in another Emacs buffer and then edit. Is there a way to do it? This might be a trivial question, for I am a newbie to Linux and Emacs. Thanks in advance!

现在我在 bash-3.2$(终端)中,希望在另一个 Emacs 缓冲区中打开这个 .R 文件,然后进行编辑。有没有办法做到这一点?这可能是一个微不足道的问题,因为我是 Linux 和 Emacs 的新手。提前致谢!

采纳答案by Juancho

Remember that in Term Mode you can type C-c C-fto open a file (just like C-x C-foutside Term Mode). The prompt will already be on your current directory, so you just have to start typing the name of the file and autocomplete it with TAB.

请记住,在术语模式下,您可以键入C-c C-f以打开文件(就像C-x C-f在术语模式之外一样)。提示将已经在您的当前目录中,因此您只需开始输入文件名并使用TAB.

回答by James Waldby - jwpat7

I don't know the official procedure for what you want to do, but here is a procedure that works:

我不知道你想要做什么的官方程序,但这里有一个有效的程序:

  1. Either tell emacs to run as a daemon (Ref: EmacsAsDaemon) or in emacs start daemon via M-x server-start.

  2. In the term, a command like emacsclient -n filenamewill start editing the specified file in the current window. Note, emacsclient also has a -c, --create-frameoption to edit in a new frame. You probably will want to use a -noption as above, so you can continue using your term, after selecting it from the buffers list in another pane or frame.

  3. If you start the daemon via M-x server-startin emacs, the daemon will terminate when you exit from emacs. If you set it up via reference mentioned above, use kill-emacsor save-buffers-kill-emacscommands or shell command emacsclient -e '(kill-emacs)'to stop it, as mentioned in part 6 of reference.

  1. 要么告诉 emacs 作为守护进程运行(参考:EmacsAsDaemon),要么在 emacs 中通过M-x server-start.

  2. 在术语中,像这样的命令emacsclient -n filename将在当前窗口中开始编辑指定的文件。请注意,emacsclient 还可以-c, --create-frame选择在新框架中进行编辑。您可能希望使用上述-n选项,以便在从另一个窗格或框架的缓冲区列表中选择它后继续使用您的术语。

  3. 如果您通过M-x server-start在 emacs 中启动守护进程,守护进程将在您退出 emacs 时终止。如果您通过上述参考进行设置,请使用kill-emacssave-buffers-kill-emacs命令或 shell 命令emacsclient -e '(kill-emacs)'停止它,如参考的第 6 部分所述。