[PATCH v5 3/4] emacs: show: add invisibility button action
authorMark Walters <markwalters1009@gmail.com>
Tue, 18 Dec 2012 19:27:59 +0000 (19:27 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:31 +0000 (09:52 -0800)
e4/bd12475daec33b40c12796e9ddd68d366d26a3 [new file with mode: 0644]

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