# Searching in exmh

There are several ways to search for things in exmh:

## In the current message.

Search for a string in the current message body. Searching uses regular expression syntax, and case is ignored. Note that this only looks in the currently displayed message. (Use the "Search" field in Pick to search through all messages in a folder. )

## In the scan listing

Search for a string in the table of contents. Searching uses regular expression syntax, and case is ignored. This just searches over what you can see in the display. If you select All, then all matching messages are selected.

## In the current folder

The MH pick program is used to search within a folder. This can run slowly because each message in the folder must be processed.

The pick dialog displays some command buttons, two fields, and a menu that says "Choose pick option".

Ignore the fields labeled "Add to Sequence" and "Pick from Seq/msg" unless you are already familiar with pick.

Choose your selection criteria with the menu, which offers:

- subject
- from
- to
- cc
- before - select messages received before this date or time.
- after - select messages received after this date or time.
- search - search the contents of all messages for a string.
- component - enter a mail header name, like X-URL, and a value to search for in that header.

If you choose more than one option, the messages must match all of them, unless you use the Not and Or buttons to build up more complex criteria.
The "Add to Sequence(s)" option will add the matching messages to an MH sequence. Just pick a meaningful name for the sequence.

The "Pick from Seq/msg(s)" lets you narrow the search to a sequence (e.g., "unseen" or something you defined yourself) or a set of messages (e.g., last:100 for the last 100 messages in the folder).
The "Add to Sel" option determines if the matching messages are added to the currently selected set, or if a new set is created.

## In all folders

A full text search over all folders uses the Glimpse facility.

First you must create an index, which costs about %10 to %15 space overhead based on the size of your message storage. You can index the current folder or all folders. The indexing runs in the background but it may take some time.

The search can be over all folders, the current folder, or the current folder and all of its nested folders. A search over multiple folders can be stopped, although the Stop happens at the end of a folder.

The search tolerates spelling errors, and you can control this with the Opts... menu.

The results of the search are displayed, and you can click on the message IDs and exmh will visit that message.

### Maintaining your Glimpse Indexes.

The exmh interface does not automatically maintain your Glimpse Indexes. The typical scenario is that you periodically index your mail, either by choosing Index as you leave for the day, or with a nightly "cron job". Your job can send a Tcl command to Exmh and have it do all the hard work. You may have trouble connecting to exmh, but you can try something like:

In your crontab, for 1:30 AM

    30 1 * * * /tilde/welch/scripts/glimpseindex -display unix:0

In the script, using a hack to allow /bin/sh to run the script:

#!/import/tcl/bin/wish4.0.g
# The next line is a comment in Tcl, but not to /bin/sh \
exec /import/tcl/bin/wish4.0.g -f "$0" ${1+"$@"}
message .msg -text "Starting Glimpse Index"
pack .msg
if [catch {send exmh Glimpse_Index} err] {
catch {exec cat > /dev/console << $err}
}
exit

If you want to write your own script, use something like this:

#!/bin/csh -f
cat /dev/null > ~/Mail/glimpseindex.log
foreach f (`cat ~/Mail/.folders`)
glimpseindex -H /tilde/welch/Mail/.glimpse/$f ~/Mail/$f | \
egrep '(Indexing|Size)' >> ~/Mail/glimpseindex.log
end

## Main Help Index