[notmuch] [RFC] Precedence of OR and AND

2009-11-23 Thread Carl Worth
On Sun, 22 Nov 2009 22:43:30 +0100, Jed Brown  wrote:
> On Sun, 22 Nov 2009 16:36:49 -0500, Bart Trojanowski  
> wrote:
> Absolutely, and I have this applied locally to notmuch.el,

Patch please?

>but I didn't
> fix notmuch-search-filter-by-tag because that would really need to parse
> the expression.

I don't see the difference here. Any time we append to the search
string, we should be doing so with parentheses.

>  I'm just asking if anyone else thinks binding OR
> tighter than AND would be desirable.

Right now, Xapian is doing all of our query parsing. So we'd have to
take things up there to get anything changed for now.

In the future we might be forced into writing our own query parser to
get all the functionality we want.

-Carl


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Jed Brown
On Sun, 22 Nov 2009 16:36:49 -0500, Bart Trojanowski  wrote:
> Wouldn't this problem be solved by each filter appending a bracketed
> version of your filter?
> 
> You start with tag:inbox and you filter on "term1 or term2" you'd get:
> 
> tag:inbox and (term1 or term2)

Absolutely, and I have this applied locally to notmuch.el, but I didn't
fix notmuch-search-filter-by-tag because that would really need to parse
the expression.  I'm just asking if anyone else thinks binding OR
tighter than AND would be desirable.

Jed


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Jed Brown
Currently OR binds more weakly than AND, which is natural in most
contexts, but I think it is rarely desirably for this sort of search.
Suppose I am in looking at my inbox and decide to filter by

  term1 OR term2

Notmuch makes the query

  tag:inbox AND term1 OR term2

which is actually

  (tag:inbox AND term1) OR term2

and not at all what I wanted.  Adding the necessary parentheses to
notmuch-search-filter is trivial but it requires more parentheses for
the overwhelming majority of searches that I think are more common.

Are most searches indeed closer to conjunctive form?

Should OR bind tighter than AND?


Jed


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Bart Trojanowski
* Jed Brown  [091122 16:43]:
> Absolutely, and I have this applied locally to notmuch.el, but I didn't
> fix notmuch-search-filter-by-tag because that would really need to parse
> the expression.  I'm just asking if anyone else thinks binding OR
> tighter than AND would be desirable.

Maybe some of the ambiguity would go away if we used && and || instead
of AND and OR.  Then no matter the default, we could distinguish if
someone meant 2 or 3 tags when they typed in 'foo and bar'.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Bart Trojanowski
Wouldn't this problem be solved by each filter appending a bracketed
version of your filter?

You start with tag:inbox and you filter on "term1 or term2" you'd get:

tag:inbox and (term1 or term2)

Doing it again would result in...

tag:inbox and (term1 or term2) and (term3 or term4)

To me, it would seem the most intuitive solution.

Actually, I think I'll add that to notmuch.vim right now. :)

-Bart

* Jed Brown  [091122 16:26]:
> Currently OR binds more weakly than AND, which is natural in most
> contexts, but I think it is rarely desirably for this sort of search.
> Suppose I am in looking at my inbox and decide to filter by
> 
>   term1 OR term2
> 
> Notmuch makes the query
> 
>   tag:inbox AND term1 OR term2
> 
> which is actually
> 
>   (tag:inbox AND term1) OR term2
> 
> and not at all what I wanted.  Adding the necessary parentheses to
> notmuch-search-filter is trivial but it requires more parentheses for
> the overwhelming majority of searches that I think are more common.
> 
> Are most searches indeed closer to conjunctive form?
> 
> Should OR bind tighter than AND?
> 
> 
> Jed
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

-- 
WebSig: http://www.jukie.net/~bart/sig/