[comp.mail.mh] Message sorting into folders when doing inc

he@idt.unit.no (05/19/89)

This is a beginners question on using MH. I have read the documentation,
but have not found what I was looking for.  I have also read the
comp.mail.mh newsgroup for a while, with same result (unfortunately, I am
currently unable to post to that newsgroup).

What I am looking for, is a way to tell 'inc' to sort individual messages
into their respective folders based on criteria a'la pick, instead of
lumping them all into +inbox. I have found a couple of alternative ways to
do (almost) what I want, but not quite:

 - mhook. This is asynchronous, and therefore undesirable. I want to
   control when messages are inc'ed.

 - repeated combinations of pick and refile with the desired criteria.
   This is undesirable for a number of reasons:

     - inefficient -- several passes with 'pick' of new messages
     - what happens when 'pick' returns no messages as in
       % refile `pick criteria` +to-folder
       I suspect the result would not be what I wanted, especially if
       several of these are run "automatically" in sequence.

I also inspected the paper "MH.5: How to process 200 messages a day and
still get some real work done", and didn't find an explanation of this
there either. It is hard for me to imagine how anyone can accomplish the
feat described above without automatic sorting of messages into appropriate
folders, so I suspect this is an old question.  I will happily pursue any
pointers to the documentation or elsewhere for more information on how to
do this. If the suggested method also works with xmh (the X.11 frontend,
you know), so much the better.

Thanks in advance.

Haavard Eidnes, Division of Computer Systems and Telematics
he@idt.unit.no		Norwegian Institute of Technology

jdpeek@RODAN.ACS.SYR.EDU (Jerry Peek) (05/19/89)

> This is a beginners question on using MH. I have read the documentation,
> but have not found what I was looking for.  I have also read the
> comp.mail.mh newsgroup for a while, with same result (unfortunately, I am
> currently unable to post to that newsgroup).

You just did.  If you post to this mailing list, it's sent to the newsgroup
(but messages posted directly to the newsgroup do NOT show up on this list...)

> What I am looking for, is a way to tell 'inc' to sort individual messages
> into their respective folders based on criteria a'la pick, instead of
> lumping them all into +inbox.

I have a shell script called "inc_split" that can be hacked to do what you
want.  I wrote it to run unattended, once a day or so, on a "housekeeping"
account that gets log and error messages in the mail.  The script refiles
messages from certain addresses, and leaves the rest in the inbox folder.
It sends mail to the gurus and shows them what's in the inbox.
You'd probably need to hack on it some.  I'd be glad to send you a copy.

Maybe this is enough to help you, though:  The script uses the feature called
"Unseen-sequence" to decide which mail in the inbox hasn't been touched.
To use this, put a line in your .mh_profile that says:    
	Unseen-sequence: unseen
When "inc" runs, it puts a list of the unread messages in a sequence called
"unseen".  You can use this sequence with the "pick" command, like this:
	pick unseen -from fred -seq temp
This command tells "pick" to look through the list of unseen messages --
and put a list of all the messages from "fred" in another sequence called
"temp".  Then, you can use this sequence with a command like refile:
	refile temp +somefolder
or in a Unix shell script, to do something else:
	dosomething `mhpath temp`

Hope that helps.

> Haavard Eidnes, Division of Computer Systems and Telematics
> he@idt.unit.no		Norwegian Institute of Technology

--Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY
  jdpeek@rodan.acs.syr.edu, jdpeek@suvm.bitnet
  +1 315 443-3995

mcgrew@ichthous.Sun.COM (Darin McGrew) (05/20/89)

In article <8905191059.AA14214@garm> he@idt.unit.no writes:
>     - what happens when 'pick' returns no messages as in
>       % refile `pick criteria` +to-folder
>       I suspect the result would not be what I wanted, especially if
>       several of these are run "automatically" in sequence.

Here's the version of MH we have...

	version: MH 6.5 #65[UCI] (crowd) of Tue Feb 28 11:22:13 PST 1989
	options: [ATZ] [BANG] [BERK] [BIND] [BSD42] [BSD43] [DUMB] [MHE]
		 [NETWORK] [OVERHEAD] [RPATHS] [TTYD] [FOLDPROT='"0700"']
		 [MSGPROT='"0600"'] [SBACKUP='"#"'] [SENDMTS] [SMTP]

Our version of pick has a -list option that forces it to print a
0 when nothing matches, thus:

	% pick -list -from no_such_user
	pick: no messages match specification
	0
	% refile `pick -list -from no_such_user` +my_folder
	pick: no messages match specification
	refile: no messages match specification

I'm still able to cope with refiling my messages by hand, so I
don't have any solutions for automatically sorting mail.

Darin

gregg@cbnewsc.ATT.COM (gregg.g.wonderly) (05/22/89)

From article <8905191059.AA14214@garm>, by he@idt.unit.no:
> This is a beginners question on using MH. I have read the documentation,
> but have not found what I was looking for.  I have also read the
> comp.mail.mh newsgroup for a while, with same result (unfortunately, I am
> currently unable to post to that newsgroup).
> 
> What I am looking for, is a way to tell 'inc' to sort individual messages
> into their respective folders based on criteria a'la pick, instead of
> lumping them all into +inbox. I have found a couple of alternative ways to
> do (almost) what I want, but not quite:

I wrote a replacement for slocal which I call rcvmail.  It reads the file
~/.mh_delivery which contains lines of the form

pick args		:	accept/reject	:	shell command

When mail is passed to it on stdin, it files the mail into the folder,
+newmail (by default) using rcvstore(1).  It then runs commands of
the form

pick all +newmail 'pick args'

on a pipe.  When pick returns matches, it runs 'shell command' with
the messages (one at a time).  If accept is specified, the message
is accepted as delivered and rcvmail exits.  If reject is specified
the it continues through the actions until one matches, or EOF is reached.
At EOF, the message is filed into +inbox with the Unseen-sequence set.

I have modified rcvstore(1) so that it accepts a -alert flag which causes
it to send scan lines formatted by, scan.new, to the terminal, or to the
fifo ~/.maildrop if it exists (this allows me to run cat off of the fifo to
a specially allocated window on my 630).  A new component (pseudo I suppose),
%{folder}, was added to allow the scan line to look like

inbox  8  14:24  foobar@goof.us.dis   [ Just some stuff ]  <<Gregg, I notic

(scansbr.c knows about a global char * which is set to the folder name
by rcvstore(1).  Other MH programs could do this too, but I haven't
though of a reason for them to yet) This is really great because as I
get new mail that is squirreled away into some folder, I know when I
get it, where to find it.

Now for the biggy.  How do I find everything when I log in and have new
mail?  Easy, I modified m_update(), and added some routines of my own,
so that MH maintains lines in ~/Mail/context of the form (unread is my
Unseen-sequence)

unread: inbox mh trains planes automobiles

A new mh program, seq(1), will return either the sequences that a folder
contains, or the folders containing a sequence.  So, I have a simple
shell script which pushes the folder list onto the Folder-Stack, and
does

	echo "New mail in '`folder -list`'"

I can then just do

while there are folders with unread mail
do
	scan unread

	show them
	show them
	show them

	folder -pop
done

-- 
-----
gregg.g.wonderly@att.com   (AT&T bell laboratories)