#### 4.3.2 The Folder Browser

In addition to the simple commands just described, IMAIL also provides a Dired-like browser for viewing and manipulating folders. The browser is generic, meaning that it will view collections of both IMAP folders and file folders, although it works better and is more useful in conjunction with IMAP folders.

The `imail-browser-view-container` command is used to enter the folder browser. In an IMAIL folder buffer, this command is bound to the `^` key, and will bring up a folder browser that is viewing the container of the current folder. With a prefix argument, you will be asked for the URL of a container to browse.

An IMAIL browser buffer is arranged so that each line in the browser represents a folder or a container (or both, in the case of IMAP containers). Here is an example:

    imap://localhost/inbox/
    -----------------------
      + debian/
      + family
      + gnu/
      + ham/
      + hp-laptops/
      + linux/
      + misc/
      + mit/
      + music/
      + purchases
      + scheme/
      + software/
      + sysadmin
      + vendors/
      + vlsi

There are several interesting features of this buffer. The first two lines of the buffer are a title, telling you the URL of the container that this buffer is browsing. Each of the remaining lines shows the name of a folder (or container) that is inside the container. You can perform various operations on one of these folders by moving point to the folder’s line and invoking commands.

Each line uses special characters to give you cues about the object being described. If the object is a container, there is a ‘`+`’ character at the beginning of the line. Because our example is showing an IMAP container, and virtually all IMAP folders are also containers, every line in the example starts with ‘`+`’. Additionally, if the object is only a container, then the object’s name ends in the character ‘`/`’; if the object is only a folder, or if it is both a folder and a container, then there is no trailing ‘`/`’.

The following commands are available in an IMAIL browser buffer.

`f`

  View the folder on the current line in an IMAIL buffer (`imail-browser-view-selected-folder`).

`t`

  If the object on the current line is a container, toggle whether its contents are shown (`imail-browser-toggle-container`).

`c`

  Browse the container on the current line (`imail-browser-view-selected-container`).

`^`

  Browse the container of the this buffer’s container (`imail-browser-view-container`).

`d`

  Mark the object on the current line for subsequent deletion (`imail-browser-flag-folder-deletion`).

`m`

  Mark the object on the current line for subsequent operations (`imail-browser-mark`).

`u`

  Remove any mark from the current line and move to the next line (`imail-browser-unmark`).

`DEL`

  Move to the previous line and remove any mark there (`imail-browser-unmark-backward`).

`M-DEL char`

  Remove marks from all folders (`imail-browser-unmark-all-folders`).

`C URL RET`

  Copy the folder on the current line to the folder named URL, creating it if needed (`imail-browser-do-copy`).

`R URL RET`

  Rename the object on the current line to be URL (`imail-browser-do-rename`).

`D`

  Delete the object on the current line (`imail-browser-do-delete`). Prompts for confirmation before performing the deletion.

`x`

  Delete all objects that have been marked for deletion (`imail-browser-do-flagged-delete`). Prompts for confirmation before any deletion is performed.

`+ URL RET`

  Create a folder named URL (`imail-create-folder`).

`g`

  Recompute the buffer’s contents by querying the server or file system (`imail-browser-revert`).

`q`

  Kill the current buffer (`imail-browser-quit`).

If point is on a line describing a folder, use the `f` (`imail-browser-view-selected-folder`) command to view the contents of that folder. This selects an IMAIL folder buffer for that folder.

If point is on a line describing a container, use the `t` (`imail-browser-toggle-container`) command to show the contents of the container in the current buffer. This causes the ‘`+`’ on this line to change to a ‘`-`’, and new lines describing the contents are inserted into the buffer following the current line. The new lines are slightly indented to indicate the container relationship. For example:

    imap://localhost/inbox/
    -----------------------
      - debian/
          + bugs
          + maintainer
          + misc
      + family
      + gnu/
      + ham/
      + hp-laptops/
      + linux/
      + misc/
      + mit/
      + music/
      + purchases
      + scheme/
      + software/
      + sysadmin
      + vendors/
      + vlsi

To hide the container’s content lines, use the `t` command again. Another way to open and close containers is to click the left mouse button on the ‘`+`’ or ‘`-`’ character for the container (`imail-browser-mouse-toggle-container`).

If you would rather browse a container in a separate buffer, use the `c` (`imail-browser-view-selected-container`) command. To browse the container of this buffer’s container, use the `^` (`imail-browser-view-container`) command.

Besides simple browsing capabilities, the IMAIL folder browser also provides the ability to modify folders and containers, by copying, renaming, and deleting them. The commands to do this normally operate on the object on the current line. However, you can mark one or more lines, and subsequently perform an operation on all of them at once.

There are several marking and unmarking commands. The `m` (`imail-browser-mark`) command marks the current line and moves down to the next line. The mark is visible as an asterisk at the beginning of the line. A numeric argument serves as a repeat count. The `d` (`imail-browser-flag-folder-deletion`) is just like `m`, except that it marks lines with ‘`D`’. ‘`D`’ marks are used to flag objects for deletion, while ‘`*`’ marks are used for everything else.

To unmark a line, use the `u` (`imail-browser-unmark`) command. This removes any mark from the current line and moves to the next line. Like `m`, a numeric argument serves as a repeat count. The `DEL` (`imail-browser-unmark-backward`) command moves upward, removing flags; it is like `u` with argument `-1`. Finally, the `M-DEL` (`imail-browser-unmark-all-folders`) prompts for a character and unmarks all lines marked with that character; specifying `RET` as the character removes all marks.

The next three commands perform the copy, rename, and delete operations. These commands all operate on one or more folders, which you specify either by marking them, or by moving point to the corresponding lines. The folders to be operated on are specified as follows. If the command is given a numeric argument N, then the next N folders are specified. Otherwise, any folders marked with an asterisk are specified. If there is no argument and no marked folders, then the folder on the current line is specified.

The `C` (`imail-browser-do-copy`) command copies one or more folders. If one folder is specified, the command prompts for the URL of another folder, and appends the messages of the first folder to the end of the second folder. The second folder is created if necessary. If more than one folder is specified, the command prompts for the URL of an existing container, and copies the source folders into the target container with the same names.

The `R` (`imail-browser-do-rename`) command renames one or more folders. If one folder is specified, the command prompts for a URL, and changes the name of the folder to the URL. If more than one folder is specified, the command prompts for the URL of an existing container, and moves the folders into the container. Note that in both cases, it is an error if there is already a folder with the new name. Furthermore, this command only works in limited circumstances, specifically, when moving a folder from one place to another on a single IMAP server, or when moving a file folder from one place to another within the same file system.

The `D` (`imail-browser-do-delete`) command deletes one or more folders. The command prompts for confirmation before any folders are deleted. The `x` (`imail-browser-do-flagged-delete`) command is similar, except that the folders it deletes are those that have been marked with ‘`D`’. (The `x` command is mostly provided for compatibility with Dired.)

The `+` (`imail-create-folder`) command creates a new, empty folder. It prompts for a URL, and signals an error if the name is already in use. This command is rarely used since the message-copying commands automatically create folders as needed.

The `g` (`imail-browser-revert`) command re-reads the contents of the browser buffer’s container and uses that information to regenerate the buffer’s contents. Any marks that you have placed in the buffer are preserved.

The `q` (`imail-browser-quit`) command kills the current buffer. If you have marked some folders for later operation, the marks are discarded and the operations are not performed.