Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
[bpt/emacs.git] / lisp / gnus / mm-view.el
index 73cab0a..5972a06 100644 (file)
     (html2text  html2text))
   "The attributes of washer types for text/html.")
 
+(defcustom mm-fill-flowed t
+  "If non-nil an format=flowed article will be displayed flowed."
+  :type 'boolean
+  :version "22.1"
+  :group 'mime-display)
+
 ;;; Internal variables.
 
 ;;;
 
 (defun mm-w3m-cid-retrieve-1 (url handle)
   (dolist (elem handle)
-    (when (listp elem)
-      (if (equal url (mm-handle-id elem))
-         (progn
-           (mm-insert-part elem)
-           (throw 'found-handle (mm-handle-media-type elem))))
-      (if (equal "multipart" (mm-handle-media-supertype elem))
-         (mm-w3m-cid-retrieve-1 url elem)))))
+    (when (consp elem)
+      (when (equal url (mm-handle-id elem))
+       (mm-insert-part elem)
+       (throw 'found-handle (mm-handle-media-type elem)))
+      (when (and (stringp (car elem))
+                (equal "multipart" (mm-handle-media-supertype elem)))
+       (mm-w3m-cid-retrieve-1 url elem)))))
 
 (defun mm-w3m-cid-retrieve (url &rest args)
   "Insert a content pointed by URL if it has the cid: scheme."
   (when (string-match "\\`cid:" url)
-    (catch 'found-handle
-      (mm-w3m-cid-retrieve-1 (concat "<" (substring url (match-end 0)) ">")
-                            (with-current-buffer w3m-current-buffer
-                              gnus-article-mime-handles)))))
+    (or (catch 'found-handle
+         (mm-w3m-cid-retrieve-1
+          (setq url (concat "<" (substring url (match-end 0)) ">"))
+          (with-current-buffer w3m-current-buffer
+            gnus-article-mime-handles)))
+       (prog1
+           nil
+         (message "Failed to find \"Content-ID: %s\"" url)))))
 
 (defun mm-inline-text-html-render-with-w3m (handle)
   "Render a text/html part using emacs-w3m."
          (mm-insert-part handle)
          (goto-char (point-max)))
       (insert (mm-decode-string (mm-get-part handle) charset)))
-    (when (and (equal type "plain")
+    (when (and mm-fill-flowed
+              (equal type "plain")
               (equal (cdr (assoc 'format (mm-handle-type handle)))
                      "flowed"))
       (save-restriction
              ;; disable prepare hook
              gnus-article-prepare-hook
              (gnus-newsgroup-charset
-              (or charset gnus-newsgroup-charset)))
+              (unless (eq charset 'gnus-decoded) ;; mm-uu might set it.
+                (or charset gnus-newsgroup-charset))))
          (let ((gnus-original-article-buffer (mm-handle-buffer handle)))
            (run-hooks 'gnus-article-decode-hook))
          (gnus-article-prepare-display)