[Top] [All Lists]

Re: using formail and sed to remove subject cruft

2001-08-12 21:24:57
Doug Porter <dsp(_at_)waterspout(_dot_)com> writes:
I've got a little regex issue here.  This is almost certainly a
silly regex mistake on my part, but no one who has looked at this
thus far has figured it out. :/

A little background first...  I filter mail from all the lists I
am subscribed to into individual folders.  I really dislike lists
that put [list-name] in the subject because it just waste
valuable space on the screen.  I worked up the following stuff a
couple months ago to filter most lists and remove the junk from
the subject.

* ^(List-Id|X-Mailing-List): [^<]*<\/[^>]+>
   LIST=`echo $MATCH | sed -e 's/[(_dot_)(_at_)](_dot_)*$//'`

If you wrote the initial condition differently, you eliminate the need
for that sed command:

        * ^(List-Id|X-Mailing-List): [^<]*<\/[^.@>]+
                LIST = $MATCH

   :0 Wh
   SUBJECT=| formail -fxSubject:

   SUBJECT=`echo $SUBJECT | sed -e 's/\['$LIST'\][ ]*//i'`

   :0 fWh
   | formail -fI"Subject: $SUBJECT"

Ditto, I think:
        :0 fWh
        * $ ^Subject: *\[$\LIST\]\/.*
        | formail -fI"Subject: $MATCH"

There is obviously more to my procmailrc, but that is the part
that counts for this discussion.  Cleaning the subject seems to
work great on all the lists I am except one.  When the message
contains "Subject: [Mailman-Developers] this is an example" and
"List-Id: <>" the subject ends up
being (without fail) "Subject: l this is an example" instead of
what I want, "Subject: this is an example".

If the above doesn't fix it, or if that latter recipe doesn't work so you
have to go back to your previous version, then you should try turning
on verbose logging iff the message is from that list.  Put this right
after the LIST assignment:

        * LIST ?? mailman-developers
        { VERBOSE = on }

and then check your logfile (you _do_ have a logfile, right?) to see
what it shows for the SUBJECT assignments or formail invocation.

Philip Guenther
procmail mailing list

<Prev in Thread] Current Thread [Next in Thread>