Support a new variable `shr-ignore-cache' to re-fetch images when hitting `g' in...
authorLars Magne Ingebrigtsen <larsi@stories.gnus.org>
Sat, 24 Sep 2011 11:25:23 +0000 (13:25 +0200)
committerLars Magne Ingebrigtsen <larsi@stories.gnus.org>
Sat, 24 Sep 2011 11:25:23 +0000 (13:25 +0200)
lisp/ChangeLog
lisp/gnus-sum.el
lisp/shr.el

index 6845320..2e02c3c 100644 (file)
@@ -1,3 +1,11 @@
+2011-09-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-sum.el (gnus-summary-show-article): Bind `shr-ignore-cache' to
+       re-fetch images.
+
+       * shr.el (shr-tag-img): Support a new variable `shr-ignore-cache' to
+       re-fetch images when hitting `g' in Gnus.
+
 2011-09-22  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * mml.el (mml-inhibit-compute-boundary): New internal variable.
index 423de35..66b6618 100644 (file)
@@ -9611,8 +9611,10 @@ C-u g', show the raw article."
        (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
          (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
    ((not arg)
-    ;; Select the article the normal way.
-    (gnus-summary-select-article nil 'force))
+    (require 'shr)
+    (let ((shr-ignore-cache t))
+      ;; Select the article the normal way.
+      (gnus-summary-select-article nil 'force)))
    ((equal arg '(16))
     ;; C-u C-u g
     (let ((gnus-inhibit-article-treatments t))
index 8faa507..fc2f577 100644 (file)
@@ -112,6 +112,7 @@ cid: URL as the argument.")
 (defvar shr-table-depth 0)
 (defvar shr-stylesheet nil)
 (defvar shr-base nil)
+(defvar shr-ignore-cache nil)
 
 (defvar shr-map
   (let ((map (make-sparse-keymap)))
@@ -896,10 +897,16 @@ ones, in case fg and bg are nil."
            (if (> (string-width alt) 8)
                (shr-insert (truncate-string-to-width alt 8))
              (shr-insert alt))))
-        ((url-is-cached (shr-encode-url url))
+        ((and (not shr-ignore-cache)
+              (url-is-cached (shr-encode-url url)))
          (funcall shr-put-image-function (shr-get-image-data url) alt))
         (t
          (insert alt)
+         (when (and shr-ignore-cache
+                    (url-is-cached (shr-encode-url url)))
+           (let ((file (url-cache-create-filename (shr-encode-url url))))
+             (when (file-exists-p file)
+               (delete-file file))))
          (funcall
           (if (fboundp 'url-queue-retrieve)
               'url-queue-retrieve