As a Free Software enthusiast, I take part in a lot of mailing-lists. To browse the messages (and to read my personal mail, too), I use mutt. This article describes a trick to make your mutt experience more enjoyable: a way to unsubscribe from specific mailing-list threads.
When downloading mailing-list messages, we are often confronted with threads we deem interesting and threads which are not. The immediate solution is to delete unwanted messages, like so:
1 May 05 To debian-user@ (0.7K) Interesting and useful thread
2 D May 05 To debian-user@ (1.2K) Flame, boring thread
The issue is not solved, though. We deleted that particular message, but other people may have replied to it. The next time we are going to fetch e-mails, those replies will be there, forcing another deletion:
1 May 05 To debian-user@ (0.7K) Interesting and useful thread
2 May 05 Cc debian-user@ (0.8K) ├─>
3 May 05 To Debian User (4.2K) └─>
4 D May 05 To debian-user@ (4.1K) Re: Flame, boring thread
5 D May 05 To debian-user@ (2.8K) └─>
6 D May 05 To debian-user@ (0.7K) └─>
And again, and again, and again. Heated discussions can lead to nested threads (visit the emacs-devel archives to check yourself). Alas, there is no way to “unsubscribe” from a specific mailing-list thread (like you would in a forum); you can unsubscribe to the list itself, but then you would be entirely cut off from the communication.
Soon you will get tired of pressing <C-d>
to weed out those messages:
1 May 05 To debian-user@ (0.7K) Interesting and useful thread
2 May 05 Cc debian-user@ (0.8K) ├─>
3 May 05 To Debian User (4.2K) └─>
4 May 06 To debian-user@ (3.4K) └─>
5 D May 06 Cc debian-user@ (1.7K) Re: Re: Re: the never-ending, obnoxious flame thread
2 D May 06 Cc debian-user@ (1.1K) ├─>
6 D May 06 To debian-user@ (2.8K) └─>
7 D May 06 To debian-user@ (0.7K) └─>
8 D May 06 To debian-user@ (1.1K) └─>
9 D May 06 To debian-user@ (5.0K) ├─>
10 D May 06 To debian-user@ (7.6K) └─>
11 May 06 To haskell-cafe (1.3K) [Haskell-cafe] Functional programming blues
Instead of setting up a complex scoring system (with procmail or other mail processors), we can take advantage of mutt pattern matching capabilities:
macro index <Esc>d "<delete-pattern>~l~N(!~(!~x.+))(!~(~F))<enter>"
Place this in your .muttrc. This is a <delete-pattern>
macro, which means
that it will bulk delete messages that will match the expression. Let us
examine this bit by bit:
~l~N
limits the effect to new mailing-list messages only. Make sure
you told mutt which mailing-lists you are subscribed to, following the
instructions in the manual.
!~(!~x.+)
is a “thread pattern”, which means it will only match
threads containing at least one message with a certain pattern. In this
case it will match threads where there are no messages which are
not a reply to another message.
This is the core of the macro; it seems complicated, but that is just because regular expressions read clunky. In simple words it would be: “threads with only replies”. Threads with only replies means threads where the originating post isn’t present; if it is not present is because we deleted it; if we deleted it we didn’t like it and we don’t want replies to it, too.
!~(~F)
is another “thread pattern”, and it’s there to make sure we don’t
mark for deletion messages which are in a thread where we marked some message
as “important”.
When you press <Esc>d
, messages stemming from threads you were not
interested in will be marked for deletion. The macro will leave new threads
and old, undeleted threads untouched.
Be careful on how how threads are grouped! With
strict_threads=no
, mutt will make use of In-Reply-To/References
headers to group messages together and by default, messages with the
same subject will be grouped together in the same “pseudo-thread”.
475 Aug 25 To help-gnu-ema (0.4K) Gist: get output of an external program on region
476 Aug 26 To help-gnu-ema ( 15) └*>
477 Aug 25 To help-gnu-ema (1.2K) └─>
Everything ok.
See the second messages? It lacked In-Reply-To (probably fell victim to some clobbering agent) but it is still correctly shown in the same thread (with an asterisk) because it shares the same Subject.
Now let’s see what happens with strict_threads=yes
:
475 Aug 25 To help-gnu-ema (0.4K) Gist: get output of an external program on region
476 D Aug 26 To help-gnu-ema ( 15) Re: Gist: get output of an external program on region
477 D Aug 25 To help-gnu-ema (1.2K) └─>
Woops!
Now the last two messages are considered a different, “head-less” thread and hence marked for deletion! This might lead to unwanted removal of interesting e-mails!
My suggestion to you is to turn strict_threads
off; it will save you
from the above mentioned problems and, if you want, you can fine-tune its
behaviour by tweaking $sort_re
setting.
Coping with busy mailing lists is not an easy task; Debian Developer Joey Hess’ Thread patterns has more tongue-in-cheek tips on how to sever the wicked from among the just.
On 25 Aug 2015 Ian Zimmerman wrote:
I didn’t know about the !~(!~x.+) pattern, so thanks for teaching me about it. I see how it will be very useful.
However, and unfortunately, it won’t by itself help in emacs-help and other lists with a mail<->news gateway managed by Mailman. :-( That’s because Mailman clobbers the Message-ID (but not References) when forwarding a message from one world to the other, so a mail reply to a message posted originally via news will always appear to break the thread.
Now, if you have some mutt magic to deal with this issue, you are $DEITY incarnate.
I think emacs-devel (which you mention as an example of flamey list where such a pattern and macro would help) is in this category too, so maybe you already know what I’m talking about.
On 26 Aug 2015 Francesco Ariis wrote:
[This took some more mails which I’ll summarise here] The trick to deal with clobbered message lies in
strict_thread
and$sort_re
settings. I have updated the article, glad to hear this is being useful!