From: Mark Walters Date: Sat, 1 Jun 2013 08:15:46 +0000 (+0100) Subject: [PATCH v4 4/5] emacs: show: modify the way hidden state is recorded. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6554b3aadadfb130d4193e58444b73a3e2fd9654;p=notmuch-archives.git [PATCH v4 4/5] emacs: show: modify the way hidden state is recorded. --- diff --git a/fb/84996b0cff44753ba5d0a85874c437b64e9ae4 b/fb/84996b0cff44753ba5d0a85874c437b64e9ae4 new file mode 100644 index 000000000..bd8058055 --- /dev/null +++ b/fb/84996b0cff44753ba5d0a85874c437b64e9ae4 @@ -0,0 +1,160 @@ +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 E0A4B421161 + for ; Sat, 1 Jun 2013 01:16:43 -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 jaukW1m-cJnV for ; + Sat, 1 Jun 2013 01:16:38 -0700 (PDT) +Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com + [74.125.82.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 28948429E4A for ; Sat, 1 Jun 2013 01:16:29 -0700 + (PDT) +Received: by mail-wg0-f52.google.com with SMTP id z11so1826154wgg.31 + for ; Sat, 01 Jun 2013 01:16:28 -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=4q8vYTjj6cSSpMm8tbxmfihn6ZTJQ+5sN2EcIJY+81g=; + b=1A75/YcuktELBk/y4YmF1ZeNVkdXz20XEiLceEKoNwQ6O/mM4ddbV4oeVyDXGfFekL + 1n6NLzYcz2l4BPbXDoLhnpVQRTrUi25rtotF6XWROYXX/Hcm63QAtB8V0q7S+4gs31SH + +R/MZ1JQJV/DJKEWT6CSO9UxdUcEsmvc5YU7Kj7myAyL5UZJYcCaaAHthSlHs9aMZ3SB + vgyRCkBFtAKs/Ek88hnB3bdsdowbWHQvMQKaBMn8ToNrSrS5Ehah73MgGw76vFSyfvLW + yERrlw1TOHgAx1oKW1ApRG/RYOEvdRxtOcnCrTF8dwu5ZqnmiIlSxcZBaF5RcamDSk4E + cXdQ== +X-Received: by 10.194.238.42 with SMTP id vh10mr1757357wjc.28.1370074588082; + Sat, 01 Jun 2013 01:16:28 -0700 (PDT) +Received: from localhost (94.197.247.227.threembb.co.uk. [94.197.247.227]) + by mx.google.com with ESMTPSA id d5sm8657346wic.1.2013.06.01.01.16.25 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 01 Jun 2013 01:16:27 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org, Austin Clements , + Adam Wolfe Gordon +Subject: [PATCH v4 4/5] emacs: show: modify the way hidden state is recorded. +Date: Sat, 1 Jun 2013 09:15:46 +0100 +Message-Id: <1370074547-24677-5-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com> +References: <1370074547-24677-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, 01 Jun 2013 08:16:44 -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 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index cdea271..49f85ba 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.10.4 +