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

Re: Recommended mail filters for use with mutt?



On Fri, Apr 04, 2008 at 11:43:17PM +0200, Alain Bench wrote:
>  On Friday, April 4, 2008 at 10:53:02 +0100, Chris Green wrote:
[...]
> Something like a $display_filter acting on index but not on replies
> would surely be good, but it doesn't exist yet.

Aside: back in 2006 I implemented something like this for 1.5.12 by
incorporating a Lua interpreter into mutt.  When displaying a subject
line, mutt would convert the message's ENVELOPE data into a Lua table,
call a Lua function "get_printable_subject", and then use whatever
string came back as the displayed subject line.  The actual message
file/data was never modified, so when replying it would still use the
original subject line.

> > [MDA] removes those annoying "[<list name>]" insertions in the subject
> > lines

Ironically my goal was to _add_ those [list] tags to the lists that
didn't already have them.  I normally use a single inbox for all mail
and I wanted my lists consistently marked.  The Lua code looked
something like this:

    function is_to(envelope,addr)
        return envelope.to ~= nil and envelope.to[1].mailbox == addr
    end

    function is_xubuntu_message(envelope)
        return is_to(envelope,'xubuntu-devel@xxxxxxxxxxxxxxxx')
    end

    function get_printable_subject(envelope)
        local subject = envelope.subject
        if subject == nil then subject = '' end

        if is_xubuntu_message(envelope) then
            subject = '[xubuntu] ' .. subject
        end

        ...many more cases...

        return subject
    end

It could certainly have done the opposite -- searching for and cutting
out the [list] tags instead.

I also had mutt call a "get_matchable_subject" Lua function when
matching a subject line.  My Lua code defined get_matchable_subject()
to be the same as get_printable_subject(), so searches and limit
operations were able to see the fake [list] tags as well.

Eventually I reinstalled the OS and started using the newer mutt
supplied by the distribution vendor (without my Lua hooks).  I've been
meaning to rebase the patches on a more recent mutt but just haven't
gotten around to it yet.

                                                  -Dave Dodge