Using Ange-ftp Mode

FTP is a standard way to move files around on the Internet or on any TCP/IP network. There are thousands of “anonymous” FTP servers on the Internet from which you can copy files. You might use archie, as we discussed, to locate a particular file, then FTP to copy it to your local server.

Ange-ftp mode alleviates the need for learning FTP commands. Essentially, you just “find” files on remote systems using C-x C-f, then copy them using Dired commands (described in Chapter 5). Ange-ftp mode is a transparent interface to FTP, and it is included in Emacs.

Copying Files with Ange-ftp Mode

From the user’s point of view, ange-ftp mode is really just an extension of the find-file command, C-x C-f, with a little added syntax. So how does Emacs know that you want to start up ange-ftp when you type C-x C-f? Emacs knows to start ange-ftp mode if the following three conditions are met:

  1. The filename begins with a slash

  2. The slash is followed by username@systemname

  3. There is a colon (:) between the system name and the directory or filenames, if any (for example, /anonymous@rtfm.mit.edu:/pub)

For example, typing /anonymous@rtfm.mit.edu:/pub opens an FTP connection to rtfm.mit.edu and displays the /pub directory. It is easy to forget the slash at the beginning and even easier to forget the colon between the system name and the path to the file. If Emacs says,

New file

or

Use M-x make-dir RET RET to create a directory

type C-x C-v (for find-alternate-file) to correct the mistake. Check ...

Get Learning GNU Emacs, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.