The power of Tramp

Posted on Thu 29 July 2010 by alex in geek

The project I've been working on at work the last few weeks has involved bringing up a brand new embedded system. As part of that I've been tweaking a lot of start-up scripts and configuration files on the new system.

For part of that task I've installed GNU Zile which provides a nice Emacs-like experience for quick edits where you would usually fire-up vi. Despite the fact the new platform has a considerably larger backing store I'm not going to install the full-fat Emacs just to satisfy my editing needs.

Fortunately the full-fat Emacs has long carried a feature called TRAMP (standing for "Transparent Remote (file) Access, Multiple Protocol") which is incredibly useful in this and other use cases. TRAMP allows you to edit files on remote machines in your normal home Emacs environment. find-file and friends all behave as if you are editing local files while behind the scenes Emacs pulls directory listings and files from the remote machine with ssh (or ftp or whatever actually works). I use TRAMP all the time to edit files on the rather ancient build machine rather the using the relatively ancient Emacs it has installed on it.

There was one minor wrinkle getting TRAMP working with my new embedded system. As some of the methods used to move files back and forth are designed for transferring text files Emacs goes to great pains to ensure the files are moved across un-mangled. Typically this involves some sort of encode/decode utility. The tramp code is actually quite a good example of using elisp in an extensible way and if you look at tramp-remote-coding-commands you'll see it will even fall back to running remote in-line perl if it has to. As it happens we don't have perl running on the embedded platform and as it would be a little overkill to put perl on the remote machine so I added the recode utility.

I consider TRAMP to be one of Emacs' killer features. Next time you sigh at the prospect of being consigned to an inferior editor on some remote box consider visiting the file with TRAMP straight from your current Emacs session.