[RFC] lib: add support for date:<query>..! to mean date:<query>..<query>
authorJani Nikula <jani@nikula.org>
Sat, 7 Mar 2015 12:55:59 +0000 (14:55 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:19 +0000 (14:48 -0700)
0d/4c74b8e8e58ff710ba7544b10d7e1de49cee7b [new file with mode: 0644]

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