From: W. Trevor King Date: Wed, 30 Dec 2015 19:16:59 +0000 (+1600) Subject: [PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7181f55f12685797a88bdff35a31db43b90dc06f;p=notmuch-archives.git [PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together --- diff --git a/9f/166ea29dad8b7a32c5084ffb3174efbc378f11 b/9f/166ea29dad8b7a32c5084ffb3174efbc378f11 new file mode 100644 index 000000000..383d15432 --- /dev/null +++ b/9f/166ea29dad8b7a32c5084ffb3174efbc378f11 @@ -0,0 +1,134 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id E1ACC6DE1B2E + for ; Wed, 30 Dec 2015 11:29:56 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.01 +X-Spam-Level: +X-Spam-Status: No, score=-0.01 tagged_above=-999 required=5 tests=[AWL=0.091, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id ebiXFsaUJAFa for ; + Wed, 30 Dec 2015 11:29:55 -0800 (PST) +Received: from resqmta-po-11v.sys.comcast.net (resqmta-po-11v.sys.comcast.net + [96.114.154.170]) + by arlo.cworth.org (Postfix) with ESMTPS id BFB5B6DE1ADE + for ; Wed, 30 Dec 2015 11:29:54 -0800 (PST) +Received: from resomta-po-20v.sys.comcast.net ([96.114.154.244]) + by resqmta-po-11v.sys.comcast.net with comcast + id zvQC1r0085Geu2801vQvDF; Wed, 30 Dec 2015 19:24:55 +0000 +Received: from mail.tremily.us ([73.221.72.168]) + by resomta-po-20v.sys.comcast.net with comcast + id zvNv1r0013dr3C901vNvPg; Wed, 30 Dec 2015 19:22:55 +0000 +Received: by mail.tremily.us (Postfix, from userid 1000) + id CAB261B2C400; Wed, 30 Dec 2015 11:22:54 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; + t=1451503374; bh=/qaXP/NDXrdtLNpcBWbhxia40bhBkJbfIJoYUIinQEc=; + h=Resent-From:Resent-Date:Resent-To:From:To:Cc:Subject:Date: + In-Reply-To:References:In-Reply-To:References; + b=swAVUGtG2rhXxDBrrTIQuEJz6uiCWaeuT/Ts0Z9pR3db6eJKGLt6csUOJs1wlMMoo + v9EGpTLx6oXHzMHw7zkEBPh+vZxA9/75j2kn0cVI7b+iHffabTqM8uOveOApERdonL + 8C6xevIr073a3Rdq0rI1cHiCJs1Z5Rc/P0DBcmN8= +Resent-From: "W. Trevor King" +Resent-Date: Wed, 30 Dec 2015 11:22:54 -0800 +Resent-Message-ID: <20151230192254.GE2452@odin.tremily.us> +Resent-To: notmuch@notmuchmail.org +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Cc: David Bremner , + Tomi Ollila , Jani Nikula , + Carl Worth , "W. Trevor King" +Subject: [PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when + and-ing together +Date: Wed, 30 Dec 2015 11:16:59 -0800 +Message-Id: + <32c5603342644a01afd201ce6139299558d7f80b.1451502495.git.wking@tremily.us> +X-Mailer: git-send-email 2.1.0.60.g85f0837 +In-Reply-To: +References: +In-Reply-To: +References: +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1451503495; + bh=EcehF8MUVRFBFDfclA3rVuX7jEFND3Twl67wOJnaxwY=; + h=Received:Received:Received:From:To:Subject:Date:Message-Id; + b=EtA9QmpPEWNUv6sKJjXljVSdK315XKQk4GJgpFba1HFBMd/NMqzZs1p2d5xRRp6Rc + 8GjWcp9Pm8+9gSXAZUPwWfA/xsQuQgnHrxmm8hNld9LVZVGWB7aB7vjVsit4tczBTf + zoJb4tdPN4VytV96Nq4L9+9zJI71KMGVawNsQPQoEEZUIU8OWE/5GAYPPpFpu57Sac + ammF9IFuKcQRb1c44b3nVaJCiFIrIO9NHn9XomK+BmfLaJMUeBOgt1LyfqbAd33FTg + 0HHF5VISPMafYmoKeR0zGyrv/+dglJFik29a5uoUwTlPqIAbkxWfAnLhfBp2zqCP3F + HzOZEo6O1wXJg== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Wed, 30 Dec 2015 19:29:57 -0000 + +For example: + + "query": ["tag:a", "tag:b or tag:c"] + +is now converted to: + + ( tag:a ) and ( tag:b or tag:c ) + +instead of the old: + + tag:a and tag:b or tag:c + +This helps us avoid confusion due to Xapian's higher-precedence AND +[1], where the old query would be interpreted as: + + ( tag:a and tag:b ) or tag:c + +[1]: http://xapian.org/docs/queryparser.html +--- + NEWS | 3 +++ + devel/nmbug/nmbug-status | 3 ++- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index 9a6a757..1c618d1 100644 +--- a/NEWS ++++ b/NEWS +@@ -9,6 +9,9 @@ A new `nmbug-status(5)` describes `nmbug-status`'s JSON config file. + nmbug-status + ------------ + ++`nmbug-status` now wraps query phrases in parentheses when and-ing ++them together, to avoid confusion about clause grouping. ++ + `nmbug-status` now supports `meta.message-url` to override the Gmane + template. For example, you can use: + +diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status +index 336d0d2..a477af8 100755 +--- a/devel/nmbug/nmbug-status ++++ b/devel/nmbug/nmbug-status +@@ -167,7 +167,8 @@ class Page (object): + view['title'], sort_key)) + if 'query-string' not in view: + query = view['query'] +- view['query-string'] = ' and '.join(query) ++ view['query-string'] = ' and '.join( ++ '( {} )'.format(q) for q in query) + q = notmuch.Query(database, view['query-string']) + q.set_sort(sort) + threads = self._get_threads(messages=q.search_messages()) +-- +2.1.0.60.g85f0837 +