Skip to content
izahn edited this page Jan 14, 2013 · 3 revisions

emacsclient information

Ista Zahn on [2013-01-10 jeu] authored the following text.

ssh -X and emacsclient -c

A simple approach to collaborative editing of Org files is to use ssh and emacsclient to visit the same file in two separate emacs frames on different machines. I’ve set up and tested this approach and it works well.

Set up for remote running Emacs in a terminal

The simplest version is to connect to an Emacs session on a remote computer using Emacs running in a terminal. On the remote computer make sure the Emacs server is running with M-x emacs-server-start. On the local computer, ssh into the remote machine and start emacsclient -t. Visit the same file on both machines and edit! It may be convenient to open an indirect buffer with M-x clone-indirect-buffer so you are not bothered by the other user’s collapsing/expanding headlines.

Set up for remote running X11 Emacs

This version is more difficult, and requires X11 Emacs running on the remote computer. If the remote computer is running a Linux this is not an issue, but if e.g., the remote computer is a Mac this may be more difficult. In any case, first enable X11Forwarding on the remote computer by editing the sshd config and setting X11Forwarding yes. From the local computer, ssh into the remote computer with ssh -X <remote.ip> and start emacsclient -c. If all goes well you should have an Emacs frame from the remote computer displayed on the local computer. As above, visiting the same buffer and running M-x clone-indirect-buffer on the local computer should result in a pleasant editing experience. However, all may not go well…

Limitations

  • X11Forwarding requires X11 on both the local and remote machine, and an X11 Emacs on the remote machine (I think). For example, I was not able to use X11Forwarding to connect to an Emacs running on my remote Mac, as the Emacs running on the Mac is compiled with Cocoa, not X11.
  • X11Forwarding can be slow. I’ve not figured out all the factors involved, but with some client/server pairs it is reasonably fast, while with others it is terribly slow (even running on the same network).
  • Without X11Forwarding, it still works, but you get no images in Org buffers, something I use heavily and really miss.
  • The local machine must ssh into the remote machine as the same user that started the emacs server.