procmail
[Top] [All Lists]

Re: Stripping First Word from Subject

1997-01-29 16:34:27
Lars Kellogg-Stedman suggested to Ryan Bradford Neily:

| This mess boils down to:
| 
| :0f
| * ^Subject: *\[JEEP-L[^]]*\] *\/.*
| | formail -I "Subject: $MATCH"

Actually, we can improve that three more ways in addition to those Lars
already has.  First, there's no reason to take the trouble to pass the
through the filter, since the filter changes only the head.  Second, we don't
need to be so specific about what precedes the right bracket, as we know that
this mailing list will always put that expression there (and the list manager
thinks it's a big favor; sheesh).  Third, Lars's suggested regexp will leave
the space after the right bracket in $MATCH, and we don't want it there.

  :0hf
  * ^Subject:.*] *\/[^ ].*
  | formail -I "Subject: $MATCH"

If anything comes in from the Jeep List with no other subject, "[JEEP-L:id#]"
will now remain unchanged as the subject.  However, the cost of keeping that
is that the regexp won't match, so we have to make sure the message still is
filed in the right folder.

So the question is what does Ryan want when "[JEEP-L:id#]" is the entire
subject?  If he wants to preserve it (and drop that part only when there is
more to the subject), then

  :0
  * ^Subject: \[JEEP-L
  {
   :0hf
   * ^Subject:.*] *\/[^ ].*
   | formail -I "Subject: $MATCH"
    
   :0: # use local lockfile unless $MAILDIR/INBOX.JEEP-L is a directory
   INBOX.JEEP-L
  }

If Ryan wants to drop the subject when it consists only of "[JEEP-L:id#]"
(after all, the message will still be filed in the right folder),

  :0fh # keep spacing from incoming subject
  * ^Subject: \[JEEP-L:.*]\/.*
  | formail -I "$Subject:$MATCH"
   :0A:
   INBOX.JEEP-L