Re: How to display format=flowed?
* On 2005.10.12, in <20051012193111.GB15632@xxxxxxxxxxxxxxxxx>,
* "Kyle Wheeler" <kyle-mutt@xxxxxxxxxxxxxx> wrote:
>
> Filtering through par is a pretty nifty solution. I'm a little picky,
> though... I would change your perl script like so (to avoid problems
> with attribution lines and signatures):
Thanks! I don't use it often and just haven't worried about it, but
your thinking is right, and I'll update my copy.
I already have a PARINIT, though, so I'll just take the bits that change
for this purpose. :) My PARINIT='rTbgq B=.,?!_A_a Q=_s>|+' . Adding P
is certainly wise, for e-mail, but I don't always want it. I found R
unappealing as it terminates the display if anything fills a single line
up to the screen width.
Really there should be a "$cols -= 2" in there, too. I added that just
before posting, for portability. :p
Hmm... this almost makes it desirable to switch directions and use the
filter by default, with a macro for the cases where I *don't* want it.
--
-D. dgc@xxxxxxxxxxxx NSIT University of Chicago
#!/usr/bin/env perl
##
## a display filter for mutt.
##
use strict;
## Find window width.
my $cols = `tput cols`;
chomp $cols;
$cols -= 2;
# Reflow using fmt:
#my $fmt = "fmt -w$cols";
# Or reflow using par:
# (I have PARINIT='rTbgq B=.,?!_A_a Q=_s>|+' . The par command
# here should contain display-filter settings that aren't in your
# general-purpose PARINIT.)
my $fmt = "par w${cols}h P=_s";
# Presume no .signature, but check later.
my $has_sig = 0;
# Skip header block
while (<STDIN>) {
print;
last if (/^$/);
}
# Reflow the body, if formatter is found.
open (FMT, "| $fmt") or *FMT = *STDOUT;
while (<STDIN>) {
# Stop reflowing at signature indicator. Can't just reassign output
# fh because it can put perl's output and $fmt's output out of order.
if (/^-- $/) {
$has_sig = 1;
print;
last;
}
print FMT "$_";
}
# Copy the .signature, if found.
if ($has_sig) {
print while (<STDIN>);
}
close(FMT);