From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 5CB24429E29 for ; Tue, 13 Dec 2011 09:12:11 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BjaJkPGz3rN4 for ; Tue, 13 Dec 2011 09:12:10 -0800 (PST) Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222]) by olra.theworths.org (Postfix) with ESMTP id 4F095429E2E for ; Tue, 13 Dec 2011 09:12:09 -0800 (PST) Received: from thor.loria.fr (thor.loria.fr [152.81.12.250]) by ks3536.kimsufi.com (Postfix) with ESMTPSA id 8B1826A002B; Tue, 13 Dec 2011 18:12:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net; s=key-schnouki; t=1323796328; bh=oEGl7iFrfq2YxyQ9ot7Z/4rGgDdMVu6uuBT4zYsmZD0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=BnXzyDvLW3U2awNMTCfM3Sml5aubeCadGGqxmo2Zaip8TeH72y6WjCSfWGKb0ZSBc 1kQ0Mix5oN09cqVLN7R+iDUDF7+Cj3sJqveXXxr/iQn1kzFaEBKnMNH7hBqvEKOTya bnBUaA/UsR7bs7eV2G7DdqLmsqCz8qwzLYyI96kg= From: Thomas Jost To: notmuch@notmuchmail.org Subject: [PATCH 3/5] lib: Make MTIME values searchable Date: Tue, 13 Dec 2011 18:11:43 +0100 Message-Id: <1323796305-28789-4-git-send-email-schnouki@schnouki.net> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1323796305-28789-1-git-send-email-schnouki@schnouki.net> References: <1323796305-28789-1-git-send-email-schnouki@schnouki.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2011 17:12:11 -0000 Tag modification times are now searchable as ranges (just like regular message dates) with the "mtime:" prefix. --- lib/database-private.h | 1 + lib/database.cc | 3 +++ notmuch.1 | 14 ++++++++++++-- notmuch.c | 13 ++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 88532d5..e71c8e4 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -52,6 +52,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; + Xapian::ValueRangeProcessor *mtime_value_range_processor; }; /* Return the list of terms from the given iterator matching a prefix. diff --git a/lib/database.cc b/lib/database.cc index 6dc6f73..cc970c1 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -677,12 +677,14 @@ notmuch_database_open (const char *path, notmuch->term_gen = new Xapian::TermGenerator; notmuch->term_gen->set_stemmer (Xapian::Stem ("english")); notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); + notmuch->mtime_value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_MTIME, "mtime:"); notmuch->query_parser->set_default_op (Xapian::Query::OP_AND); notmuch->query_parser->set_database (*notmuch->xapian_db); notmuch->query_parser->set_stemmer (Xapian::Stem ("english")); notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME); notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor); + notmuch->query_parser->add_valuerangeprocessor (notmuch->mtime_value_range_processor); for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) { prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i]; @@ -726,6 +728,7 @@ notmuch_database_close (notmuch_database_t *notmuch) delete notmuch->query_parser; delete notmuch->xapian_db; delete notmuch->value_range_processor; + delete notmuch->mtime_value_range_processor; talloc_free (notmuch); } diff --git a/notmuch.1 b/notmuch.1 index 3dbd67e..2235096 100644 --- a/notmuch.1 +++ b/notmuch.1 @@ -644,6 +644,8 @@ terms to match against specific portions of an email, (where folder: + mtime: + The .B from: prefix is used to match the name or address of the sender of an email @@ -707,8 +709,8 @@ operators, but will have to be protected from interpretation by the shell, (such as by putting quotation marks around any parenthesized expression). -Finally, results can be restricted to only messages within a -particular time range, (based on the Date: header) with a syntax of: +Results can be restricted to only messages within a particular time range, +(based on the Date: header) with a syntax of: .. @@ -721,6 +723,14 @@ specify a date range to return messages from 2009\-10\-01 until the current time: $(date +%s \-d 2009\-10\-01)..$(date +%s) + +Finally, the +.B mtime: +prefix can be used to search for messages which were modified (e.g. tags were +added or removed) within a particular time range, with the same syntax as +before: + + mtime:.. .SH HOOKS Hooks are scripts (or arbitrary executables or symlinks to such) that notmuch invokes before and after certain actions. These scripts reside in diff --git a/notmuch.c b/notmuch.c index c0ce026..443cf59 100644 --- a/notmuch.c +++ b/notmuch.c @@ -71,6 +71,7 @@ static const char search_terms_help[] = "\t\tid:\n" "\t\tthread:\n" "\t\tfolder:\n" + "\t\tmtime:\n" "\n" "\tThe from: prefix is used to match the name or address of\n" "\tthe sender of an email message.\n" @@ -112,8 +113,8 @@ static const char search_terms_help[] = "\tinterpretation by the shell, (such as by putting quotation\n" "\tmarks around any parenthesized expression).\n" "\n" - "\tFinally, results can be restricted to only messages within a\n" - "\tparticular time range, (based on the Date: header) with:\n" + "\tResults can be restricted to only messages within a particular\n" + "\ttime range, (based on the Date: header) with:\n" "\n" "\t\t..\n" "\n" @@ -125,7 +126,13 @@ static const char search_terms_help[] = "\tfollowing syntax would specify a date range to return messages\n" "\tfrom 2009-10-01 until the current time:\n" "\n" - "\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n"; + "\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n" + "\n" + "\tFinally, the mtime: prefix can be used to search for messages\n" + "\twhich were modified (e.g. tags were added or removed) within a\n" + "\tparticular time range, with the same syntax as before:\n" + "\n" + "\t\tmtime:..\n"; static const char hooks_help[] = "\tHooks are scripts (or arbitrary executables or symlinks to such) that\n" -- 1.7.8