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 4CB14429E32 for ; Fri, 31 May 2013 11:27:52 -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 gVTbjmb7Hh0B for ; Fri, 31 May 2013 11:27:46 -0700 (PDT) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id BAAF0429E34 for ; Fri, 31 May 2013 11:27:26 -0700 (PDT) Received: by mail-wi0-f181.google.com with SMTP id hi5so962562wib.14 for ; Fri, 31 May 2013 11:27: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=NzwqXnMZ2smnb1/JhTNQRyJO1YLCnbUlj0bBHWuMpiM=; b=N3NWsDqWOHFpBCCPN3Oto3xIUpS24sF1qhW9V4EWdcbJWTUmjrMRwIm8uSA7bj7PQ2 Nm2ZhfKSPe3xBv2CaAURqbQkF+t2vi3kvQAZYH6xtEGtvlqF4he2R7VZd7pSN5NWGsg5 B/UDpFl1W8tlDYiQBU3iw7152Ei5xJ+tGZLOLueN/H1XOGlfRBe8z8AcTXlyxBqv+lxW 9+IDDgLbU/+mtj71g+gp+fSXLh1GIrQk35+mfLiLoFVNwSF77pM/YZ7eFDApeTkMevlH Fhc2psYESe4d8WsHWb9+E/lUCTH+qssPB6nsv2NDVVdb+JrS5/HtCeM1UoZT9pAjMpKT 0W2g== X-Received: by 10.180.206.77 with SMTP id lm13mr4448242wic.18.1370024845601; Fri, 31 May 2013 11:27:25 -0700 (PDT) Received: from localhost (92.40.240.237.threembb.co.uk. [92.40.240.237]) by mx.google.com with ESMTPSA id d5sm5742397wic.1.2013.05.31.11.27.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 31 May 2013 11:27:25 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements , Adam Wolfe Gordon Subject: [PATCH v3 4/5] emacs: show: modify the way hidden state is recorded. Date: Fri, 31 May 2013 19:26:45 +0100 Message-Id: <1370024806-6616-5-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> References: <1370024806-6616-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: Fri, 31 May 2013 18:27:52 -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 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 66cc3a5..89199e8 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -495,6 +495,7 @@ message at DEPTH in the current thread." (concat "[ " base-label " ]") :base-label base-label :type 'notmuch-show-part-button-type + :notmuch-part-hidden nil :notmuch-part nth :notmuch-filename name :notmuch-content-type content-type)) @@ -555,18 +556,20 @@ 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)) (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) ]")) (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)))))) (defun notmuch-show-multipart/*-to-list (part) (mapcar (lambda (inner-part) (plist-get inner-part :content-type)) @@ -851,7 +854,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 @@ -859,11 +862,9 @@ 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. @@ -889,7 +890,9 @@ 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 beg (point) hide))) + (notmuch-show-create-part-overlays button beg (point)) + (when hide + (notmuch-show-toggle-part-invisibility button)))) (defun notmuch-show-insert-body (msg body depth) "Insert the body BODY at depth DEPTH in the current thread." -- 1.7.10.4