From 7b7531106a6564eb6fe8564aa73bce97f2cb70e8 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Tue, 18 Dec 2012 19:27:59 +0000 Subject: [PATCH] [PATCH v5 3/4] emacs: show: add invisibility button action --- e4/bd12475daec33b40c12796e9ddd68d366d26a3 | 131 ++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 e4/bd12475daec33b40c12796e9ddd68d366d26a3 diff --git a/e4/bd12475daec33b40c12796e9ddd68d366d26a3 b/e4/bd12475daec33b40c12796e9ddd68d366d26a3 new file mode 100644 index 000000000..79234fcd5 --- /dev/null +++ b/e4/bd12475daec33b40c12796e9ddd68d366d26a3 @@ -0,0 +1,131 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BB6AC431FD4 + for ; Tue, 18 Dec 2012 11:28:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id slx5W8P4Pn3o for ; + Tue, 18 Dec 2012 11:28:21 -0800 (PST) +Received: from mail-we0-f179.google.com (mail-we0-f179.google.com + [74.125.82.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 01CC9431FC4 + for ; Tue, 18 Dec 2012 11:28:17 -0800 (PST) +Received: by mail-we0-f179.google.com with SMTP id r6so522141wey.10 + for ; Tue, 18 Dec 2012 11:28:16 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to + :references; bh=K9IB+DnX3shaOIDNyrgy5fzvQtHkwls4BNa9BnOt20U=; + b=yxWhsB3if2H2HSxlu151QKeSAmcDRtLcFl1xjAwUppCzWxeL42oO1MObXN3Y2GvRE4 + L+biNi269meJEhgz0hBdxJOwkUiAZtuyZFP+4q2q0t8fGO3QyVFnCWWJyB2hgYerPoGZ + kykJozq6YEYmqW3k+Xyqj9hwt+z3Ut7AFLswejj4NN3s/yR0jtZvURcBHqVTpqY0K0gK + PcoRRDMcg2fLF6i3V2KPPZZ12uPG46q0gJJ0kh99AjixFtGsqR2BrKZAJhT9+vHE9NO0 + Xzcul86y/CZ5AiFWegN7qtLERcxdQR9ZWkeX2tjgwF5oYTBsI6rS3SK76KXivr7Ts7bI + QoAw== +X-Received: by 10.180.75.208 with SMTP id e16mr7043582wiw.3.1355858896786; + Tue, 18 Dec 2012 11:28:16 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPS id dw4sm4131325wib.1.2012.12.18.11.28.15 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 18 Dec 2012 11:28:16 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v5 3/4] emacs: show: add invisibility button action +Date: Tue, 18 Dec 2012 19:27:59 +0000 +Message-Id: <1355858880-16329-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1355858880-16329-1-git-send-email-markwalters1009@gmail.com> +References: <1355858880-16329-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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, 18 Dec 2012 19:28:23 -0000 + +This adds a button action to show hidden parts. In this version "RET" +toggles the visibility of any part which puts content in the buffer +(as opposed to attachments such as application/pdf). + +The button is used to hide parts when appropriate (eg text/html in +multipart/alternative). +--- + emacs/notmuch-show.el | 31 +++++++++++++++++++++++++++++-- + 1 files changed, 29 insertions(+), 2 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index dc86b43..f9366d0 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -554,6 +554,25 @@ message at DEPTH in the current thread." + (let ((handle (mm-make-handle (current-buffer) (list content-type)))) + (mm-pipe-part handle)))) + ++;; This is taken from notmuch-wash: maybe it should be unified? ++(defun notmuch-show-toggle-part-invisibility (&optional button) ++ (interactive) ++ (let* ((button (or button (button-at (point)))) ++ (overlay (button-get button 'overlay))) ++ (when overlay ++ (let* ((show (overlay-get overlay 'invisible)) ++ (new-start (button-start button)) ++ (button-label (button-get button :base-label)) ++ (old-point (point)) ++ (inhibit-read-only t)) ++ (overlay-put overlay 'invisible (not show)) ++ (goto-char new-start) ++ (insert "[ " button-label (if show " ]" " (hidden) ]")) ++ (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)))))))) ++ + (defun notmuch-show-multipart/*-to-list (part) + (mapcar (lambda (inner-part) (plist-get inner-part :content-type)) + (plist-get part :content))) +@@ -847,7 +866,12 @@ message at DEPTH in the current thread." + ;; also need to check that the button is a genuine part button not + ;; a notmuch-wash button. + (when (and button (/= part-beg end) (button-get button :base-label)) +- (button-put button 'overlay (make-overlay part-beg end))))) ++ (button-put button 'overlay (make-overlay part-beg end)) ++ ;; We toggle the button for hidden parts as that gets the ++ ;; button label right. ++ (save-excursion ++ (when hide ++ (notmuch-show-toggle-part-invisibility button)))))) + + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + "Insert the body part PART at depth DEPTH in the current thread. +@@ -1953,7 +1977,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." + + (defun notmuch-show-part-button-default (&optional button) + (interactive) +- (notmuch-show-part-button-internal button notmuch-show-part-button-default-action)) ++ (let ((button (or button (button-at (point))))) ++ (if (button-get button 'overlay) ++ (notmuch-show-toggle-part-invisibility button) ++ (notmuch-show-part-button-internal button notmuch-show-part-button-default-action)))) + + (defun notmuch-show-part-button-save (&optional button) + (interactive) +-- +1.7.9.1 + -- 2.26.2