From 0a9fcd6718ce9247d78803e2245c7b611e84696b Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Tue, 9 Feb 2016 20:29:37 +0000 Subject: [PATCH] Re: [PATCH v4 2/7] emacs/show: Accommodate the lack of part header buttons --- c1/2e320857b9b3c43a93c5d06461691359271484 | 228 ++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 c1/2e320857b9b3c43a93c5d06461691359271484 diff --git a/c1/2e320857b9b3c43a93c5d06461691359271484 b/c1/2e320857b9b3c43a93c5d06461691359271484 new file mode 100644 index 000000000..0bfc958e3 --- /dev/null +++ b/c1/2e320857b9b3c43a93c5d06461691359271484 @@ -0,0 +1,228 @@ +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 A27E46DE1635 + for ; Tue, 9 Feb 2016 12:29:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.074 +X-Spam-Level: +X-Spam-Status: No, score=-0.074 tagged_above=-999 required=5 + tests=[AWL=-0.007, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=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 wRffkv0fA2t6 for ; + Tue, 9 Feb 2016 12:29:41 -0800 (PST) +Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com + [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 553A76DE01D3 for + ; Tue, 9 Feb 2016 12:29:41 -0800 (PST) +Received: by mail-wm0-f67.google.com with SMTP id 128so34922wmz.3 + for ; Tue, 09 Feb 2016 12:29:41 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=dme-org.20150623.gappssmtp.com; s=20150623; + h=to:subject:in-reply-to:references:from:date:message-id:mime-version + :content-type; bh=3RFOOIy3QrsqMHS7iuZc1ukgPhOVau/OSCYp/gsG0so=; + b=pLfxvIJe/3xQEQDGd8dijvDiMYmQhtuEXBCgiIdiE7vCXa7Pdz4N3Dgo4FNrWMLk+6 + v+YpYOBF6zRM4lP/q4nUWLax5wsTbBSPIAz6vjOf1cmhDPKhthEQvSzuQ65VJMbl09tR + EW0cZsB7boxaUJZhTBovQsmLkZ02fm/D/H7sFb+vKGWkJKb0RB4qhXFLXs2moiYwIqUO + pW8yI8dhx5Loqww0hrjOUqncjI2CYo88YKzqF+xwUh0vE/dT/vhaxfrqGvLgHch6ihMl + F7HZlEV/s5rtM9GUip4dygvgOK3EcN/KetgfIYo7g6DkXuEJQzMRh821J1LsyYrLmwaX + M0vA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:to:subject:in-reply-to:references:from:date + :message-id:mime-version:content-type; + bh=3RFOOIy3QrsqMHS7iuZc1ukgPhOVau/OSCYp/gsG0so=; + b=XQBvJq5Lvg4pqSwNbIHwYwACjMykfLQ8q5oIm2E7hlWm6Iq2M9xX+Dqw0hLo1JhdoR + EsN7lYLwWPqngXlI5fjwbHXp3CIt/KBo1DiBIHpYILzXyFBwB2AuyaMpYl7gOz1nFDhP + Wvl8Yop4mnJML4Z62woKK/K41CJa1EdPbq0KdQoBzOCu8lsSuTwmfVh9sbDTHiF0nk0i + ZlKThRFi36hT90oxo4eNHq32raMHY2kdjZSB8QicMtg7n6dY56L20yCwFKGVOFBjp44X + dJ7BnF0HpivqONjgKmOt1dVNzDKdCW2gEFdHOe08Lr4M1K8lgkXWH7FHHFmHA8471jXe + 4QeA== +X-Gm-Message-State: + AG10YOSyIJegAXLHUKOlXrCGFtri+tC4LIxO+/tJ7QVccUaGiwuHLDJucmbi7uBVvFVM0g== +X-Received: by 10.28.174.72 with SMTP id x69mr6812910wme.68.1455049779988; + Tue, 09 Feb 2016 12:29:39 -0800 (PST) +Received: from disaster-area.hh.sledj.net + ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) + by smtp.gmail.com with ESMTPSA id e194sm233611wma.19.2016.02.09.12.29.38 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 09 Feb 2016 12:29:38 -0800 (PST) +Received: from localhost (disaster-area.hh.sledj.net [local]) + by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 801af144; + Tue, 9 Feb 2016 20:29:37 +0000 (UTC) +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v4 2/7] emacs/show: Accommodate the lack of part header + buttons +In-Reply-To: <1446894276-7814-3-git-send-email-markwalters1009@gmail.com> +References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> + <1446894276-7814-3-git-send-email-markwalters1009@gmail.com> +From: David Edmondson +Date: Tue, 09 Feb 2016 20:29:37 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain +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: Tue, 09 Feb 2016 20:29:43 -0000 + +On Sat, Nov 07 2015, Mark Walters wrote: +> 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. + +This looks fine. + +> --- +> 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 47a02e5..9fc79e0 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -509,36 +509,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 +> +> @@ -647,14 +648,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))) +> @@ -668,17 +672,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)) +> @@ -977,8 +984,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