--- /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 olra.theworths.org (Postfix) with ESMTP id B1885431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id VrG3s8aRV+5u for <notmuch@notmuchmail.org>;\r
+ Mon, 12 May 2014 05:29:38 -0700 (PDT)\r
+Received: from mail-we0-f169.google.com (mail-we0-f169.google.com\r
+ [74.125.82.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id DF9BC431FC9\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:33 -0700 (PDT)\r
+Received: by mail-we0-f169.google.com with SMTP id u56so6864113wes.28\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:32 -0700 (PDT)\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:from:to:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=WPZlGZYbpH1b/MkEKfmRPD6mQPqcX7o640i99rZjADA=;\r
+ b=OVJkKTbeiNAl+dvDCZek0M1Yl+DkdBMRHciU4XODUBhoxlduLfcexrGR5t2yNtDvbs\r
+ u2XfUEeMCVvU8u3NcGAZ5o1YiLQ4Jzo95fItcpWdTAJ1/hbhNMj/Vscflk1o1LWc/F9r\r
+ QHPAUAbLKtHWHnVQYFlutcGN8d3ytl7HTQ3Ixyt4D/6vHVeYFf1sTcrePbYZ3nTyV7Gm\r
+ s4jdtQs/aNLoAX8FJRS8EMcIf3tfbJASeIu1kP2LinrHlH15zcgGoCGfkjp0/iDwthtM\r
+ wWiNNKjx5ADpq0IvUubWbPAwFYbDDso5bKMO7na7PuUWdUQfOjH36V//nFKTPbS4QIBJ\r
+ xvzg==\r
+X-Gm-Message-State:\r
+ ALoCoQll/F3i7PX6qQYqv1tyZxjLOZdr7ZdxMS1DeHub0/m35AfGxzEeUoLUTG2YJlg2HQxBu1eJ\r
+X-Received: by 10.180.78.225 with SMTP id e1mr15384000wix.17.1399897772761;\r
+ Mon, 12 May 2014 05:29:32 -0700 (PDT)\r
+Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net.\r
+ [81.149.164.25]) by mx.google.com with ESMTPSA id\r
+ pj5sm15865576wic.20.2014.05.12.05.29.30 for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 12 May 2014 05:29:30 -0700 (PDT)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 3C1EB10B326; Mon, 12 May 2014 13:29:29 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 3/9] emacs/show: Accommodate the lack of part header\r
+ buttons\r
+Date: Mon, 12 May 2014 13:29:23 +0100\r
+Message-Id: <1399897769-26809-4-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.0.0.rc0\r
+In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org>\r
+References: <87sixdujkv.fsf@qmul.ac.uk>\r
+ <1399897769-26809-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 12 May 2014 12:29:44 -0000\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
+ 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 f78a0ab..e511655 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -494,36 +494,37 @@ message at DEPTH in the current thread."\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
+ ;; MIME part renderers\r
+ \r
+@@ -632,14 +633,17 @@ message at DEPTH in the current thread."\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
+@@ -653,17 +657,20 @@ message at DEPTH in the current thread."\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
+@@ -930,8 +937,9 @@ useful for quoting in replies)."\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.0.0.rc0\r
+\r