12

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!

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks a lot! That works and is really convenient within the bash mode :)
But, surprisingly this is shell dependent. This doesn't work in fish-shell
Neither for zsh, for bash it does
4

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 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.

  3. 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.

1 Comment

Thank you for your comments! It seems to be a little complicated.. what I hope to see is some key-binding in emacs that will do the work. Maybe there is none. Anyway, thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.