On 11.05.2015, Ian Zimmerman wrote: 

> 2. Mailman managed lists (and maybe others) insert the annoying [Foo-List]
> tags in the Subject header.  Other MUAs allow one to massage the Subject
> header (for display only) so as to hide the tag, and (again) save screen
> space.  Is this possible with mutt?  Should it be?

Use procmail or similar to filter your mail. Here's a quick'n'dirty hack to do
the job (and to encourage others to make it different/better):

#!/usr/bin/perl

while (<>) {
    if (/^Subject:/) {
            @test = split;
            @test = grep !/\[.*\]/, @test;
            $newsubject = join (" ", @test);
            s/^Subject:.*/$newsubject/;
        }
    print STDOUT $_;
}


Just pipe the mailheader through the script.

You could also do something hackish like that within a procmail rule:

:0fh
| perl -pe 's/^Subject:\s+(.*)\[Mailinglist-tag\]\s*(.*)/Subject: $1$2/; '

The first one could also be "enhanced" to decode/encode UTF and the like, if it
should be necessary, e.g. something like that:

#!/usr/bin/perl

use Encode;

while (<>) {
    if (/^Subject:/) {
        if (/\s*\=\?iso-8859/i) {
            $_ = decode("MIME-Header", $_);
            @test = split;
            @test = grep !/\[.*\]/, @test;
            $subject = join (" ", @test);
            $newsubject = encode("MIME-Header", $subject);
            # $newsubject  = encode("iso-8859-1", $subject);
            s/^Subject:.*/$newsubject/;
        }
        if (/\=\?UTF-8/i) {
            $_ = decode("MIME-Header", $_);
            @test = split;
            @test = grep !/\[.*\]/, @test;
            $subject = join (" ", @test);
            $newsubject = encode("MIME-Header", $subject);
            s/^Subject:.*/$newsubject/;
        }
        else {
            @test = split;
            @test = grep !/\[.*\]/, @test;
            $newsubject = join (" ", @test);
            s/^Subject:.*/$newsubject/;
        }
    }
    print STDOUT $_;
}

Reply via email to