Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 76 / 39e097751e69139e3aa5a3985f1cb2346d381c
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 arlo.cworth.org (Postfix) with ESMTP id DE2A96DE17CB\r
6  for <notmuch@notmuchmail.org>; Sat, 20 Feb 2016 10:25:08 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.282\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.282 tagged_above=-999 required=5 tests=[AWL=0.288,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id afEWqku6i42i for <notmuch@notmuchmail.org>;\r
19  Sat, 20 Feb 2016 10:25:07 -0800 (PST)\r
20 Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com\r
21  [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 2D8156DE1532 for\r
22  <notmuch@notmuchmail.org>; Sat, 20 Feb 2016 10:24:53 -0800 (PST)\r
23 Received: by mail-wm0-f45.google.com with SMTP id c200so118212991wme.0\r
24  for <notmuch@notmuchmail.org>; Sat, 20 Feb 2016 10:24:53 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=1XiGUeP5ed4vYQrWYrW4kl1g0+Z4jIegeDWg0A2wmek=;\r
28  b=pDcNFqhzxDtMtb91KA/Ya3jBgR2g0y2cvRVXJZ9Sb6AdGRJW1N44hOZymcc3atTV8X\r
29  oji7W3QtcuNt2KCwqAJwlozUMl+P+pp6tvYJz9qu2bwdyrwCzO5x+N/9CtIU1lPLhSOu\r
30  tHHpwXd9tlTUO3yhhjFN0Gob6XTF9xZg7Zn7OqSRHzpC3MGip3DuErixF3a5XUA4+Ucg\r
31  adkj3dlNsgQe0SfShoUqnescHXZEbC2Z3kDFV445elgFfG0YrZ3gWqCfhpf9g0lgOcqu\r
32  ldg+kaqBCqzk5fMtbDBZr3wpeWTlf/2pIbMqdcs+Eh4FaYYIBIBg7V4jwGPVegb5Zf7F\r
33  fJ0A==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=1XiGUeP5ed4vYQrWYrW4kl1g0+Z4jIegeDWg0A2wmek=;\r
39  b=QQMY9Qps2IQOeELhI/71oHR7Gv7wHPx6fHADsI4lSxokiPTTr4bXbiaHpfCoQKQQ+b\r
40  qFABTEAQFb2a9VYnIpwGunrMznlDjNY0CK+SEqQKerrAC3DDrPUlVf40w2WnhuihOo7L\r
41  I3YZR2fqJpteY6V+Qk49gK2cpgG995Zmj9mnoQS2Hx46aeV/kZVNzP/FegVSUGme0na0\r
42  vhzJSMuCPPGYO3pbXNPdRrrOD4jQEnD5HTeFluXKJ9G46SHwDAwXlxuXZQYpdQ8qqcIx\r
43  /A9nInDxhtfN78kQSstXZQ1JyWEnoEkv7VykT1kn8fk39enpiybMvMZcF+f7go5AayFG\r
44  qa3Q==\r
45 X-Gm-Message-State:\r
46  AG10YOTqL8XAKuux3TJsVsHAPbRMlkndGWB3y9wv9kF+KmNOZ0Gj+KQQ+2B1mwcOfOZAfA==\r
47 X-Received: by 10.194.88.195 with SMTP id bi3mr18926811wjb.34.1455992691963;\r
48  Sat, 20 Feb 2016 10:24:51 -0800 (PST)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id gg7sm16686629wjd.10.2016.02.20.10.24.51\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Sat, 20 Feb 2016 10:24:51 -0800 (PST)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH v6 3/6] emacs/show: Accommodate the lack of part header\r
56  buttons\r
57 Date: Sat, 20 Feb 2016 18:24:37 +0000\r
58 Message-Id: <1455992680-24978-4-git-send-email-markwalters1009@gmail.com>\r
59 X-Mailer: git-send-email 2.1.4\r
60 In-Reply-To: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com>\r
61 References: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.20\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Sat, 20 Feb 2016 18:25:09 -0000\r
75 \r
76 From: David Edmondson <dme@dme.org>\r
77 \r
78 Various pieces of code assumed (reasonably) that part header buttons\r
79 are present. Modify them to avoid problems if no part headers were\r
80 inserted.\r
81 ---\r
82  emacs/notmuch-show.el | 88 ++++++++++++++++++++++++++++-----------------------\r
83  1 file changed, 48 insertions(+), 40 deletions(-)\r
84 \r
85 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
86 index ddb9c65..8222f0d 100644\r
87 --- a/emacs/notmuch-show.el\r
88 +++ b/emacs/notmuch-show.el\r
89 @@ -501,36 +501,37 @@ (defun notmuch-show-insert-part-header (nth content-type declared-type &optional\r
90  \r
91  (defun notmuch-show-toggle-part-invisibility (&optional button)\r
92    (interactive)\r
93 -  (let* ((button (or button (button-at (point))))\r
94 -        (overlay (button-get button 'overlay))\r
95 -        (lazy-part (button-get button :notmuch-lazy-part)))\r
96 -    ;; We have a part to toggle if there is an overlay or if there is a lazy part.\r
97 -    ;; If neither is present we cannot toggle the part so we just return nil.\r
98 -    (when (or overlay lazy-part)\r
99 -      (let* ((show (button-get button :notmuch-part-hidden))\r
100 -            (new-start (button-start button))\r
101 -            (button-label (button-get button :base-label))\r
102 -            (old-point (point))\r
103 -            (properties (text-properties-at (button-start button)))\r
104 -            (inhibit-read-only t))\r
105 -       ;; Toggle the button itself.\r
106 -       (button-put button :notmuch-part-hidden (not show))\r
107 -       (goto-char new-start)\r
108 -       (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
109 -       (set-text-properties new-start (point) properties)\r
110 -       (let ((old-end (button-end button)))\r
111 -         (move-overlay button new-start (point))\r
112 -         (delete-region (point) old-end))\r
113 -       (goto-char (min old-point (1- (button-end button))))\r
114 -       ;; Return nil if there is a lazy-part, it is empty, and we are\r
115 -       ;; trying to show it.  In all other cases return t.\r
116 -       (if lazy-part\r
117 -           (when show\r
118 -             (button-put button :notmuch-lazy-part nil)\r
119 -             (notmuch-show-lazy-part lazy-part button))\r
120 -         ;; else there must be an overlay.\r
121 -         (overlay-put overlay 'invisible (not show))\r
122 -         t)))))\r
123 +  (let ((button (or button (button-at (point)))))\r
124 +    (when button\r
125 +      (let ((overlay (button-get button 'overlay))\r
126 +           (lazy-part (button-get button :notmuch-lazy-part)))\r
127 +       ;; We have a part to toggle if there is an overlay or if there is a lazy part.\r
128 +       ;; If neither is present we cannot toggle the part so we just return nil.\r
129 +       (when (or overlay lazy-part)\r
130 +         (let* ((show (button-get button :notmuch-part-hidden))\r
131 +                (new-start (button-start button))\r
132 +                (button-label (button-get button :base-label))\r
133 +                (old-point (point))\r
134 +                (properties (text-properties-at (button-start button)))\r
135 +                (inhibit-read-only t))\r
136 +           ;; Toggle the button itself.\r
137 +           (button-put button :notmuch-part-hidden (not show))\r
138 +           (goto-char new-start)\r
139 +           (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
140 +           (set-text-properties new-start (point) properties)\r
141 +           (let ((old-end (button-end button)))\r
142 +             (move-overlay button new-start (point))\r
143 +             (delete-region (point) old-end))\r
144 +           (goto-char (min old-point (1- (button-end button))))\r
145 +           ;; Return nil if there is a lazy-part, it is empty, and we are\r
146 +           ;; trying to show it.  In all other cases return t.\r
147 +           (if lazy-part\r
148 +               (when show\r
149 +                 (button-put button :notmuch-lazy-part nil)\r
150 +                 (notmuch-show-lazy-part lazy-part button))\r
151 +             ;; else there must be an overlay.\r
152 +             (overlay-put overlay 'invisible (not show))\r
153 +             t)))))))\r
154  \r
155  ;; Part content ID handling\r
156  \r
157 @@ -639,14 +640,17 @@ (defun notmuch-show-insert-part-multipart/related (msg part content-type nth dep\r
158    t)\r
159  \r
160  (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button)\r
161 -  (button-put button 'face 'notmuch-crypto-part-header)\r
162 -  ;; add signature status button if sigstatus provided\r
163 +  (when button\r
164 +    (button-put button 'face 'notmuch-crypto-part-header))\r
165 +  ;; Add signature status button if sigstatus provided.\r
166    (if (plist-member part :sigstatus)\r
167        (let* ((from (notmuch-show-get-header :From msg))\r
168              (sigstatus (car (plist-get part :sigstatus))))\r
169         (notmuch-crypto-insert-sigstatus-button sigstatus from))\r
170 -    ;; if we're not adding sigstatus, tell the user how they can get it\r
171 -    (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
172 +    ;; If we're not adding the signature status, tell the user how\r
173 +    ;; they can get it.\r
174 +    (when button\r
175 +      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
176  \r
177    (let ((inner-parts (plist-get part :content))\r
178         (start (point)))\r
179 @@ -660,17 +664,20 @@ (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth dept\r
180    t)\r
181  \r
182  (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button)\r
183 -  (button-put button 'face 'notmuch-crypto-part-header)\r
184 -  ;; add encryption status button if encstatus specified\r
185 +  (when button\r
186 +    (button-put button 'face 'notmuch-crypto-part-header))\r
187 +  ;; Add encryption status button if encryption status is specified.\r
188    (if (plist-member part :encstatus)\r
189        (let ((encstatus (car (plist-get part :encstatus))))\r
190         (notmuch-crypto-insert-encstatus-button encstatus)\r
191 -       ;; add signature status button if sigstatus specified\r
192 +       ;; Add signature status button if signature status is\r
193 +       ;; specified.\r
194         (if (plist-member part :sigstatus)\r
195             (let* ((from (notmuch-show-get-header :From msg))\r
196                    (sigstatus (car (plist-get part :sigstatus))))\r
197               (notmuch-crypto-insert-sigstatus-button sigstatus from))))\r
198 -    ;; if we're not adding encstatus, tell the user how they can get it\r
199 +    ;; If we're not adding the encryption status, tell the user how\r
200 +    ;; they can get it.\r
201      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
202  \r
203    (let ((inner-parts (plist-get part :content))\r
204 @@ -980,8 +987,9 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
205  \r
206      (if show-part\r
207          (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
208 -      (button-put button :notmuch-lazy-part\r
209 -                  (list msg part mime-type nth depth button)))\r
210 +      (when button\r
211 +       (button-put button :notmuch-lazy-part\r
212 +                   (list msg part mime-type nth depth button))))\r
213  \r
214      ;; Some of the body part handlers leave point somewhere up in the\r
215      ;; part, so we make sure that we're down at the end.\r
216 -- \r
217 2.1.4\r
218 \r