Format files and message ranges make the scan command really flexible, and the next two examples should get you started on custom versions that do just what you want. Beginning with MH 6.7, scan lets you scan files such as your system mailbox. This section shows you how to scan your new (unincorporated) mail.
For example, to scan the current message (and change folder to project):
% cur +project 24+ SENT: 19Jan CHARS: 1068 FROM: Raymond LaPlante <ray@phobos.spacey.com> TO: Al Bok <al@phl.ph.com>, zot!ant@uunet.uu.net SUBJ: Update on my researchTo make c10, cur, l5, or whatever you choose as versions of cur, see the Section Making a New Command Version. To make aliases or functions, see the Section Writing Command Versions as Aliases or Functions.
Then, add entries like the following to your MH profile -- or add the arguments to your alias or function. Of course, you don't have to use the same names or switches shown here:
c10: cur:+10 cur: cur -form scan.more -width 235 l5: -reverse last:5 n20: cur:-10 cur:10For cur:, I used the scan.more file.
% sscan 2 3 2 11/23 15326 Al Bok Query about "repl -query"<<I ha 3 -02/09 739 "Wilbur, Orville" X Terminal Presentation/DemonstTo make sscan as a version of scan, 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 the following entry to your MH profile, or add the arguments to your alias or function:
sscan: -form scan.sizeThe Section MH Format Strings shows how to make custom scan formats. These format files are perfect to use in a new scan version.
NOTE: msgscan only works with the new scan -file switch in MH 6.7 -- earlier versions of scan don't have it.
Here's an example -- with a couple of msgchk commands:
% msgchk You have new mail waiting; last read on Mon, 09 Jan 1995 20:49:54 EST % msgscan 1 01/10 21:54EST To:al@phlabs.ph.co New MH feature<<Al, scan is 2 01/10 21:13CST Al Bok Re: New MH feature<<I scann % msgchk You have old mail waiting; last read on Tue, 10 Jan 1995 09:00:05 ESTThe first msgchk shows that there's mail to read. Running msgscan tells that there are two messages waiting; one is a message you sent last night, the other is a reply. Another msgchk calls your mail "old" and says that you've "read" the mail. That's because msgscan reads your system mailbox directly. But the mail is still there, like before; msgscan just changes the mailbox file's last-access time when it reads for new mail.
With the scan.msgscan file, the output looks like this:
% msgscan From: "Emma H. User" <ehuser@phlabs Subject: New MH feature ------------------- From: Al Bok <al@phlabs.ph.com> Subject: Re: New MH feature -------------------My scan.msgscan file cuts off the first line at 35 characters. Your version doesn't have to.
The steps to make your own msgscan are:
Add an entry like one of the two below to your MH profile -- or add the arguments to your alias or function. Be sure to replace username with your own username and fix the pathname for your system mailbox:
msgscan: -file /usr/spool/mail/username -form scan.time msgscan: -file /usr/spool/username -form scan.msgscan -width 120
%<{from}From: %35{from}%|%<{sender}Sender: %35{sender}%|\ Apparently-From: %35{apparently-from}%>%>\n\ %<{subject}Subject: %{subject}\n%>\ -------------------
$ for num in 2-22 unseen:5 ...not what you want > do show $num | printer -h "Message $num" > doneWhat you want is a command that will expand the MH ranges and sequences into individual message numbers. The loop needs to look like this:
$ for num in 2 3 6 15 20 22 44 45 46 47 48 ...the effect you want > do show $num | printer -h "Message $num" > doneBut you don't want to type in those message numbers -- or to have to figure out which message numbers in a range are valid. (As you can see, a range like 2-22 can have gaps in the message numbering.) The msgnums version of scan does what you want. It expands ranges and sequences into message numbers:
$ for num in `msgnums 2-22 unseen:5` ...the answer > do show $num | printer -h "Message $num" > doneThe Section Working in an MH Directory has another example.
A lot of people use pick to make lists of message numbers. But, in my experience, msgnums runs faster than pick.
To make msgnums as a version of scan, 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 the following entry to your MH profile, or add the arguments to your alias or function:
msgnums: -format %(msg)In a shell alias or function, you'll have to put quotes around %(msg). Remember that scan options like -reverse in the MH profile will affect an alias or function.
This uses the MH format string %(msg), which gives the number of the current message.
[Table of Contents] [Index] [Previous: Version of send: push] [Next: Fast Folder Changes with fo]
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: Jerry Peek <jerry@ora.com>
HIVE: All information for read only. Please respect copyright! |