djcb/mu — pull request #267 by leathekd (2013-09-10 01:29:29+00:00)
Title: Pluggable renderers

This branch adds another extension point to mu4e inside the
```mu4e-view``` function. ```mu4e-view-render-func``` takes the msg
and handles the inserting and formatting of the message. It is
similar to ```mu4e-view-func``` but tighter in scope. I.e., in cases
where you want to override the rendering but not the behavior around
embedding and various state management between the view and headers
buffer.

The motivating factor was that I wanted to use w3m for rendering HTML
parts. If the txt part is chosen for rendering the new w3m renderer
will fall back to the default (current) rendering function.

New vars:
- ```mu4e-view-render-func```: used to determine what function will
be called to render the message. Defaults to
```mu4e-default-render-handler```, the current rendering
functionality.
- ```mu4e-w3m-fill-column```: used to influence how many columns w3m
will utilize when rendering.

Other vars used:
- ```mu4e-view-html-plaintext-ratio-heuristic```: works the same as
now
- ```mu4e-view-prefer-html```: works the same as now
- ```mu4e-view-show-images```: instructs w3m to display images

To use this new renderer the following should be added to the user's
init file:
``` lisp
;; so that w3m remains optional for people who don't use mu4e-w3m
(require 'mu4e-w3m)
;; actually use it
(setq mu4e-view-render-func 'mu4e-w3m-render-handler)
```

I've been using it with ```mu4e-view-prefer-html``` set to true and it
has worked quite well, though I can't claim to have run every mu4e
command with the w3m renderer.

One issue that comes to mind is that some HTML emails don't use the
standard ">" character for quotes. In this case those quotes will be
indented but not colorized. Nor will they disappear when hiding
citations. I am not 100% sure there is a general solution as I don't
know all of the different ways that HTML email clients indent text.
Gmail seems to use ```blockquote``` tags and I suppose something could
be done in that case, but didn't know if it was worth the effort.

I did notice the other pull request but as there hadn't been much
movement on it in awhile I thought I'd see if there was any interest
in this approach.

Thanks, and let me know if you have any suggestions or other tests
that I should run.