<<< Date Index >>>     <<< Thread Index >>>

Re: How to copy with badly wrapped lines in pager



* On 2005.05.01, in <20050501185810.GA6825@pc1>,
*       "Ton Boelens" <linux@xxxxxxxxxxxxx> wrote:
> 
> Sometimes, I receive mails from Outlook Express that are 'prewrapped'
> at the wrong width and simply look awfull in my Mutt's pager :-)
> 
> Is there a way to 'rewrap' these messages automatically when they
> arrive (I use Procmail) or to use some kind of display-filer to
> resolve this? Set smart-wrap = yes does not do the trick.


I don't like modifying incoming messages, and no filter is going to be
reliable in all cases, so I hesitate to use a filter all the time.  For
this kind of scenario I've created a display-filter that I activate with
a macro:

macro   pager   \Cr     "<enter-command>set 
display_filter=\"display-filter\"<enter><display-message><enter-command>unset 
display_filter<enter>" "Reflow formatting"

When I get an unreadable message, I press ^R and it's made readable.
(I have a ^X macro that rot-13s the text, which I use the same way.)


Here is "display-filter".  It just presents the headers as they are
and feeds the body to par(1).  It should be modified to stop at a
.signature, but I don't care that much. :)


#!/usr/bin/env perl
##
## a display filter for mutt.
##

use strict;

while (<STDIN>) {
        print;
        last if (/^$/);
}

open (OUT, "| par") or *OUT = *STDOUT;
while (<STDIN>) {
        print OUT "$_";
}
close(OUT);


I find par indispensible -- I use it for reflowing my own text in vi,
too.  (Cue vim vs. vi flamewar.)  I recommend it highly.

My $PARINIT is set: PARINIT="rTbgqR B=.,?!_A_a Q=_s>|+" .  You'll want
something similar if you use that filter.

-- 
 -D.    dgc@xxxxxxxxxxxx        NSIT    University of Chicago