Reading HTML mail using vilistextum

#### <COMMERCIAL>

Do you suffer from relatives that always send html mails?
Do you hate those spam mails that are sent in html?
Have you subscribed to a newsletter but it doesn't offer a plain ASCII version?

Stop puzzling what those tags mean! Stop trying to decipher those html entities!
Try using the fabulous Vilistextum for converting your html mail into readable ASCII!

#### </COMMERCIAL>

For the time being, I know how to convert HTML mails for mutt, Gnus 5.8.8 and Gnus 5.10.
Instructions for other mail reader are welcome.

### mutt

Put this in your .mailcap:

    text/html; vilistextum %s - ; copiousoutput

And this in your .muttrc:

    auto_view text/html

### Gnus Oort and newer (5.10, No Gnus)

Put the following lines into your .gnus:

    ;; prefer to show plain text over markup for multipart/alternative
    (setq  mm-discouraged-alternatives (append mm-discouraged-alternatives
                                        '("text/html" "text/richtext")))

    ;; add buttons and emphasize for html MIME parts
    (add-to-list 'gnus-buttonized-mime-types '"text/html")
    (add-to-list 'gnus-article-treat-types "text/html")

    (add-to-list 'mm-text-html-renderer-alist
                 '(vilistextum mm-inline-render-with-file nil
                   "vilistextum" "-l" "-r" "-c" "-s" file "-"))
    (add-to-list 'mm-text-html-washer-alist
                 '(vilistextum mm-inline-wash-with-file nil
                   "vilistextum" "-l" "-r" "-c" "-s" file "-"))
    (setq mm-text-html-renderer 'vilistextum)

### Gnus 5.8.8 resp. 5.9.0

Put this in your .emacs, or .gnus or somewhere else where it might be appropriate:

    ;; ---------------------------------------------------------------------
    ;; prefer to show plain text over markup for multipart/alternative
    (setq  mm-discouraged-alternatives (append mm-discouraged-alternatives
        '("text/html" "text/richtext")))

    ;; adapted from Mark Thomas (swoon@bellatlantic.net)
    ;; use external program to view inline HTML
    (when t ;; change to nil to comment out
      (let ((old-text-html-test (assoc "text/html" mm-inline-media-tests))
            (new-text-html-test '("text/html"
                                  my:gnus-html2text
                                  (lambda (handle)
                                    (fboundp 'my:gnus-html2text)))))
        (if old-text-html-test
            (setcdr old-text-html-test (cdr new-text-html-test))
          (setq mm-inline-media-tests (cons new-text-html-test
                                            mm-inline-media-tests)))))

    ;; function to call to handle text/html attachments
    (defun my:gnus-html2text (handle)
      (let (text)
        (with-temp-buffer
          (mm-insert-part handle)
          (save-window-excursion
            (my:html2text-region (point-min) (point-max))
            (setq text (buffer-string))))
        (mm-insert-inline handle text)))

    (defun my:html2text-region-vilistextum (min max)
      "Replace the region with the result of running vilistextum on it. "
      (interactive "r")
      ;; vilistextum accepts html on stdin
      (call-process-region min max "vilistextum" t t t "-clrs" "-" "-"))

    (defalias 'my:html2text-region 'my:html2text-region-vilistextum)
    ;; ---------------------------------------------------------------------