[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Using TRAMP

Once you have installed TRAMP it will operate fairly transparently. You will be able to access files on any remote machine that you can log in to as though they were local.

Files are specified to TRAMP using a formalized syntax specifying the details of the system to connect to. This is similar to the syntax used by the EFS package.

Something that might happen which surprises you is that XEmacs remembers all your keystrokes, so if you see a password prompt from XEmacs, say, and hit RET twice instead of once, then the second keystroke will be processed by XEmacs after TRAMP has done its thing. Why, this type-ahead is normal behavior, you say. Right you are, but be aware that opening a remote file might take quite a while, maybe half a minute when a connection needs to be opened. Maybe after half a minute you have already forgotten that you hit that key!

5.1 TRAMP filename conventions  
5.2 Multi-hop filename conventions  
5.3 Filename completion  
5.4 Dired  
5.5 Compile remote files  

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 TRAMP filename conventions

To access the file localname on the remote machine machine you would specify the filename `/[machine]localname'. This will connect to machine and transfer the file using the default method. See section 4.5 Selecting a default method.

Some examples of TRAMP filenames are shown below.

Edit the file `.emacs' in your home directory on the machine melancholia.

This edits the same file, using the fully qualified domain name of the machine.

This also edits the same file -- the `~' is expanded to your home directory on the remote machine, just like it is locally.

This edits the file `.emacs' in the home directory of the user daniel on the machine melancholia. The `~<user>' construct is expanded to the home directory of that user on the remote machine.

This edits the file `/etc/squid.conf' on the machine melancholia.

Unless you specify a different name to use, TRAMP will use the current local user name as the remote user name to log in with. If you need to log in as a different user, you can specify the user name as part of the filename.

To log in to the remote machine as a specific user, you use the syntax `/[user@machine]/path/to.file'. That means that connecting to melancholia as daniel and editing `.emacs' in your home directory you would specify `/[daniel@melancholia].emacs'.

It is also possible to specify other file transfer methods (see section 4.5 Selecting a default method) as part of the filename. This is done by replacing the initial `/[' with `/[<method>/'. (Note the trailing slash!). The user, machine and file specification remain the same.

So, to connect to the machine melancholia as daniel, using the `ssh' method to transfer files, and edit `.emacs' in my home directory I would specify the filename `/[ssh/daniel@melancholia].emacs'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Multi-hop filename conventions

The syntax of multi-hop file names is necessarily slightly different than the syntax of other TRAMP file names. Here's an example multi-hop file name:


This is quite a mouthful. So let's go through it step by step. The file name consists of three parts. The parts are separated by slashes and square brackets. The first part is `/[multi', the method specification. The second part is `rsh:out@gate/telnet:kai@real.host' and specifies the hops. The final part is `/path/to.file' and specifies the file name on the remote host.

The first part and the final part should be clear. See 4.4 Connecting to a remote host using multiple hops, for a list of alternatives for the method specification.

The second part can be subdivided again into components, so-called hops. In the above file name, there are two hops, `rsh:out@gate' and `telnet:kai@real.host'.

Each hop can again be subdivided into (three) components, the hop method, the user name and the host name. The meaning of the second and third component should be clear, and the hop method says what program to use to perform that hop.

The first hop, `rsh:out@gate', says to use rsh to log in as user out to the host gate. Starting at that host, the second hop, `telnet:kai@real.host', says to use telnet to log in as user kai to host real.host.

See section 4.4 Connecting to a remote host using multiple hops, for a list of possible hop method values. The variable tramp-multi-connection-function-alist contains the list of possible hop methods and information on how to execute them, should you want to add your own.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 Filename completion

Filename completion works with TRAMP for completion of method names, of user names and of machine names (except multi-hop methods) as well as for completion of file names on remote machines.

If you, for example, type C-x C-f /[t TAB, TRAMP might give you as result the choice for

[telnet/				   [toto]

`[telnet/' is a possible completion for the respective method, and `[toto]' might be a host TRAMP has detected in your `~/.ssh/known_hosts' file (given you're using default method `ssh').

If you go on to type e TAB, the minibuffer is completed to `/[telnet/'. Next TAB brings you all machine names TRAMP detects in your `/etc/hosts' file, let's say

[telnet/]		   [telnet/]
[telnet/localhost]		   [telnet/melancholia.danann.net]

Now you can choose the desired machine, and you can continue to complete file names on that machine.

As filename completion needs to fetch the listing of files from the remote machine, this feature is sometimes fairly slow. As TRAMP does not yet cache the results of directory listing, there is no gain in performance the second time you complete filenames.

If the configuration files (see section 4.7 Selecting config files for user/host name completion), which TRAMP uses for analysis of completion, offer user names, those user names will be taken into account as well.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Dired

TRAMP works transparently with dired, enabling you to use this powerful file management tool to manage files on any machine you have access to over the Internet.

If you need to browse a directory tree, Dired is a better choice, at present, than filename completion. Dired has its own cache mechanism and will only fetch the directory listing once.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 Compile remote files

TRAMP provides commands for compilation of files on remote machines. In order to get them loaded, you need to require `tramp-util.el':

(require 'tramp-util)

Afterwards, you can use the commands tramp-compile and tramp-recompile instead of compile and recompile, respectively; See Info file `xemacs', node `Compilation'. This does not work for the `ftp' and `smb' methods.

The corresponding key bindings and menu entries calling these commands are redefined automatically for buffers associated with remote files.

After finishing the compilation, you can use the usual commands like previous-error, next-error and first-error for navigation in the `*Compilation*' buffer.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html