Searching Through Messages

[previous] [next] [table of contents] [index]

Note: HTML conversion may not be complete.

You can search a folder for messages to or from a particular person or about a particular subject. In fact, you can also search for messages containing selected strings in any arbitrary header field or any string found within the messages. Use the M-s command. You are first prompted for the name of the folder to search and then placed in the following buffer (the Figure Pick window) in MH-Pick mode.

Edit this template by entering your search criteria in an appropriate header field that is already there, or create a new field yourself. If the string you're looking for could be anywhere in a message, then place the string underneath the row of dashes. The M-s command uses the MH command pick(1) to do the real work, so read the Section Finding Messages with pick to find out more about how to enter the criteria.

There are no semantics associated with the search criteria -- they are simply treated as strings. Case is ignored when all lowercase is used, and regular expressions (a la ed(1)) are available. It is all right to specify several search criteria. What happens then is that a logical and of the various fields is performed. If you prefer a logical or operation, run M-s multiple times.

Figure: Pick window


As an example, let's say that we want to find messages from Ginnean about horseback riding in the Kosciusko National Park (Australia) during January 16-22, 1994. Normally we would start with a broad search and narrow it down if necessary to produce a manageable amount of data, but we'll cut to the chase and create a fairly restrictive set of criteria as follows:

From: ginnean
Date: Jan 1994
Subject: horse.*kosciusko
As with MH-Letter mode, MH-Pick provides commands like C-c C-f C-t to help you fill in the blanks.
Command    |  Description
C-c C-f C-t|  Move to To: header field
C-c C-f C-c|  Move to cc: header field
C-c C-f C-s|  Move to Subject: header field
C-c C-f C-r|  Move to From: header field
C-c C-f C-b|  Move to Bcc: header field
C-c C-f C-f|  Move to Fcc: header field
C-c C-f C-d|  Move to Dcc: header field
C-c C-c    |  Execute the search
To perform the search, type C-c C-c. The selected messages are placed in the search sequence, which you can use later in forwarding (Forwarding Mail), printing (Printing Your Mail), or narrowing your field of view (Using Sequences). Subsequent searches are appended to the search sequence. If, however, you wish to start with a clean slate, first delete the search sequence (how to do this is discussed in the Section Using Sequences).

If you're searching in a folder that is already displayed in a MH-Folder buffer, only those messages contained in the buffer are used for the search. Therefore, if you want to search in all messages, first kill the folder's buffer with C-x k or scan the entire folder with M-r.

[Table of Contents] [Index] [Previous: Moving Your Mail Around] [Next: Using Sequences]

(This section was written by Bill Wohler.)
Last change $Date: 1996/07/14 17:35:00 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Bill Wohler <>