From: Austin Clements Date: Thu, 30 May 2013 23:28:18 +0000 (+2000) Subject: Re: [PATCH v2 3/3] emacs: show: implement lazy hidden part handling X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5cfb1a49b4b2784bb74babef55017913f6cbc6d9;p=notmuch-archives.git Re: [PATCH v2 3/3] emacs: show: implement lazy hidden part handling --- diff --git a/9b/68a2e20503562396ece69c22f38576fbdf38bf b/9b/68a2e20503562396ece69c22f38576fbdf38bf new file mode 100644 index 000000000..7fa0a5fa9 --- /dev/null +++ b/9b/68a2e20503562396ece69c22f38576fbdf38bf @@ -0,0 +1,179 @@ +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 11A86431FD5 + for ; Thu, 30 May 2013 16:28:31 -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 kZ1Q8rkpxN42 for ; + Thu, 30 May 2013 16:28:25 -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 5DB58431FC3 + for ; Thu, 30 May 2013 16:28:25 -0700 (PDT) +X-AuditID: 1209190e-b7f4f6d000005142-07-51a7e0964e45 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id 38.F7.20802.690E7A15; Thu, 30 May 2013 19:28:22 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4UNSLk6011926; + Thu, 30 May 2013 19:28:22 -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 r4UNSJbA030419 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Thu, 30 May 2013 19:28:20 -0400 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1UiCGZ-0006Bb-07; Thu, 30 May 2013 19:28:19 -0400 +From: Austin Clements +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 3/3] emacs: show: implement lazy hidden part handling +In-Reply-To: <1369555061-21361-4-git-send-email-markwalters1009@gmail.com> +References: <1369555061-21361-1-git-send-email-markwalters1009@gmail.com> + <1369555061-21361-4-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: Thu, 30 May 2013 19:28:18 -0400 +Message-ID: <877gig2gkt.fsf@awakening.csail.mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrjvtwfJAg8Xn5SxWz+WxuH5zJrMD + k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlbGvu42x4L1Kxbo3k1gbGKfJdjFyckgImEj8 + W/6NFcIWk7hwbz1bFyMXh5DAPkaJgy8fMkM4Gxklnpz/zwrhnGaS2Ln6PRtIi5DAEkaJz+sz + QWw2AX2JFWsngY0SEXCVePrtMzOILSzgIzF72mawOKeAl8ST1ScYIQa1M0qcudLFCJIQFUiQ + WHn3BJjNIqAq8eHCbbBmXqD7Hl55ywphC0qcnPmEBcRmFtCSuPHvJdMERoFZSFKzkKQWMDKt + YpRNya3SzU3MzClOTdYtTk7My0st0jXWy80s0UtNKd3ECApJTkm+HYxfDyodYhTgYFTi4c1I + Wh4oxJpYVlyZe4hRkoNJSZT3zT2gEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHeznNAOd6UxMqq + 1KJ8mJQ0B4uSOO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd7m+0CNgkWp6akVaZk5JQhpJg5O + kOE8QMNXgtTwFhck5hZnpkPkTzEqSonzzgBJCIAkMkrz4HphKeMVozjQK8K8tSBVPMB0A9f9 + CmgwE9DgJ9Zgg0sSEVJSDYwy1Sw7ohdfDlUPT7pzr/XCLWvVdeGc7vo6M1dJR18KLzs1q6Wu + uUPD7fZn/gbmnh1fui63eATUijv2Hd1sL3Z1to3f+S2TTiXn8b5LPGazbqsNQ9v+dV3vPu6M + MfN7VzU3pMNAV7M27/rvCTVd4qaxGx9vyS6a21Jm+/jiJaGEjzvf/r/dWqDEUpyRaKjFXFSc + CAAohjxI9AIAAA== +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: Thu, 30 May 2013 23:28:31 -0000 + +On Sun, 26 May 2013, Mark Walters wrote: +> This adds the actual code to do the lazy insertion of hidden parts. +> +> We use a memory inefficient but simple method: when we come to insert +> the part if it is hidden we just store all of the arguments to the +> part insertion function as a button property. This means when we want +> to show the part we can just resume where we left off. +> +> The only slight subtlety/hack is that to simplify the handling of the +> invisibility overlay (for the hiding unhiding later) we do insert some +> dummy text which we remove when we show the part. +> --- +> emacs/notmuch-show.el | 32 ++++++++++++++++++++++++++++++-- +> 1 files changed, 30 insertions(+), 2 deletions(-) +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 591ad56..94faa9b 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -560,6 +560,7 @@ message at DEPTH in the current thread." +> (overlay (button-get button 'overlay))) +> (when overlay +> (let* ((show (overlay-get overlay 'invisible)) +> + (lazy-part (button-get button :notmuch-lazy-part)) +> (new-start (button-start button)) +> (button-label (button-get button :base-label)) +> (old-point (point)) +> @@ -570,7 +571,11 @@ message at DEPTH in the current thread." +> (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)))) +> + (when (and show lazy-part) +> + (save-excursion +> + (button-put button :notmuch-lazy-part nil) +> + (notmuch-show-lazy-part lazy-part button))))))) +> +> (defun notmuch-show-multipart/*-to-list (part) +> (mapcar (lambda (inner-part) (plist-get inner-part :content-type)) +> @@ -854,6 +859,24 @@ message at DEPTH in the current thread." +> (setq handlers (cdr handlers)))) +> t) +> +> +(defun notmuch-show-lazy-part (part-args button) +> + (interactive) +> + ;; We have to save the depth as we can't find the depth when narrowed +> + (let ((inhibit-read-only t) +> + (overlay (button-get button 'overlay)) +> + (depth (notmuch-show-get-depth))) +> + (save-restriction +> + (narrow-to-region (overlay-start overlay) (1- (overlay-end overlay))) +> + (delete-region (overlay-start overlay) (1- (overlay-end overlay))) +> + (goto-char (overlay-start overlay)) +> + (apply #'notmuch-show-insert-bodypart-internal (nconc part-args (list button))) + +Is there a reason 'button' couldn't be included in parts-args when +parts-args was originally constructed below? (If so, then this probably +deserves a comment.) + +> + (indent-rigidly (overlay-start overlay) +> + (1- (overlay-end overlay)) +> + depth)) +> + ;; We deferred deleting this character to simplify handling of the +> + ;; overlay: all of the above takes place inside the overlay. +> + (delete-region (1- (overlay-end overlay)) (overlay-end overlay)))) +> + +> (defun notmuch-show-create-part-overlays (msg beg end hide) +> "Add an overlay to the part between BEG and END" +> (let* ((button (button-at beg)) +> @@ -888,7 +911,12 @@ If HIDE is non-nil then initially hide this part." +> (button (unless (string= mime-type "text/plain") +> (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))) +> +> - (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button) +> + (if (not hide) +> + (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button) +> + (insert "lazy part") + +The insert is worth a comment. Or fixing if it's not too difficult. + +> + (button-put button :notmuch-lazy-part +> + (list msg part mime-type nth depth content-type))) +> + + +To summarize the IRC discussion for the record, this changes the +behavior of lazily inserted parts that we can't render. Currently the +only way we know if we can render a part is by attempting to render it. +As a result, lazily inserted parts that we can't render that would +previously have offered to save the part when the part button was +selected will now attempt to render the part and simply not display +anything. + +> ;; Some of the body part handlers leave point somewhere up in the +> ;; part, so we make sure that we're down at the end. +> (goto-char (point-max)) +> -- +> 1.7.9.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch