From 2ded7c28020b1562af0c48f9ad42c30d1f787173 Mon Sep 17 00:00:00 2001 From: Vladimir Marek Date: Tue, 9 Jul 2013 14:22:00 +0200 Subject: [PATCH] how to work with entire threads --- ce/5bb50664b211ea0d18570c9cd178a884d5b3ca | 110 ++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 ce/5bb50664b211ea0d18570c9cd178a884d5b3ca diff --git a/ce/5bb50664b211ea0d18570c9cd178a884d5b3ca b/ce/5bb50664b211ea0d18570c9cd178a884d5b3ca new file mode 100644 index 000000000..033353a4e --- /dev/null +++ b/ce/5bb50664b211ea0d18570c9cd178a884d5b3ca @@ -0,0 +1,110 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id ED132431FAF + for ; Tue, 9 Jul 2013 05:22:18 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.299 +X-Spam-Level: +X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id gbIsk59iIex3 for ; + Tue, 9 Jul 2013 05:22:11 -0700 (PDT) +Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 651B3431FAE + for ; Tue, 9 Jul 2013 05:22:11 -0700 (PDT) +Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) + by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with + ESMTP id r69CMAPF030370 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) + for ; Tue, 9 Jul 2013 12:22:10 GMT +Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) + by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r69CM6h7018595 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; Tue, 9 Jul 2013 12:22:10 GMT +Received: from abhmt111.oracle.com (abhmt111.oracle.com [141.146.116.63]) + by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r69CM6op015715 + for ; Tue, 9 Jul 2013 12:22:06 GMT +Received: from virt.cz.oracle.com (/10.163.102.127) + by default (Oracle Beehive Gateway v4.0) + with ESMTP ; Tue, 09 Jul 2013 05:22:06 -0700 +Date: Tue, 9 Jul 2013 14:22:00 +0200 +From: Vladimir Marek +To: notmuch@notmuchmail.org +Subject: how to work with entire threads +Message-ID: <20130709122200.GA11501@virt.cz.oracle.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +User-Agent: Mutt/ (2012-12-30) +X-Source-IP: acsinet22.oracle.com [141.146.126.238] +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 09 Jul 2013 12:22:19 -0000 + +Hi, + +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? + +Thank you +-- + Vlad -- 2.26.2