Allow treatment functions to run on html bits by default
[gnus] / lisp / gnus-art.el
index 435a103..a3f5311 100644 (file)
@@ -33,6 +33,7 @@
 (defvar w3m-minor-mode-map)
 
 (require 'gnus)
+(require 'gnus-util)
 (require 'gnus-sum)
 (require 'gnus-spec)
 (require 'gnus-int)
@@ -1121,8 +1122,8 @@ parts.  When nil, redisplay article."
           (const :tag "Header" head)))
 
 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
-                                  "text/x-patch")
-  "Parts to treat.")
+                                  "text/x-patch" "text/html")
+  "Part types eligible for treatment.")
 
 (defvar gnus-inhibit-treatment nil
   "Whether to inhibit treatment.")
@@ -2718,7 +2719,7 @@ If READ-CHARSET, ask for a coding system."
       (while (re-search-forward
              "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
        (replace-match "\\1\\3" t)))
-    (when (interactive-p)
+    (when (gmm-called-interactively-p 'any)
       (gnus-treat-article nil))))
 
 (defun article-wash-html ()
@@ -2759,14 +2760,12 @@ summary buffer."
             (progn
               (or how (setq how gnus-article-browse-delete-temp))
               (if (eq how 'ask)
-                  (let* ((files (length gnus-article-browse-html-temp-list))
-                         (ans (gnus-y-or-n-p
-                               (if (= files 1)
-                                   "Delete the temporary HTML file? "
-                                 (format
-                                  "Delete all %s temporary HTML files? "
-                                  files)))))
-                    (or ans
+                  (let ((files (length gnus-article-browse-html-temp-list)))
+                    (or (gnus-y-or-n-p
+                         (if (= files 1)
+                             "Delete the temporary HTML file? "
+                           (format "Delete all %s temporary HTML files? "
+                                   files)))
                         (setq gnus-article-browse-html-temp-list nil)))
                 how)))
     (dolist (file gnus-article-browse-html-temp-list)
@@ -2879,21 +2878,23 @@ message header will be added to the bodies of the \"text/html\" parts."
             ;; Add a meta html tag to specify charset and a header.
             (cond
              (header
-              (let (title eheader body hcharset coding force-charset)
+              (let (title eheader body hcharset coding)
                 (with-temp-buffer
                   (mm-enable-multibyte)
                   (setq case-fold-search t)
                   (insert header "\n")
                   (setq title (message-fetch-field "subject"))
                   (goto-char (point-min))
-                  (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
+                  (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
+                                            nil t)
                     (replace-match (cond ((match-beginning 1) "&lt;")
                                          ((match-beginning 2) "&gt;")
-                                         (t "&amp;"))))
+                                         ((match-beginning 3) "&amp;")
+                                         (t "<br>\n"))))
                   (goto-char (point-min))
-                  (insert "<pre>\n")
+                  (insert "<div align=\"left\">\n")
                   (goto-char (point-max))
-                  (insert "</pre>\n<hr>\n")
+                  (insert "</div>\n<hr>\n")
                   ;; We have to examine charset one by one since
                   ;; charset specified in parts might be different.
                   (if (eq charset 'gnus-decoded)
@@ -2902,8 +2903,7 @@ message header will be added to the bodies of the \"text/html\" parts."
                                                              charset)
                             title (when title
                                     (mm-encode-coding-string title charset))
-                            body (mm-encode-coding-string content charset)
-                            force-charset t)
+                            body (mm-encode-coding-string content charset))
                     (setq hcharset (mm-find-mime-charset-region (point-min)
                                                                 (point-max)))
                     (cond ((= (length hcharset) 1)
@@ -2934,8 +2934,7 @@ message header will be added to the bodies of the \"text/html\" parts."
                                       body (mm-encode-coding-string
                                             (mm-decode-coding-string
                                              content body)
-                                            charset)
-                                      force-charset t)))
+                                            charset))))
                           (setq charset hcharset
                                 eheader (mm-encode-coding-string
                                          (buffer-string) coding)
@@ -2949,7 +2948,7 @@ message header will be added to the bodies of the \"text/html\" parts."
                   (mm-disable-multibyte)
                   (insert body)
                   (when charset
-                    (mm-add-meta-html-tag handle charset force-charset))
+                    (mm-add-meta-html-tag handle charset t))
                   (when title
                     (goto-char (point-min))
                     (unless (search-forward "<title>" nil t)
@@ -4541,18 +4540,17 @@ commands:
            (gnus-article-mode))
          (setq truncate-lines gnus-article-truncate-lines)
          (current-buffer))
-      (with-current-buffer (gnus-get-buffer-create name)
-       (gnus-article-mode)
-       (setq truncate-lines gnus-article-truncate-lines)
-       (make-local-variable 'gnus-summary-buffer)
-       (setq gnus-summary-buffer
-             (gnus-summary-buffer-name gnus-newsgroup-name))
-       (gnus-summary-set-local-parameters gnus-newsgroup-name)
-       (when article-lapsed-timer
-         (gnus-stop-date-timer))
-       (when gnus-article-update-date-headers
-         (gnus-start-date-timer gnus-article-update-date-headers))
-       (current-buffer)))))
+      (let ((summary gnus-summary-buffer))
+       (with-current-buffer (gnus-get-buffer-create name)
+         (gnus-article-mode)
+         (setq truncate-lines gnus-article-truncate-lines)
+         (set (make-local-variable 'gnus-summary-buffer) summary)
+         (gnus-summary-set-local-parameters gnus-newsgroup-name)
+         (when article-lapsed-timer
+           (gnus-stop-date-timer))
+         (when gnus-article-update-date-headers
+           (gnus-start-date-timer gnus-article-update-date-headers))
+         (current-buffer))))))
 
 (defun gnus-article-stop-animations ()
   (dolist (timer (and (boundp 'timer-list)