--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\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 964C56DE1B7C\r
+ for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:03:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.503\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.503 tagged_above=-999 required=5 tests=[AWL=0.493, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 RR2H6y1SffnT for <notmuch@notmuchmail.org>;\r
+ Sun, 5 Apr 2015 16:03:32 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id AC7FB6DE1BC7\r
+ for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:03:26 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1YetY1-0002pM-1d; Sun, 05 Apr 2015 23:01:45 +0000\r
+Received: (nullmailer pid 2249 invoked by uid 1000); Sun, 05 Apr 2015\r
+ 22:59:25 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [WIP2 07/12] lib: Add "lastmod:" queries for filtering by last\r
+ modification\r
+Date: Mon, 6 Apr 2015 07:59:09 +0900\r
+Message-Id: <1428274754-1698-8-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>\r
+References: <1428274754-1698-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 05 Apr 2015 23:03:33 -0000\r
+\r
+From: Austin Clements <amdragon@mit.edu>\r
+\r
+XXX Includes reference to notmuch search --db-revision, which doesn't\r
+exist.\r
+---\r
+ doc/man7/notmuch-search-terms.rst | 8 ++++++++\r
+ lib/database-private.h | 1 +\r
+ lib/database.cc | 4 ++++\r
+ 3 files changed, 13 insertions(+)\r
+\r
+diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst\r
+index 1d27ac1..d9f213e 100644\r
+--- a/doc/man7/notmuch-search-terms.rst\r
++++ b/doc/man7/notmuch-search-terms.rst\r
+@@ -54,6 +54,8 @@ indicate user-supplied values):\r
+ \r
+ - date:<since>..<until>\r
+ \r
++- lastmod:<since>..<until>\r
++\r
+ The **from:** prefix is used to match the name or address of the sender\r
+ of an email message.\r
+ \r
+@@ -124,6 +126,12 @@ The time range can also be specified using timestamps with a syntax of:\r
+ Each timestamp is a number representing the number of seconds since\r
+ 1970-01-01 00:00:00 UTC.\r
+ \r
++The **lastmod:** prefix can be used to restrict the result by the\r
++database revision number of when messages were last modified (tags\r
++were added/removed or filenames changed). This is usually used in\r
++conjunction with the **--db-revision** argument to **notmuch search**\r
++to find messages that have changed since an earlier query.\r
++\r
+ Operators\r
+ ---------\r
+ \r
+diff --git a/lib/database-private.h b/lib/database-private.h\r
+index 4e93257..3fb10f7 100644\r
+--- a/lib/database-private.h\r
++++ b/lib/database-private.h\r
+@@ -176,6 +176,7 @@ struct _notmuch_database {\r
+ Xapian::TermGenerator *term_gen;\r
+ Xapian::ValueRangeProcessor *value_range_processor;\r
+ Xapian::ValueRangeProcessor *date_range_processor;\r
++ Xapian::ValueRangeProcessor *last_mod_range_processor;\r
+ };\r
+ \r
+ /* Prior to database version 3, features were implied by the database\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index f88bdb3..afa34d6 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -986,6 +986,7 @@ 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
++ 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
+ notmuch->query_parser->set_database (*notmuch->xapian_db);\r
+@@ -993,6 +994,7 @@ notmuch_database_open_verbose (const char *path,\r
+ notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);\r
+ notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor);\r
+ notmuch->query_parser->add_valuerangeprocessor (notmuch->date_range_processor);\r
++ notmuch->query_parser->add_valuerangeprocessor (notmuch->last_mod_range_processor);\r
+ \r
+ for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) {\r
+ prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i];\r
+@@ -1071,6 +1073,8 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
+ notmuch->value_range_processor = NULL;\r
+ delete notmuch->date_range_processor;\r
+ notmuch->date_range_processor = NULL;\r
++ delete notmuch->last_mod_range_processor;\r
++ notmuch->last_mod_range_processor = NULL;\r
+ \r
+ return status;\r
+ }\r
+-- \r
+2.1.4\r
+\r