how to work with entire threads

Vladimir Marek Vladimir.Marek at Oracle.COM
Sun Jul 21 06:00:10 PDT 2013


> > I would like to create the following process:
> >
> >  1) if I tag any message with the keyword 'kill', it means that I don't
> >    want to see any message from whole thread in my inbox
> >
> > At the moment I do something like
> >
> > THREADS=$(notmuch search --output=threads tag:kill)
> > [ -z "$THREADS" ] || notmuch tag -unread -- '(' $THREADS ')'
> >
> >  2) if there is such a 'killed' thread and it won't receive message for
> > 30 days, I want to remove the kill tag from the thread
> >
> > That I achieved by something like
> >
> > N=notmuch
> > KILL=$( $N search --output=threads tag:kill )                                                                                                                                                          
> > if [ -n "$KILL" ]; then
> >    # Then find threads which contain messages younger than 30 days
> >    KILL_RECENT=$( $N search --output=threads '(' $KILL ')' and date:30days.. )
> >    KILL_RECENT=${KILL_RECENT:-'*'}
> >    # Then find 'kill' threads not matching those recent
> >    KILL_COUNT=$( $N count --output=threads '(' $KILL ')' and not '(' $KILL_RECENT ')' )
> >    if [ $KILL_COUNT -gt 0 ]; then
> >       echo "Threads to remove 'kill': $KILL"
> >       $N tag -kill -- $( $N search --output=threads '(' $KILL ')' and not '(' $KILL_RECENT ')' )
> >    fi
> > fi
> >
> >
> >
> > I was thinking if it could not be simplified. Without knowing anything about
> > notmuch or xapian internals, it seems that it would be handy to change the
> > search pattern to return threads. My two previous examples would then read like
> >
> > 1) notmuch tag -unread -- 'threads(tag:kill)'
> > and
> > 2) notmuch tag -kill -- 'threads(tag:kill)' and not 'threads(date:30days..)'
> >
> > Given that this would be possible in the first place, wouldn't it be a nice
> > addition to notmuch?
> 
> Some form of general thread based search would definitely be a nice
> addition. This seems to be non-trivial as we would need to parse the
> query ourselves rather than leaving that to xapian.
> 
> However, I think thread bases tagging would be quite easy:
> 
> eg
> 
> notmuch tag --thread +/-tags <search-term>
> 
> to tag all messages in all threads that contain a message match the
> search terms. Your first case would become notmuch tag --thread
> -unread tag:kill but your second case would still not be directly
> possible.
> 
> Would this be a useful addition by itself?


As you said, marking whole threads as read would be a case I would use
regularly. If anyone is willing to add that feature, I would be glad.

Even the second case would be possible, just not as elegant (but still
better than my shell construct)

notmuch tag --thread +kill -- tag:kill
notmuch tag -kill -- tag:kill and not date:30days..

Cheers
-- 
	Vlad


More information about the notmuch mailing list