3

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?

  • 1
    What 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. – icarus Feb 1 '17 at 3:26
  • @icarus: It is Debian Linux, X is running. Nice idea, although I thought there might be a more direct way. – pawel_winzig Feb 1 '17 at 7:04
3

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.

0

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.

-2

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 myuser@myserver.work.domain 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 myuser@myserver.work.domain killall emacs
$ ssh myuser@myserver.work.domain 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. – phils Feb 1 '17 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. – ElazarR Feb 2 '17 at 19:19
  • Anyway, I edited my answer to address this case too. – ElazarR Feb 2 '17 at 19:25
  • * Down-voting my original answer (which was relevant for similar question of other users) is counter-productive... – ElazarR Feb 2 '17 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. – phils Feb 2 '17 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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