Open file in emacs buffer while in emacs terminal

Suppose I am a terminal in Emacs (term Mx), and I list the following files in the current directory:

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 it. Is there any way to do this? This might be a trivial question as I am new to Linux and Emacs. Thanks in advance!

+8
bash emacs
source share
2 answers

Remember that in Term mode, you can enter Cc Cf to open the file (like Cx Cf outside of Term Mode). The request will already be in your current directory, so you just need to start typing the file name and autofill it with TAB .

+7
source share

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

  • Either tell emacs to start as a daemon (Ref: EmacsAsDaemon ), or in emacs start daemon via Mx server-start .

  • In this case, a command like emacsclient -n filename will start editing the specified file in the current window. Note. Emacsclient also has the -c, --create-frame option -c, --create-frame for editing in the new frame. You will probably want to use the -n option as described above, so you can continue to use your term by selecting it from a list of buffers in another panel or frame.

  • If you start the daemon via Mx server-start in emacs, the daemon will end when you exit emacs. If you install it from the link mentioned above, use the kill-emacs or save-buffers-kill-emacs commands or the emacsclient -e '(kill-emacs)' shell emacsclient -e '(kill-emacs)' to stop it, as described in part 6 of the help.

+2
source share

All Articles