Re: [PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together

2015-12-31 Thread W. Trevor King
On Wed, Dec 30, 2015 at 11:16:59AM -0800, W. Trevor King wrote:
> @@ -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)

This patch is missing a similar change around line 414 to handle:

  $ nmbug-status --get-query VIEW

I've queued that for v2.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together

2015-12-30 Thread W. Trevor King
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

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch