unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] emacs: Work around gnus-inhibit-images bug in mm-shr
Date: Sat, 29 Sep 2012 13:55:14 -0400	[thread overview]
Message-ID: <1348941314-8377-4-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1348941314-8377-1-git-send-email-amdragon@mit.edu>

Emacs 24's mm-shr HTML email renderer fails to load gnus-art before
referencing gnus-inhibit-images, resulting in a void-variable error
when notmuch attempts to render an HTML email with inline images.
This works around this bug by providing a definition for
gnus-inhibit-images.

This fixes the "Rendering HTML mail with images" test for Emacs 24.
---
 emacs/notmuch-lib.el |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 20d990d..c74035c 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -254,6 +254,30 @@ the given type."
   (or (plist-get part :content)
       (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))
 
+;; Workaround: The call to `mm-display-part' below triggers a bug in
+;; Emacs 24 if it attempts to use the shr renderer to display an HTML
+;; part with images in it (demonstrated in 24.1 and 24.2 on Debian and
+;; Fedora 17, though unreproducable in other configurations).
+;; `mm-shr' references the variable `gnus-inhibit-images' without
+;; first loading gnus-art, which defines it, resulting in a
+;; void-variable error.  Unfortunately, gnus-art and its dependencies
+;; are very large and often not needed, making it undesirable to
+;; simply load gnus-art here.  Instead, we directly define the
+;; variable here.  We use defcustom instead of defvar so that it
+;; interacts properly with user customizations of the variable (if the
+;; custom value has already been loaded, only defcustom will make it
+;; visible).  There is a danger of overriding the documentation string
+;; if gnus-art is already loaded, so we don't do anything if the
+;; variable is already defined.  If the user attempts to customize the
+;; variable, we instruct custom to load gnus-art before displaying the
+;; widget, which will override this definition with the proper
+;; documentation string, groups, etc.
+(if (and (>= emacs-major-version 24)
+         (not (boundp 'gnus-inhibit-images)))
+    (defcustom gnus-inhibit-images nil
+      "Documentation will be available after loading gnus-art."
+      :load "gnus-art"))
+
 (defun notmuch-mm-display-part-inline (msg part nth content-type process-crypto)
   "Use the mm-decode/mm-view functions to display a part in the
 current buffer, if possible."
-- 
1.7.10

  parent reply	other threads:[~2012-09-29 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-29 17:55 [PATCH 0/3] Fix gnus-inhibit-images bug in Emacs 24 Austin Clements
2012-09-29 17:55 ` [PATCH 1/3] test: Clear test-ouput output file before running Emacs tests Austin Clements
2012-09-29 17:55 ` [PATCH 2/3] test: Add a test for HTML email with inline images Austin Clements
2012-10-03  9:35   ` Dmitry Kurochkin
2012-10-03 14:28     ` Austin Clements
2012-10-03 14:41       ` Dmitry Kurochkin
2012-09-29 17:55 ` Austin Clements [this message]
2012-09-29 18:03   ` [PATCH] emacs: Work around gnus-inhibit-images bug in mm-shr Austin Clements
2012-09-29 20:26 ` [PATCH 0/3] Fix gnus-inhibit-images bug in Emacs 24 Tomi Ollila
2012-10-01  2:38   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348941314-8377-4-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).