This chapter discusses the things you can do with folders within MH-E. The commands in this chapter are also found in the ‘Folder’ and ‘Message’ menus.
Display cheat sheet for the MH-E commands (
Repeat last output command (
Copy range to folder (
Display cheat sheet for the commands of the current prefix in
Display ticked messages (
Delete range from the ‘unseen’ sequence (
Remove folder (
List all folders (
Display unseen messages (
Pack folder (
Display messages in any sequence (
Rescan folder (
Search your MH mail (
Sort folder (
Undo all refiles and deletes in the current folder (
Visit folder (
Refile (output) range into folder (
Quit the current MH-E folder (
Toggle between MH-Folder and MH-Folder Show modes
Undo pending deletes or refiles in range (
Process outstanding delete and refile requests
The ‘mh-folder’ customization group is used to tune these commands.
Folders searched for the ‘unseen’ sequence (default:
Folders searched for
The number of messages that indicates a large folder (default: 200).
On means to recenter the summary window (default: ‘off’).
On means that commands which operate on folders do so recursively (default: ‘off’).
Additional arguments for
The following hooks are available.
Hook run by x after performing outstanding refile and delete
Hook run by x before performing outstanding refile and delete
Hook run by q before quitting MH-E (default:
Hook run by
mh-folder-mode when visiting a new folder (default:
Abnormal hook run at the beginning of
Hook run by
mh-pack-folder after renumbering the messages
Hook run by q after quitting MH-E (default:
Hook run by o after marking each message for refiling (default:
The following faces are available for customizing the appearance of the MH-Folder buffer. See Scan Line Formats.
Body text face.
Current message number face.
Deleted message face.
Message number face.
Refiled message face.
Fontification hint face in messages sent directly to us. The detection
of messages sent to us is governed by the scan format
mh-scan-format-nmh and regular expression
Sender face in messages sent directly to us. The detection of messages
sent to us is governed by the scan format
and regular expression
Ticked message face.
mh-folder-mode-hook is called when visiting a new
folder in MH-Folder mode. This could be used to set your own key
bindings, for example:
(defvar my-mh-init-done nil "Non-
nilwhen one-time MH-E settings made.") (defun my-mh-folder-mode-hook () "Hook to set key bindings in MH-Folder mode." (if (not my-mh-init-done) ; only need to bind the keys once (progn (local-set-key "//" 'my-search-msg) (local-set-key "b" 'mh-burst-digest) ; better use of b (setq my-mh-init-done t)))) (add-hook 'mh-folder-mode-hook 'my-mh-folder-mode-hook) (defun my-search-msg () "Search for a regexp in the current message." (interactive) ; user function (save-window-excursion (other-window 1) ; go to next window (isearch-forward-regexp))) ; string search; hit return ; when done Create additional key bindings via mh-folder-mode-hook
MH-E has analogies for each of the MH
refile commands28. To refile a message in
another folder, use the command o (
(mnemonic: “output”). You are prompted for the folder name
(see Folder Selection). Note that this command can also be used to
create folders. If you specify a folder that does not exist, you will
be prompted to create it. The hook
mh-refile-msg-hook is called
after a message is marked to be refiled.
If you are refiling several messages into the same folder, you can use
the command ! (
mh-refile-or-write-again) to repeat the
last refile or write (for the description of >
mh-write-msg-to-file), see Files and Pipes). You can use a
range in either case (for example, C-u o 1 3 5-7 last:5 frombob
RET, see Ranges).
If you’ve deleted a message or refiled it, but changed your mind, you
can cancel the action before you’ve executed it. Use u
mh-undo) to undo a refile on or deletion of a single message.
You can also undo refiles and deletes for messages that are found in a
given range (see Ranges).
Alternatively, you can use F u (
mh-undo-folder) to undo
all refiles and deletes in the current folder.
If you’ve marked messages to be deleted or refiled and you want to go
ahead and delete or refile the messages, use x
mh-execute-commands). Many MH-E commands that may affect the
numbering of the messages (such as F r or F p) will ask if
you want to process refiles or deletes first and then either run
x for you or undo the pending refiles and deletes.
The command x runs
before the commands are processed and
mh-after-commands-processed-hook after the commands are
processed. Variables that are useful with the former hook include
mh-refile-list which can be used to
see which changes will be made to the current folder,
mh-current-folder. Variables that are useful with the latter
mh-folders-changed, which lists which folders were
affected by deletes and refiles. This list will always include the
If you wish to copy a message to another folder, you can use the
command c (
mh-copy-msg) (see the -link argument
refile(1)). Like the command o, this command
prompts you for the name of the target folder and you can specify a
range (see Ranges). Note that unlike the command o, the copy
takes place immediately. The original copy remains in the current
The command t (
mh-toggle-showing) switches between
MH-Folder mode and MH-Folder Show mode29. MH-Folder mode turns off
the associated show buffer so that you can perform operations on the
messages quickly without reading them. This is an excellent way to
prune out your junk mail or to refile a group of messages to another
folder for later examination.
When you use t to toggle from MH-Folder Show mode to MH-Folder
mode, the MH-Show buffer is hidden and the MH-Folder buffer is left
mh-recenter-summary-flag to a non-
value causes the toggle to display as many scan lines as possible,
with the cursor at the middle. The effect of
mh-recenter-summary-flag is rather useful, but it can be
annoying on a slow network connection.
When you want to read the messages that you have refiled into folders,
use the command F v (
mh-visit-folder) to visit the
folder. You are prompted for the folder name. The folder buffer will
show just unseen messages if there are any; otherwise, it will show
all the messages in the buffer as long there are fewer than
mh-large-folder messages. If there are more, then you are
prompted for a range of messages to scan. You can provide a prefix
argument in order to specify a range of messages to show when you
visit the folder (see Ranges). In this case, regions are not used
to specify the range and
mh-large-folder is ignored. Note that
this command can also be used to create folders. If you specify a
folder that does not exist, you will be prompted to create it.
If you forget where you’ve refiled your messages, you can find them
using F s (
mh-search). See Searching.
If you use a program such as
procmail to file your incoming
mail automatically, you can display new, unseen, messages using the
command F n (
mh-index-new-messages). All messages in the
‘unseen’ sequence from the folders in
mh-new-messages-folders are listed. However, this list of
folders can be overridden with a prefix argument: with a prefix
argument, enter a space-separated list of folders, or nothing to
search all folders.
If you have ticked messages (see Sequences), you can display them
using the command F ' (
messages in the ‘tick’ sequence from the folders in
mh-ticked-messages-folders are listed. With a prefix argument,
enter a space-separated list of folders, or nothing to search all
You can display messages in any sequence with the command F q
mh-index-sequenced-messages). All messages from the folders in
mh-new-messages-folders in the sequence you provide are listed.
With a prefix argument, enter a space-separated list of folders at the
prompt, or nothing to search all folders.
Set the options
mh-ticked-messages-folders to ‘Inbox’ to search the
‘+inbox’ folder or ‘All’ to search all of the top level
folders. Otherwise, list the folders that should be searched with the
‘Choose Folders’ menu item. See
Other commands you can perform on folders include: F l
mh-list-folders), to place a listing of all the folders in
your mail directory in a buffer called *MH-E Folders*
(see Miscellaneous); F k (
mh-kill-folder), to remove
a folder; F S (
mh-sort-folder), to sort the messages by
sortm(1) to see how to sort by other criteria);
F p (
mh-pack-folder), to pack a folder, removing gaps
from the numbering sequence; and F r (
to rescan the folder, which is useful to grab all messages in your
‘+inbox’ after processing your new mail for the first time. If
you don’t want to rescan the entire folder, the commands F r or
F p will accept a range (see Ranges).
The command F p runs
renumbering the messages. A variable that is useful with this hook
By default, operations on folders work only one level at a time. Set
mh-recursive-folders-flag to non-
nil to operate on all
folders. This mostly means that you’ll be able to see all your folders
when you press TAB when prompted for a folder name.
mh-kill-folder-suppress-prompt-functions is an abnormal
hook run at the beginning of the command k. The hook functions
are called with no arguments and should return a non-
nil value to
suppress the normal prompt when you remove a folder. This is useful
for folders that are easily regenerated. The default value of
mh-search-p suppresses the prompt on folders generated by
Use this hook with care. If there is a bug in your hook which returns
ton ‘+inbox’ and you press k by accident in the
+inboxfolder, you will not be happy.
mh-sortm-args holds extra arguments to pass on to
sortm30 when a prefix argument is used with F S. Normally
default arguments to
sortm are specified in the MH profile.
This option may be used to provide an alternate view. For example,
‘'(\"-nolimit\" \"-textfield\" \"subject\")’ is a useful setting.
When you want to quit using MH-E and go back to editing, you can use
the q (
mh-quit) command. This buries the buffers of the
current MH-E folder and restores the buffers that were present when
you first ran M-x mh-rmail. It also removes any MH-E working
buffers whose name begins with ‘ *mh-’ or *MH-E
(see Miscellaneous). You can later restore your MH-E session by
selecting the ‘+inbox’ buffer or by running M-x mh-rmail
The two hooks
called by q. The former one is called before the quit occurs, so
you might use it to perform any MH-E operations; you could perform
some query and abort the quit or call
example. The latter is not run in an MH-E context, so you might use it
to modify the window setup. If you find that q buries a lot of
buffers that you would rather remove, you can use both
mh-quit-hook to accomplish that.
(defvar my-mh-folder-buffer-to-delete nil "Folder buffer that is being quit.") (defun my-mh-before-quit-hook () "Save folder buffer that is to be deleted." (setq my-mh-folder-buffer-to-delete (current-buffer))) (defun my-mh-quit-hook () "Kill folder buffer rather than just bury it." (set-buffer my-mh-folder-buffer-to-delete) (if (get-buffer mh-show-buffer) (kill-buffer mh-show-buffer)) (kill-buffer (current-buffer))) Kill MH-Folder buffer instead of burying it
You can use dired to manipulate the folders themselves. For example, I
renamed my ‘+out’ folder to the more common ‘+outbox’ by
running dired on my mail directory (M-x dired RET ~/Mail RET),
moving my cursor to ‘out’ and using the command R
For you Emacs wizards, this is implemented as an Emacs minor mode.
See the section Sorting Messages: sortm in the MH book.