From 0f3efdbbb25b86badccec334312479ff3695aa09 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Fri, 10 Feb 2012 10:05:46 +0000 Subject: [PATCH] Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show --- a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 | 162 ++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 diff --git a/a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 b/a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 new file mode 100644 index 000000000..3c200384c --- /dev/null +++ b/a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 @@ -0,0 +1,162 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6B6BB431FB6 + for ; Fri, 10 Feb 2012 02:05:56 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 g3GKWL3ngK33 for ; + Fri, 10 Feb 2012 02:05:55 -0800 (PST) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 693B3431FAE + for ; Fri, 10 Feb 2012 02:05:55 -0800 (PST) +Received: by werp13 with SMTP id p13so2076456wer.26 + for ; Fri, 10 Feb 2012 02:05:54 -0800 (PST) +Received: by 10.180.97.196 with SMTP id ec4mr8186003wib.11.1328868354043; + Fri, 10 Feb 2012 02:05:54 -0800 (PST) +Received: from hotblack-desiato.hh.sledj.net + (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) + by mx.google.com with ESMTPS id s8sm2163125wiz.8.2012.02.10.02.05.51 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 10 Feb 2012 02:05:52 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id 897A8A48BB; Fri, 10 Feb 2012 10:05:50 +0000 (GMT) +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative + parts to show +In-Reply-To: + +References: + +User-Agent: Notmuch/0.11.1+166~gd2ef4ed (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +From: David Edmondson +Date: Fri, 10 Feb 2012 10:05:46 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha1; protocol="application/pgp-signature" +X-Gm-Message-State: + ALoCoQkgQeaVaL0R7DD9VshOjKaCAft1/HgScJsWCWOZe/aLaQQ4Jh4JEIy4jOwGqV8PfmMts9aU +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: Fri, 10 Feb 2012 10:05:56 -0000 + +--=-=-= +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Thu, 9 Feb 2012 14:46:02 +0000, Jani Nikula wrote: +> Make notmuch-show-all-multipart/alternative-parts accept a list of +> regexps to match the part types to determine which parts to show in +> addition to the preferred types. This allows the user to force display +> some alternative part types while normally showing just the preferred +> ones. +>=20 +> Signed-off-by: Jani Nikula +> --- +> emacs/notmuch-show.el | 23 ++++++++++++++++++----- +> 1 files changed, 18 insertions(+), 5 deletions(-) +>=20 +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 24fde05..5f643f1 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -94,10 +94,20 @@ any given message." +> :group 'notmuch-show +> :group 'notmuch-hooks) +>=20=20 +> -;; Mostly useful for debugging. +> (defcustom notmuch-show-all-multipart/alternative-parts t +> - "Should all parts of multipart/alternative parts be shown?" +> - :type 'boolean +> + "Which parts of multipart/alternative should be shown? +> + +> +This variable determines which parts of multipart/alternative +> +should be displayed. Set to t (the default) to show all +> +parts. Set to nil to only show the preferred parts. Set to a list +> +of regexps to display the preferred parts, and parts matching any +> +of the regexps, for example: + +"If set to `t' (the default), all sub-parts of a +\"multipart/alternative\" part are shown. If set to `nil', only the +preferred part is shown. If set to a list of regexps, the preferred part +and all parts whose type matches one of the regexps will be shown." + +> + +> + (setq notmuch-show-all-multipart/alternative-parts +> + '(\"text/.*calendar\" \"text/html\"))" +> + :type '(choice (const :tag "Show all parts" t) +> + (const :tag "Show preferred parts" nil) +> + (repeat :tag "Show preferred and parts matching regexps" string)) +> :group 'notmuch-show) +>=20=20 +> (defcustom notmuch-show-indent-messages-width 1 +> @@ -513,8 +523,11 @@ current buffer, if possible." +> ;; should be chosen if there are more than one that match? +> (mapc (lambda (inner-part) +> (let ((inner-type (plist-get inner-part :content-type))) +> - (if (or notmuch-show-all-multipart/alternative-parts +> - (string=3D chosen-type inner-type)) +> + (if (or (equal notmuch-show-all-multipart/alternative-parts t) +> + (string=3D 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=3D chosen-type inner-type) + (equal notmuch-show-all-multipart/alternative-parts t) + (notmuch-string-match-list-p notmuch-show-all-multipart/alterna= +tive-parts inner-type)) + ... + +? + +> (notmuch-show-insert-bodypart msg inner-part depth) +> (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type= + inner-type nil " (not shown)")))) +> inner-parts) +> --=20 +> 1.7.1 +>=20 + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.11 (GNU/Linux) + +iEYEARECAAYFAk806/sACgkQaezQq/BJZRbrjACghxHLdoo1AttvN/NZ0uqBikRn +XucAn3CtUz5ZVcvSdMXW9OXMS00+IEwJ +=EcqW +-----END PGP SIGNATURE----- +--=-=-=-- -- 2.26.2