--- /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 89648431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:17:22 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.138\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.138 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_MED=-2.3]\r
+ 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 rynoQqTPLqnR for <notmuch@notmuchmail.org>;\r
+ Sat, 24 Jan 2015 13:17:19 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
+ [18.9.25.13])\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 82735431FD4\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:17:13 -0800 (PST)\r
+X-AuditID: 1209190d-f79006d000000cfe-3b-54c40bd60e82\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 5D.F2.03326.7DB04C45; Sat, 24 Jan 2015 16:17:11 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id t0OLH9xU001792; \r
+ Sat, 24 Jan 2015 16:17:09 -0500\r
+Received: from drake (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 t0OLH63l007464\r
+ (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
+ Sat, 24 Jan 2015 16:17:07 -0500\r
+Received: from amthrax by drake with local (Exim 4.84)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1YF84n-0005Rr-NP; Sat, 24 Jan 2015 16:17:05 -0500\r
+From: Austin Clements <amdragon@mit.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 8/8] emacs: Support cid: references with shr renderer\r
+Date: Sat, 24 Jan 2015 16:17:03 -0500\r
+Message-Id: <1422134223-20739-9-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.1.3\r
+In-Reply-To: <1422134223-20739-1-git-send-email-amdragon@mit.edu>\r
+References: <1422134223-20739-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFrrFIsWRmVeSWpSXmKPExsUixCmqrHud+0iIwYmX7BY3WrsZLfbd2cJk\r
+ sXouj8X1mzOZLd6snMfqwOqx6/lfJo+ds+6yexz+upDF49mqW8weWw69Zw5gjeKySUnNySxL\r
+ LdK3S+DK+HPyGlvBefGKOa+OMDUwLhTuYuTkkBAwkfj0cxoThC0mceHeerYuRi4OIYHFTBK9\r
+ S+cyQjgbGSUuTl7BBOFcZJL4+uMBK4QziVHi28vFLCD9bAIaEr9vLQabJSIgLbHz7mxWEJtZ\r
+ oE7i75zzjCC2sICHxIVT35hBbBYBVYnO+61gcV4BB4nW+duBejmA7pCT2LrOGyTMKeAocWPD\r
+ LrDxQkAl3Z8b2SYw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6SXm1mil5pSuokRHISS\r
+ vDsY3x1UOsQowMGoxMP749+hECHWxLLiytxDjJIcTEqivKt+HQ4R4kvKT6nMSCzOiC8qzUkt\r
+ PsQowcGsJMJ7YQNQjjclsbIqtSgfJiXNwaIkzrvpB1+IkEB6YklqdmpqQWoRTFaGg0NJgncx\r
+ 15EQIcGi1PTUirTMnBKENBMHJ8hwHqDh3SA1vMUFibnFmekQ+VOMilLivOtBEgIgiYzSPLhe\r
+ WJJ4xSgO9Iowbz1IFQ8wwcB1vwIazAQ0uGD7AZDBJYkIKakGxi6W0Fdim78vqBXN3Zmd9Ltt\r
+ kpfAio8TE5TVY/PnCITbvr/F+NjwQvUcscUMSj9FuPdETJXx2y/W800x+ZTdvRoH/9rren9F\r
+ jPOm7LZ80XLOwf/G3c/dV1kKIuVm1rNJl6fUBy6tuSPyMPrgzsW9qk+vZyy50nt38v78qa8c\r
+ nk//tP0656eyo0osxRmJhlrMRcWJAExwTiLtAgAA\r
+Cc: tomi.ollila@iki.fi\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: Sat, 24 Jan 2015 21:17:22 -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 | 45 +++++++++++++++++++++++++++++++++++++--------\r
+ 1 file changed, 37 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 34dcedd..66350d4 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -767,14 +767,43 @@ (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
++;; These functions are used by notmuch-show--insert-part-text/html-shr\r
++(declare-function libxml-parse-html-region "xml.c")\r
++(declare-function shr-insert-document "shr")\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
+2.1.3\r
+\r