I have just started using notmuch for email. I was wondering if there is some way I can view the HTML part of an email in an external browser or rendered to a pdf and viewed inside Emacs (like you can do with mu4e)?
You can use
notmuch-show-view-part (bound to
.-v by default) while point is in the
text/html part to accomplish this.
For this to function properly you'll need to make sure your
~/.mailcap file has settings for
Here's what I have in mine on my Mac:
text/html; open %s; nametemplate=%s.html
Each line is
; delimited with the first field specifying the content type, the second field specifying the command to use, and any additional fields specifying options.
So I have
nametemplate which essentially adds
.html to the filename that
notmuch generates, which is then passed to
open (which knows how to handle it because of the
The format is described in RFC 1524.
As mentioned, you need to be in the
text/hmtl part of the email for this to work. Since this can be inconvenient, I use this function which you can call from anywhere in the message in order to open the html part:
(defun notmuch-show-view-html+ () "Open the text/html part of the current message using `notmuch-show-view-part'." (interactive) (save-excursion (goto-char (prop-match-beginning (text-property-search-forward :notmuch-part "text/html" (lambda (value notmuch-part) (equal (plist-get notmuch-part :content-type) value))))) (notmuch-show-view-part)))