[PATCH 3/3] emacs: show: add invisibility button action
authorMark Walters <markwalters1009@gmail.com>
Tue, 4 Dec 2012 23:27:42 +0000 (23:27 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:30 +0000 (09:51 -0800)
48/da098805455954b327f1c016155c6e5e72ee7c [new file with mode: 0644]

diff --git a/48/da098805455954b327f1c016155c6e5e72ee7c b/48/da098805455954b327f1c016155c6e5e72ee7c
new file mode 100644 (file)
index 0000000..434bb64
--- /dev/null
@@ -0,0 +1,143 @@
+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 6BFB7431FC0\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 15:28:02 -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 dVLHjmHKi7Id for <notmuch@notmuchmail.org>;\r
+       Tue,  4 Dec 2012 15:27:58 -0800 (PST)\r
+Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
+       [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id E646C431FC7\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 15:27:54 -0800 (PST)\r
+Received: by mail-wi0-f169.google.com with SMTP id hq12so1271837wib.2\r
+       for <notmuch@notmuchmail.org>; Tue, 04 Dec 2012 15:27:53 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=q/7FmSp30zN6J5A7ffR738RN63A+tQM477LMsf8RsDk=;\r
+       b=vdwtqL5ciuiMeqSUrqKtR4iuxsrMMtV275dHb0ZixYqxZIwt/zHenVIvEol6mHUrBl\r
+       S2BiaO3ZgVYyGVTtOOOpY/iJiAS0oqxSpzw2nIZbfhploxvDdTASXEACzKzsgM/NF/iW\r
+       Nozrfe/RXmgyzIiWX+PYK8J1fTfQoEXfmfgIbwcUJ1p/6M+0qyICkMcoeWT6ofmYIoeZ\r
+       8cQhgKieNLUTkqZuIA20qDFu6epjXJj2UeDGs0WES1RCMPsJotcZDc6H42n8auueLosI\r
+       ZWUH0EZ4BpXqA0FHzwXwAqlkEDUmh7MGchzRXIQ6VU7lvMLvnS1ubFIdVGLgt1MtoYBo\r
+       UE3Q==\r
+Received: by 10.180.109.166 with SMTP id ht6mr59119wib.7.1354663673756;\r
+       Tue, 04 Dec 2012 15:27:53 -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 cf6sm4005280wib.3.2012.12.04.15.27.52\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 04 Dec 2012 15:27:53 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] emacs: show: add invisibility button action\r
+Date: Tue,  4 Dec 2012 23:27:42 +0000\r
+Message-Id: <1354663662-20524-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354663662-20524-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354663662-20524-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, 04 Dec 2012 23:28:02 -0000\r
+\r
+This adds a button action to show hidden parts. In this version "t"\r
+toggles the visibility of a part. In addition "RET" on a non-shown\r
+part shows it.\r
+\r
+The button is used to hide parts when appropriate (eg text/html in\r
+multipart/alternative).\r
+---\r
+ emacs/notmuch-show.el |   36 +++++++++++++++++++++++++++++++++++-\r
+ 1 files changed, 35 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 3215ebc..a4daff8 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -478,6 +478,7 @@ message at DEPTH in the current thread."\r
+     (define-key map "v" 'notmuch-show-part-button-view)\r
+     (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
+     (define-key map "|" 'notmuch-show-part-button-pipe)\r
++    (define-key map "t" 'notmuch-show-toggle-invisible-part-action)\r
+     map)\r
+   "Submap for button commands")\r
+ (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+@@ -555,6 +556,31 @@ 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-invisible-part-action (&optional button no-redisplay)\r
++  (interactive)\r
++  (let* ((button (or button (button-at (point))))\r
++       (overlay (button-get button 'overlay))\r
++       (invis-spec (button-get button 'invisibility-spec))\r
++       (show (invisible-p invis-spec)))\r
++    (when overlay\r
++      (if show\r
++        (remove-from-invisibility-spec invis-spec)\r
++      (add-to-invisibility-spec invis-spec))\r
++      (let* ((new-start (button-start button))\r
++           (button-label (button-get button :base-label))\r
++           (old-point (point))\r
++           (inhibit-read-only t))\r
++      (goto-char new-start)\r
++      (insert "[ " button-label (if show " ]" " (not shown) ]"))\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
++      (unless no-redisplay\r
++      (force-window-update)\r
++      (redisplay t)))))\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
+@@ -867,6 +893,11 @@ message at DEPTH in the current thread."\r
\r
+       (button-put button 'invisibility-spec invis-spec)\r
+       (button-put button 'overlay overlay))\r
++\r
++      ;; We toggle the button for hidden parts as that gets the\r
++      ;; button label right.\r
++      (when not-shown\r
++      (notmuch-show-toggle-invisible-part-action button t))\r
+       (goto-char (point-max)))))\r
\r
+ (defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
+@@ -1996,7 +2027,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 (invisible-p (button-get button 'invisibility-spec))\r
++      (notmuch-show-toggle-invisible-part-action 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