Re: [RFC PATCH 5/5] cli: add support for deduplicating based on case insensitive...
[notmuch-archives.git] / 4d / 5e4312e8d57fefbe2a3682d705d123c95c11d0
1 Return-Path: <tomi.ollila@iki.fi>\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 olra.theworths.org (Postfix) with ESMTP id 70DF6431FAF\r
6         for <notmuch@notmuchmail.org>; Fri, 26 Oct 2012 14:12:46 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id dXXVP8UIYBaN for <notmuch@notmuchmail.org>;\r
16         Fri, 26 Oct 2012 14:12:45 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 9FA4A431FAE\r
19         for <notmuch@notmuchmail.org>; Fri, 26 Oct 2012 14:12:45 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 5C7AD100045;\r
22         Sat, 27 Oct 2012 00:12:46 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH 1/3] emacs: Introduce generic boolean term escaping\r
26         function\r
27 In-Reply-To: <1351282692-11455-1-git-send-email-amdragon@mit.edu>\r
28 References: <1351282692-11455-1-git-send-email-amdragon@mit.edu>\r
29 User-Agent: Notmuch/0.14+59~gf9031cd (http://notmuchmail.org) Emacs/24.2.1\r
30         (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Sat, 27 Oct 2012 00:12:45 +0300\r
35 Message-ID: <m2k3uduecy.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Fri, 26 Oct 2012 21:12:46 -0000\r
51 \r
52 On Fri, Oct 26 2012, Austin Clements wrote:\r
53 \r
54 > Currently, we only properly escape stashed id queries, but there are\r
55 > other places where the Emacs UI constructs queries for boolean terms.\r
56 > Since this escaping function is meant to be used in other places, it\r
57 > avoids escaping strings that don't need escaping.\r
58 > ---\r
59 \r
60 These 3 patches LGTM.\r
61 \r
62 Tomi\r
63 \r
64 \r
65 >  emacs/notmuch-lib.el |   16 +++++++++++++++-\r
66 >  test/emacs           |    2 +-\r
67 >  2 files changed, 16 insertions(+), 2 deletions(-)\r
68 >\r
69 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
70 > index 69867ad..eeb005f 100644\r
71 > --- a/emacs/notmuch-lib.el\r
72 > +++ b/emacs/notmuch-lib.el\r
73 > @@ -161,9 +161,23 @@ the user hasn't set this variable with the old or new value."\r
74 >       "[No Subject]"\r
75 >        subject)))\r
76 >  \r
77 > +(defun notmuch-escape-boolean-term (term)\r
78 > +  "Escape a boolean term for use in a query.\r
79 > +\r
80 > +The caller is responsible for prepending the term prefix and a\r
81 > +colon.  This performs minimal escaping in order to produce\r
82 > +user-friendly queries."\r
83 > +\r
84 > +  (save-match-data\r
85 > +    (if (or (equal term "")\r
86 > +         (string-match "[ ()]\\|^\"" term))\r
87 > +     ;; Requires escaping\r
88 > +     (concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"")\r
89 > +      term)))\r
90 > +\r
91 >  (defun notmuch-id-to-query (id)\r
92 >    "Return a query that matches the message with id ID."\r
93 > -  (concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\""))\r
94 > +  (concat "id:" (notmuch-escape-boolean-term id)))\r
95 >  \r
96 >  ;;\r
97 >  \r
98 > diff --git a/test/emacs b/test/emacs\r
99 > index 21f1d16..44f641e 100755\r
100 > --- a/test/emacs\r
101 > +++ b/test/emacs\r
102 > @@ -667,7 +667,7 @@ Some One <someone@somewhere.org>\r
103 >  Some One Else <notsomeone@somewhere.org>\r
104 >  Notmuch <notmuch@notmuchmail.org>\r
105 >  Stash my stashables\r
106 > -id:"bought"\r
107 > +id:bought\r
108 >  bought\r
109 >  inbox,stashtest\r
110 >  ${gen_msg_filename}\r
111 > -- \r
112 > 1.7.10\r
113 >\r
114 > _______________________________________________\r
115 > notmuch mailing list\r
116 > notmuch@notmuchmail.org\r
117 > http://notmuchmail.org/mailman/listinfo/notmuch\r