procmail
[Top] [All Lists]

Re: the "-Reply" nonsense

1997-08-20 17:30:00
Timothy Luoma asked,

| Anyone else sick of this?
| 
|       Subject: a topic we have talked about -Reply
| 
| rather than
| 
|       Subject: Re: a topic we have talked about

I'm sick of it only because responses to such a subject end up with both
"Re:" in front and "-Reply" on the end ... though often they come in that
way, because "-Reply" was appended to a subject that already had "Re:".

| How do I get rid of the -Reply and _pre_pend a "Re:" _unless_ one is
| already there?

Timothy, I agree with some of your logic but you have an awful lot of forks
in your suggested code (and when I come to a fork in the code, I take the
code less traveled by).  It can be done within procmail without all the seds
and pipes and with only one call to formail at the tag end.

So, here we go ... in the main rcfile (this requires a recent enough version
of procmail such that MATCH can be reset in the middle of a recipe):

 :0
 * ^Subject:\/.+-Reply$
 {
  CURRENT_SUBJ=$MATCH
  INCLUDERC=$HOME/.-replystriprc # or wherever

  :0fwh
  | formail -zI "Subject: $FINAL_SUBJ"
 }

and in ~/.-replystriprc,

 # Keep taking off -Reply until all occurrences are gone.
 # Brackets in first condition enclose space and tab;
 # those in third condition enclose caret, hyphen, space, tab.
 :0
 * CURRENT_SUBJ ?? ^^.-Reply[   ]*$
 * CURRENT_SUBJ ?? ^^\/.+-
 * MATCH ?? ^^\/.*[^-   ]
 { CURRENT_SUBJ=$MATCH  INCLUDERC=$_ }

 # When the first part stops recursing, make sure Re: is present and return.
 # `E' flags will make procmail skip these while earlier recursions unwind.
 :0E
 * CURRENT_SUBJ ?? ^Re[^a-z]*:
 { FINAL_SUBJ=$CURRENT_SUBJ }
 :0E
 { FINAL_SUBJ="Re: $CURRENT_SUBJ" }

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