unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: tags starting with / are effectively forbidden
Date: Thu, 06 Jun 2024 08:39:07 -0300	[thread overview]
Message-ID: <875xums3l0.fsf@tethera.net> (raw)


Via ukleink on IRC

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

    % notmuch tag +/foo -- id:87edveqpj6.fsf@tethera.net
    notmuch tag: A Xapian exception occurred
    A Xapian exception occurred parsing query: unmatched regex delimiter in '/foo'
    Query string was: ( id:87edveqpj6.fsf@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

                 reply	other threads:[~2024-06-06 11:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xums3l0.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).