From b9ae7a54141aecef9b4e824a816b4725cdc945d2 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Mon, 8 Dec 2014 17:17:24 +0000 Subject: [PATCH] Re: notmuch_query_add_tag_excluded and notmuch_query_search_threads --- a1/175ff3de38d04c80860d01fb21f96978c62d42 | 117 ++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 a1/175ff3de38d04c80860d01fb21f96978c62d42 diff --git a/a1/175ff3de38d04c80860d01fb21f96978c62d42 b/a1/175ff3de38d04c80860d01fb21f96978c62d42 new file mode 100644 index 000000000..f2cb73d09 --- /dev/null +++ b/a1/175ff3de38d04c80860d01fb21f96978c62d42 @@ -0,0 +1,117 @@ +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 1AA55431FD0 + for ; Mon, 8 Dec 2014 09:17:53 -0800 (PST) +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 abcPYVQ4cSuZ for ; + Mon, 8 Dec 2014 09:17:49 -0800 (PST) +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 90C50431FC0 + for ; Mon, 8 Dec 2014 09:17:49 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Xy1w5-0003dc-Hi; Mon, 08 Dec 2014 17:17:45 +0000 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Xy1w5-0007yN-5g; Mon, 08 Dec 2014 17:17:25 +0000 +From: Mark Walters +To: David Bremner , notmuch@notmuchmail.org +Subject: Re: notmuch_query_add_tag_excluded and notmuch_query_search_threads +In-Reply-To: <87r3wbe4si.fsf@maritornes.cs.unb.ca> +References: <1417905319-astroid-0-i86er7iwg5-10728@strange> + <87388rfzhw.fsf@maritornes.cs.unb.ca> + <1417958519-astroid-0-ydniq6pte2-8575@strange> + <87wq63ef9s.fsf@maritornes.cs.unb.ca> + <1417962498-astroid-0-zqj7j2s0ov-9575@strange> + <87r3wbe4si.fsf@maritornes.cs.unb.ca> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Mon, 08 Dec 2014 17:17:24 +0000 +Message-ID: <87y4qi83iz.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: ddb8490478411c8ab9c42674f3cd47b0 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +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.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * -0.1 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: Mon, 08 Dec 2014 17:17:53 -0000 + + +Hi + +> +> At the end of this message is a simpler example, that I think +> demonstrates a bug. At the very list it's not very nice that the +> destructiveness only shows up when excludes are involved. +> +> Here is the output; note the second exclude query! + +I think I know what is causing this and can (almost) give a fix. + +The problem is that _notmuch_exclude_tags in lib/query.cc is not +idempotent: it iterates through the list of excluded tag attached to +query and changes any which match a tag in the query to "". But this +gets confused if applied a second time as it sees an empty string rather +than Ktag (where "K" is the prefix for 'tag'). + +We could just check in _notmuch_exclude_tags whether the excluded item +is "" and if so, just skip it. (I am not sure what the right syntax for +this in the mix of C and C++ that happens in query.cc) + +Alternatively we could try and modify the list of excluded tags directly +when doing the iteration (ie link the previous tag to the next +tag). + +Since both of these do modify the actual query (as we do currently) +there is a possibility that a user could be surprised. I think the user +can't modify the actual query string so I don't think this actually +occurs. + +Any thoughts? + +Mark + + + + + -- 2.26.2