Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / f8 / c60a6f01809cf03b4436c9ee7409c854304d1d
1 Return-Path: <markwalters1009@gmail.com>\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 F0AC8431FC2\r
6         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:53 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id msAg503a5g-x for <notmuch@notmuchmail.org>;\r
18         Sat, 15 Dec 2012 00:15:51 -0800 (PST)\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
20         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id B5958429E3A\r
23         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:47 -0800 (PST)\r
24 Received: by mail-wi0-f181.google.com with SMTP id hm9so961770wib.2\r
25         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:46 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=zI3e/xD7ruqFjuVI8QrWB/clc/lMkFSkIixLgluXGdU=;\r
29         b=IN8sxuU6GHUl4jZbE2w0vbWlyfoukSPNfhDhR24jpPFkpOmBFGWsJ2Fe2OhjNr5smC\r
30         qyJCXNkcJt14ILt7zt02VX/Xsgx/OC2O2uHRJHSr1srQRMuoY7dowPfFVEDg4sYd1VUU\r
31         giwhyP54acX+FZvSRR7u957iabvewkpbgZng3OAuwK51PKpGbP6sNc4kPUpJekpZGp4H\r
32         XBton5BrkdGqHO2BeHS/joPEA1g8nYl9vKBzz481qpD7ABfOGBIhHTVm0qyGBCjTGEAr\r
33         ln0U1kHXMOFcJRkAtVbk4DzRoEfVnC/gBvCtoQXhPer+jMgyxG7pal1pd+42AGrmUPaq\r
34         5OAA==\r
35 Received: by 10.180.88.70 with SMTP id be6mr6462313wib.14.1355559346523;\r
36         Sat, 15 Dec 2012 00:15:46 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id h19sm958302wiv.7.2012.12.15.00.15.45\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 15 Dec 2012 00:15:45 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v3 2/5] emacs: show: add overlays for each part\r
44 Date: Sat, 15 Dec 2012 08:15:34 +0000\r
45 Message-Id: <1355559338-14313-3-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1355559338-14313-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1355559338-14313-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 15 Dec 2012 08:15:54 -0000\r
62 \r
63 This makes notmuch-show-insert-bodypart add an overlay for any\r
64 non-trivial part with a button header (currently the first text/plain\r
65 part does not have a button). At this point the overlay is available\r
66 to the button but there is no action using it yet.\r
67 \r
68 In addition the argument HIDE is passed down to\r
69 notmuch-show-insert-part-overlays to request that the part be hidden\r
70 by default but this is not acted on yet.\r
71 ---\r
72  emacs/notmuch-show.el |   60 ++++++++++++++++++++++++++++++++++++------------\r
73  1 files changed, 45 insertions(+), 15 deletions(-)\r
74 \r
75 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
76 index 06f7ca5..b65c339 100644\r
77 --- a/emacs/notmuch-show.el\r
78 +++ b/emacs/notmuch-show.el\r
79 @@ -567,11 +567,10 @@ message at DEPTH in the current thread."\r
80      ;; but it's not clear that this is the wrong thing to do - which\r
81      ;; should be chosen if there are more than one that match?\r
82      (mapc (lambda (inner-part)\r
83 -           (let ((inner-type (plist-get inner-part :content-type)))\r
84 -             (if (or notmuch-show-all-multipart/alternative-parts\r
85 -                     (string= chosen-type inner-type))\r
86 -                 (notmuch-show-insert-bodypart msg inner-part depth)\r
87 -               (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
88 +           (let* ((inner-type (plist-get inner-part :content-type))\r
89 +                 (hide (not (or notmuch-show-all-multipart/alternative-parts\r
90 +                          (string= chosen-type inner-type)))))\r
91 +             (notmuch-show-insert-bodypart msg inner-part depth hide)))\r
92           inner-parts)\r
93  \r
94      (when notmuch-show-indent-multipart\r
95 @@ -839,17 +838,48 @@ message at DEPTH in the current thread."\r
96        (setq handlers (cdr handlers))))\r
97    t)\r
98  \r
99 -(defun notmuch-show-insert-bodypart (msg part depth)\r
100 -  "Insert the body part PART at depth DEPTH in the current thread."\r
101 +(defun notmuch-show-create-part-overlays (msg beg end hide)\r
102 +  "Add an overlay to the part between BEG and END"\r
103 +  (let* ((button (button-at beg))\r
104 +        (part-beg (and button (1+ (button-end button)))))\r
105 +\r
106 +    ;; If the part contains no text we do not make it toggleable.\r
107 +    (when (and button (/= part-beg end))\r
108 +      (let ((base-label (button-get button :base-label))\r
109 +           (overlay (make-overlay part-beg end))\r
110 +           (message-invis-spec (plist-get msg :message-invis-spec))\r
111 +           (invis-spec (make-symbol "notmuch-part-region")))\r
112 +\r
113 +       (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
114 +       (overlay-put overlay 'priority 10)\r
115 +       ;; Now we have to add invis-spec to every overlay this\r
116 +       ;; overlay contains, otherwise these inner overlays will\r
117 +       ;; override this one.\r
118 +       (dolist (inner (overlays-in part-beg end))\r
119 +         (when (and (>= (overlay-start inner) part-beg)\r
120 +                          (<= (overlay-end inner) end))\r
121 +                 (overlay-put inner 'invisible\r
122 +                              (cons invis-spec (overlay-get inner 'invisible)))))\r
123 +\r
124 +       (button-put button 'invisibility-spec invis-spec)\r
125 +       (button-put button 'overlay overlay)))))\r
126 +\r
127 +(defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
128 +  "Insert the body part PART at depth DEPTH in the current thread.\r
129 +\r
130 +If HIDE is non-nil then initially hide this part."\r
131    (let ((content-type (downcase (plist-get part :content-type)))\r
132 -       (nth (plist-get part :id)))\r
133 -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
134 -  ;; Some of the body part handlers leave point somewhere up in the\r
135 -  ;; part, so we make sure that we're down at the end.\r
136 -  (goto-char (point-max))\r
137 -  ;; Ensure that the part ends with a carriage return.\r
138 -  (unless (bolp)\r
139 -    (insert "\n")))\r
140 +       (nth (plist-get part :id))\r
141 +       (beg (point)))\r
142 +\r
143 +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\r
144 +    ;; Some of the body part handlers leave point somewhere up in the\r
145 +    ;; part, so we make sure that we're down at the end.\r
146 +    (goto-char (point-max))\r
147 +    ;; Ensure that the part ends with a carriage return.\r
148 +    (unless (bolp)\r
149 +      (insert "\n"))\r
150 +    (notmuch-show-create-part-overlays msg beg (point) hide)))\r
151  \r
152  (defun notmuch-show-insert-body (msg body depth)\r
153    "Insert the body BODY at depth DEPTH in the current thread."\r
154 -- \r
155 1.7.9.1\r
156 \r