Re: limit header size

2001-10-25 Thread Gary Johnson

On Wed, Oct 24, 2001 at 09:01:17AM +0200, R . Leponce wrote:

> Is there a way to limit the size of CC and To field when receiving an
> email also sent to many users ?

Not built in to mutt, but it can be done with an external script and the
display_filter variable.  I use the following in my muttrc:

set display_filter=mail-to-filter

where mail-to-filter is a perl script (attached) which I wrote
originally in awk and converted to perl with a2p.

"To:" and "Cc:" lists are only truncated if they are longer than three
lines and the deleted lines are replaced with a message saying how many
lines were deleted.  Since the filter is applied only as the message is
displayed, the original message remains intact so that, for example,
group replies work correctly.

Gary

-- 
Gary Johnson   | Agilent Technologies
[EMAIL PROTECTED]   | Spokane, Washington, USA
http://www.spocom.com/users/gjohnson/mutt/ |


#!/usr/local/bin/perl
# mail-to-filter - strips long distribution lists from mail
#
# AUTHOR
#   Gary A. Johnson <[EMAIL PROTECTED]>
#   Agilent Technologies
#   Spokane, Washington
#   May 22, 2000

eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
# process any FOO=bar switches

$[ = 1; # set array base to 1
$, = ' ';   # set output field separator
$\ = "\n";  # set output record separator

$in_to_list = 0;
$in_cc_list = 0;
$spaces = sprintf('%80s', '');

line: while (<>) {
chop;   # strip record separator
s/\s+$//;   # Remove excess spaces at the ends of lines
# that can cause lines to wrap unnecessarily.
@Fld = split(' ', $_, );

if ($in_to_list == 1) {
if (/^T[Oo]:.*@/) {
$lines += 1;
$last_line = $_;
next line;
}
if (/^[^ \t]/ || /^$/) {
if ($lines == 1) {
print $last_line;
}
elsif ($lines > 1) {
print $indentation . '[' . $lines . ' lines deleted]';
}
$in_to_list = 0;
}
else {
$lines += 1;
$last_line = $_;
next line;
}
}
if ($in_cc_list == 1) {
if (/^C[Cc]:.*@/) {
$lines += 1;
$last_line = $_;
next line;
}
if (/^[^ \t]/ || /^$/) {
if ($lines == 1) {
print $last_line;
}
elsif ($lines > 1) {
print $indentation . '[' . $lines . ' lines deleted]';
}
$in_cc_list = 0;
}
else {
$lines += 1;
$last_line = $_;
next line;
}
}
if (/^T[Oo]:.*@/) {
$indentation = substr($spaces, 1, index($_, $Fld[2]) - 1);
$in_to_list = 1;
$lines = 0;
}
if (/^C[Cc]:.*@/) {
$indentation = substr($spaces, 1, index($_, $Fld[2]) - 1);
$in_cc_list = 1;
$lines = 0;
}
print $_;
}

exit 0;



Re: limit header size

2001-10-24 Thread David Champion

On 2001.10.24, in <[EMAIL PROTECTED]>,
"R . Leponce" <[EMAIL PROTECTED]> wrote:
> Hello all mutt-users !!
> 
> Is there a way to limit the size of CC and To field when receiving an email also 
>sent to
> many users ?

I had this problem with mail forwarded from my VMS account; its mail
facility expanded groups to a big list on the header lines. I came up
with this procmail rule:

FORMAIL=/path/to/formail
TO=`${FORMAIL} -zx To:`
CC=`${FORMAIL} -zx Cc:`

:0 f
* ^A1-type:
| ( \
if [ `echo "$TO" | wc -l` -gt 5 ] ; then \
${FORMAIL} -R To: X-VMS-Long-To-Header: | \
${FORMAIL} -I "To: X-VMS-Long-To-Header:;"; \
else \
cat; \
fi; \
) | ( \
if [ `echo "$CC" | wc -l` -gt 5 ] ; then \
${FORMAIL} -R Cc: X-VMS-Long-Cc-Header: | \
${FORMAIL} -I "Cc: X-VMS-Long-Cc-Header:;"; \
else \
cat; \
fi; \
)

This saves the original to: and cc: headers to X-VMS-Long-??-Header:,
and strips out the corresponding ??: header, whenever the list occupies
more than 5 lines. This might not work for you if your header lines are
all in one long line, but if they're properly continued rfc822 headers,
it should be ok.

You'd want to adapt it a little, of course.

-- 
 -D.[EMAIL PROTECTED]NSITUniversity of Chicago



Re: limit header size

2001-10-24 Thread David T-G

R --

Before I forget, I should note that you should send your posts to the
mailing list at mutt.org instead of at gbnet.net; while mutt.org is
hosted at gbnet, and their address sometimes leaks through, the gbnet
address isn't the right one to use.

...and then R . Leponce said...
% Hello all mutt-users !!
% 
% Is there a way to limit the size of CC and To field when receiving an email also 
sent to
% many users ?

Since you speak of receiving a mail, where those fields are already
created, I can only figure that you want to limit the amount of real
estate they occupy in the pager as you're reading the message.  No,
there's no way to tell mutt to cut a given header after so many bytes,
but you can certainly ignore it.  I'd whip up a pair of macros that
respectively ignore and unignore the To: and Cc: headers.  Something like

  macro pager ,i ":ignore cc to"
  macro pager ,u ":unignore cc to"

might do you, though that code is entirely untested.


% 
% Thanks in advance

HTH & HAND


% 
% R.
% -- 
%  ghost, t'as quel provider ?
%  redhat
% 
%  - #linuxfr


:-D
-- 
David T-G  * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


 PGP signature