Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 12 Feb 2012 14:37:58 +0000 (16:37 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:22 +0000 (09:44 -0800)
f2/8820e56c84259e919f5c7ad41cf370cb338283 [new file with mode: 0644]

diff --git a/f2/8820e56c84259e919f5c7ad41cf370cb338283 b/f2/8820e56c84259e919f5c7ad41cf370cb338283
new file mode 100644 (file)
index 0000000..226a92b
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 9C2FC431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 12 Feb 2012 06:38:02 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id N6LCglQK4OxA for <notmuch@notmuchmail.org>;\r
+       Sun, 12 Feb 2012 06:37:58 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
+       by olra.theworths.org (Postfix) with ESMTP id 67EEC431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 12 Feb 2012 06:37:58 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id C02C568055; Sun, 12 Feb 2012 16:37:58 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jani Nikula <jani@nikula.org>, David Edmondson <dme@dme.org>,\r
+       notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative\r
+       parts to show\r
+In-Reply-To: <874nuwi76y.fsf@nikula.org>\r
+References: <cover.1328719309.git.jani@nikula.org>\r
+       <ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani@nikula.org>\r
+       <cunobt7ypdx.fsf@hotblack-desiato.hh.sledj.net>\r
+       <874nuwi76y.fsf@nikula.org>\r
+User-Agent: Notmuch/0.11.1+164~g6619341 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sun, 12 Feb 2012 16:37:58 +0200\r
+Message-ID: <m2ipjc6rsp.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 12 Feb 2012 14:38:02 -0000\r
+\r
+On Sun, 12 Feb 2012 14:09:57 +0200, Jani Nikula <jani@nikula.org> wrote:\r
+> On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson <dme@dme.org> wrote:\r
+> > On Thu,  9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:\r
+\r
+[...]\r
+\r
+> > > +              (if (or (equal notmuch-show-all-multipart/alternative-parts t)\r
+> > > +                      (string= chosen-type inner-type)\r
+> > > +                      (and\r
+> > > +                       notmuch-show-all-multipart/alternative-parts\r
+> > > +                       (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))\r
+> > \r
+> > This is quite messy. How about we add a general helper to "notmuch-lib.el":\r
+> > \r
+> > (defun notmuch-string-match-list-p (regexps string)\r
+> >   (loop for regexp in regexps\r
+> >    if (string-match-p regexp string)\r
+> >    return t))\r
+> > \r
+> > and then write:\r
+> > \r
+> >     (if (or (string= chosen-type inner-type)\r
+> >             (equal notmuch-show-all-multipart/alternative-parts t)\r
+> >             (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type))\r
+> >        ...\r
+> \r
+> Hmm. I wrapped the regexps between ^ and $ to not match substrings. I\r
+> think that's less surprising and better than having the user add them,\r
+> and the user can still use e.g. ".*foo.*" to explicitly match a\r
+> substring.\r
+> \r
+> If this is fixed in notmuch-string-match-list-p then it's not general\r
+> anymore. But does adding a mapcar to wrap the regexps here make this\r
+> messy again...? What if notmuch-string-match-list-p were just a local\r
+> specific helper for clarity?\r
+\r
+Something like this could work...\r
+\r
+ (defun notmuch-string-match-list-p (regexps string)\r
+   (loop for regexp in regexps\r
+       if (string-match-p (concat "^" regexp "$") string)\r
+       return t))\r
+\r
+But if you-re going to pre-anchor these regexps then it is better to be\r
+documented clearly as the final 'regexp' works in non-standard way.\r
+\r
+> > \r
+> > ?\r
+\r
+Tomi\r