Error when viewing mails.
[notmuch-archives.git] / f2 / 8820e56c84259e919f5c7ad41cf370cb338283
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 9C2FC431FB6\r
6         for <notmuch@notmuchmail.org>; Sun, 12 Feb 2012 06:38:02 -0800 (PST)\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 N6LCglQK4OxA for <notmuch@notmuchmail.org>;\r
16         Sun, 12 Feb 2012 06:37:58 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 67EEC431FAE\r
19         for <notmuch@notmuchmail.org>; Sun, 12 Feb 2012 06:37:58 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id C02C568055; Sun, 12 Feb 2012 16:37:58 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: Jani Nikula <jani@nikula.org>, David Edmondson <dme@dme.org>,\r
24         notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative\r
26         parts to show\r
27 In-Reply-To: <874nuwi76y.fsf@nikula.org>\r
28 References: <cover.1328719309.git.jani@nikula.org>\r
29         <ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani@nikula.org>\r
30         <cunobt7ypdx.fsf@hotblack-desiato.hh.sledj.net>\r
31         <874nuwi76y.fsf@nikula.org>\r
32 User-Agent: Notmuch/0.11.1+164~g6619341 (http://notmuchmail.org) Emacs/23.3.1\r
33         (x86_64-unknown-linux-gnu)\r
34 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
35         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
36         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
37 Date: Sun, 12 Feb 2012 16:37:58 +0200\r
38 Message-ID: <m2ipjc6rsp.fsf@guru.guru-group.fi>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain; charset=us-ascii\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sun, 12 Feb 2012 14:38:02 -0000\r
54 \r
55 On Sun, 12 Feb 2012 14:09:57 +0200, Jani Nikula <jani@nikula.org> wrote:\r
56 > On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson <dme@dme.org> wrote:\r
57 > > On Thu,  9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:\r
58 \r
59 [...]\r
60 \r
61 > > > +       (if (or (equal notmuch-show-all-multipart/alternative-parts t)\r
62 > > > +               (string= chosen-type inner-type)\r
63 > > > +               (and\r
64 > > > +                notmuch-show-all-multipart/alternative-parts\r
65 > > > +                (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))\r
66 > > \r
67 > > This is quite messy. How about we add a general helper to "notmuch-lib.el":\r
68 > > \r
69 > > (defun notmuch-string-match-list-p (regexps string)\r
70 > >   (loop for regexp in regexps\r
71 > >     if (string-match-p regexp string)\r
72 > >     return t))\r
73 > > \r
74 > > and then write:\r
75 > > \r
76 > >     (if (or (string= chosen-type inner-type)\r
77 > >             (equal notmuch-show-all-multipart/alternative-parts t)\r
78 > >             (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))\r
79 > >        ...\r
80\r
81 > Hmm. I wrapped the regexps between ^ and $ to not match substrings. I\r
82 > think that's less surprising and better than having the user add them,\r
83 > and the user can still use e.g. ".*foo.*" to explicitly match a\r
84 > substring.\r
85\r
86 > If this is fixed in notmuch-string-match-list-p then it's not general\r
87 > anymore. But does adding a mapcar to wrap the regexps here make this\r
88 > messy again...? What if notmuch-string-match-list-p were just a local\r
89 > specific helper for clarity?\r
90 \r
91 Something like this could work...\r
92 \r
93  (defun notmuch-string-match-list-p (regexps string)\r
94    (loop for regexp in regexps\r
95         if (string-match-p (concat "^" regexp "$") string)\r
96         return t))\r
97 \r
98 But if you-re going to pre-anchor these regexps then it is better to be\r
99 documented clearly as the final 'regexp' works in non-standard way.\r
100 \r
101 > > \r
102 > > ?\r
103 \r
104 Tomi\r