Don't bug out when updating multiple headers.
[gnus] / lisp / gnus-html.el
index 4df9a0f..7c0d63f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gnus-html.el --- Render HTML in a buffer.
 
-;; Copyright (C) 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2011  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: html, web
@@ -169,7 +169,14 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
 
 (defun gnus-html-wash-images ()
   "Run through current buffer and replace img tags by images."
-  (let (tag parameters string start end images url alt-text)
+  (let (tag parameters string start end images url alt-text
+           inhibit-images blocked-images)
+    (if (buffer-live-p gnus-summary-buffer)
+       (with-current-buffer gnus-summary-buffer
+         (setq inhibit-images gnus-inhibit-images
+               blocked-images (gnus-blocked-images)))
+      (setq inhibit-images gnus-inhibit-images
+           blocked-images (gnus-blocked-images)))
     (goto-char (point-min))
     ;; Search for all the images first.
     (while (re-search-forward "<img_alt \\([^>]*\\)>" nil t)
@@ -192,15 +199,18 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
                                   (gnus-html-display-image url start end
                                                            ,alt-text))
               'gnus-image (list url start end alt-text)))
-       (gnus-overlay-put (gnus-make-overlay start end)
-                         'local-map gnus-html-image-map)
+       (widget-convert-button
+        'url-link start (point)
+        :help-echo alt-text
+        :keymap gnus-html-image-map
+        url)
        (if (string-match "\\`cid:" url)
            ;; URLs with cid: have their content stashed in other
            ;; parts of the MIME structure, so just insert them
            ;; immediately.
            (let* ((handle (mm-get-content-id (substring url (match-end 0))))
                   (image (when (and handle
-                                    (not gnus-inhibit-images))
+                                    (not inhibit-images))
                            (gnus-create-image
                             (mm-with-part handle (buffer-string))
                             nil t))))
@@ -222,13 +232,8 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
                 :keymap gnus-html-image-map
                 :button-keymap gnus-html-image-map)))
          ;; Normal, external URL.
-         (if (or gnus-inhibit-images
-                 (gnus-html-image-url-blocked-p
-                  url
-                  (if (buffer-live-p gnus-summary-buffer)
-                      (with-current-buffer gnus-summary-buffer
-                        (gnus-blocked-images))
-                    (gnus-blocked-images))))
+         (if (or inhibit-images
+                 (gnus-html-image-url-blocked-p url blocked-images))
              (widget-convert-button
               'link start end
               :action 'gnus-html-insert-image
@@ -390,7 +395,7 @@ Use ALT-TEXT for the image string."
             4)
       (setq args (nconc args (list t))))
     (ignore-errors
-      (apply #'url-retrieve args))))
+      (push (apply #'url-retrieve args) gnus-buffers))))
 
 (defun gnus-html-image-fetched (status buffer image)
   "Callback function called when image has been fetched."
@@ -471,10 +476,11 @@ Return a string with image data."
                   (let ((image (gnus-rescale-image image (gnus-html-maximum-image-size))))
                     (delete-region start end)
                     (gnus-put-image image alt-text 'external)
-                    (gnus-put-text-property start (point) 'help-echo alt-text)
-                    (gnus-overlay-put
-                    (gnus-make-overlay start (point)) 'local-map
-                    gnus-html-displayed-image-map)
+                   (widget-convert-button
+                    'url-link start (point)
+                    :help-echo alt-text
+                    :keymap gnus-html-displayed-image-map
+                    url)
                     (gnus-put-text-property start (point)
                                            'gnus-alt-text alt-text)
                     (when url
@@ -505,13 +511,15 @@ Return a string with image data."
 ;;;###autoload
 (defun gnus-html-prefetch-images (summary)
   (when (buffer-live-p summary)
-    (let ((blocked-images (with-current-buffer summary
-                            (gnus-blocked-images))))
+    (let (inhibit-images blocked-images)
+      (with-current-buffer summary
+       (setq inhibit-images gnus-inhibit-images
+             blocked-images (gnus-blocked-images)))
       (save-match-data
        (while (re-search-forward "<img[^>]+src=[\"']\\(http[^\"']+\\)" nil t)
          (let ((url (gnus-html-encode-url
                      (mm-url-decode-entities-string (match-string 1)))))
-           (unless (or gnus-inhibit-images
+           (unless (or inhibit-images
                        (gnus-html-image-url-blocked-p url blocked-images))
               (when (gnus-html-cache-expired url gnus-html-image-cache-ttl)
                 (gnus-html-schedule-image-fetching nil