I wanted to get remote compiles going in Emacs because I wanted to work in Aquamacs on my Mac. In terminal mode, a lot of keys don’t work like in particular Control + the arrow keys and in X11, I lose my Emacs session every time I disconnect and take my laptop home (unless I use something like VNC (slow) or figure out how to get FreeNX to suspend & resume properly).
Here’s how I did it. The basic approach is to use rcompile.el which seems geared for doing remote compiles over rsh, but it can be cajoled into working over ssh:
- Set the Emacs variable
remote-compile-host
to foobar.com -p 8000
. The -p 8000
was only necessary for me because I am sshing to a particular FreeBSD jail that has the build environment i need for the particular project I’m working on.
- Set the Emacs variable
remote-shell-program
to /sw/bin/ssh
. This path is a little unusual because I’m using a version of OpenSSH that I installed on my PowerBook using Fink. I’m choosing this over the stock OS X ssh because OpenSSH 4.0 and up support the ControlMaster feature which speeds up repeated connections to the same remote host.
- Instead of the Emacs
compile
command, use remote-compile
(defined in rcompile.el).
At this point, Emacs was still crapping out because it was confused by the remote file pathname from TRAMP and didn’t know how to change directories on the remote host:
bash: line 0: cd: /ssh:foobar.com:/home/marc/src/foo/bar:
No such file or directory
In order to solve this I got tricky and did this:
sudo ln -s / /ssh:foobar.com:
This is very hacky though and not everyone may have root access to the remote host they’re using, so I came up with a patch for rcompile.el which works for me.
Let me know if it works for you…
