Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When working with EMACS over SSH, is there any way to spawn a new frame of the same emacs session on a different terminal?

In my use case, I have screen running, so I have multiple terminals, and can recover which pseudo terminal they're attached to with pts. Suppose I have two "windows" (in GNU screen parlance). The first one is attached to /dev/pts/12 and the second one is attached to /dev/pts/13. I launch emacs on the first window. Is there any way for me to start a new frame of the same session on the second window?

I've been playing with passing arguments to make-frame but it seems that the usage that allows me to specify a terminal requires that a terminal object already exists, and I can't see any way to create a new terminal object.

share|improve this question

1 Answer 1

I think my question may have been ill-formed. My goal was to be able to access a single emacs session (with common buffers, settings, etc). I still don't know how to send an emacs frame from an existing emacs process to an arbitrary terminal, but it is easy to connect to an existing emacs session from an arbitrary terminal. This can be accomplished using an emacs server and emacsclient.

First, you must start an emacs server. If you don't have emacs open, you can simply run emacs --daemon to launch emacs into the background and let it start a server. If you already have emacs open, you can run M-x server-start.

Second, from the terminal where you want to connect to the emacs server, run emacsclient -t. This will create a new frame on the current terminal connected to the existing emacs server session. The -t flag tells emacsclient to create a tty-style frame, as if you have launched emacs with the -nw flag. If your terminal is associated with an X display and has DISPLAY set, you can instead run emacsclient -c which will spawn a new X window with a new emacs frame connected to your existing emacs session.

There are more details for usage of emacsclient in its man page.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.