[PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together
authorW. Trevor King <wking@tremily.us>
Wed, 30 Dec 2015 19:16:59 +0000 (11:16 +1600)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:50:17 +0000 (14:50 -0700)
9f/166ea29dad8b7a32c5084ffb3174efbc378f11 [new file with mode: 0644]

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