Commands such as C-x C-f (
find-file) use the minibuffer
to read a file name argument (see Basic Files). When the
minibuffer is used to read a file name, it typically starts out with
some initial text ending in a slash. This is the default
directory. For example, it may start out like this:
Find file: /u2/emacs/src/
Here, ‘Find file: ’ is the prompt and ‘/u2/emacs/src/’ is the default directory. If you now type buffer.c as input, that specifies the file /u2/emacs/src/buffer.c. See File Names, for information about the default directory.
You can specify the parent directory with ..: /a/b/../foo.el is equivalent to /a/foo.el. Alternatively, you can use M-<DEL> to kill directory names backwards (see Words).
To specify a file in a completely different directory, you can kill the entire default with C-a C-k (see Minibuffer Edit). Alternatively, you can ignore the default, and enter an absolute file name starting with a slash or a tilde after the default directory. For example, you can specify /etc/termcap as follows:
Find file: /u2/emacs/src//etc/termcap
A double slash causes Emacs to ignore everything before the second slash in the pair. In the example above, /u2/emacs/src/ is ignored, so the argument you supplied is /etc/termcap. The ignored part of the file name is dimmed if the terminal allows it. (To disable this dimming, turn off File Name Shadow mode with the command M-x file-name-shadow-mode.)
Emacs interprets ~/ as your home directory. Thus, ~/foo/bar.txt specifies a file named bar.txt, inside a directory named foo, which is in turn located in your home directory. In addition, ~user-id/ means the home directory of a user whose login name is user-id. Any leading directory name in front of the ~ is ignored: thus, /u2/emacs/~/foo/bar.txt is equivalent to ~/foo/bar.txt.
On MS-Windows and MS-DOS systems, where a user doesn't always have a home directory, Emacs uses several alternatives. For MS-Windows, see Windows HOME; for MS-DOS, see MS-DOS File Names. On these systems, the ~user-id/ construct is supported only for the current user, i.e., only if user-id is the current user's login name.
To prevent Emacs from inserting the default directory when reading
file names, change the variable
nil. In that case, the minibuffer starts out empty.
Nonetheless, relative file name arguments are still interpreted based
on the same default directory.
You can also enter remote file names in the minibuffer. See Remote Files.