From 46e3dedc5718ab0653514b4c4226e1e17a0fe255 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 21 Jul 2013 09:49:35 +0100 Subject: [PATCH] Re: how to work with entire threads --- e9/53231ee9dd673cf1e35f81e672d465fccc919f | 137 ++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 e9/53231ee9dd673cf1e35f81e672d465fccc919f diff --git a/e9/53231ee9dd673cf1e35f81e672d465fccc919f b/e9/53231ee9dd673cf1e35f81e672d465fccc919f new file mode 100644 index 000000000..592c1224a --- /dev/null +++ b/e9/53231ee9dd673cf1e35f81e672d465fccc919f @@ -0,0 +1,137 @@ +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 ECABB431FBF + for ; Sun, 21 Jul 2013 01:49:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 4nghuZfRbJsn for ; + Sun, 21 Jul 2013 01:49:38 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 32AAD431FB6 + for ; Sun, 21 Jul 2013 01:49:38 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1V0pKi-0000QS-FU; Sun, 21 Jul 2013 09:49:36 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1V0pKi-0004V3-4w; Sun, 21 Jul 2013 09:49:36 +0100 +From: Mark Walters +To: Vladimir Marek , notmuch@notmuchmail.org +Subject: Re: how to work with entire threads +In-Reply-To: <20130709122200.GA11501@virt.cz.oracle.com> +References: <20130709122200.GA11501@virt.cz.oracle.com> +User-Agent: Notmuch/0.15.2+192~g8222af3 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Sun, 21 Jul 2013 09:49:35 +0100 +Message-ID: <87bo5w8fhc.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: d6edd6da35e110395b9db86f3666b79f (of first 20000 bytes) +X-SpamAssassin-Score: 0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored 0.0 points. Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.0 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Sun, 21 Jul 2013 08:49:44 -0000 + + +Hi +Vladimir Marek writes: + +> 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? + +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 + +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? + +Best wishes + +Mark + -- 2.26.2