Merge branch 'master' of https://git.gnus.org/gnus
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 22 Sep 2010 19:46:31 +0000 (21:46 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 22 Sep 2010 19:46:31 +0000 (21:46 +0200)
lisp/ChangeLog
lisp/gnus-html.el

index fe339b9..870cedc 100644 (file)
@@ -1,3 +1,11 @@
+2010-09-22  Julien Danjou  <julien@danjou.info>
+
+       * gnus-html.el (gnus-html-image-automatic-caching): Add custom
+       variable.
+       (gnus-html-image-fetched): Only cache if
+       gnus-html-image-automatic-caching is set.
+       (gnus-html-image-fetched): Check for errors.
+
 2010-09-22  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-start.el (gnus-read-active-for-groups): Only run -request-scan
index f796bde..6879bb2 100644 (file)
 (require 'browse-url)
 
 (defcustom gnus-html-image-cache-ttl (days-to-time 7)
-  "Time in seconds used to cache the image on disk."
+  "Time used to determine if we should use images from the cache."
   :version "24.1"
   :group 'gnus-art
   :type 'integer)
 
+(defcustom gnus-html-image-automatic-caching t
+  "Whether automatically cache retrieve images."
+  :version "24.1"
+  :group 'gnus-art
+  :type 'boolean)
+
 (defcustom gnus-html-frame-width 70
   "What width to use when rendering HTML."
   :version "24.1"
@@ -345,14 +351,17 @@ Use ALT-TEXT for the image string."
                   (list buffer image))))
 
 (defun gnus-html-image-fetched (status buffer image)
-  (url-store-in-cache (current-buffer))
-  (when (and (or (search-forward "\n\n" nil t)
-                 (search-forward "\r\n\r\n" nil t))
-             (buffer-live-p buffer))
-    (let ((data (buffer-substring (point) (point-max))))
-      (with-current-buffer buffer
-        (let ((inhibit-read-only t))
-          (gnus-html-put-image data (car image) (cadr image))))))
+  "Callback function called when image has been fetched."
+  (unless (plist-get status :error)
+    (when gnus-html-image-automatic-caching
+      (url-store-in-cache (current-buffer)))
+    (when (and (or (search-forward "\n\n" nil t)
+                   (search-forward "\r\n\r\n" nil t))
+               (buffer-live-p buffer))
+      (let ((data (buffer-substring (point) (point-max))))
+        (with-current-buffer buffer
+          (let ((inhibit-read-only t))
+            (gnus-html-put-image data (car image) (cadr image)))))))
   (kill-buffer (current-buffer)))
 
 (defun gnus-html-get-image-data (url)