--- /dev/null
+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 arlo.cworth.org (Postfix) with ESMTP id A27E46DE1635\r
+ for <notmuch@notmuchmail.org>; Tue, 9 Feb 2016 12:29:43 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.074\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.074 tagged_above=-999 required=5\r
+ tests=[AWL=-0.007, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id wRffkv0fA2t6 for <notmuch@notmuchmail.org>;\r
+ Tue, 9 Feb 2016 12:29:41 -0800 (PST)\r
+Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com\r
+ [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 553A76DE01D3 for\r
+ <notmuch@notmuchmail.org>; Tue, 9 Feb 2016 12:29:41 -0800 (PST)\r
+Received: by mail-wm0-f67.google.com with SMTP id 128so34922wmz.3\r
+ for <notmuch@notmuchmail.org>; Tue, 09 Feb 2016 12:29:41 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=dme-org.20150623.gappssmtp.com; s=20150623;\r
+ h=to:subject:in-reply-to:references:from:date:message-id:mime-version\r
+ :content-type; bh=3RFOOIy3QrsqMHS7iuZc1ukgPhOVau/OSCYp/gsG0so=;\r
+ b=pLfxvIJe/3xQEQDGd8dijvDiMYmQhtuEXBCgiIdiE7vCXa7Pdz4N3Dgo4FNrWMLk+6\r
+ v+YpYOBF6zRM4lP/q4nUWLax5wsTbBSPIAz6vjOf1cmhDPKhthEQvSzuQ65VJMbl09tR\r
+ EW0cZsB7boxaUJZhTBovQsmLkZ02fm/D/H7sFb+vKGWkJKb0RB4qhXFLXs2moiYwIqUO\r
+ pW8yI8dhx5Loqww0hrjOUqncjI2CYo88YKzqF+xwUh0vE/dT/vhaxfrqGvLgHch6ihMl\r
+ F7HZlEV/s5rtM9GUip4dygvgOK3EcN/KetgfIYo7g6DkXuEJQzMRh821J1LsyYrLmwaX\r
+ M0vA==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:to:subject:in-reply-to:references:from:date\r
+ :message-id:mime-version:content-type;\r
+ bh=3RFOOIy3QrsqMHS7iuZc1ukgPhOVau/OSCYp/gsG0so=;\r
+ b=XQBvJq5Lvg4pqSwNbIHwYwACjMykfLQ8q5oIm2E7hlWm6Iq2M9xX+Dqw0hLo1JhdoR\r
+ EsN7lYLwWPqngXlI5fjwbHXp3CIt/KBo1DiBIHpYILzXyFBwB2AuyaMpYl7gOz1nFDhP\r
+ Wvl8Yop4mnJML4Z62woKK/K41CJa1EdPbq0KdQoBzOCu8lsSuTwmfVh9sbDTHiF0nk0i\r
+ ZlKThRFi36hT90oxo4eNHq32raMHY2kdjZSB8QicMtg7n6dY56L20yCwFKGVOFBjp44X\r
+ dJ7BnF0HpivqONjgKmOt1dVNzDKdCW2gEFdHOe08Lr4M1K8lgkXWH7FHHFmHA8471jXe\r
+ 4QeA==\r
+X-Gm-Message-State:\r
+ AG10YOSyIJegAXLHUKOlXrCGFtri+tC4LIxO+/tJ7QVccUaGiwuHLDJucmbi7uBVvFVM0g==\r
+X-Received: by 10.28.174.72 with SMTP id x69mr6812910wme.68.1455049779988;\r
+ Tue, 09 Feb 2016 12:29:39 -0800 (PST)\r
+Received: from disaster-area.hh.sledj.net\r
+ ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+ by smtp.gmail.com with ESMTPSA id e194sm233611wma.19.2016.02.09.12.29.38\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Tue, 09 Feb 2016 12:29:38 -0800 (PST)\r
+Received: from localhost (disaster-area.hh.sledj.net [local])\r
+ by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 801af144;\r
+ Tue, 9 Feb 2016 20:29:37 +0000 (UTC)\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 2/7] emacs/show: Accommodate the lack of part header\r
+ buttons\r
+In-Reply-To: <1446894276-7814-3-git-send-email-markwalters1009@gmail.com>\r
+References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com>\r
+ <1446894276-7814-3-git-send-email-markwalters1009@gmail.com>\r
+From: David Edmondson <dme@dme.org>\r
+Date: Tue, 09 Feb 2016 20:29:37 +0000\r
+Message-ID: <m2d1s54oge.fsf@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 09 Feb 2016 20:29:43 -0000\r
+\r
+On Sat, Nov 07 2015, Mark Walters wrote:\r
+> From: David Edmondson <dme@dme.org>\r
+>\r
+> Various pieces of code assumed (reasonably) that part header buttons\r
+> are present. Modify them to avoid problems if no part headers were\r
+> inserted.\r
+\r
+This looks fine.\r
+\r
+> ---\r
+> emacs/notmuch-show.el | 88 ++++++++++++++++++++++++++++-----------------------\r
+> 1 file changed, 48 insertions(+), 40 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 47a02e5..9fc79e0 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -509,36 +509,37 @@ (defun notmuch-show-insert-part-header (nth content-type declared-type &optional\r
+> \r
+> (defun notmuch-show-toggle-part-invisibility (&optional button)\r
+> (interactive)\r
+> - (let* ((button (or button (button-at (point))))\r
+> - (overlay (button-get button 'overlay))\r
+> - (lazy-part (button-get button :notmuch-lazy-part)))\r
+> - ;; We have a part to toggle if there is an overlay or if there is a lazy part.\r
+> - ;; If neither is present we cannot toggle the part so we just return nil.\r
+> - (when (or overlay lazy-part)\r
+> - (let* ((show (button-get button :notmuch-part-hidden))\r
+> - (new-start (button-start button))\r
+> - (button-label (button-get button :base-label))\r
+> - (old-point (point))\r
+> - (properties (text-properties-at (button-start button)))\r
+> - (inhibit-read-only t))\r
+> - ;; Toggle the button itself.\r
+> - (button-put button :notmuch-part-hidden (not show))\r
+> - (goto-char new-start)\r
+> - (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
+> - (set-text-properties new-start (point) properties)\r
+> - (let ((old-end (button-end button)))\r
+> - (move-overlay button new-start (point))\r
+> - (delete-region (point) old-end))\r
+> - (goto-char (min old-point (1- (button-end button))))\r
+> - ;; Return nil if there is a lazy-part, it is empty, and we are\r
+> - ;; trying to show it. In all other cases return t.\r
+> - (if lazy-part\r
+> - (when show\r
+> - (button-put button :notmuch-lazy-part nil)\r
+> - (notmuch-show-lazy-part lazy-part button))\r
+> - ;; else there must be an overlay.\r
+> - (overlay-put overlay 'invisible (not show))\r
+> - t)))))\r
+> + (let ((button (or button (button-at (point)))))\r
+> + (when button\r
+> + (let ((overlay (button-get button 'overlay))\r
+> + (lazy-part (button-get button :notmuch-lazy-part)))\r
+> + ;; We have a part to toggle if there is an overlay or if there is a lazy part.\r
+> + ;; If neither is present we cannot toggle the part so we just return nil.\r
+> + (when (or overlay lazy-part)\r
+> + (let* ((show (button-get button :notmuch-part-hidden))\r
+> + (new-start (button-start button))\r
+> + (button-label (button-get button :base-label))\r
+> + (old-point (point))\r
+> + (properties (text-properties-at (button-start button)))\r
+> + (inhibit-read-only t))\r
+> + ;; Toggle the button itself.\r
+> + (button-put button :notmuch-part-hidden (not show))\r
+> + (goto-char new-start)\r
+> + (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
+> + (set-text-properties new-start (point) properties)\r
+> + (let ((old-end (button-end button)))\r
+> + (move-overlay button new-start (point))\r
+> + (delete-region (point) old-end))\r
+> + (goto-char (min old-point (1- (button-end button))))\r
+> + ;; Return nil if there is a lazy-part, it is empty, and we are\r
+> + ;; trying to show it. In all other cases return t.\r
+> + (if lazy-part\r
+> + (when show\r
+> + (button-put button :notmuch-lazy-part nil)\r
+> + (notmuch-show-lazy-part lazy-part button))\r
+> + ;; else there must be an overlay.\r
+> + (overlay-put overlay 'invisible (not show))\r
+> + t)))))))\r
+> \r
+> ;; Part content ID handling\r
+> \r
+> @@ -647,14 +648,17 @@ (defun notmuch-show-insert-part-multipart/related (msg part content-type nth dep\r
+> t)\r
+> \r
+> (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button)\r
+> - (button-put button 'face 'notmuch-crypto-part-header)\r
+> - ;; add signature status button if sigstatus provided\r
+> + (when button\r
+> + (button-put button 'face 'notmuch-crypto-part-header))\r
+> + ;; Add signature status button if sigstatus provided.\r
+> (if (plist-member part :sigstatus)\r
+> (let* ((from (notmuch-show-get-header :From msg))\r
+> (sigstatus (car (plist-get part :sigstatus))))\r
+> (notmuch-crypto-insert-sigstatus-button sigstatus from))\r
+> - ;; if we're not adding sigstatus, tell the user how they can get it\r
+> - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
+> + ;; If we're not adding the signature status, tell the user how\r
+> + ;; they can get it.\r
+> + (when button\r
+> + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
+> \r
+> (let ((inner-parts (plist-get part :content))\r
+> (start (point)))\r
+> @@ -668,17 +672,20 @@ (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth dept\r
+> t)\r
+> \r
+> (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button)\r
+> - (button-put button 'face 'notmuch-crypto-part-header)\r
+> - ;; add encryption status button if encstatus specified\r
+> + (when button\r
+> + (button-put button 'face 'notmuch-crypto-part-header))\r
+> + ;; Add encryption status button if encryption status is specified.\r
+> (if (plist-member part :encstatus)\r
+> (let ((encstatus (car (plist-get part :encstatus))))\r
+> (notmuch-crypto-insert-encstatus-button encstatus)\r
+> - ;; add signature status button if sigstatus specified\r
+> + ;; Add signature status button if signature status is\r
+> + ;; specified.\r
+> (if (plist-member part :sigstatus)\r
+> (let* ((from (notmuch-show-get-header :From msg))\r
+> (sigstatus (car (plist-get part :sigstatus))))\r
+> (notmuch-crypto-insert-sigstatus-button sigstatus from))))\r
+> - ;; if we're not adding encstatus, tell the user how they can get it\r
+> + ;; If we're not adding the encryption status, tell the user how\r
+> + ;; they can get it.\r
+> (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
+> \r
+> (let ((inner-parts (plist-get part :content))\r
+> @@ -977,8 +984,9 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
+> \r
+> (if show-part\r
+> (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
+> - (button-put button :notmuch-lazy-part\r
+> - (list msg part mime-type nth depth button)))\r
+> + (when button\r
+> + (button-put button :notmuch-lazy-part\r
+> + (list msg part mime-type nth depth button))))\r
+> \r
+> ;; Some of the body part handlers leave point somewhere up in the\r
+> ;; part, so we make sure that we're down at the end.\r
+> -- \r
+> 2.1.4\r