]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
nmbug-status: Wrap query phrases in parentheses when and-ing together
authorW. Trevor King <wking@tremily.us>
Sat, 2 Jan 2016 06:07:42 +0000 (22:07 -0800)
committerDavid Bremner <david@tethera.net>
Thu, 24 Mar 2016 10:39:42 +0000 (07:39 -0300)
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
devel/nmbug/nmbug-status

diff --git a/NEWS b/NEWS
index 6ccff2b9cfa4d2db7bc21915c50d79f7a29c84c3..0d9496d66b7be1c8a3084ec069af293d297eff0b 100644 (file)
--- 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:
 
index 9de80d36ecd704be780ad12d8398cb626187ed53..94be6717c5f6fbbf012309f50b5a12771b8154ad 100755 (executable)
@@ -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())
@@ -421,7 +422,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