Suppose I am in terminal in Emacs (M-x term), and I list the following files in 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. 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!
Remember that in Term Mode you can type C-c C-f to open a file (just like C-x C-f outside 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.
I don't know the official procedure for what you want to do, but here is a procedure that works:
Either tell emacs to run as a daemon (Ref: EmacsAsDaemon) or in emacs start daemon via M-x server-start
.
In the term, a command like emacsclient -n filename
will start editing the specified file in the current window. Note, emacsclient also has a -c, --create-frame
option to edit in a new frame. You probably will want to use a -n
option as above, so you can continue using your term, after selecting it from the buffers list in another pane or frame.
If you start the daemon via M-x server-start
in emacs, the daemon will terminate when you exit from emacs. If you set it up via reference mentioned above, use kill-emacs
or save-buffers-kill-emacs
commands or shell command emacsclient -e '(kill-emacs)'
to stop it, as mentioned in part 6 of reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With