Skip to content

Instantly share code, notes, and snippets.

@syl20bnr
Created January 5, 2013 07:11
Show Gist options
  • Save syl20bnr/4460279 to your computer and use it in GitHub Desktop.
Save syl20bnr/4460279 to your computer and use it in GitHub Desktop.
Open the message at point in the default external browser.
;; adapted from https://groups.google.com/d/topic/mu-discuss/ZXB72TR5GL0/discussion
(defun mu4e-msgv-action-view-in-browser (msg)
"View the body of the message in a web browser."
(interactive)
(let ((html (mu4e-msg-field (mu4e-message-at-point t) :body-html))
(tmpfile (format "%s/%d.html" temporary-file-directory (random))))
(unless html (error "No html part for this message"))
(with-temp-file tmpfile
(insert
"<html>"
"<head><meta http-equiv=\"content-type\""
"content=\"text/html;charset=UTF-8\">"
html))
(browse-url (concat "file://" tmpfile))))
(add-to-list 'mu4e-view-actions
'("View in browser" . mu4e-msgv-action-view-in-browser) t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment