[PATCH 09/11] emacs: Use generalized content caching in w3m CID code
authorAustin Clements <amdragon@MIT.EDU>
Mon, 21 Apr 2014 18:37:46 +0000 (14:37 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:01:50 +0000 (10:01 -0800)
5a/ba2e9f76ee45a113f8bbadac4901550511f229 [new file with mode: 0644]

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