displaying messages in a web browser

305 views
Skip to first unread message

SF

unread,
Feb 26, 2013, 10:47:47 PM2/26/13
to mu-di...@googlegroups.com
Sometimes I get really nasty HTML emails that neither w3m, lynx, or elinks will convert into something useful. This little action helps in these cases. Comments on how to turn this a pure elisp solution are welcome :)

(defun mu4e-action-view-in-browser (msg)
  (let* ((q mu4e-html2text-command)
     )
    (setq mu4e-html2text-command "mu4e-showinbrowser.sh")
    (mu4e-message-body-text msg)
    (setq mu4e-html2text-command q)
    ))

(add-to-list 'mu4e-headers-actions
         '("in browser" . mu4e-action-view-in-browser) t)
(add-to-list 'mu4e-view-actions
         '("in browser" . mu4e-action-view-in-browser) t)


And here is mu4e-showinbrowser.sh:

#!/bin/bash
_fname=$(mktemp mu4etowww.XXXXXXXXXXXXXXXXX)
cat - > ${_fname}
/usr/bin/firefox --new-window ${_fname}

SF

unread,
Mar 3, 2013, 9:40:43 AM3/3/13
to mu-di...@googlegroups.com
Since many HTML messages don't have an enclosing html tag, this version of mu4e-showinbrowser.sh works better:

#!/bin/bash
_fname=$(mktemp)
echo "<html>" > ${_fname}
cat - >> ${_fname}
echo "</html>" >> ${_fname}
/usr/bin/firefox --new-window ${_fname}

SF

unread,
Mar 17, 2013, 8:08:03 PM3/17/13
to mu-di...@googlegroups.com
Note that the latest version of mu has an action build in that does this without the need of an external bash script. The action is called mu4e-action-view-in-browser, so just add it to your header and view action list.
Reply all
Reply to author
Forward
0 new messages