Import Gnus v5.10.3.
[elisp/gnus.git-] / lisp / mm-view.el
index 9de2f94..f6e4a66 100644 (file)
@@ -54,7 +54,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-render-with-stdin nil
+    (w3m-standalone mm-inline-wash-with-stdin nil
                    "w3m" "-dump" "-T" "text/html")
     (links mm-inline-wash-with-file
           mm-links-remove-leading-blank
     (setq mm-w3m-setup t))
   (setq w3m-display-inline-images mm-inline-text-html-with-images))
 
+(defun mm-w3m-cid-retrieve-1 (url handle)
+  (dolist (elem handle)
+    (when (and (listp elem)
+              (equal url (mm-handle-id elem)))
+      (mm-insert-part elem)
+      (throw 'found-handle (mm-handle-media-type 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)
     (setq url (concat "<" (substring url (match-end 0)) ">"))
     (catch 'found-handle
-      (dolist (handle (with-current-buffer w3m-current-buffer
-                       gnus-article-mime-handles))
-       (when (and (listp handle)
-                  (equal url (mm-handle-id handle)))
-         (mm-insert-part handle)
-         (throw 'found-handle (mm-handle-media-type handle)))))))
+      (let ((handles (with-current-buffer w3m-current-buffer
+                      gnus-article-mime-handles)))
+       (if (mm-multiple-handles handles)
+           (dolist (handle handles)
+             (mm-w3m-cid-retrieve-1 url handle))
+         (mm-w3m-cid-retrieve-1 url handles))))))
 
 (eval-and-compile
   (unless (or (featurep 'xemacs)
              (>= emacs-major-version 21))
     (defvar mm-w3m-mode-map nil
-      "Keymap for text/html part rendered by `mm-w3m-preview-text/html'.
-This map is overwritten by `mm-w3m-local-map-property' based on the
-value of `w3m-minor-mode-map'.  Therefore, in order to add some
-commands to this map, add them to `w3m-minor-mode-map' instead of this
-map.")))
+      "Keymap for text/html parts rendered by emacs-w3m.
+This keymap will be bound only when Emacs 20 is running and overwritten
+by the value of `w3m-minor-mode-map'.  In order to add some commands to
+this keymap, add them to `w3m-minor-mode-map' instead of this keymap.")))
 
 (defun mm-w3m-local-map-property ()
   (when (and (boundp 'w3m-minor-mode-map) w3m-minor-mode-map)
@@ -255,6 +261,7 @@ map.")))
          (add-text-properties
           (point-min) (point-max)
           (nconc (mm-w3m-local-map-property)
+                 ;; Put the mark meaning this part was rendered by emacs-w3m.
                  '(mm-inline-text-html-with-w3m t)))))
       (mm-handle-set-undisplayer
        handle
@@ -439,7 +446,8 @@ map.")))
              gnus-article-prepare-hook
              (gnus-newsgroup-charset
               (or charset gnus-newsgroup-charset)))
-         (run-hooks 'gnus-article-decode-hook)
+         (let ((gnus-original-article-buffer (mm-handle-buffer handle)))
+           (run-hooks 'gnus-article-decode-hook))
          (gnus-article-prepare-display)
          (setq handles gnus-article-mime-handles))
        (goto-char (point-min))