From: Austin Clements Date: Mon, 21 Apr 2014 18:37:46 +0000 (+2000) Subject: [PATCH 09/11] emacs: Use generalized content caching in w3m CID code X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c95b30e77f9dd1a5db1776fd38ab503204132890;p=notmuch-archives.git [PATCH 09/11] emacs: Use generalized content caching in w3m CID code --- diff --git a/5a/ba2e9f76ee45a113f8bbadac4901550511f229 b/5a/ba2e9f76ee45a113f8bbadac4901550511f229 new file mode 100644 index 000000000..6972b6259 --- /dev/null +++ b/5a/ba2e9f76ee45a113f8bbadac4901550511f229 @@ -0,0 +1,132 @@ +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 8085A431FBC + for ; Mon, 21 Apr 2014 11:38:10 -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 n0SWJZZ-L3Lz for ; + Mon, 21 Apr 2014 11:38:05 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu + [18.9.25.14]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 51E9D431FC0 + for ; Mon, 21 Apr 2014 11:37:59 -0700 (PDT) +X-AuditID: 1209190e-f79ee6d000000c40-95-53556586fb18 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id A1.75.03136.68565535; Mon, 21 Apr 2014 14:37:58 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3LIbuwm018332; + Mon, 21 Apr 2014 14:37:57 -0400 +Received: from drake.dyndns.org + (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [216.15.114.40]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3LIbsGU029724 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 21 Apr 2014 14:37:56 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1WcJ6I-0003lF-Gn; Mon, 21 Apr 2014 14:37:54 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 09/11] emacs: Use generalized content caching in w3m CID code +Date: Mon, 21 Apr 2014 14:37:46 -0400 +Message-Id: <1398105468-14317-10-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.9.1 +In-Reply-To: <1398105468-14317-1-git-send-email-amdragon@mit.edu> +References: <1398105468-14317-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrduWGhps8PgGv8X1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CVcWH6J7aCq4IVm9pWMjUwLuLrYuTgkBAwkdi4R6GLkRPIFJO4 + cG89WxcjF4eQwGwmiZbDv5ghnI2MEtdnfGOFcO4wSZw/fw6qbC6jxLyuRhaQfjYBDYlt+5cz + gtgiAtISO+/OZgVZwSygJvGnSwUkLCzgK/Hh9Go2kDCLgKrEvhZ9kDCvgKPEq/6tbBBXyEmc + PDaZFcTmBIq3rX7JDmILCThIbNi7hmkCI/8CRoZVjLIpuVW6uYmZOcWpybrFyYl5ealFusZ6 + uZkleqkppZsYwSEjybeD8etBpUOMAhyMSjy8BUahwUKsiWXFlbmHGCU5mJREeV9FAYX4kvJT + KjMSizPii0pzUosPMUpwMCuJ8K7XBMrxpiRWVqUW5cOkpDlYlMR531pbBQsJpCeWpGanphak + FsFkZTg4lCR4b6YANQoWpaanVqRl5pQgpJk4OEGG8wANvwhSw1tckJhbnJkOkT/FqCglztsG + khAASWSU5sH1wmL6FaM40CvCvC0gVTzAdADX/QpoMBPQ4CdbQkAGlyQipKQaGC2EmLxPnO1m + erPXgX3ubrPN5eLLE7JNLe8Fhl5sP7Jp8+I8Qfk7i6QSuh3uMa2b6cD57fPKF1r7tuiwFf9m + bJnsv/zhMYMaq5C6o27b0gUKlQ6pztjn99Vb/9AcrcUWAZJ2s5XYj99runLPpHjrzi0zcuZ9 + unm1Vy9uV/NnphtJUsptZqGi/kosxRmJhlrMRcWJAPohi0DEAgAA +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, 21 Apr 2014 18:38:10 -0000 + +Previously this did its own caching, but this is now supported by more +generally by `notmuch-get-bodypart-binary'. +--- + emacs/notmuch-show.el | 23 ++++++++--------------- + 1 file changed, 8 insertions(+), 15 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 537c558..9411c9a 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -540,15 +540,14 @@ (defvar w3m-current-buffer) ;; From `w3m.el'. + (defvar notmuch-show-w3m-cid-store nil) + (make-variable-buffer-local 'notmuch-show-w3m-cid-store) + +-(defun notmuch-show-w3m-cid-store-internal (content-id msg part content) +- (push (list content-id msg part content) +- notmuch-show-w3m-cid-store)) ++(defun notmuch-show-w3m-cid-store-internal (content-id msg part) ++ (push (list content-id msg part) notmuch-show-w3m-cid-store)) + + (defun notmuch-show-w3m-cid-store (msg part) + (let ((content-id (plist-get part :content-id))) + (when content-id + (notmuch-show-w3m-cid-store-internal (concat "cid:" content-id) +- msg part nil)))) ++ msg part)))) + + (defun notmuch-show-w3m-cid-retrieve (url &rest args) + (let ((matching-part (with-current-buffer w3m-current-buffer +@@ -556,18 +555,12 @@ (defun notmuch-show-w3m-cid-retrieve (url &rest args) + (if matching-part + (let* ((msg (nth 1 matching-part)) + (part (nth 2 matching-part)) +- (content (nth 3 matching-part)) + (content-type (plist-get part :content-type))) +- ;; If we don't already have the content, get it and cache +- ;; it, as some messages reference the same cid: part many +- ;; times (hundreds!), which results in many calls to +- ;; `notmuch part'. +- (unless content +- (setq content (notmuch-get-bodypart-binary +- msg part notmuch-show-process-crypto)) +- (with-current-buffer w3m-current-buffer +- (notmuch-show-w3m-cid-store-internal url msg part content))) +- (insert content) ++ ;; Request content caching, as some messages reference the ++ ;; same cid: part many times (hundreds!), which results in ++ ;; many calls to `notmuch show'. ++ (insert (notmuch-get-bodypart-binary ++ msg part notmuch-show-process-crypto 'cache)) + content-type) + nil))) + +-- +1.9.1 +