From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 9349A431FD6 for ; Fri, 31 May 2013 16:09:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 QsN4opE4px8Y for ; Fri, 31 May 2013 16:09:47 -0700 (PDT) Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id 424E6431FBD for ; Fri, 31 May 2013 16:09:47 -0700 (PDT) X-AuditID: 1209190e-b7f4f6d000005142-78-51a92db9d25a Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 98.3B.20802.9BD29A15; Fri, 31 May 2013 19:09:45 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r4VN9iDU001529; Fri, 31 May 2013 19:09:44 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4VN9gQb027710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 31 May 2013 19:09:43 -0400 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1UiYS6-00059K-82; Fri, 31 May 2013 19:09:42 -0400 From: Austin Clements To: Mark Walters , notmuch@notmuchmail.org, Adam Wolfe Gordon Subject: Re: [PATCH v3 4/5] emacs: show: modify the way hidden state is recorded. In-Reply-To: <1370024806-6616-5-git-send-email-markwalters1009@gmail.com> References: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> <1370024806-6616-5-git-send-email-markwalters1009@gmail.com> User-Agent: Notmuch/0.15.2+83~g8bee3c4 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Fri, 31 May 2013 19:09:42 -0400 Message-ID: <871u8m3fwp.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsUixCmqrLtTd2WgwdKPOhZH9sxit1g9l8fi +s2ZzA7MHjtn3WX3eLbqFrNH04/FrAHMUVw2Kak5mWWpRfp2CVwZ63cvZSuYrFwx+clfpgbG +9JdjJwcEgImEi9mL2KCsMUkLtxbz9bFyMUhJLCPUeJw+0woZyOjxI8nz5khnNNMEpf6njBB OEsYJTp2XGQH6WcT0JdYsXYSK4gtIlAmsWX6LLC5zAI6Eid2b2MEsYUFAiUeTd8JVsMp4Cnx Z8J6qEGtjBKN67uYQRKiAgkSK++eAGtgEVCVuHr0IQuIzQt07Im325ghbEGJkzOfsEAs0JK4 8e8l0wRGwVlIUrOQpBYwMq1ilE3JrdLNTczMKU5N1i1OTszLSy3SNdbLzSzRS00p3cQIDmBJ vh2MXw8qHWIU4GBU4uE1WLEiUIg1say4MvcQoyQHk5Iob736ykAhvqT8lMqMxOKM+KLSnNTi Q4wSHMxKIrz5c4DKeVMSK6tSi/JhUtIcLErivFdSbvoLCaQnlqRmp6YWpBbBZGU4OJQkeA/r AA0VLEpNT61Iy8wpQUgzcXCCDOcBGv4YpIa3uCAxtzgzHSJ/ilFRSpz3DkhCACSRUZoH1wtL MK8YxYFeEeZ9ClLFA0xOcN2vgAYzAQ1+Yr0cZHBJIkJKqoEx0mG1rpH3lS9vC+YEyF4T2PR6 QeyrY0VznRhUhfm/dZ7/8uTa24v/enqSb/JXS1YmmGjHmgW5h6uG5K1cNreNsefVkebKvoDN Cn32/5yvWqeGfdigc9TETkB9jqr45a2WGbtPfFh2X133QPu3X1dmfJN5HpAjMks8ca1WGsOn qjXrg1oWXstXYinOSDTUYi4qTgQAQp1/aAsDAAA= 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 23:09:53 -0000 On Fri, 31 May 2013, Mark Walters wrote: > 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)) > + Ah, I see the mis-indentation was only temporary. > > (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)))) This lost the save-excursion around notmuch-show-toggle-part-invisibility. I'm surprised that works, given how notmuch-show-toggle-part-invisibility moves point, but then again, I can believe that the planets happen to align here because you're hiding a part and that part happens to go to (point-max). Might be worth a comment or putting back the save-excursion just so people don't have to think about it. > > (defun notmuch-show-insert-body (msg body depth) > "Insert the body BODY at depth DEPTH in the current thread." > -- > 1.7.10.4