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
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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
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
37 Content-Type: text/plain
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\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
52 On Fri, Oct 26 2012, Austin Clements wrote:
\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
60 These 3 patches LGTM.
\r
65 > emacs/notmuch-lib.el | 16 +++++++++++++++-
\r
67 > 2 files changed, 16 insertions(+), 2 deletions(-)
\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
77 > +(defun notmuch-escape-boolean-term (term)
\r
78 > + "Escape a boolean term for use in a query.
\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
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
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
98 > diff --git a/test/emacs b/test/emacs
\r
99 > index 21f1d16..44f641e 100755
\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
110 > ${gen_msg_filename}
\r
114 > _______________________________________________
\r
115 > notmuch mailing list
\r
116 > notmuch@notmuchmail.org
\r
117 > http://notmuchmail.org/mailman/listinfo/notmuch
\r