From c80d71c936214bf9edd32c8f3eb12d488835bb34 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 18 Apr 2015 11:07:10 +0300 Subject: [PATCH] Re: [RFC] lib: add support for date:..! to mean date:.. --- 7e/bd49c48481c393f6546f8077ad578787faadd5 | 104 ++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 7e/bd49c48481c393f6546f8077ad578787faadd5 diff --git a/7e/bd49c48481c393f6546f8077ad578787faadd5 b/7e/bd49c48481c393f6546f8077ad578787faadd5 new file mode 100644 index 000000000..fe73e5447 --- /dev/null +++ b/7e/bd49c48481c393f6546f8077ad578787faadd5 @@ -0,0 +1,104 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 8753F6DE0149 + for ; Sat, 18 Apr 2015 01:07:38 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.146 +X-Spam-Level: * +X-Spam-Status: No, score=1.146 tagged_above=-999 required=5 tests=[AWL=0.494, + SPF_NEUTRAL=0.652] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id KqzDHYixxFgi for ; + Sat, 18 Apr 2015 01:07:36 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 216876DE0130 + for ; Sat, 18 Apr 2015 01:07:36 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 2BBDC1000F3; + Sat, 18 Apr 2015 11:07:11 +0300 (EEST) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [RFC] lib: add support for date:..! to + mean date:.. +In-Reply-To: <1425732959-2282-1-git-send-email-jani@nikula.org> +References: <1425732959-2282-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.19+107~gab55bdb (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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, 18 Apr 2015 08:07:38 -0000 + +On Sat, Mar 07 2015, Jani Nikula wrote: + +> 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. + + +I'd rather see a temporary ugly hack in implementation (to expand +date: to date:..) than permanent interface feature. +But this looks simple enough... and I'd go just with this implementation +(i.e. ..!) + + +Tomi + + +> 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; +> -- 2.26.2