hint: ignoring threads

Michal Sojka sojkam1 at fel.cvut.cz
Wed Nov 24 13:21:16 PST 2010


On Tue, 23 Nov 2010, Sebastian Spaeth wrote:
> I like to ignore annoying threads, but notmuch has not easy way to
> achieve it, right? Well, it actually has...
> 
> 1) ok, in notmuch-show I read a message, decide the thread is uninteresting
> (or annoying) and tag that message as "ignore".
> 
> 2) Adding "and not tag:ignore in my saved searches doesn't help as there
> are still messages without tag ignore, so notmuch search will still show
> the threads. So I run this now after notmuch new: TADAA...
> 
> notmuch tag +ignore -- not tag:ignore and `notmuch search
> --output=threads tag:ignore`

You should use xargs to not reach the limit of the command line length.
Something like (not tested):

notmuch search --output=threads tag:ignore | xargs notmuch tag +ignore -- not tag:ignore and

> It seems to work, afterwords all messages in a thread where at least one
> message was tagges "ignore" will be tagged "ignore" and my saved
> searches suppress them.
> 
> Just wanted to share this tidbit as I can imagine plenty of usecases
> where a similar scheme could be handy.

In my view, this approach has a small disadvantage: the more threads
that are tagged as "ignore" the longer time is needed to search for
them.

Since I want my initial tagging script to be as fast as possible I use a
little bit different approach. My actual implementation is more
complicated than I show here, but it can be simplified as follows:

ignored_threads=$(notmuch search tag:new|grep ignore|cut -f 1 -d ' ')
notmuch tag -new $ignored_threads

I only search the new messages and use grep to match threads where at
least one message is tagged as "ignore" (the regexp must be more complex
to match only the tag part of the search output). Finally, I untag the
ignored threads so that they do not appear in inbox (the last command of
my tagging script is notmuch tag -new +inbox tag:new).

It would be easier to write such script if we have
notmuch search --output=thread-tags, which would print only tag part of
the standard notmuch search output.

-Michal


More information about the notmuch mailing list