--- /dev/null
+Return-Path: <Vladimir.Marek@Oracle.COM>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 39649431FBF\r
+ for <notmuch@notmuchmail.org>; Sun, 21 Jul 2013 06:00:30 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.299\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id V0r2P7p3QeqM for <notmuch@notmuchmail.org>;\r
+ Sun, 21 Jul 2013 06:00:22 -0700 (PDT)\r
+Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 10AA9431FB6\r
+ for <notmuch@notmuchmail.org>; Sun, 21 Jul 2013 06:00:22 -0700 (PDT)\r
+Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])\r
+ by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
+ ESMTP id r6LD0Hgu013243\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
+ Sun, 21 Jul 2013 13:00:19 GMT\r
+Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231])\r
+ by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r6LD0FFZ000781\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\r
+ Sun, 21 Jul 2013 13:00:16 GMT\r
+Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71])\r
+ by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r6LD0FFr016485; Sun, 21 Jul 2013 13:00:15 GMT\r
+Received: from virt.cz.oracle.com (/10.163.102.127)\r
+ by default (Oracle Beehive Gateway v4.0)\r
+ with ESMTP ; Sun, 21 Jul 2013 06:00:14 -0700\r
+Date: Sun, 21 Jul 2013 15:00:10 +0200\r
+From: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: Re: how to work with entire threads\r
+Message-ID: <20130721130010.GA4405@virt.cz.oracle.com>\r
+References: <20130709122200.GA11501@virt.cz.oracle.com>\r
+ <87bo5w8fhc.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+In-Reply-To: <87bo5w8fhc.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/ (2012-12-30)\r
+X-Source-IP: ucsinet22.oracle.com [156.151.31.94]\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 21 Jul 2013 13:00:30 -0000\r
+\r
+> > I would like to create the following process:\r
+> >\r
+> > 1) if I tag any message with the keyword 'kill', it means that I don't\r
+> > want to see any message from whole thread in my inbox\r
+> >\r
+> > At the moment I do something like\r
+> >\r
+> > THREADS=$(notmuch search --output=threads tag:kill)\r
+> > [ -z "$THREADS" ] || notmuch tag -unread -- '(' $THREADS ')'\r
+> >\r
+> > 2) if there is such a 'killed' thread and it won't receive message for\r
+> > 30 days, I want to remove the kill tag from the thread\r
+> >\r
+> > That I achieved by something like\r
+> >\r
+> > N=notmuch\r
+> > KILL=$( $N search --output=threads tag:kill ) \r
+> > if [ -n "$KILL" ]; then\r
+> > # Then find threads which contain messages younger than 30 days\r
+> > KILL_RECENT=$( $N search --output=threads '(' $KILL ')' and date:30days.. )\r
+> > KILL_RECENT=${KILL_RECENT:-'*'}\r
+> > # Then find 'kill' threads not matching those recent\r
+> > KILL_COUNT=$( $N count --output=threads '(' $KILL ')' and not '(' $KILL_RECENT ')' )\r
+> > if [ $KILL_COUNT -gt 0 ]; then\r
+> > echo "Threads to remove 'kill': $KILL"\r
+> > $N tag -kill -- $( $N search --output=threads '(' $KILL ')' and not '(' $KILL_RECENT ')' )\r
+> > fi\r
+> > fi\r
+> >\r
+> >\r
+> >\r
+> > I was thinking if it could not be simplified. Without knowing anything about\r
+> > notmuch or xapian internals, it seems that it would be handy to change the\r
+> > search pattern to return threads. My two previous examples would then read like\r
+> >\r
+> > 1) notmuch tag -unread -- 'threads(tag:kill)'\r
+> > and\r
+> > 2) notmuch tag -kill -- 'threads(tag:kill)' and not 'threads(date:30days..)'\r
+> >\r
+> > Given that this would be possible in the first place, wouldn't it be a nice\r
+> > addition to notmuch?\r
+> \r
+> Some form of general thread based search would definitely be a nice\r
+> addition. This seems to be non-trivial as we would need to parse the\r
+> query ourselves rather than leaving that to xapian.\r
+> \r
+> However, I think thread bases tagging would be quite easy:\r
+> \r
+> eg\r
+> \r
+> notmuch tag --thread +/-tags <search-term>\r
+> \r
+> to tag all messages in all threads that contain a message match the\r
+> search terms. Your first case would become notmuch tag --thread\r
+> -unread tag:kill but your second case would still not be directly\r
+> possible.\r
+> \r
+> Would this be a useful addition by itself?\r
+\r
+\r
+As you said, marking whole threads as read would be a case I would use\r
+regularly. If anyone is willing to add that feature, I would be glad.\r
+\r
+Even the second case would be possible, just not as elegant (but still\r
+better than my shell construct)\r
+\r
+notmuch tag --thread +kill -- tag:kill\r
+notmuch tag -kill -- tag:kill and not date:30days..\r
+\r
+Cheers\r
+-- \r
+ Vlad\r