On Thu, Feb 21, 2002 at 02:19:51PM +0100, Alexander Skwar wrote:
> In large mailinglists, I sometimes want to limit the messages to only
> these messages which are part of thread in which I've written something.
> Is it somehow possible to comeup with a limit criteria which will do
> that?
> 
> The criteria should not only list those messages which are replies to my
> message, but also the messages to which I replied.

I wanted to do the same thing, as well as "watch" threads that I
didn't start.  The solution I came up with could stand vast
improvement, but is working for me right now.

The basic idea depends on scoring:

1) Setup a key binding in mutt that saves the message's subject to a
file.

2) Write a script to turn the lines the the above file into valid mutt
"score" commands.

3) Have mutt source the script.

Now you can set mutt to sort by scores, and all of your "watched"
messages appear at the top of the message index.

The current version handles messages with the [listname] prefix and
ignores beginning Re:'s.  It doesn't currently work if the message has
an apostrophe in it (it doesn't crash, just doesn't watch the thread),
but that's just a quoting problem.  I just found that bug today, so I
haven't had time to fix it.

If you're still interested, here's how to set it up:

Add the following lines to an appropriate section of your .muttrc,
being sure to change the paths appropriately:

# Macros for message watching.
macro index <Esc>w "<pipe-message> formail -x subject >>/home/ben/mail/watch<enter>" 
"Watch currently hilighted message"
macro index <Esc>W "<enter-command> source /home/ben/mail/watch.py|<enter>" "Reread 
watched messages file"
macro index <Esc>1 "<shell-escape>vim /home/ben/mail/watch<enter>" "Edit watched 
messages"

Here's watch.py:
-----Begin watch.py-----
#!/usr/bin/python

import string,re

watch_file = "/home/ben/mail/watch"  # Change as needed
f = open(watch_file,"r")

line = f.readline()
while line:
        # Strip any beginning [listnamehere] strings, because they screw everything up
        line = re.sub(r"""^(\s*\[[^]]+\])?\s*(Re:\s*)*(?i)""","",line)
        print """score "~s '%s'" 10""" % 
string.replace(re.escape(string.strip(line)),"\\","\\\\")
        line = f.readline()

f.close()
------End watch.py------
Be sure to set the watch_file variable to suit your setup.

Now be sure you have sorting by scoring set.  I also have it set to
show the messages' scores in my index (particularly useful for
debugging).

To watch a thread, press <Esc>w in the index view.  To make the
changes take effect immediately (instead of next time you start mutt)
press <Esc>W.  To remove messages from the list (un-watch them), press
<Esc>1 and remove the line(s) you don't want to watch any more.

Kludgy, but it works for me. :)

Regards,
Ben

-- 
Ben Logan: ben at wblogan dot net
OpenPGP Key KeyID: A1ADD1F0

I can give you my word, but I know what it's worth and you don't.
                -- Nero Wolfe, "Over My Dead Body"

Reply via email to