Re: [RFC] lib: add support for date:<query>..! to mean date:<query>..<query>
authorTomi Ollila <tomi.ollila@iki.fi>
Sat, 18 Apr 2015 08:07:10 +0000 (11:07 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:50 +0000 (14:48 -0700)
7e/bd49c48481c393f6546f8077ad578787faadd5 [new file with mode: 0644]

diff --git a/7e/bd49c48481c393f6546f8077ad578787faadd5 b/7e/bd49c48481c393f6546f8077ad578787faadd5
new file mode 100644 (file)
index 0000000..fe73e54
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <tomi.ollila@iki.fi>\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 8753F6DE0149\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Apr 2015 01:07:38 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.146\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.146 tagged_above=-999 required=5 tests=[AWL=0.494, \r
+ SPF_NEUTRAL=0.652] 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 KqzDHYixxFgi for <notmuch@notmuchmail.org>;\r
+ Sat, 18 Apr 2015 01:07:36 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 216876DE0130\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Apr 2015 01:07:36 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 2BBDC1000F3;\r
+ Sat, 18 Apr 2015 11:07:11 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [RFC] lib: add support for date:<query>..! to\r
+ mean  date:<query>..<query>\r
+In-Reply-To: <1425732959-2282-1-git-send-email-jani@nikula.org>\r
+References: <1425732959-2282-1-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.19+107~gab55bdb (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 18 Apr 2015 11:07:10 +0300\r
+Message-ID: <m2y4lplv0x.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Sat, 18 Apr 2015 08:07:38 -0000\r
+\r
+On Sat, Mar 07 2015, Jani Nikula <jani@nikula.org> wrote:\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
+\r
+I'd rather see a temporary ugly hack in implementation (to expand\r
+date:<date> to date:<date>..<date>) than permanent interface feature.\r
+But this looks simple enough... and I'd go just with this implementation\r
+(i.e. <date>..!)\r
+\r
+\r
+Tomi\r
+\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