[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Packaged version of killfile?



On Thu, May 17, 2007 at 12:44:25PM +0100, Steve Kemp wrote:
> On Wed May 16, 2007 at 03:27:41 -0700, Paul Johnson wrote:
> 
> > >> This is a function of your MUA, most decent mail readers and all news
> > >> readers worthy of being called such support highlight/kill by thread,
> > >> usually in a single keystroke.
> > > 
> > > I have to admit my ignorance then. I'm a keen mutt user, but I cannot
> > > find that feature (!)
> > 
> > As advanced as Mutt is, this is where Mutt really falls down.  I 
> > ultimately
> > ended up switching to kmail to get that feature.
> 
>   OK here's a simple version.

That's the sort of thing I was after - but in the mean time I've created 
my own based on message-ids, as I realised that threading isn't done by 
subject. 

It's not perfect (because of other people's broken MUAs) - long threads 
will end up with mails that do not refer to my "killed" message-id 
(apparantly MUAs are only required to keep 8 message-ids in References:) 
still end up in my normal list mailbox.  At least it allow me to check 
up on Goodwin's law :-)

~/.mutt/muttrc fragment:
        macro index,pager '<Esc>d' '|bin/killfile add<Return><delete-subthread>'

~/.procmailrc fragment:

    :0 H
    * X-Mailing-List:
    * ! X-Mailing-List:.*debian-security-announce
    * ! X-Mailing-List:.*debian-news
    {
        :0 : kill-lock
        * ? killfile test
        Mail/lists-killed/

        :0 
        Mail/lists/
    }

I have crontab entries using archivemail(1) to keep the mailbox sizes 
down:

    15 4 * * * cd ~/Mail && archivemail --days=7 --quiet --delete lists
    15 5 * * * cd ~/Mail && archivemail --days=3 --quiet --delete lists-killed

And finally the killfile command:
    #!/bin/sh

    KILLFILE=$HOME/.killfile
    MAXLEN=1000

    test -f $KILLFILE || touch $KILLFILE

    case "$1" in
        (add)
            msgid=`formail -czx Message-ID:`
            if nice fgrep -e "$msgid" $KILLFILE ; then
                exit 0
            fi
            (cat $KILLFILE ; echo "$msgid" ) | tail --lines=$MAXLEN > ${KILLFILE}.new
            mv ${KILLFILE}.new $KILLFILE
            ;;
        (test)
            formail -czx References: | nice fgrep --file=$KILLFILE --max-count=1 --silent - 
            rc=$?
            if test -t 1 ; then
                if test $rc -eq 0 ; then
                    echo Kill kill kill
                else
                    echo good good good
                fi
            fi
            exit $rc
            ;;
        (*)
            echo 1>&2 Usage: `basename $0` add \< mail \# Adds a thread to the kill file
            echo 1>&2 Usage: `basename $0` test \< mail \# Gives exit code 0 if to be killed
            ;;
    esac

Suggestions and improvements are welcome. Especially if somebody has 
ideas of packaging it neatly...

-- 
Karl E. Jorgensen
karl@jorgensen.org.uk  http://www.jorgensen.org.uk/
karl@jorgensen.com     http://karl.jorgensen.com
==== Today's fortune:
It was OK before you touched it.

Attachment: signature.asc
Description: Digital signature


Reply to: