Unfortunately, I forgot to start the emacs-server at work, running on Linux. Is there now any option to connect to my remote graphical X11 emacs session via ssh?
1What OS is running on the remote machine? If it is linux, is it running X? You might be able to use something like manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html to convince your emacs instance to do M-x server-start.– icarusFeb 1, 2017 at 3:26
@icarus: It is Debian Linux, X is running. Nice idea, although I thought there might be a more direct way.– pawel_winzigFeb 1, 2017 at 7:04
Since this is running on X, it might be possible to use a program like xdotool , xdo, or wmctrl
All these programs allow you to list windows, select one, and simulate typing on them.
Another approach would be to run x11vnc on the remote machine and connect to it with a local vnc viewer. The referenced manual page tells you how to forward needed ports using ssh.
Not answering the direct question, but I suggest the following in your init file to prevent this from happening in future.
;; Start server (but don't restart). (require 'server) (unless (server-running-p) (server-start))
Alternatively (but still not helpful for your present situation), under the FUBAR: Impossible to connect heading on the "Emacs As Daemon" EmacsWiki page, there's an ingenious approach to enabling a server start to be triggered with a process signal.
If you have
ssh access to the respective server at work you can start the emacs server at work using the command (with the respective username and server host name):
$ ssh -X email@example.com emacs --daemon
EDIT: If your emacs is already started on the server than just kill it and add automatic server start in your .emacs:
$ ssh firstname.lastname@example.org killall emacs $ ssh email@example.com sh -c "echo '(server-start)' >> ~/.emacs"
Now you can start emacs in daemon mode as described on the first command. The added server-start command would enable the server on the opened emacs session.
The question was about connecting to an existing emacs instance.– philsFeb 1, 2017 at 8:18
It is not clear from the question. The question states "I forgot to start the emacs-server". Anyone using emacs-server on a regular basis has it started automatically when emacs is started. So stating that emacs-server was not started sounds like emacs itself is closed. Feb 2, 2017 at 19:19
Anyway, I edited my answer to address this case too. Feb 2, 2017 at 19:25
* Down-voting my original answer (which was relevant for similar question of other users) is counter-productive... Feb 2, 2017 at 19:26
The question text "Is there now any option to connect to my remote emacs session" is pretty clear -- they have a remote emacs session, and they wish to connect to it. Killing the remote session helps (for this particular question) even less.– philsFeb 2, 2017 at 21:22