notmuch_query_add_tag_excluded and notmuch_query_search_threads

Mark Walters markwalters1009 at gmail.com
Mon Dec 8 09:17:24 PST 2014


Hi

>
> At the end of this message is a simpler example, that I think
> demonstrates a bug. At the very list it's not very nice that the
> destructiveness only shows up when excludes are involved.
>
> Here is the output; note the second exclude query!

I think I know what is causing this and can (almost) give a fix.

The problem is that _notmuch_exclude_tags in lib/query.cc is not
idempotent: it iterates through the list of excluded tag attached to
query and changes any which match a tag in the query to "". But this
gets confused if applied a second time as it sees an empty string rather
than Ktag (where "K" is the prefix for 'tag'). 

We could just check in _notmuch_exclude_tags whether the excluded item
is "" and if so, just skip it. (I am not sure what the right syntax for
this in the mix of C and C++ that happens in query.cc)

Alternatively we could try and modify the list of excluded tags directly
when doing the iteration (ie link the previous tag to the next
tag). 

Since both of these do modify the actual query (as we do currently)
there is a possibility that a user could be surprised. I think the user
can't modify the actual query string so I don't think this actually
occurs.

Any thoughts?

Mark



 



More information about the notmuch mailing list