Via ukleink on IRC

    % notmuch tag --batch
    +/foo -- id:87edveqpj6....@tethera.net
    notmuch tag: A Xapian exception occurred
    A Xapian exception occurred parsing query: unmatched regex delimiter in 
'/foo'
    Query string was: ( id:87edveqpj6....@tethera.net ) and (not tag:/foo)

    % notmuch tag +/foo -- id:87edveqpj6....@tethera.net
    notmuch tag: A Xapian exception occurred
    A Xapian exception occurred parsing query: unmatched regex delimiter in 
'/foo'
    Query string was: ( id:87edveqpj6....@tethera.net ) and (not tag:/foo)

The problem here is the implicit query to avoid re-tagging things
already tagged /foo. There is some unfortunate use of strings to
construct a query in notmuch-tag.c. This string is parsed by same parser
as other notmuch queries, which means it attempts to support regexes.
In retrospect using strings to construct queries is pretty obviously a
bad idea, but we don't currently have a C API for constructing queries.
The closest is the sexp parse, but this would still require constructing
a serialized query (as a sexp) and then parsing it again.

Some potential solutions (roughly in order of effort and flexibility) include

- pushing the query optimization code inside libnotmuch, using the
  Xapian API directly. This has the advantage that it makes it available
  to all bindings users.

- extend the notmuch_query API to allow updating the underlying
  query using some operator and a single term, something like

  notmuch_query_modify(query, NOTMUCH_OP_ANDNOT, "tag", "/foo")

- providing a low level wrapper around Xapian::Query, taking care of
  translating prefixes.

  At the moment I think only this last would allow the elimination of
  constructing strings in the CLI code to pass to libnotmuch.

d
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to