--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 16E3F6DE096D\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:25:30 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.015\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.015 tagged_above=-999 required=5\r
+ tests=[AWL=-0.004, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id BUOzCT26C_rt for <notmuch@notmuchmail.org>;\r
+ Sat, 30 Apr 2016 18:25:22 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 65B7E6DE0361\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:24:55 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1awg7u-0006co-Bt; Sat, 30 Apr 2016 21:24:50 -0400\r
+Received: (nullmailer pid 29941 invoked by uid 1000);\r
+ Sun, 01 May 2016 01:24:43 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v3 02/11] lib: optionally support single argument date:\r
+ queries\r
+Date: Sat, 30 Apr 2016 22:24:30 -0300\r
+Message-Id: <1462065879-29860-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.0.rc3\r
+In-Reply-To: <1462065879-29860-1-git-send-email-david@tethera.net>\r
+References: <1462065879-29860-1-git-send-email-david@tethera.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 01 May 2016 01:25:30 -0000\r
+\r
+This relies on the FieldProcessor API, which is only present in xapian\r
+>= 1.3.\r
+---\r
+ doc/man7/notmuch-search-terms.rst | 22 +++++++++++++++++++---\r
+ lib/database-private.h | 3 +++\r
+ lib/database.cc | 6 ++++++\r
+ lib/parse-time-vrp.cc | 21 +++++++++++++++++++++\r
+ lib/parse-time-vrp.h | 5 +++++\r
+ test/T500-search-date.sh | 6 ++++++\r
+ 6 files changed, 60 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst\r
+index 2fbc16d..adedf5a 100644\r
+--- a/doc/man7/notmuch-search-terms.rst\r
++++ b/doc/man7/notmuch-search-terms.rst\r
+@@ -281,9 +281,10 @@ matches from the beginning of January to the end of February.\r
+ date:<expr>..! can be used as a shorthand for date:<expr>..<expr>. The\r
+ expansion takes place before interpretation, and thus, for example,\r
+ date:monday..! matches from the beginning of Monday until the end of\r
+-Monday. (Note that entering date:<expr> without "..", for example\r
+-date:yesterday, won't work, as it's not interpreted as a range\r
+-expression at all. Again, use date:yesterday..!)\r
++Monday.\r
++With **Xapian Field Processor** support (see below), non-range\r
++date queries such as date:yesterday will work, but otherwise\r
++will give unexpected results; if in doubt use date:yesterday..!\r
+ \r
+ Currently, we do not support spaces in range expressions. You can\r
+ replace the spaces with '\_', or (in most cases) '-', or (in some cases)\r
+@@ -370,6 +371,21 @@ Time zones\r
+ \r
+ Some time zone codes, e.g. UTC, EET.\r
+ \r
++XAPIAN FIELD PROCESSORS\r
++=======================\r
++\r
++Certain optional features of the notmuch query processor rely on the\r
++presence of the Xapian field processor API. You can determine if your\r
++notmuch was built against a sufficiently recent version of Xapian by running\r
++\r
++::\r
++\r
++ % notmuch config get built_with.field_processor\r
++\r
++Currently the following features require field processor support:\r
++\r
++- non-range date queries, e.g. "date:today"\r
++\r
+ SEE ALSO\r
+ ========\r
+ \r
+diff --git a/lib/database-private.h b/lib/database-private.h\r
+index 3fb10f7..e1962f4 100644\r
+--- a/lib/database-private.h\r
++++ b/lib/database-private.h\r
+@@ -176,6 +176,9 @@ struct _notmuch_database {\r
+ Xapian::TermGenerator *term_gen;\r
+ Xapian::ValueRangeProcessor *value_range_processor;\r
+ Xapian::ValueRangeProcessor *date_range_processor;\r
++#if HAVE_XAPIAN_FIELD_PROCESSOR\r
++ Xapian::FieldProcessor *date_field_processor;\r
++#endif\r
+ Xapian::ValueRangeProcessor *last_mod_range_processor;\r
+ };\r
+ \r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index c8c5e26..ebe019f 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1000,6 +1000,12 @@ notmuch_database_open_verbose (const char *path,\r
+ notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));\r
+ notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);\r
+ notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);\r
++#if HAVE_XAPIAN_FIELD_PROCESSOR\r
++ /* This currently relies on the query parser to pass anything\r
++ * with a .. to the range processor */\r
++ notmuch->date_field_processor = new DateFieldProcessor();\r
++ notmuch->query_parser->add_boolean_prefix("date", notmuch->date_field_processor);\r
++#endif\r
+ notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");\r
+ \r
+ notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);\r
+diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc\r
+index 03804cf..b15b77c 100644\r
+--- a/lib/parse-time-vrp.cc\r
++++ b/lib/parse-time-vrp.cc\r
+@@ -64,3 +64,24 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end)\r
+ \r
+ return valno;\r
+ }\r
++\r
++#if HAVE_XAPIAN_FIELD_PROCESSOR\r
++/* XXX TODO: is throwing an exception the right thing to do here? */\r
++Xapian::Query DateFieldProcessor::operator()(const std::string & str) {\r
++ time_t from, to, now;\r
++\r
++ /* Use the same 'now' for begin and end. */\r
++ if (time (&now) == (time_t) -1)\r
++ throw Xapian::QueryParserError("Unable to get current time");\r
++\r
++ if (parse_time_string (str.c_str (), &from, &now, PARSE_TIME_ROUND_DOWN))\r
++ throw Xapian::QueryParserError ("Didn't understand date specification '" + str + "'");\r
++\r
++ if (parse_time_string (str.c_str (), &to, &now, PARSE_TIME_ROUND_UP_INCLUSIVE))\r
++ throw Xapian::QueryParserError ("Didn't understand date specification '" + str + "'");\r
++\r
++ return Xapian::Query(Xapian::Query::OP_AND,\r
++ Xapian::Query(Xapian::Query::OP_VALUE_GE, 0, Xapian::sortable_serialise ((double) from)),\r
++ Xapian::Query(Xapian::Query::OP_VALUE_LE, 0, Xapian::sortable_serialise ((double) to)));\r
++}\r
++#endif\r
+diff --git a/lib/parse-time-vrp.h b/lib/parse-time-vrp.h\r
+index 094c4f8..3bd12bf 100644\r
+--- a/lib/parse-time-vrp.h\r
++++ b/lib/parse-time-vrp.h\r
+@@ -37,4 +37,9 @@ public:\r
+ Xapian::valueno operator() (std::string &begin, std::string &end);\r
+ };\r
+ \r
++#if HAVE_XAPIAN_FIELD_PROCESSOR\r
++class DateFieldProcessor : public Xapian::FieldProcessor {\r
++ Xapian::Query operator()(const std::string & str);\r
++};\r
++#endif\r
+ #endif /* NOTMUCH_PARSE_TIME_VRP_H */\r
+diff --git a/test/T500-search-date.sh b/test/T500-search-date.sh\r
+index f5cea42..198a2e6 100755\r
+--- a/test/T500-search-date.sh\r
++++ b/test/T500-search-date.sh\r
+@@ -12,6 +12,12 @@ test_begin_subtest "Absolute date range with 'same' operator"\r
+ output=$(notmuch search date:2010-12-16..! | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)"\r
+ \r
++if [ "${NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR}" = "1" ]; then\r
++ test_begin_subtest "Absolute date field"\r
++ output=$(notmuch search date:2010-12-16 | notmuch_search_sanitize)\r
++ test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)"\r
++fi\r
++\r
+ test_begin_subtest "Absolute time range with TZ"\r
+ notmuch search date:18-Nov-2009_02:19:26-0800..2009-11-18_04:49:52-06:00 | notmuch_search_sanitize > OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-- \r
+2.8.0.rc3\r
+\r