MH & nmh: Email for Users & Programmers

May, 2006

Versions of pick: Repeatable Custom Searches

Do you do the same pick search often? For instance, you might get messages from system programs with the word "system error" in their Subject: fields. An MH command version called (for example) pickerrs can find these messages, starting from the current message to the last message in the folder, save their numbers in a sequence named errors, and zero out the previous contents of that sequence (assuming that you've already handled the previous errors). Or you might make a whole series of pick command versions called pick-sun-errs, pick-win95-errs, and so on. That's a hypothetical situation, of course, but it shows what you can do.

To make pickerrs as a version of pick, see the Section Making a New Command Version. To make an alias or function, see the Section Writing Command Versions as Aliases or Functions.

Add an entry similar to the following to your MH profile, or add the arguments to your alias or function.

    pickerrs: -subject system.error -sequence errors -list -zero cur-last
    
The MH profile entry above shows one weakness of making pickerrs as an MH command version: Because a shell doesn't read the MH profile, you can't use shell quoting to keep multiple-word search patterns together. I used a dot (.), a regular expression for "any character", to join the words. An alias or shell function would probably be easier in cases like this.