--- /dev/null
+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 9290F431E64\r
+ for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:22 -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 OCDgO+ODL92l for <notmuch@notmuchmail.org>;\r
+ Mon, 21 Apr 2014 11:38:17 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+ [18.7.68.37])\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 EB895431FC9\r
+ for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:03 -0700 (PDT)\r
+X-AuditID: 12074425-f79906d000000cf9-27-5355658a88d8\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-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id D9.F3.03321.A8565535; Mon, 21 Apr 2014 14:38:02 -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 s3LIc18g018353; \r
+ Mon, 21 Apr 2014 14:38:01 -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 s3LIbshb029728\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 21 Apr 2014 14:38:00 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WcJ6I-0003lL-I6; Mon, 21 Apr 2014 14:37:54 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 11/11] emacs: Support cid: references with shr renderer\r
+Date: Mon, 21 Apr 2014 14:37:48 -0400\r
+Message-Id: <1398105468-14317-12-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+NgFtrMIsWRmVeSWpSXmKPExsUixCmqrduVGhpssLrByuL6zZnMDowez1bd\r
+ Yg5gjOKySUnNySxLLdK3S+DKeHD9KGPBDLGKzrd/mBsY/wh2MXJySAiYSOxoPMICYYtJXLi3\r
+ nq2LkYtDSGA2k8Syn/OZIZyNjBJfXh1jhXDuMEk8XLecBcKZyyjxas8GRpB+NgENiW37l4PZ\r
+ IgLSEjvvzgbq4OBgFlCT+NOlAhIWFnCXaLm0hRnEZhFQlTh8+TgTiM0r4CixZ/ZUNogz5CRO\r
+ HpvMCmJzAsXbVr9kB7GFBBwkNuxdwzSBkX8BI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXQu9\r
+ 3MwSvdSU0k2MoLBhd1HdwTjhkNIhRgEORiUe3gKj0GAh1sSy4srcQ4ySHExKoryvooBCfEn5\r
+ KZUZicUZ8UWlOanFhxglOJiVRHjXawLleFMSK6tSi/JhUtIcLErivG+trYKFBNITS1KzU1ML\r
+ UotgsjIcHEoSvGkpQI2CRanpqRVpmTklCGkmDk6Q4TxAw6NAaniLCxJzizPTIfKnGBWlxHnb\r
+ QBICIImM0jy4Xlhcv2IUB3pFmNcdpIoHmBLgul8BDWYCGvxkSwjI4JJEhJRUA+M8CwVHhy+N\r
+ +fMmLPM+LsjKneiu++qLeZiCUlHbJ7+nbKXrDKRe9OWUCmQzruLYGB+0m1Eu2Smv6vrBwuvq\r
+ CvzTTnQcWfqieZnkrX3OMt5FWmG1365Vu7RamLqYy0w8m7GkaI1vwMlPmyKkviVmqB6Weyx/\r
+ rSyjqe7Igildx7f+Y1ucHPu9WYmlOCPRUIu5qDgRACHRn1/GAgAA\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:23 -0000\r
+\r
+shr has really nice support for inline image rendering, but previously\r
+we only had the hooks for w3m cid: references.\r
+---\r
+ emacs/notmuch-show.el | 41 +++++++++++++++++++++++++++++++++--------\r
+ 1 file changed, 33 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index f758091..a489279 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -745,14 +745,39 @@ (defun notmuch-show-get-mime-type-of-application/octet-stream (part)\r
+ nil))))\r
+ \r
+ (defun notmuch-show-insert-part-text/html (msg part content-type nth depth button)\r
+- ;; text/html handler to work around bugs in renderers and our\r
+- ;; invisibile parts code. In particular w3m sets up a keymap which\r
+- ;; "leaks" outside the invisible region and causes strange effects\r
+- ;; in notmuch. We set mm-inline-text-html-with-w3m-keymap to nil to\r
+- ;; tell w3m not to set a keymap (so the normal notmuch-show-mode-map\r
+- ;; remains).\r
+- (let ((mm-inline-text-html-with-w3m-keymap nil))\r
+- (notmuch-show-insert-part-*/* msg part content-type nth depth button)))\r
++ (if (eq mm-text-html-renderer 'shr)\r
++ ;; It's easier to drive shr ourselves than to work around the\r
++ ;; goofy things `mm-shr' does (like irreversibly taking over\r
++ ;; content ID handling).\r
++ (notmuch-show--insert-part-text/html-shr msg part)\r
++ ;; Otherwise, let message-mode do the heavy lifting\r
++ ;;\r
++ ;; w3m sets up a keymap which "leaks" outside the invisible region\r
++ ;; and causes strange effects in notmuch. We set\r
++ ;; mm-inline-text-html-with-w3m-keymap to nil to tell w3m not to\r
++ ;; set a keymap (so the normal notmuch-show-mode-map remains).\r
++ (let ((mm-inline-text-html-with-w3m-keymap nil))\r
++ (notmuch-show-insert-part-*/* msg part content-type nth depth button))))\r
++\r
++(defun notmuch-show--insert-part-text/html-shr (msg part)\r
++ ;; Make sure shr is loaded before we start let-binding its globals\r
++ (require 'shr)\r
++ (let ((dom (let (process-crypto notmuch-show-process-crypto)\r
++ (with-temp-buffer\r
++ (insert (notmuch-get-bodypart-text msg part process-crypto))\r
++ (libxml-parse-html-region (point-min) (point-max)))))\r
++ (shr-content-function\r
++ (lambda (url)\r
++ ;; shr strips the "cid:" part of URL, but doesn't\r
++ ;; URL-decode it (see RFC 2392).\r
++ (let ((cid (url-unhex-string url)))\r
++ (first (notmuch-show--get-cid-content cid)))))\r
++ ;; Block all external images to prevent privacy leaks and\r
++ ;; potential attacks. FIXME: If we block an image, offer a\r
++ ;; button to load external images.\r
++ (shr-blocked-images "."))\r
++ (shr-insert-document dom)\r
++ t))\r
+ \r
+ (defun notmuch-show-insert-part-*/* (msg part content-type nth depth button)\r
+ ;; This handler _must_ succeed - it is the handler of last resort.\r
+-- \r
+1.9.1\r
+\r