* Wed 2001-02-14 violet@torithoughts.org list.procmail-smartlist | Peter Hartzler wrote: | | >"8.3: How can I add "[listname]" to all of the mailing list messages for | >easy filtering?" | > | >http://www.hartzler.net/smartlist/SmartList-FAQ.html#Section_8.3 | > | >Let me know if this doesn't cut it. The recipes cited first check for the | >pattern before inserting the tag... | | I'd actually been meaning to write in about this... | | No, unfortuately these recipes won't take care of what David's having | problems with. I've been using Leigh Wolenczak's recipe myself for the | last few years and had constant problems with multiple re:s and listnames | appearing in the subject. May I suggest this procmail module, which I haven't touched long time, but I will update it if it doesn't work. I'm busy elswhere, but I'm planning to put the Procmail development to sourceforge in this Spring. http://www.procmail.org/jari/ Especially see this note at the end: to remove that list prefix, you simply match it JA_SUBJECT_KILL = "(list-xxx|list-yyy)" Jari Pm-jasubject.rc -- Subject field cleaner and canonicalizer (Re:) File id .Copyright (C) 1998-2001 Jari Aalto <jari.aalto@poboxes.com> .$Created: 1998-01 $ .$Contctid: Jari Aalto <jari.aalto@poboxes.com> $ .$Keywords: procmail, subroutine, subject clean $ This code is free software in terms of GNU Gen. pub. Lic. v2 or later Refer to http://www.gnu.org/copyleft/gpl.html Description There are many different Email programs out there that add their own `reply' characters to the subject field. The most sad programs come usually from PC platform. Eg. Microsoft has gained a lot of bad reputation due to it's own standards. o MS Explorer can use localized reply strings, Eg `Vs:' or `vast:' seems to be finnish `Vastaus'. o MS product Outlook (??) can be configured similarly. I have received swedish `Sv:' `-Svar' for `Svaring' (eng: reply) o MS mail uses `FW:' in forwarded mails. o Intelligent MUAs try to keep count of replies with `Re2:' or `Re[2]' o Japanese MUA Denshin 8 Go V321.1b7 has sent Re^2: o Some mua uses `Re>' o Lotus notes (in French version) uses `Ref:' o Some MS product sends `UQ:' o XXX uses `-reply' o Forwarding schemes: (fwd) [fwd] <fwd> fw: [FWD: [FWD:]] o Subject references: -subj subj- subj: There already is a de facto standard where message should contain only single `Re:' if message has been replied to (no matter how many times). This makes it possible to do efficient message threading by only using Subject and date fields. And grepping same subjects is lot easier than from this horrible mess. Note that all text is on one line, the subject has been broken only for visual reasons: Subject: re- Re^2: Re[32]: FW: Re: Re(15) Sv: Re[9]: -reply (fwd) [fwd] <fwd> fw: [FWD: [FWD:]] -subj subj: subj: subj- test This recipe standardizes any subject (like above) that has been replied to, to de facto format below. That is: "Any number of RE will be converted to *single* RE and any number of FWD will be converted to *single* FWD." Subject: Re: test (fwd) About In-Reply-To header If there is `In-Reply-to' header in the message, but there is not *Re:* in the subject line, one is added automatically. Some broken Mailers forget to add the *Re:* to the Subject line. Variable JA_SUBJECT_SAVE This is by default `yes' which makes the original subject saved under header field `X-Old-Subject'. If you don't want that extra header generated, set this variable to `no' Variable JA_SUBJECT_FWD_KILL This is by default `yes', which will kill extra forwarding indication words like (fwd) [fwd] <fwd> <f>. If you set this to `no', then all the fowarding words are preserved. The de facto forwad format is: Subject: This subject (fwd) Code note This subroutine's intention is to make your Subject like more expressive by deleting redundant information. I have taken a simplistic aproach where the Subject consists of list of WORDS whose each attribute can be either `ok' or `delete'. There is no attempt made to investigate the structire of the Subject. I'll explain this better with examples: Re: New subject (was Re: Old subject) should be treated syntactically like "New subject" and forgetting anything between parenthesis. This is however not respected and not even tried. The rule applied here is "One Re: is tolerated", so the subject won't change. It doesn't matter where "Re:" is. But here the subjject is changed. The rule applied is "Delete all unwanted words and then add one Re: to the beginning if OLD content had any Reply indications" Re: New subject (was Re: Old subject) --> Re: New subject (was Old subject) Now you understand how the Subject changing works. IMPORTANT notice Please check that your SHELL variable setting for procmail is `sh' derivate, /bin/sh or /bin/bash. This module won't work well with other shells. Awk usage note `awk' is a small, efective and much smaller than perl for little tasks. See the verbose log and make sure your awk understands VAR="value" passing syntax. Change it to `nawk' or `gawk' if they work better than your standard awk. AWK = "nawk" # you may need this, try also gawk Example usage You need nothing special, just include this recipe before you save message to folder. INCLUDERC = $PMSRC/pm-jasubject.rc Customizations: Let's say Polish M$Outlook uses `ODP:' instead of standard `re:' and you want to handle that too: Then set: JA_SUBJECT_KILL = "odp:" # NOTE: all lowercase JA_SUBJECT_SAVE = "no" INCLUDERC = $PMSRC/pm-jasubject.rc You ca use JA_SUBJECT_KILL to kill any additional words from the subject line. Eg. if you have good newsreader, you don't need the mailing list prefixes that some mailing lists add to the beginning Subject: [LIST-xxx] the subject here to remove that list prefix, you simply match it JA_SUBJECT_KILL = "(list-xxx|list-yyy)" Inportant: The regexp must be _all_ lowercase, because when match happens, the word has been converted to lowercase. Debugging You can dry-run test this module with following command and wathing output. Substitute variables as they are in your system. You feed the content of entire example mail where the Subject that needs correction is found. % procmail SHELL=/bin/sh AWK=gawk VERBOSE=on LOGABSTRACT=all \ PMSRC=txt JA_SUBJECT_KILL="(ace-users)" txt/pm-jasubject.rc \ < ~/test.mail Thank you Thanks to <Tony.Lam@Eng.Sun.Com> for his creative improvement suggestions and sending code that this recipe didn't catch at first.