unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "W. Trevor King" <wking@tremily.us>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>,
	Tomi Ollila <tomi.ollila@iki.fi>, Jani Nikula <jani@nikula.org>,
	Carl Worth <cworth@cworth.org>,
	"W. Trevor King" <wking@tremily.us>
Subject: [PATCH v2 3/4] nmbug-status: Wrap query phrases in parentheses when and-ing together
Date: Fri,  1 Jan 2016 22:07:42 -0800	[thread overview]
Message-ID: <a82a76a738a823df9b56c25e9b34d9523d5d4395.1451683912.git.wking@tremily.us> (raw)
In-Reply-To: <cover.1451683912.git.wking@tremily.us>
In-Reply-To: <cover.1451683912.git.wking@tremily.us>

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 | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 9f2e860..403a046 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Notmuch 0.22 (UNRELEASED)
 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 d72f1db..7d3a76e 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())
@@ -411,7 +412,7 @@ if args.list_views:
 elif args.get_query != None:
     for view in config['views']:
         if args.get_query == view['title']:
-            print(' and '.join(view['query']))
+            print(' and '.join('( {} )'.format(q) for q in view['query']))
     sys.exit(0)
 else:
     # only import notmuch if needed
-- 
2.1.0.60.g85f0837

  parent reply	other threads:[~2016-01-02  6:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
2016-01-07 13:27   ` David Bremner
2016-01-02  6:07 ` [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting W. Trevor King
2016-03-23 11:19   ` David Bremner
2016-03-23 16:42     ` W. Trevor King
2016-01-02  6:07 ` W. Trevor King [this message]
2016-01-02  6:07 ` [PATCH v2 4/4] status-config.json: Remove parens from query entry W. Trevor King
2016-03-24 10:53   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a82a76a738a823df9b56c25e9b34d9523d5d4395.1451683912.git.wking@tremily.us \
    --to=wking@tremily.us \
    --cc=cworth@cworth.org \
    --cc=david@tethera.net \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).