procmail
[Top] [All Lists]

Re: fmt to reformat body

2000-07-12 13:31:00
Dave Robbins asked,

| I often receive mail in which the sender's MUA is creating lines
| longer than 80 characters.  Generally, I just use "pipe fmt"
| in mailx to look at this but then I don't get it /bin/more'd.

Would mailx let you pipe fmt | more, or pipe 'fmt|more' with the apostrophes?

| If I wanted procmail to do this for me for a particular sender
| already being filtered, how would I change the following simple
| recipe to do the fmt and -not as important- change or delete
| the now incorrect Content-Length header?
| 
|    :0c
|    * ^From(_dot_)*rex138(_at_)aol(_dot_)com
|    rex.king
| 

First, you need to filter, not save a copy; second, you need to filter only
the body.  Third, I'd say it makes more sense to check the message rather
than the sender.  If only one sender or a few are problems, you could have
a condition to check who is sending as well, but it certainly is not worth
reformatting the occasional message from such a person that doesn't exceed
sensible width.

  :0Bbf # eighty dots total (see note farther along)
  * ........................................\
    ........................................
  | fmt -72

I'd say to forget about the Content-Length: header, because if anything you
are making the message longer by adding more newlines, and Content-Length:
just says how far to count in the body before looking for another postmark
line.  Shortening a message can get you into trouble if you don't fix or
remove Content-Length:, but lengthening almost never will.

But if you are concerned, add this recipe next:

  :0Ahf # if there's a Content-Length: header, remove it
  * ^Content-Length:
  | formail -I Content-Length:

Now for that note: many terminal types automatically go to the beginning of
the next line if a character is displayed in the rightmost column, so a block
of text justified to eighty columns would show up double-spaced on an eighty-
column screen.  It's safer to disallow filling the line as well as exceeding
it and to reformat any text with an eighty-character line but pass any where
the longest line is seventy-nine characters or narrower.  That's why I put
only eighty, not eighty-one, periods into the condition line; even eighty
should be enough to reformat.  However, if your terminal type works diffe-
rently and you want to allow eighty-character lines as long as there are no
eighty-one-character lines, add an eighty-first period to the condition.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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