Originate edit of remote file using emacs tramp from ssh session

You can set up your emacs-server to use a tcp connection (not just a local socket), and then on the remote side, tell emacsclient to connect to that tcp connection:

In your .emacs

(setq server-use-tcp t)
(setq server-host "name_of_local_machine")
(server-start)

And then on the remote side:

emacsclient -f ~/.emacs.d/server/server /`hostname`:/path/to/local/file

The above call to emacsclient brings up a file local to the “remote” machine in your Emacs running in the “local” machine. Obviously you can wrap the call to emacsclient in whatever kind of script you want to make it easier.

If your home directory is not visible on the remote machine, you will need
to customize the server-auth-dir variable like so:

(setq server-auth-dir "/some/path/visible/on/both/machines")

For more documentation, see Emacsclient options.

Leave a Comment