Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / ce / ff64e0967efe9fb8d86c8ccb0c1c6a02b0ac49
1 Return-Path: <m.walters@qmul.ac.uk>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id C1A8D6DE1006\r
6  for <notmuch@notmuchmail.org>; Fri, 17 Apr 2015 11:56:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.093\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.093 tagged_above=-999 required=5 tests=[AWL=1.741, \r
12  DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13  NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\r
15  RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01,\r
16  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
17 Received: from arlo.cworth.org ([127.0.0.1])\r
18  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
19  with ESMTP id Z6C9YGvHAQ3u for <notmuch@notmuchmail.org>;\r
20  Fri, 17 Apr 2015 11:56:41 -0700 (PDT)\r
21 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
22  by arlo.cworth.org (Postfix) with ESMTPS id 4E57B6DE0FB0\r
23  for <notmuch@notmuchmail.org>; Fri, 17 Apr 2015 11:56:41 -0700 (PDT)\r
24 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
25  by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
26  (envelope-from <m.walters@qmul.ac.uk>)\r
27  id 1YjBRI-0001zq-Db; Fri, 17 Apr 2015 19:56:34 +0100\r
28 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
29  by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
30  (envelope-from <m.walters@qmul.ac.uk>)\r
31  id 1YjBRI-0001Ww-5R; Fri, 17 Apr 2015 19:56:32 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
34 Subject: Re: [RFC] lib: add support for date:<query>..! to\r
35  mean   date:<query>..<query>\r
36 In-Reply-To: <1425732959-2282-1-git-send-email-jani@nikula.org>\r
37 References: <1425732959-2282-1-git-send-email-jani@nikula.org>\r
38 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/24.4.1\r
39  (x86_64-pc-linux-gnu)\r
40 Date: Fri, 17 Apr 2015 19:57:27 +0100\r
41 Message-ID: <87a8y6fuqw.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=utf-8\r
44 Content-Transfer-Encoding: quoted-printable\r
45 X-Sender-Host-Address: 87.81.223.162\r
46 X-QM-Geographic: According to ripencc,\r
47  this message was delivered by a machine in Britain (UK) (GB).\r
48 X-QM-SPAM-Info: Sender has good ham record.  :)\r
49 X-QM-Body-MD5: 96ee783ea36004e61c3f2388004b0221 (of first 20000 bytes)\r
50 X-SpamAssassin-Score: -0.0\r
51 X-SpamAssassin-SpamBar: /\r
52 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
53  determine if it is\r
54  spam. We require at least 5.0 points to mark a message as spam.\r
55  This message scored -0.0 points.\r
56  Summary of the scoring: \r
57  *  0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider\r
58  *      (markwalters1009[at]gmail.com)\r
59  * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
60  *      domain\r
61 X-QM-Scan-Virus: ClamAV says the message is clean\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.18\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Fri, 17 Apr 2015 18:56:44 -0000\r
75 \r
76 \r
77 Hi\r
78 \r
79 On Sat, 07 Mar 2015, Jani Nikula <jani@nikula.org> wrote:\r
80 > Up to debate:\r
81 >\r
82 > 1) Is something like this useful at all as an intermediate step before\r
83 > we can have support for date:<query>? (This can be done with a future\r
84 > version of Xapian, or with a custom query query parser.)\r
85 \r
86 This looks good to me. Yes it may not be needed in the future but the\r
87 patch is very small. It passes all tests. +1 from me.\r
88 \r
89 > 2) If yes, are there better alternatives to "!" as the end point? (Or\r
90 > should the special case be the start point?) Also "@" and "same" have\r
91 > been suggested. Examples: date:yesterday..! date:today..@\r
92 > date:@..monday date:january..same.\r
93 \r
94 I would be happy with any of these.\r
95 \r
96 Best wishes\r
97 \r
98 Mark\r
99 \r
100 >\r
101 > Idea from Mark Walters <markwalters1009@gmail.com>.\r
102 > ---\r
103 >  lib/parse-time-vrp.cc    | 5 +++++\r
104 >  test/T500-search-date.sh | 4 ++++\r
105 >  2 files changed, 9 insertions(+)\r
106 >\r
107 > diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc\r
108 > index 33f07db3410e..03804cf50fa8 100644\r
109 > --- a/lib/parse-time-vrp.cc\r
110 > +++ b/lib/parse-time-vrp.cc\r
111 > @@ -31,6 +31,7 @@ Xapian::valueno\r
112 >  ParseTimeValueRangeProcessor::operator() (std::string &begin, std::strin=\r
113 g &end)\r
114 >  {\r
115 >      time_t t, now;\r
116 > +    std::string b;\r
117 >=20=20\r
118 >      /* Require date: prefix in start of the range... */\r
119 >      if (STRNCMP_LITERAL (begin.c_str (), PREFIX))\r
120 > @@ -38,6 +39,7 @@ ParseTimeValueRangeProcessor::operator() (std::string &=\r
121 begin, std::string &end)\r
122 >=20=20\r
123 >      /* ...and remove it. */\r
124 >      begin.erase (0, sizeof (PREFIX) - 1);\r
125 > +    b =3D begin;\r
126 >=20=20\r
127 >      /* Use the same 'now' for begin and end. */\r
128 >      if (time (&now) =3D=3D (time_t) -1)\r
129 > @@ -51,6 +53,9 @@ ParseTimeValueRangeProcessor::operator() (std::string &=\r
130 begin, std::string &end)\r
131 >      }\r
132 >=20=20\r
133 >      if (!end.empty ()) {\r
134 > +     if (end =3D=3D "!" && ! b.empty ())\r
135 > +         end =3D b;\r
136 > +\r
137 >       if (parse_time_string (end.c_str (), &t, &now, PARSE_TIME_ROUND_UP_INCL=\r
138 USIVE))\r
139 >           return Xapian::BAD_VALUENO;\r
140 >=20=20\r
141 > diff --git a/test/T500-search-date.sh b/test/T500-search-date.sh\r
142 > index 70bcf344b4f7..18a47b114fa9 100755\r
143 > --- a/test/T500-search-date.sh\r
144 > +++ b/test/T500-search-date.sh\r
145 > @@ -8,6 +8,10 @@ test_begin_subtest "Absolute date range"\r
146 >  output=3D$(notmuch search date:2010-12-16..12/16/2010 | notmuch_search_s=\r
147 anitize)\r
148 >  test_expect_equal "$output" "thread:XXX   2010-12-16 [1/1] Olivier Berge=\r
149 r; Essai accentu=C3=A9 (inbox unread)"\r
150 >=20=20\r
151 > +test_begin_subtest "Absolute date range with 'same' operator"\r
152 > +output=3D$(notmuch search date:2010-12-16..! | notmuch_search_sanitize)\r
153 > +test_expect_equal "$output" "thread:XXX   2010-12-16 [1/1] Olivier Berge=\r
154 r; Essai accentu=C3=A9 (inbox unread)"\r
155 > +\r
156 >  test_begin_subtest "Absolute time range with TZ"\r
157 >  notmuch search date:18-Nov-2009_02:19:26-0800..2009-11-18_04:49:52-06:00=\r
158  | notmuch_search_sanitize > OUTPUT\r
159 >  cat <<EOF >EXPECTED\r
160 > --=20\r
161 > 2.1.4\r
162 >\r
163 > _______________________________________________\r
164 > notmuch mailing list\r
165 > notmuch@notmuchmail.org\r
166 > http://notmuchmail.org/mailman/listinfo/notmuch\r