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 1DDED431FAF for ; Sun, 9 Jun 2013 21:57:39 -0700 (PDT) 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 ex8p8YgYjjPS for ; Sun, 9 Jun 2013 21:57:33 -0700 (PDT) Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com [209.85.215.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id AD80C431FBD for ; Sun, 9 Jun 2013 21:57:26 -0700 (PDT) Received: by mail-ea0-f179.google.com with SMTP id b15so3882109eae.24 for ; Sun, 09 Jun 2013 21:57:25 -0700 (PDT) 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=/rjrXVYrKPJtKMwtmKMl31jf2/xCmRSmYTgBB3dJN8s=; b=GYX7Zt6nRbfrfzc1848gx92gr8ng6b0eP/v4R7t1ymzln5G3fZkCIFrnLKAIWMABto uCC1yKC5IjDYWo7LKlLwt4dksiIcRjrdQFVgyowjN5EURuygchjJRhxN4lE6pIeP70Iu zZQd64pajfuXJULaDi+IzDTClrJMXOwFSwy2WGIEJxcn1Jfk4kX5wkd0u0UdtNUbQZCL 55l9ig6IS1p0PhZqDfN+BymcjeXgkmaT9kj24twKK64/ZbYmHb4RGKA4YKDtK81VT7/k JXR9nefs2AymXuB7E9n5traXxynjU9xgwb5J1SDvjdXX+W9Y++bAD+Q3i4ML2UiIe/Z1 qIPw== X-Received: by 10.14.98.194 with SMTP id v42mr9072097eef.61.1370840245520; Sun, 09 Jun 2013 21:57:25 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id y2sm20318516eeu.2.2013.06.09.21.57.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 09 Jun 2013 21:57:25 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements Subject: [PATCH v5 4/6] emacs: show: modify the way hidden state is recorded. Date: Mon, 10 Jun 2013 05:57:11 +0100 Message-Id: <1370840233-23258-5-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com> References: <1370840233-23258-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: Mon, 10 Jun 2013 04:57:39 -0000 Previously, whether a part was hidden or shown was recorded in the invisibility/visibility of the part overlay. Since we are going to have lazily rendered parts with no overlay store the hidden/shown state in the part button itself. Additionally, in preparation for the invisible part handling move the actual hiding of the hidden parts to insert-bodypart from create-part-overlays. Finally, we will need to know whether a part-insertion has done anything (it won't if the invisible part cannot be displayed by emacs) so we slightly rejig the code order in notmuch-show-toggle-part-invisibility to make it easier for the function to set an appropriate return value. --- emacs/notmuch-show.el | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 0a0451b..43aa88b 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -482,7 +482,8 @@ message at DEPTH in the current thread." (insert-button (concat "[ " base-label " ]") :base-label base-label - :type 'notmuch-show-part-button-type)) + :type 'notmuch-show-part-button-type + :notmuch-part-hidden nil)) (insert "\n") ;; return button button)) @@ -493,20 +494,22 @@ message at DEPTH in the current thread." (let* ((button (or button (button-at (point)))) (overlay (button-get button 'overlay))) (when overlay - (let* ((show (overlay-get overlay 'invisible)) + (let* ((show (button-get button :notmuch-part-hidden)) (new-start (button-start button)) (button-label (button-get button :base-label)) (old-point (point)) (properties (text-properties-at (point))) (inhibit-read-only t)) - (overlay-put overlay 'invisible (not show)) + ;; Toggle the button itself. + (button-put button :notmuch-part-hidden (not show)) (goto-char new-start) (insert "[ " button-label (if show " ]" " (hidden) ]")) (set-text-properties new-start (point) properties) (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)))))))) + (goto-char (min old-point (1- (button-end button)))) + (overlay-put overlay 'invisible (not show)))))) ;; MIME part renderers @@ -793,7 +796,7 @@ message at DEPTH in the current thread." (setq handlers (cdr handlers)))) t) -(defun notmuch-show-create-part-overlays (button beg end hide) +(defun notmuch-show-create-part-overlays (button beg end) "Add an overlay to the part between BEG and END" ;; If there is no button (i.e., the part is text/plain and the first @@ -801,11 +804,8 @@ message at DEPTH in the current thread." ;; toggleable. (when (and button (/= beg end)) (button-put button 'overlay (make-overlay 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))))) + ;; Return true if we created an overlay. + t)) (defun notmuch-show-insert-bodypart (msg part depth &optional hide) "Insert the body part PART at depth DEPTH in the current thread. @@ -832,7 +832,10 @@ If HIDE is non-nil then initially hide this part." ;; Ensure that the part ends with a carriage return. (unless (bolp) (insert "\n")) - (notmuch-show-create-part-overlays button content-beg (point) hide) + (notmuch-show-create-part-overlays button content-beg (point)) + (when hide + (save-excursion + (notmuch-show-toggle-part-invisibility button))) ;; Record part information. Since we already inserted subparts, ;; don't override existing :notmuch-part properties. (notmuch-map-text-property beg (point) :notmuch-part -- 1.7.9.1