procmail
[Top] [All Lists]

Re: Trimming the Subject

1998-01-14 15:04:03
Vikas Angihotri asked,

| To compound the problem, some stupid MUAs out there (PC-based surely) have
| the following Subject: header.
| 
| Subject: Re: The real subject -Reply
|                             ^^^^^^
| or even
| 
| Subject: Re: The real subject -Reply -Reply
| 
| The stupid '-Reply' string above throws off the Subject: sorting and these
| mails are detached from the  thread they belong to.
| 
| How can I trim out the -Reply string from the subject here? 
| 
| Ideally, I dont want to fork off 'sed' to do the job and have procmail do
| it itself?

Eventually you'll need a program -- formail if not sed or perl -- to replace
the bloated subject with the stripped one.  If you want to do as much as
possible within procmail, you'll need a recursive INCLUDERC setup.  Haven't
we done one for this very question before?

   :0
   * ^Subject:.*- *Reply *$
   {
    :0
    * ! ^Subject: Re[^ ]+: *\/[^ ].+
    * ! ^Subject: *\/[^ ].+
    { }
    :0E
    { RESTOFSUBJECT=$MATCH
      INCLUDERC=.strip-reply-rc

      :0fwh
      | formail -I "Subject: Re: $RESTOFSUBJECT"
    }
   }
    
and .strip-reply-rc would look something like this:

  :0
  * RESTOFSUBJECT ?? ^^\/.*-
  * MATCH ?? ^^\/.*[^-]
  { RESTOFSUBJECT=$MATCH

    :0
    * RESTOFSUBJECT ?? - *Reply *$
    { INCLUDERC=$_ }
  }

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