[OS X Emacs] Aquamacs(mac) + remote emacsclient(linux)?

David Reitter david.reitter at gmail.com
Tue Sep 13 14:54:13 EDT 2011

On Sep 13, 2011, at 2:33 PM, David Reitter wrote:
> And, finally, finally, I don't know if tramp works, but this blog post gives you the scripts that do, I think, essentially what I outline above, and it does use tramp:
> http://the.unwashedmeme.com/blog/2010/06/22/using-a-local-emacstramp-as-your-editor-on-remote-servers-with-ssh-and-emacsclient/
> I see no reason why this shouldn't work with Aquamacs as long as you use a compatible emacsclient version on the remote.

Further to my previous e-mail:  I've got curious and tried it out, and it works fine.

- Install correct emacsclient on remote.  (version 23 works OK for Aquamacs 2.x and 3.x).  Test with "emacsclient --version".

- Install editor script on remote as per blog bost.  Don't forget chmod +x aqclient

- Install SSH command script on local machine, as below (I had to adapt the paths so that it would go through Aquamacs.)  Don't forget chmod +x aqssh

- (setq server-use-tcp t) and (server-start) on local Aquamacs instance.  Can be put in your Preferences.el.

Then call "aqssh  remotemachinename" to establish connection, and when you need to edit, call "aqssh".

Works for me.  When doing "sudo", you need the root account password on the remote for obvious reasons.  The script could, of course, work around that.  Tramp is sort of slow for me.

Script follows below.

http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and support the Aquamacs Project!

SPATH=~/"Library/Application Support/Aquamacs Emacs/server"

#read from emacs server file what port it is currently listening on
PORT=`egrep  -o '[0-9]*)' "$SFILE" | sed 's/'`
#read the server file, escaping single quotes that are in the auth string
SRV=`cat "$SFILE" | sed "s/'/\\\\\\'/"`

#When connecting to the remote host, print the server file to the
# correct location and then invoke my shell.
CMD="mkdir -m 700 -p $SPATH; mkdir -p  ~/.emacs.d/server 2>/dev/null;  echo $'$SRV' > ~/.emacs.d/server/server; bash -l"
#-t : allocate a tty so we are there.
#-R : the remote port forward that lets emacsclient talk back
#$@ : any other args this script was invoked with should be passed along.
ssh -t -R $PORT:$PORT $@ "$CMD"

More information about the MacOSX-Emacs mailing list