Re: [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted
[notmuch-archives.git] / 49 / f081dbbff9a4a4a4470597119b94da52751cca
1 Return-Path: <amdragon@mit.edu>\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 28176431FC2\r
6         for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 21:40:05 -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 KcrKQjJE19of for <notmuch@notmuchmail.org>;\r
16         Fri, 14 Dec 2012 21:40:03 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id 164DC431FC0\r
20         for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 21:40:03 -0800 (PST)\r
21 X-AuditID: 12074423-b7fcb6d000000927-bf-50cc0d3046f5\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 75.12.02343.03D0CC05; Sat, 15 Dec 2012 00:40:01 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qBF5e0or023041; \r
27         Sat, 15 Dec 2012 00:40:00 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBF5dxLl013155\r
32         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
33         Sat, 15 Dec 2012 00:40:00 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1TjkTe-0007AA-NY; Sat, 15 Dec 2012 00:39:58 -0500\r
37 From: Austin Clements <aclements@csail.mit.edu>\r
38 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
39 Subject: Re: [PATCH v2 2/5] emacs: show: add overlays for each part\r
40 In-Reply-To: <1355389924-3718-3-git-send-email-markwalters1009@gmail.com>\r
41 References: <1355389924-3718-1-git-send-email-markwalters1009@gmail.com>\r
42         <1355389924-3718-3-git-send-email-markwalters1009@gmail.com>\r
43 User-Agent: Notmuch/0.14+159~g6895fee (http://notmuchmail.org) Emacs/23.4.1\r
44         (i486-pc-linux-gnu)\r
45 Date: Sat, 15 Dec 2012 00:39:58 -0500\r
46 Message-ID: <878v8zooup.fsf@awakening.csail.mit.edu>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsUixCmqrGvIeybA4MM3RovVc3ksrt+cyezA\r
51         5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdxadJa94JdqxarHCxgbGBfJdTFyckgImEi0\r
52         vn7FCGGLSVy4t56ti5GLQ0hgH6NE+/+3TBDOBkaJZR87GCGci0wSx5Y9ZANpERJYwiix65ke\r
53         iM0moC+xYu0kVhBbRMBV4um3z8wgtrCAs8SJSQeYQGxOAU+JxktvWSB6WxklZt/S7GLk4BAV\r
54         iJeYfc4HJMwioCqxZds3FpAwL9B1b16rgIR5BQQlTs58AtbJLKAlcePfS6YJjAKzkKRmIUkt\r
55         YGRaxSibklulm5uYmVOcmqxbnJyYl5dapGuml5tZopeaUrqJERSM7C7KOxj/HFQ6xCjAwajE\r
56         w7sz4nSAEGtiWXFl7iFGSQ4mJVHeVRxnAoT4kvJTKjMSizPii0pzUosPMUpwMCuJ8IptASrn\r
57         TUmsrEotyodJSXOwKInzXku56S8kkJ5YkpqdmlqQWgSTleHgUJLgfcUNNFSwKDU9tSItM6cE\r
58         Ic3EwQkynAdouBIPUA1vcUFibnFmOkT+FKOilDgvI0hCACSRUZoH1wtLFq8YxYFeEea1BKni\r
59         ASYauO5XQIOZgAbHXToOMrgkESEl1cB46V5PuJrhnuNzE7Oa5kqoCKiJnpFbcHCP4KHfgfc8\r
60         g9153y570fpbrEDAaNoN8yadYM1g7vnTHDuEtUJaY2yeLKmZxMqcJKXgPfdjvFqthkyRadMa\r
61         if76UgWL0/OXZ1RcsOvaeP1Z8+lgJqclmvvEj5bv597L/vbNZ2VXsWumJnxh+TrJykosxRmJ\r
62         hlrMRcWJACf2NPrxAgAA\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Sat, 15 Dec 2012 05:40:05 -0000\r
76 \r
77 On Thu, 13 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
78 > This makes notmuch-show-insert-bodypart add an overlay for any\r
79 > non-trivial part with a button header (currently the first text/plain\r
80 > part does not have a button). At this point the overlay is available\r
81 > to the button but there is no action using it yet.\r
82 >\r
83 > In addition the argument HIDE is passed down to\r
84 > notmuch-show-insert-part-overlays to request that the part be hidden\r
85 > by default but this is not acted on yet.\r
86 > ---\r
87 >  emacs/notmuch-show.el |   61 +++++++++++++++++++++++++++++++++++++------------\r
88 >  1 files changed, 46 insertions(+), 15 deletions(-)\r
89 >\r
90 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
91 > index 06f7ca5..3f2f277 100644\r
92 > --- a/emacs/notmuch-show.el\r
93 > +++ b/emacs/notmuch-show.el\r
94 > @@ -567,11 +567,10 @@ message at DEPTH in the current thread."\r
95 >      ;; but it's not clear that this is the wrong thing to do - which\r
96 >      ;; should be chosen if there are more than one that match?\r
97 >      (mapc (lambda (inner-part)\r
98 > -         (let ((inner-type (plist-get inner-part :content-type)))\r
99 > -           (if (or notmuch-show-all-multipart/alternative-parts\r
100 > -                   (string= chosen-type inner-type))\r
101 > -               (notmuch-show-insert-bodypart msg inner-part depth)\r
102 > -             (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
103 > +         (let* ((inner-type (plist-get inner-part :content-type))\r
104 > +               (hide (not (or notmuch-show-all-multipart/alternative-parts\r
105 > +                        (string= chosen-type inner-type)))))\r
106 > +           (notmuch-show-insert-bodypart msg inner-part depth hide)))\r
107 >         inner-parts)\r
108 >  \r
109 >      (when notmuch-show-indent-multipart\r
110 > @@ -839,17 +838,49 @@ message at DEPTH in the current thread."\r
111 >        (setq handlers (cdr handlers))))\r
112 >    t)\r
113 >  \r
114 > -(defun notmuch-show-insert-bodypart (msg part depth)\r
115 > -  "Insert the body part PART at depth DEPTH in the current thread."\r
116 > +(defun notmuch-show-insert-part-overlays (msg beg end hide)\r
117 \r
118 notmuch-show-create-part-overlays?  The other show-insert functions\r
119 actually insert text into the buffer.\r
120 \r
121 > +  "Add an overlay to the part between BEG and END"\r
122 > +  (let* ((button (button-at beg))\r
123 > +      (part-beg (and button (1+ (button-end button)))))\r
124 > +\r
125 > +    ;; If the part contains no text we do not make it toggleable.\r
126 > +    (when (and button (/= part-beg end))\r
127 > +      (let ((base-label (button-get button :base-label))\r
128 > +         (overlay (make-overlay part-beg end))\r
129 > +         (message-invis-spec (plist-get msg :message-invis-spec))\r
130 > +         (invis-spec (make-symbol "notmuch-part-region")))\r
131 > +\r
132 > +     (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
133 > +     (overlay-put overlay 'priority 10)\r
134 > +     (overlay-put overlay 'type "part")\r
135 \r
136 Since you're not actually using notmuch-wash, you don't need this 'type\r
137 property.\r
138 \r
139 > +     ;; Now we have to add invis-spec to every overlay this\r
140 > +     ;; overlay contains, otherwise these inner overlays will\r
141 > +     ;; override this one.\r
142 > +     (dolist (inner (overlays-in part-beg end))\r
143 > +       (when (and (>= (overlay-start inner) part-beg)\r
144 > +                        (<= (overlay-end inner) end))\r
145 > +               (overlay-put inner 'invisible\r
146 > +                            (cons invis-spec (overlay-get inner 'invisible)))))\r
147 > +\r
148 > +     (button-put button 'invisibility-spec invis-spec)\r
149 > +     (button-put button 'overlay overlay)))))\r
150 > +\r
151 > +(defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
152 > +  "Insert the body part PART at depth DEPTH in the current thread.\r
153 > +\r
154 > +If HIDE is non-nil then initially hide this part."\r
155 >    (let ((content-type (downcase (plist-get part :content-type)))\r
156 > -     (nth (plist-get part :id)))\r
157 > -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
158 > -  ;; Some of the body part handlers leave point somewhere up in the\r
159 > -  ;; part, so we make sure that we're down at the end.\r
160 > -  (goto-char (point-max))\r
161 > -  ;; Ensure that the part ends with a carriage return.\r
162 > -  (unless (bolp)\r
163 > -    (insert "\n")))\r
164 > +     (nth (plist-get part :id))\r
165 > +     (beg (point)))\r
166 > +\r
167 > +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\r
168 > +    ;; Some of the body part handlers leave point somewhere up in the\r
169 > +    ;; part, so we make sure that we're down at the end.\r
170 > +    (goto-char (point-max))\r
171 > +    ;; Ensure that the part ends with a carriage return.\r
172 > +    (unless (bolp)\r
173 > +      (insert "\n"))\r
174 > +    (notmuch-show-insert-part-overlays msg beg (point) hide)))\r
175 >  \r
176 >  (defun notmuch-show-insert-body (msg body depth)\r
177 >    "Insert the body BODY at depth DEPTH in the current thread."\r
178 > -- \r
179 > 1.7.9.1\r
180 >\r
181 > _______________________________________________\r
182 > notmuch mailing list\r
183 > notmuch@notmuchmail.org\r
184 > http://notmuchmail.org/mailman/listinfo/notmuch\r