From: Mark Walters Date: Fri, 17 Apr 2015 18:57:27 +0000 (+0100) Subject: Re: [RFC] lib: add support for date:..! to mean date:.. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=421f1e03315d32b8518a0595319243bbc8087299;p=notmuch-archives.git Re: [RFC] lib: add support for date:..! to mean date:.. --- diff --git a/ce/ff64e0967efe9fb8d86c8ccb0c1c6a02b0ac49 b/ce/ff64e0967efe9fb8d86c8ccb0c1c6a02b0ac49 new file mode 100644 index 000000000..c2a108722 --- /dev/null +++ b/ce/ff64e0967efe9fb8d86c8ccb0c1c6a02b0ac49 @@ -0,0 +1,166 @@ +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 C1A8D6DE1006 + for ; Fri, 17 Apr 2015 11:56:44 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.093 +X-Spam-Level: +X-Spam-Status: No, score=0.093 tagged_above=-999 required=5 tests=[AWL=1.741, + DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 Z6C9YGvHAQ3u for ; + Fri, 17 Apr 2015 11:56:41 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + by arlo.cworth.org (Postfix) with ESMTPS id 4E57B6DE0FB0 + for ; Fri, 17 Apr 2015 11:56:41 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1YjBRI-0001zq-Db; Fri, 17 Apr 2015 19:56:34 +0100 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1YjBRI-0001Ww-5R; Fri, 17 Apr 2015 19:56:32 +0100 +From: Mark Walters +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.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Fri, 17 Apr 2015 19:57:27 +0100 +Message-ID: <87a8y6fuqw.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 96ee783ea36004e61c3f2388004b0221 (of first 20000 bytes) +X-SpamAssassin-Score: -0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.0 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider + * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain +X-QM-Scan-Virus: ClamAV says the message is clean +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: Fri, 17 Apr 2015 18:56:44 -0000 + + +Hi + +On Sat, 07 Mar 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.) + +This looks good to me. Yes it may not be needed in the future but the +patch is very small. It passes all tests. +1 from me. + +> 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 would be happy with any of these. + +Best wishes + +Mark + +> +> 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::strin= +g &end) +> { +> time_t t, now; +> + std::string b; +>=20=20 +> /* 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) +>=20=20 +> /* ...and remove it. */ +> begin.erase (0, sizeof (PREFIX) - 1); +> + b =3D begin; +>=20=20 +> /* Use the same 'now' for begin and end. */ +> if (time (&now) =3D=3D (time_t) -1) +> @@ -51,6 +53,9 @@ ParseTimeValueRangeProcessor::operator() (std::string &= +begin, std::string &end) +> } +>=20=20 +> if (!end.empty ()) { +> + if (end =3D=3D "!" && ! b.empty ()) +> + end =3D b; +> + +> if (parse_time_string (end.c_str (), &t, &now, PARSE_TIME_ROUND_UP_INCL= +USIVE)) +> return Xapian::BAD_VALUENO; +>=20=20 +> 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=3D$(notmuch search date:2010-12-16..12/16/2010 | notmuch_search_s= +anitize) +> test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berge= +r; Essai accentu=C3=A9 (inbox unread)" +>=20=20 +> +test_begin_subtest "Absolute date range with 'same' operator" +> +output=3D$(notmuch search date:2010-12-16..! | notmuch_search_sanitize) +> +test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berge= +r; Essai accentu=C3=A9 (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 +> --=20 +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch