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 21E23429E3A for ; Sat, 15 Dec 2012 00:15:54 -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 8yM9gpdloElk for ; Sat, 15 Dec 2012 00:15:52 -0800 (PST) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 327F9429E4A for ; Sat, 15 Dec 2012 00:15:50 -0800 (PST) Received: by mail-wg0-f41.google.com with SMTP id ds1so801517wgb.2 for ; Sat, 15 Dec 2012 00:15:49 -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=wcKKcv6nYPXtSESbGspela0cMSy37tkWY6KK9LLvN2o=; b=Nom3zNvqvoliQQQhOFXou82YKvJOGZ4crlvAekuhNmlyP1xxjad0of2ZuQBkSN3qCD yRGHnlZ/zrLzUqsHdo3tMQLVs3nk2AfUbo/ZQnCB3gDpkEGZ0dM6e/wFlVJPQfOGrn/C hSJd6ymXNU20+6ASGoMuLQCuH/EIGrcd39k5wTbtgo1IYLa0R46+fFJxEB0I8dJEgdkz Yxvpo8YKyUHqakULiI4ol7zw/kNivJSyaEcjgy4YFzdibAmnrIFieA4UyUk9+nF/DLkk zmeYKd5zJZB03QcPiwQI8nUMLVgydukPkb/vwDU1NF+oq6hj/LUl18C0VJtOT/K31EG9 /daQ== Received: by 10.194.110.231 with SMTP id id7mr7572375wjb.6.1355559349044; Sat, 15 Dec 2012 00:15:49 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id eo10sm1136734wib.9.2012.12.15.00.15.47 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 15 Dec 2012 00:15:48 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v3 3/5] emacs: show: add invisibility button action Date: Sat, 15 Dec 2012 08:15:35 +0000 Message-Id: <1355559338-14313-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1355559338-14313-1-git-send-email-markwalters1009@gmail.com> References: <1355559338-14313-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: Sat, 15 Dec 2012 08:15:54 -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 | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b65c339..b11d65d 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -554,6 +554,28 @@ 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)) + (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 " ]" " (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))) @@ -862,7 +884,13 @@ message at DEPTH in the current thread." (cons invis-spec (overlay-get inner 'invisible))))) (button-put button 'invisibility-spec invis-spec) - (button-put button 'overlay overlay))))) + (button-put button 'overlay overlay)) + + ;; 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. @@ -1991,7 +2019,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 'invisibility-spec) + (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