From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 9C2FC431FB6 for ; Sun, 12 Feb 2012 06:38:02 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N6LCglQK4OxA for ; Sun, 12 Feb 2012 06:37:58 -0800 (PST) Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) by olra.theworths.org (Postfix) with ESMTP id 67EEC431FAE for ; Sun, 12 Feb 2012 06:37:58 -0800 (PST) Received: by guru.guru-group.fi (Postfix, from userid 501) id C02C568055; Sun, 12 Feb 2012 16:37:58 +0200 (EET) From: Tomi Ollila To: Jani Nikula , David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show In-Reply-To: <874nuwi76y.fsf@nikula.org> References: <874nuwi76y.fsf@nikula.org> User-Agent: Notmuch/0.11.1+164~g6619341 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Feb 2012 14:38:02 -0000 On Sun, 12 Feb 2012 14:09:57 +0200, Jani Nikula wrote: > On Fri, 10 Feb 2012 10:05:46 +0000, David Edmondson wrote: > > On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula wrote: [...] > > > + (if (or (equal notmuch-show-all-multipart/alternative-parts t) > > > + (string= chosen-type inner-type) > > > + (and > > > + notmuch-show-all-multipart/alternative-parts > > > + (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0))) > > > > This is quite messy. How about we add a general helper to "notmuch-lib.el": > > > > (defun notmuch-string-match-list-p (regexps string) > > (loop for regexp in regexps > > if (string-match-p regexp string) > > return t)) > > > > and then write: > > > > (if (or (string= chosen-type inner-type) > > (equal notmuch-show-all-multipart/alternative-parts t) > > (notmuch-string-match-list-p notmuch-show-all-multipart/alternative-parts inner-type)) > > ... > > Hmm. I wrapped the regexps between ^ and $ to not match substrings. I > think that's less surprising and better than having the user add them, > and the user can still use e.g. ".*foo.*" to explicitly match a > substring. > > If this is fixed in notmuch-string-match-list-p then it's not general > anymore. But does adding a mapcar to wrap the regexps here make this > messy again...? What if notmuch-string-match-list-p were just a local > specific helper for clarity? Something like this could work... (defun notmuch-string-match-list-p (regexps string) (loop for regexp in regexps if (string-match-p (concat "^" regexp "$") string) return t)) But if you-re going to pre-anchor these regexps then it is better to be documented clearly as the final 'regexp' works in non-standard way. > > > > ? Tomi