Next: , Previous: , Up: Files   [Contents][Index]


14.7 Listing a File Directory

Files are organized by Unix into directories. A directory listing is a list of all the files in a directory. Emacs provides directory listings in brief format (file names only) and verbose format (sizes, dates, and authors included).

C-x C-d dir-or-pattern

Print a brief directory listing (list-directory).

C-u C-x C-d dir-or-pattern

Print a verbose directory listing.

To print a directory listing, use C-x C-d (list-directory). This command prompts in the minibuffer for a file name which is either a directory to be listed or pattern containing wildcards for the files to be listed. For example,

C-x C-d /u2/emacs/etc RET

lists all the files in directory /u2/emacs/etc. An example of specifying a file name pattern is:

C-x C-d /u2/emacs/src/*.c RET

Normally, C-x C-d prints a brief directory listing containing just file names. A numeric argument (regardless of value) tells it to print a verbose listing (like ls -l).

Emacs obtains the text of a directory listing by running ls in an inferior process. Two Emacs variables control the switches passed to ls: list-directory-brief-switches is a string giving the switches to use in brief listings ("-CF" by default). list-directory-verbose-switches is a string giving the switches to use in a verbose listing ("-l" by default).

The variable directory-abbrev-alist is an alist of abbreviations for file directories. The list consists of elements of the form (FROM . TO), each meaning to replace FROM with TO when it appears in a directory name. This replacement is done when setting up the default directory of a newly visited file. Every FROM string should start with ‘‘^’’.

Use this feature when you have directories which you normally refer to via absolute symbolic links. Make TO the name of the link, and FROM the name it is linked to.


Next: , Previous: , Up: Files   [Contents][Index]