unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: v2 regexp search for mid/folder/path
Date: Wed, 29 Mar 2017 21:46:02 -0300	[thread overview]
Message-ID: <20170330004604.1504-1-david@tethera.net> (raw)
In-Reply-To: <20170324121436.28978-1-david@tethera.net>

This is mainly a rebase against current master, but also required an
update to the (just pushed) empty query string handling

Apparently there's at least 4 ways to test a C++ string for being
empty, so here I try a different way of writing it.

Interdiff follows:

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 26b22fe2..1598c17f 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -156,12 +156,17 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string prefix,
 Xapian::Query
 RegexpFieldProcessor::operator() (const std::string & str)
 {
-    if (str.size () == 0)
-	return Xapian::Query(Xapian::Query::OP_AND_NOT,
+    if (str.empty ()) {
+	if (options & NOTMUCH_FIELD_PROBABILISTIC) {
+	    return Xapian::Query(Xapian::Query::OP_AND_NOT,
 			     Xapian::Query::MatchAll,
 			     Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix));
+	} else {
+	    return Xapian::Query (term_prefix);
+	}
+    }
 
-    if (str.length() > 0 && str.at (0) == '/') {
+    if (str.at (0) == '/') {
 	if (str.length() > 1 && str.at (str.size () - 1) == '/'){
 	    std::string regexp_str = str.substr(1,str.size () - 2);
 	    if (slot != Xapian::BAD_VALUENO) {

  parent reply	other threads:[~2017-03-30  0:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 12:14 regexp search for more things David Bremner
2017-03-24 12:14 ` [PATCH 1/2] lib: Add regexp searching for mid: prefix David Bremner
2017-03-24 12:14 ` [PATCH 2/2] lib: Add regexp expansion for for tags and paths David Bremner
2017-03-30  0:46 ` David Bremner [this message]
2017-03-30  0:46   ` [PATCH 1/2] lib: Add regexp searching for mid: prefix David Bremner
2017-03-30  0:46   ` [PATCH 2/2] lib: Add regexp expansion for for tags and paths David Bremner
2022-05-27 15:29 ` searching to doesn't support regexes ? erik colson
2022-05-27 17:37   ` David Bremner
2022-05-27 19:35     ` erik colson

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=20170330004604.1504-1-david@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).