Lars Hecking suggested to Adam Shostack, and Chuck Durfee had a similar
recommendation,
H> :0 hfw
H> * ^Subject:[ ]+\[Devteam\][ ]+\/.*
H> | formail -I"Subject: $MATCH"
Problem #1: it requires a separate recipe for each tagging list, which Adam
didn't want to use. Problem #2: it fails if there is a Re: before the tag.
S> :0:devteam.lock
S> |formail -I "Subject: ${SUBJECT}" >> devteam
Actually, Adam didn't need to name the lockfile, as it was implicit,
H> :0:devteam.lock
H> devteam
... and Lars left it uncorrected. A second colon with no name will do fine.
Chuck Durfee responded,
D> TAG="none"
D> :0
D> *^TOdevteam
D> { TAG="devteam" }
D> ... [define $TAG for other mailing lists] ...
Good, that sets things up for a single recipe to be used for many lists.
D> :0 # if TAG changed, munge and deliver
D> * ! TAG ?? none
D> {
D> :0 hfw # don't care what's in the brackets
D> *$ ^Subject:[ ]+\[.*\][ ]+\/.+
D> | formail -I"Subject: $MATCH"
Again, as Stan Ryckman has said the right bracket doesn't need to be escaped,
and as with Lars's suggestion the condition will fail if there is a Re:
before the tag.
D> :0:$TAG$LOCKEXT
D> $TAG
And again, the implicit lockfile name will do the job.
D> }
OK, then, so now that I've criticized everyone else, I should put my money
where my mouth is. This first part is not how I do it, but it will work.
TAG FOLDER # make sure it goes in unset
:0
* conditions for tagging list 1
{ TAG="[tag1]" FOLDER=folder1 }
:0E
* conditions for tagging list 2
{ TAG="[tag2]" FOLDER=folder2 }
:0E
* conditions for tagging list 3, which uses parentheses
{ TAG="(tag3)" FOLDER=folder3 }
and so forth; now for the second part:
:0
* $ ^Subject:(.*\<)?$\TAG\>
{
LEFTSIDE
:0 # pull out Re: or variants
* ^Subject:[ ]*\/R[^ :]+:
{ LEFTSIDE="$MATCH " } # or { LEFTSIDE="Re: " } to make them uniform
:0: # empty match is acceptable
* ^Subject:.*$\TAG[ ]*\/([^ ].*)?
| formail -i"Subject: $LEFTSIDE${MATCH:-empty subject}" >> $FOLDER
}
The whitespace in brackets is space and tab, as usual.