Re: [PATCH v2 1/2] emacs: support defining a list of alternative parts to show
authorDavid Edmondson <dme@dme.org>
Fri, 10 Feb 2012 10:05:46 +0000 (10:05 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:20 +0000 (09:44 -0800)
a2/dabb4eddc9c82e8a0b02c32ad5a3003ac500b4 [new file with mode: 0644]

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