Automating remote emacsclient setup

Joel Reicher <[email protected]> Sun, 10 May 2026 00:51:06 +1000
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
I was wondering if much work had been done on this front, and if 
not what it would take to do it. There's a lot already in place.

From what I can tell the pieces would be, assuming a TCP server:

1) add port forwarding to the Tramp method (probably ssh only)
2) generate a server file at the remote
3) set Tramp prefix at the remote

3 is easy enough to do with init_SHELLNAME.sh, e.g. something like

export EMACSCLIENT_TRAMP=/-:${HOSTNAME}:

I'm thinking 1 should be done with `tramp-connection-properties', 
but there's a little piece missing. Ideally the server port would 
be extracted with something like (cadr (process-contact 
server-process)), and then that number goes into an ssh arg "-R 
0:127.0.0.1:server-port" to allow dynamic allocation of a port at 
the remote end. However the message ssh prints for that allocation 
then needs to be captured by Tramp/Emacs so that it can be 
provided in the remote server file (or some equivalent).

Thoughts? It would be really nice to have something like this.

Thanks and regards,

       - Joel