unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 12/13] lib: make a global constant for query parser flags
Date: Tue, 22 Mar 2016 07:54:53 -0300	[thread overview]
Message-ID: <1458644094-13951-13-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1458644094-13951-1-git-send-email-david@tethera.net>

It's already kindof gross that this is hardcoded in two different
places. We will also need these later in field processors calling back
into the query parser.
---
 lib/database-private.h |  4 ++++
 lib/query.cc           | 16 ++--------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/lib/database-private.h b/lib/database-private.h
index 30a045e..59708d0 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -144,6 +144,10 @@ operator&=(_notmuch_features &a, _notmuch_features b)
     return a;
 }
 
+#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | \
+				    Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \
+				    Xapian::QueryParser::FLAG_WILDCARD | Xapian::QueryParser::FLAG_PURE_NOT)
+
 #if HAVE_XAPIAN_FIELD_PROCESSOR
 class DateFieldProcessor;
 #endif
diff --git a/lib/query.cc b/lib/query.cc
index e627bfc..972a389 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -212,12 +212,6 @@ notmuch_query_search_messages_st (notmuch_query_t *query,
 	Xapian::Query string_query, final_query, exclude_query;
 	Xapian::MSet mset;
 	Xapian::MSetIterator iterator;
-	unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
-			      Xapian::QueryParser::FLAG_PHRASE |
-			      Xapian::QueryParser::FLAG_LOVEHATE |
-			      Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE |
-			      Xapian::QueryParser::FLAG_WILDCARD |
-			      Xapian::QueryParser::FLAG_PURE_NOT);
 
 	if (strcmp (query_string, "") == 0 ||
 	    strcmp (query_string, "*") == 0)
@@ -225,7 +219,7 @@ notmuch_query_search_messages_st (notmuch_query_t *query,
 	    final_query = mail_query;
 	} else {
 	    string_query = notmuch->query_parser->
-		parse_query (query_string, flags);
+		parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS);
 	    final_query = Xapian::Query (Xapian::Query::OP_AND,
 					 mail_query, string_query);
 	}
@@ -565,12 +559,6 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
 						   "mail"));
 	Xapian::Query string_query, final_query, exclude_query;
 	Xapian::MSet mset;
-	unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
-			      Xapian::QueryParser::FLAG_PHRASE |
-			      Xapian::QueryParser::FLAG_LOVEHATE |
-			      Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE |
-			      Xapian::QueryParser::FLAG_WILDCARD |
-			      Xapian::QueryParser::FLAG_PURE_NOT);
 
 	if (strcmp (query_string, "") == 0 ||
 	    strcmp (query_string, "*") == 0)
@@ -578,7 +566,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
 	    final_query = mail_query;
 	} else {
 	    string_query = notmuch->query_parser->
-		parse_query (query_string, flags);
+		parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS);
 	    final_query = Xapian::Query (Xapian::Query::OP_AND,
 					 mail_query, string_query);
 	}
-- 
2.7.0

  parent reply	other threads:[~2016-03-22 10:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 10:54 field processor features, merged series David Bremner
2016-03-22 10:54 ` [PATCH 01/13] config: autodetect xapian-1.3 David Bremner
2016-03-22 10:54 ` [PATCH 02/13] configure: detect Xapian:FieldProcessor David Bremner
2016-03-22 10:54 ` [PATCH 03/13] lib: optionally support single argument date: queries David Bremner
2016-03-22 10:54 ` [PATCH 04/13] lib/cli: add library API / CLI for compile time options David Bremner
2016-03-22 10:54 ` [PATCH 05/13] configure: check directly for xapian compaction API David Bremner
2016-03-22 10:54 ` [PATCH 06/13] lib: provide config API David Bremner
2016-03-22 10:54 ` [PATCH 07/13] lib: config list iterators David Bremner
2016-03-22 10:54 ` [PATCH 08/13] CLI: add print_status_database David Bremner
2016-03-22 10:54 ` [PATCH 09/13] CLI: add optional config data to dump output David Bremner
2016-03-22 10:54 ` [PATCH 10/13] CLI: optionally restore config data David Bremner
2016-03-22 10:54 ` [PATCH 11/13] CLI: add notmuch-config support for named queries David Bremner
2016-03-22 10:54 ` David Bremner [this message]
2016-03-22 10:54 ` [PATCH 13/13] lib: add " David Bremner

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=1458644094-13951-13-git-send-email-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).