4.3 Folder Selection

When you choose a folder in MH-E via a command such as o (mh-refile-msg), completion is used to enter the folder (see the section Completion in The GNU Emacs Manual). In addition, MH-E has several ways of choosing a suitable default so that the folder can often be selected with a single RET key.

The ‘mh-folder-selection’ customization group contains some options which are used to help with this.

mh-default-folder-for-message-function

Function to select a default folder for refiling or ‘Fcc:’ (default: nil).

mh-default-folder-list

List of addresses and folders (default: nil).

mh-default-folder-must-exist-flag

On means guessed folder name must exist to be used (default: ‘on’).

mh-default-folder-prefix

Prefix used for folder names generated from aliases (default: "").

You can set the option mh-default-folder-for-message-function to a function that provides a default folder for the message to be refiled. When this function is called, the current buffer contains the message being refiled and point is at the start of the message. This function should return the default folder as a string with a leading ‘+’ sign. It can also return nil so that the last folder name is used as the default, or an empty string to suppress the default entirely.

Otherwise, the name of the destination folder is derived from the sender as follows:

  1. The folder name associated with the first address found in the list mh-default-folder-list is used. Each element in this list contains a ‘Check Recipient’ item. If this item is turned on, then the address is checked against the recipient instead of the sender. This is useful for mailing lists.
  2. An alias prefixed by mh-default-folder-prefix corresponding to the address is used. The prefix is used to prevent clutter in your mail directory. See Aliases.

If the derived folder does not exist, and mh-default-folder-must-exist-flag is t, then the last folder name used is suggested. This is useful if you get mail from various people for whom you have an alias, but file them all in the same project folder.