+2006-01-13 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * gnus-art.el (article-wash-html): Use
+ gnus-summary-show-article-charset-alist if a numeric arg is given.
+ (gnus-article-wash-html-with-w3m-standalone): New function.
+
+ * mm-view.el (mm-text-html-renderer-alist): Map w3m-standalone to
+ 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.
+
2006-01-12 Reiner Steib <Reiner.Steib@gmx.de>
* mm-uu.el (mm-uu-type-alist): Fix previous message-marks commit.
(defun article-wash-html (&optional read-charset)
"Format an HTML article.
-If READ-CHARSET, ask for a coding system."
+If READ-CHARSET, ask for a coding system. If it is a number, the
+charset defined in `gnus-summary-show-article-charset-alist' is used."
(interactive "P")
(save-excursion
(let ((inhibit-read-only t)
charset)
- (when (gnus-buffer-live-p gnus-original-article-buffer)
- (with-current-buffer gnus-original-article-buffer
- (let* ((ct (gnus-fetch-field "content-type"))
- (ctl (and ct
- (ignore-errors
- (mail-header-parse-content-type ct)))))
- (setq charset (and ctl
- (mail-content-type-get ctl 'charset)))
- (when (stringp charset)
- (setq charset (intern (downcase charset)))))))
- (when read-charset
- (setq charset (mm-read-coding-system "Charset: " charset)))
- (unless charset
- (setq charset gnus-newsgroup-charset))
+ (if read-charset
+ (if (or (and (numberp read-charset)
+ (setq charset
+ (cdr
+ (assq read-charset
+ gnus-summary-show-article-charset-alist))))
+ (setq charset (mm-read-coding-system "Charset: ")))
+ (let ((gnus-summary-show-article-charset-alist
+ (list (cons 1 charset))))
+ (with-current-buffer gnus-summary-buffer
+ (gnus-summary-show-article 1)))
+ (error "No charset is given"))
+ (when (gnus-buffer-live-p gnus-original-article-buffer)
+ (with-current-buffer gnus-original-article-buffer
+ (let* ((ct (gnus-fetch-field "content-type"))
+ (ctl (and ct
+ (ignore-errors
+ (mail-header-parse-content-type ct)))))
+ (setq charset (and ctl
+ (mail-content-type-get ctl 'charset)))
+ (when (stringp charset)
+ (setq charset (intern (downcase charset)))))))
+ (unless charset
+ (setq charset gnus-newsgroup-charset)))
(article-goto-body)
(save-window-excursion
(save-restriction
;; Put the mark meaning this part was rendered by emacs-w3m.
'mm-inline-text-html-with-w3m t))))
+(eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
+
+(defun gnus-article-wash-html-with-w3m-standalone ()
+ "Wash the current buffer with w3m."
+ (unless (mm-coding-system-p charset)
+ ;; The default.
+ (setq charset 'iso-8859-1))
+ (let ((coding-system-for-write charset)
+ (coding-system-for-read charset))
+ (call-process-region
+ (point-min) (point-max)
+ "w3m" t t nil "-dump" "-T" "text/html"
+ "-I" (symbol-name charset) "-O" (symbol-name charset))))
+
(defun article-hide-list-identifiers ()
"Remove list identifies from the Subject header.
The `gnus-list-identifiers' variable specifies what to do."
(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)
(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.
+2006-01-13 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * gnus.texi (Article Washing): Additions.
+
2006-01-10 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus.texi (RSS): Document nnrss-wash-html-in-text-plain-parts.
\e$B$r<($9\e(B @code{Content-Type} \e$B%X%C%@!<$r;}$C$F$$$?$J$i$P!"$=$l$O\e(B gnus \e$B$K$h$C\e(B
\e$B$F<+F0E*$K9T$J$o$l$k$3$H$KCm0U$7$F2<$5$$!#\e(B
-\e$B@\F,0z?t$,M?$($i$l$k$H!"J8;z%;%C%H$r?R$M$i$l$^$9!#\e(B
+\e$B@\F,0z?t$,M?$($i$l$k$H!"J8;z%;%C%H$r?R$M$i$l$^$9!#$=$l$,$b$7?tCM$@$C$?$i!"\e(B
+@code{gnus-summary-show-article-charset-alist} (@pxref{Paging the
+Article}) \e$B$GDj5A$5$l$F$$$kJ8;z%;%C%H$,;H$o$l$^$9!#\e(B(\e$BLuCm\e(B: \e$B<B<AE*$K$O!VJ8\e(B
+\e$B;z%;%C%H!W$G$O$J$/$F\e(B @code{coding-system} \e$B$G$9!#\e(B)
@vindex gnus-article-wash-function
\e$B%G%#%U%)%k%H$G$O\e(B @acronym{HTML} \e$B$NJQ49$K\e(B @code{mm-text-html-renderer}
\e$B$j$G$9\e(B:
@table @code
-@item W3
+@item w3
Emacs/W3 \e$B$r;H$$$^$9!#\e(B
@item w3m
@uref{http://emacs-w3m.namazu.org/, emacs-w3m} \e$B$r;H$$$^$9!#\e(B
+@item w3m-standalone
+@uref{http://w3m.sourceforge.net/, w3m} \e$B$r;H$$$^$9!#\e(B
+
@item links
@uref{http://links.sf.net/, Links} \e$B$r;H$$$^$9!#\e(B
usually done automatically by Gnus if the message in question has a
@code{Content-Type} header that says that the message is @acronym{HTML}.
-If a prefix is given, a charset will be asked for.
+If a prefix is given, a charset will be asked for. If it is a number,
+the charset defined in @code{gnus-summary-show-article-charset-alist}
+(@pxref{Paging the Article}) will be used.
@vindex gnus-article-wash-function
The default is to use the function specified by
can use include:
@table @code
-@item W3
+@item w3
Use Emacs/W3.
@item w3m
Use @uref{http://emacs-w3m.namazu.org/, emacs-w3m}.
+@item w3m-standalone
+Use @uref{http://w3m.sourceforge.net/, w3m}.
+
@item links
Use @uref{http://links.sf.net/, Links}.