Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / a2 / dabb4eddc9c82e8a0b02c32ad5a3003ac500b4
1 Return-Path: <dme@dme.org>\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 6B6BB431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 02:05:56 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 g3GKWL3ngK33 for <notmuch@notmuchmail.org>;\r
16         Fri, 10 Feb 2012 02:05:55 -0800 (PST)\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
18         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 693B3431FAE\r
21         for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 02:05:55 -0800 (PST)\r
22 Received: by werp13 with SMTP id p13so2076456wer.26\r
23         for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 02:05:54 -0800 (PST)\r
24 Received: by 10.180.97.196 with SMTP id ec4mr8186003wib.11.1328868354043;\r
25         Fri, 10 Feb 2012 02:05:54 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id s8sm2163125wiz.8.2012.02.10.02.05.51\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Fri, 10 Feb 2012 02:05:52 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 897A8A48BB; Fri, 10 Feb 2012 10:05:50 +0000 (GMT)\r
33 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH v2 1/2] emacs: support defining a list of alternative\r
35         parts to show\r
36 In-Reply-To:\r
37  <ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani@nikula.org>\r
38 References: <cover.1328719309.git.jani@nikula.org>\r
39         <ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani@nikula.org>\r
40 User-Agent: Notmuch/0.11.1+166~gd2ef4ed (http://notmuchmail.org) Emacs/23.3.1\r
41         (x86_64-pc-linux-gnu)\r
42 From: David Edmondson <dme@dme.org>\r
43 Date: Fri, 10 Feb 2012 10:05:46 +0000\r
44 Message-ID: <cunobt7ypdx.fsf@hotblack-desiato.hh.sledj.net>\r
45 MIME-Version: 1.0\r
46 Content-Type: multipart/signed; boundary="=-=-=";\r
47         micalg=pgp-sha1; protocol="application/pgp-signature"\r
48 X-Gm-Message-State:\r
49  ALoCoQkgQeaVaL0R7DD9VshOjKaCAft1/HgScJsWCWOZe/aLaQQ4Jh4JEIy4jOwGqV8PfmMts9aU\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Fri, 10 Feb 2012 10:05:56 -0000\r
63 \r
64 --=-=-=\r
65 Content-Type: text/plain\r
66 Content-Transfer-Encoding: quoted-printable\r
67 \r
68 On Thu,  9 Feb 2012 14:46:02 +0000, Jani Nikula <jani@nikula.org> wrote:\r
69 > Make notmuch-show-all-multipart/alternative-parts accept a list of\r
70 > regexps to match the part types to determine which parts to show in\r
71 > addition to the preferred types. This allows the user to force display\r
72 > some alternative part types while normally showing just the preferred\r
73 > ones.\r
74 >=20\r
75 > Signed-off-by: Jani Nikula <jani@nikula.org>\r
76 > ---\r
77 >  emacs/notmuch-show.el |   23 ++++++++++++++++++-----\r
78 >  1 files changed, 18 insertions(+), 5 deletions(-)\r
79 >=20\r
80 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
81 > index 24fde05..5f643f1 100644\r
82 > --- a/emacs/notmuch-show.el\r
83 > +++ b/emacs/notmuch-show.el\r
84 > @@ -94,10 +94,20 @@ any given message."\r
85 >    :group 'notmuch-show\r
86 >    :group 'notmuch-hooks)\r
87 >=20=20\r
88 > -;; Mostly useful for debugging.\r
89 >  (defcustom notmuch-show-all-multipart/alternative-parts t\r
90 > -  "Should all parts of multipart/alternative parts be shown?"\r
91 > -  :type 'boolean\r
92 > +  "Which parts of multipart/alternative should be shown?\r
93 > +\r
94 > +This variable determines which parts of multipart/alternative\r
95 > +should be displayed. Set to t (the default) to show all\r
96 > +parts. Set to nil to only show the preferred parts. Set to a list\r
97 > +of regexps to display the preferred parts, and parts matching any\r
98 > +of the regexps, for example:\r
99 \r
100 "If set to `t' (the default), all sub-parts of a\r
101 \"multipart/alternative\" part are shown. If set to `nil', only the\r
102 preferred part is shown. If set to a list of regexps, the preferred part\r
103 and all parts whose type matches one of the regexps will be shown."\r
104 \r
105 > +\r
106 > + (setq notmuch-show-all-multipart/alternative-parts\r
107 > +      '(\"text/.*calendar\" \"text/html\"))"\r
108 > +  :type '(choice (const :tag "Show all parts" t)\r
109 > +              (const :tag "Show preferred parts" nil)\r
110 > +              (repeat :tag "Show preferred and parts matching regexps" string))\r
111 >    :group 'notmuch-show)\r
112 >=20=20\r
113 >  (defcustom notmuch-show-indent-messages-width 1\r
114 > @@ -513,8 +523,11 @@ current buffer, if possible."\r
115 >      ;; should be chosen if there are more than one that match?\r
116 >      (mapc (lambda (inner-part)\r
117 >           (let ((inner-type (plist-get inner-part :content-type)))\r
118 > -           (if (or notmuch-show-all-multipart/alternative-parts\r
119 > -                   (string=3D chosen-type inner-type))\r
120 > +           (if (or (equal notmuch-show-all-multipart/alternative-parts t)\r
121 > +                   (string=3D chosen-type inner-type)\r
122 > +                   (and\r
123 > +                    notmuch-show-all-multipart/alternative-parts\r
124 > +                    (equal (string-match-p (mapconcat (lambda (s) (format "^%s$" s)=\r
125 ) notmuch-show-all-multipart/alternative-parts "\\|") inner-type) 0)))\r
126 \r
127 This is quite messy. How about we add a general helper to "notmuch-lib.el":\r
128 \r
129 (defun notmuch-string-match-list-p (regexps string)\r
130   (loop for regexp in regexps\r
131         if (string-match-p regexp string)\r
132         return t))\r
133 \r
134 and then write:\r
135 \r
136     (if (or (string=3D chosen-type inner-type)\r
137             (equal notmuch-show-all-multipart/alternative-parts t)\r
138             (notmuch-string-match-list-p notmuch-show-all-multipart/alterna=\r
139 tive-parts inner-type))\r
140        ...\r
141 \r
142 ?\r
143 \r
144 >                 (notmuch-show-insert-bodypart msg inner-part depth)\r
145 >               (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type=\r
146  inner-type nil " (not shown)"))))\r
147 >         inner-parts)\r
148 > --=20\r
149 > 1.7.1\r
150 >=20\r
151 \r
152 --=-=-=\r
153 Content-Type: application/pgp-signature\r
154 \r
155 -----BEGIN PGP SIGNATURE-----\r
156 Version: GnuPG v1.4.11 (GNU/Linux)\r
157 \r
158 iEYEARECAAYFAk806/sACgkQaezQq/BJZRbrjACghxHLdoo1AttvN/NZ0uqBikRn\r
159 XucAn3CtUz5ZVcvSdMXW9OXMS00+IEwJ\r
160 =EcqW\r
161 -----END PGP SIGNATURE-----\r
162 --=-=-=--\r