From b360ac8bf3cf85daa23e9bb79a0eae531a07dd22 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 20 Feb 2016 18:24:37 +0000 Subject: [PATCH] [PATCH v6 3/6] emacs/show: Accommodate the lack of part header buttons --- 76/39e097751e69139e3aa5a3985f1cb2346d381c | 218 ++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 76/39e097751e69139e3aa5a3985f1cb2346d381c diff --git a/76/39e097751e69139e3aa5a3985f1cb2346d381c b/76/39e097751e69139e3aa5a3985f1cb2346d381c new file mode 100644 index 000000000..1b4fe9727 --- /dev/null +++ b/76/39e097751e69139e3aa5a3985f1cb2346d381c @@ -0,0 +1,218 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id DE2A96DE17CB + for ; Sat, 20 Feb 2016 10:25:08 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.282 +X-Spam-Level: +X-Spam-Status: No, score=-0.282 tagged_above=-999 required=5 tests=[AWL=0.288, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id afEWqku6i42i for ; + Sat, 20 Feb 2016 10:25:07 -0800 (PST) +Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com + [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 2D8156DE1532 for + ; Sat, 20 Feb 2016 10:24:53 -0800 (PST) +Received: by mail-wm0-f45.google.com with SMTP id c200so118212991wme.0 + for ; Sat, 20 Feb 2016 10:24:53 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=1XiGUeP5ed4vYQrWYrW4kl1g0+Z4jIegeDWg0A2wmek=; + b=pDcNFqhzxDtMtb91KA/Ya3jBgR2g0y2cvRVXJZ9Sb6AdGRJW1N44hOZymcc3atTV8X + oji7W3QtcuNt2KCwqAJwlozUMl+P+pp6tvYJz9qu2bwdyrwCzO5x+N/9CtIU1lPLhSOu + tHHpwXd9tlTUO3yhhjFN0Gob6XTF9xZg7Zn7OqSRHzpC3MGip3DuErixF3a5XUA4+Ucg + adkj3dlNsgQe0SfShoUqnescHXZEbC2Z3kDFV445elgFfG0YrZ3gWqCfhpf9g0lgOcqu + ldg+kaqBCqzk5fMtbDBZr3wpeWTlf/2pIbMqdcs+Eh4FaYYIBIBg7V4jwGPVegb5Zf7F + fJ0A== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=1XiGUeP5ed4vYQrWYrW4kl1g0+Z4jIegeDWg0A2wmek=; + b=QQMY9Qps2IQOeELhI/71oHR7Gv7wHPx6fHADsI4lSxokiPTTr4bXbiaHpfCoQKQQ+b + qFABTEAQFb2a9VYnIpwGunrMznlDjNY0CK+SEqQKerrAC3DDrPUlVf40w2WnhuihOo7L + I3YZR2fqJpteY6V+Qk49gK2cpgG995Zmj9mnoQS2Hx46aeV/kZVNzP/FegVSUGme0na0 + vhzJSMuCPPGYO3pbXNPdRrrOD4jQEnD5HTeFluXKJ9G46SHwDAwXlxuXZQYpdQ8qqcIx + /A9nInDxhtfN78kQSstXZQ1JyWEnoEkv7VykT1kn8fk39enpiybMvMZcF+f7go5AayFG + qa3Q== +X-Gm-Message-State: + AG10YOTqL8XAKuux3TJsVsHAPbRMlkndGWB3y9wv9kF+KmNOZ0Gj+KQQ+2B1mwcOfOZAfA== +X-Received: by 10.194.88.195 with SMTP id bi3mr18926811wjb.34.1455992691963; + Sat, 20 Feb 2016 10:24:51 -0800 (PST) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id gg7sm16686629wjd.10.2016.02.20.10.24.51 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 20 Feb 2016 10:24:51 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v6 3/6] emacs/show: Accommodate the lack of part header + buttons +Date: Sat, 20 Feb 2016 18:24:37 +0000 +Message-Id: <1455992680-24978-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com> +References: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 20 Feb 2016 18:25:09 -0000 + +From: David Edmondson + +Various pieces of code assumed (reasonably) that part header buttons +are present. Modify them to avoid problems if no part headers were +inserted. +--- + emacs/notmuch-show.el | 88 ++++++++++++++++++++++++++++----------------------- + 1 file changed, 48 insertions(+), 40 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index ddb9c65..8222f0d 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -501,36 +501,37 @@ (defun notmuch-show-insert-part-header (nth content-type declared-type &optional + + (defun notmuch-show-toggle-part-invisibility (&optional button) + (interactive) +- (let* ((button (or button (button-at (point)))) +- (overlay (button-get button 'overlay)) +- (lazy-part (button-get button :notmuch-lazy-part))) +- ;; We have a part to toggle if there is an overlay or if there is a lazy part. +- ;; If neither is present we cannot toggle the part so we just return nil. +- (when (or overlay lazy-part) +- (let* ((show (button-get button :notmuch-part-hidden)) +- (new-start (button-start button)) +- (button-label (button-get button :base-label)) +- (old-point (point)) +- (properties (text-properties-at (button-start button))) +- (inhibit-read-only t)) +- ;; Toggle the button itself. +- (button-put button :notmuch-part-hidden (not show)) +- (goto-char new-start) +- (insert "[ " button-label (if show " ]" " (hidden) ]")) +- (set-text-properties new-start (point) properties) +- (let ((old-end (button-end button))) +- (move-overlay button new-start (point)) +- (delete-region (point) old-end)) +- (goto-char (min old-point (1- (button-end button)))) +- ;; Return nil if there is a lazy-part, it is empty, and we are +- ;; trying to show it. In all other cases return t. +- (if lazy-part +- (when show +- (button-put button :notmuch-lazy-part nil) +- (notmuch-show-lazy-part lazy-part button)) +- ;; else there must be an overlay. +- (overlay-put overlay 'invisible (not show)) +- t))))) ++ (let ((button (or button (button-at (point))))) ++ (when button ++ (let ((overlay (button-get button 'overlay)) ++ (lazy-part (button-get button :notmuch-lazy-part))) ++ ;; We have a part to toggle if there is an overlay or if there is a lazy part. ++ ;; If neither is present we cannot toggle the part so we just return nil. ++ (when (or overlay lazy-part) ++ (let* ((show (button-get button :notmuch-part-hidden)) ++ (new-start (button-start button)) ++ (button-label (button-get button :base-label)) ++ (old-point (point)) ++ (properties (text-properties-at (button-start button))) ++ (inhibit-read-only t)) ++ ;; Toggle the button itself. ++ (button-put button :notmuch-part-hidden (not show)) ++ (goto-char new-start) ++ (insert "[ " button-label (if show " ]" " (hidden) ]")) ++ (set-text-properties new-start (point) properties) ++ (let ((old-end (button-end button))) ++ (move-overlay button new-start (point)) ++ (delete-region (point) old-end)) ++ (goto-char (min old-point (1- (button-end button)))) ++ ;; Return nil if there is a lazy-part, it is empty, and we are ++ ;; trying to show it. In all other cases return t. ++ (if lazy-part ++ (when show ++ (button-put button :notmuch-lazy-part nil) ++ (notmuch-show-lazy-part lazy-part button)) ++ ;; else there must be an overlay. ++ (overlay-put overlay 'invisible (not show)) ++ t))))))) + + ;; Part content ID handling + +@@ -639,14 +640,17 @@ (defun notmuch-show-insert-part-multipart/related (msg part content-type nth dep + t) + + (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button) +- (button-put button 'face 'notmuch-crypto-part-header) +- ;; add signature status button if sigstatus provided ++ (when button ++ (button-put button 'face 'notmuch-crypto-part-header)) ++ ;; Add signature status button if sigstatus provided. + (if (plist-member part :sigstatus) + (let* ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-crypto-insert-sigstatus-button sigstatus from)) +- ;; if we're not adding sigstatus, tell the user how they can get it +- (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")) ++ ;; If we're not adding the signature status, tell the user how ++ ;; they can get it. ++ (when button ++ (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))) + + (let ((inner-parts (plist-get part :content)) + (start (point))) +@@ -660,17 +664,20 @@ (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth dept + t) + + (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button) +- (button-put button 'face 'notmuch-crypto-part-header) +- ;; add encryption status button if encstatus specified ++ (when button ++ (button-put button 'face 'notmuch-crypto-part-header)) ++ ;; Add encryption status button if encryption status is specified. + (if (plist-member part :encstatus) + (let ((encstatus (car (plist-get part :encstatus)))) + (notmuch-crypto-insert-encstatus-button encstatus) +- ;; add signature status button if sigstatus specified ++ ;; Add signature status button if signature status is ++ ;; specified. + (if (plist-member part :sigstatus) + (let* ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-crypto-insert-sigstatus-button sigstatus from)))) +- ;; if we're not adding encstatus, tell the user how they can get it ++ ;; If we're not adding the encryption status, tell the user how ++ ;; they can get it. + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")) + + (let ((inner-parts (plist-get part :content)) +@@ -980,8 +987,9 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + + (if show-part + (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) +- (button-put button :notmuch-lazy-part +- (list msg part mime-type nth depth button))) ++ (when button ++ (button-put button :notmuch-lazy-part ++ (list msg part mime-type nth depth button)))) + + ;; Some of the body part handlers leave point somewhere up in the + ;; part, so we make sure that we're down at the end. +-- +2.1.4 + -- 2.26.2