From: Jani Nikula Date: Sat, 7 Mar 2015 12:55:59 +0000 (+0200) Subject: [RFC] lib: add support for date:..! to mean date:.. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=01aff4c7d2cdd36c4b87d322508cbfd0a94c3108;p=notmuch-archives.git [RFC] lib: add support for date:..! to mean date:.. --- diff --git a/0d/4c74b8e8e58ff710ba7544b10d7e1de49cee7b b/0d/4c74b8e8e58ff710ba7544b10d7e1de49cee7b new file mode 100644 index 000000000..5829aa8e3 --- /dev/null +++ b/0d/4c74b8e8e58ff710ba7544b10d7e1de49cee7b @@ -0,0 +1,133 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 0AD17431FBC + for ; Sat, 7 Mar 2015 04:55:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.738 +X-Spam-Level: * +X-Spam-Status: No, score=1.738 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7] + 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 I7VVOqVkFpw2 for ; + Sat, 7 Mar 2015 04:55:41 -0800 (PST) +Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com + [74.125.82.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 98D29431FAE for ; Sat, 7 Mar 2015 04:55:41 -0800 + (PST) +Received: by wghn12 with SMTP id n12so11112498wgh.6 + for ; Sat, 07 Mar 2015 04:55:40 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version + :content-type:content-transfer-encoding; + bh=U2s6VwB2XLkX1e+xGY9YAYlinsEBNWmm6WLVLFGiWiM=; + b=YqeWpBnb/vtW/xaO+aaYe8nqpVuR2R2O9gU1VmuuFtDHG/i8ulPP54XDsQhoRMc6Zs + 2Mbe9UuCT23rePq8TFOmAu6NMoEFyJPTvJAOBWZqXiFBoB3OkW/JTgsVrZ+7LWknq0XK + 3QFZaeTgdqGGjaibt//K+x327xLKMe84/FMWoaaTJYS/8vR4a0Jx3he2uBZXLPBrpF5Q + aAKvPai9tPKHsKpund/yyRsSrfYkuIlw38cZtWlAByPaIhlvLk1R2frXOI6CxMf3EsHK + RLEgJfFgUPz8Hli96ObDrDt0IXR59n8Laixq6LuhgxRQkO2bYcjNdkXR6pJznamneQdN + 5thA== +X-Gm-Message-State: + ALoCoQl+UaM0+DPCF9GKn+gyNhxfM/X67McF9YC1+0DOCjYpZCTTbv++K9ZkgLcCcDqQVpDMO5Gm +X-Received: by 10.195.12.71 with SMTP id eo7mr39926547wjd.3.1425732940684; + Sat, 07 Mar 2015 04:55:40 -0800 (PST) +Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi. + [188.238.59.76]) + by mx.google.com with ESMTPSA id l9sm6571941wij.16.2015.03.07.04.55.39 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 07 Mar 2015 04:55:39 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [RFC] lib: add support for date:..! to mean + date:.. +Date: Sat, 7 Mar 2015 14:55:59 +0200 +Message-Id: <1425732959-2282-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +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: Sat, 07 Mar 2015 12:55:45 -0000 + +Up to debate: + +1) Is something like this useful at all as an intermediate step before +we can have support for date:? (This can be done with a future +version of Xapian, or with a custom query query parser.) + +2) If yes, are there better alternatives to "!" as the end point? (Or +should the special case be the start point?) Also "@" and "same" have +been suggested. Examples: date:yesterday..! date:today..@ +date:@..monday date:january..same. + +Idea from Mark Walters . +--- + lib/parse-time-vrp.cc | 5 +++++ + test/T500-search-date.sh | 4 ++++ + 2 files changed, 9 insertions(+) + +diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc +index 33f07db3410e..03804cf50fa8 100644 +--- a/lib/parse-time-vrp.cc ++++ b/lib/parse-time-vrp.cc +@@ -31,6 +31,7 @@ Xapian::valueno + ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end) + { + time_t t, now; ++ std::string b; + + /* Require date: prefix in start of the range... */ + if (STRNCMP_LITERAL (begin.c_str (), PREFIX)) +@@ -38,6 +39,7 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end) + + /* ...and remove it. */ + begin.erase (0, sizeof (PREFIX) - 1); ++ b = begin; + + /* Use the same 'now' for begin and end. */ + if (time (&now) == (time_t) -1) +@@ -51,6 +53,9 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end) + } + + if (!end.empty ()) { ++ if (end == "!" && ! b.empty ()) ++ end = b; ++ + if (parse_time_string (end.c_str (), &t, &now, PARSE_TIME_ROUND_UP_INCLUSIVE)) + return Xapian::BAD_VALUENO; + +diff --git a/test/T500-search-date.sh b/test/T500-search-date.sh +index 70bcf344b4f7..18a47b114fa9 100755 +--- a/test/T500-search-date.sh ++++ b/test/T500-search-date.sh +@@ -8,6 +8,10 @@ test_begin_subtest "Absolute date range" + output=$(notmuch search date:2010-12-16..12/16/2010 | notmuch_search_sanitize) + test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)" + ++test_begin_subtest "Absolute date range with 'same' operator" ++output=$(notmuch search date:2010-12-16..! | notmuch_search_sanitize) ++test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)" ++ + test_begin_subtest "Absolute time range with TZ" + notmuch search date:18-Nov-2009_02:19:26-0800..2009-11-18_04:49:52-06:00 | notmuch_search_sanitize > OUTPUT + cat <EXPECTED +-- +2.1.4 +