Next: , Previous: , Up: Message view   [Contents]


5.5 Displaying rich-text messages

mu4e normally prefers the plain-text version for messages that consist of both a plain-text and html (rich-text) versions of the body-text. You can change this by setting mu4e-view-prefer-html to t. And you can toggle this value (globally) using h in the message view; this also refreshes the message with the new setting.

Note, when using html-based rendering, you don’t get the hyperlink shortcuts the text-version provides.

If there is only an html-version, or if the plain-text version is too short in comparison with the html part26, mu4e tries to convert the html into plain-text for display.

With emacs 24.4 or newer, this defaults to mu4e-shr2text, which uses the built-in shr renderer. For older emacs versions, this defaults to the built-in html2text function. In practice, the latter gives much better results.

If you use mu4e-shr2text, it might be useful to emulate some of the shr key bindings, with something like:

(add-hook 'mu4e-view-mode-hook
  (lambda()
    ;; try to emulate some of the eww key-bindings
    (local-set-key (kbd "<tab>") 'shr-next-link)
    (local-set-key (kbd "<backtab>") 'shr-previous-link)))

If you’re using a dark theme, and the messages are hard to read, it can help to change the luminosity, e.g.:

(setq shr-color-visible-luminance-min 80)

If your emacs does not have shr yet, it can be useful to use a custom method. For that, you can set the variable mu4e-html2text-command to either a shell command or a function instead.

5.5.1 Html2text commands

If mu4e-html2text-command is a shell command, it is expected to take html from standard input and write plain text in UTF-8 encoding on standard output.

An example of such a program is the program that is actually called html2text27. After installation, you can set it up with something like the following:

(setq mu4e-html2text-command "html2text -utf8 -width 72")

An alternative to this is the Python python-html2text package; after installing that, you can tell mu4e to use it with something like:

(setq mu4e-html2text-command
  "html2markdown | grep -v '&nbsp_place_holder;'")

On OS X, there is a program called textutil as yet another alternative:

(setq mu4e-html2text-command
  "textutil -stdin -format html -convert txt -stdout")

5.5.2 Html2text functions

If mu4e-html2text-command refers to an elisp function, it is expected to take the current buffer in html as input, and transform it into text (just like the html2text function).

5.5.3 Privacy aspects

When opening your messages in a graphical browser, it may expose you doing so to the sender, due to the presence of specially crafted image URLs, or Javascript.

If that is an issue, it is recommended to use a browser (or browser profile) that does not load images. The same applies to Javascript.


Footnotes

(26)

this is e.g. for the case where the text-part is only a short blurb telling you to use the html-version; see mu4e-view-html-plaintext-ratio-heuristic

(27)

http://www.mbayer.de/html2text/


Next: , Previous: , Up: Message view   [Contents]