(mm-text-html-renderer-alist): Map w3m-standalone to
authorKatsumi Yamaoka <yamaoka@jpl.org>
Fri, 13 Jan 2006 07:14:46 +0000 (07:14 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Fri, 13 Jan 2006 07:14:46 +0000 (07:14 +0000)
 mm-inline-text-html-render-with-w3m-standalone.
(mm-text-html-washer-alist): Map w3m-standalone to
 gnus-article-wash-html-with-w3m-standalone.
(mm-inline-text-html-render-with-w3m-standalone): New function.

lisp/mm-view.el

index d88a789..e7915c3 100644 (file)
@@ -49,8 +49,7 @@
 (defvar mm-text-html-renderer-alist
   '((w3  . mm-inline-text-html-render-with-w3)
     (w3m . mm-inline-text-html-render-with-w3m)
-    (w3m-standalone mm-inline-render-with-stdin nil
-                   "w3m" "-dump" "-T" "text/html")
+    (w3m-standalone . mm-inline-text-html-render-with-w3m-standalone)
     (links mm-inline-render-with-file
           mm-links-remove-leading-blank
           "links" "-dump" file)
@@ -62,8 +61,7 @@
 (defvar mm-text-html-washer-alist
   '((w3  . gnus-article-wash-html-with-w3)
     (w3m . gnus-article-wash-html-with-w3m)
-    (w3m-standalone mm-inline-wash-with-stdin nil
-                   "w3m" "-dump" "-T" "text/html")
+    (w3m-standalone . gnus-article-wash-html-with-w3m-standalone)
     (links mm-inline-wash-with-file
           mm-links-remove-leading-blank
           "links" "-dump" file)
              (delete-region ,(point-min-marker)
                             ,(point-max-marker)))))))))
 
+(defun mm-inline-text-html-render-with-w3m-standalone (handle)
+  "Render a text/html part using w3m."
+  (let ((source (mm-get-part handle))
+       (charset (mail-content-type-get (mm-handle-type handle) 'charset))
+       cs)
+    (unless (and charset
+                (setq cs (mm-charset-to-coding-system charset))
+                (not (eq cs 'ascii)))
+      ;; The default.
+      (setq charset "iso-8859-1"
+           cs 'iso-8859-1))
+    (mm-insert-inline
+     handle
+     (mm-with-unibyte-buffer
+       (insert source)
+       (mm-enable-multibyte)
+       (let ((coding-system-for-write 'binary)
+            (coding-system-for-read cs))
+        (call-process-region
+         (point-min) (point-max)
+         "w3m" t t nil "-dump" "-T" "text/html"
+         "-I" charset "-O" charset))
+       (buffer-string)))))
+
 (defun mm-links-remove-leading-blank ()
   ;; Delete the annoying three spaces preceding each line of links
   ;; output.