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