Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
@ 2010-09-19  7:23 Julien Danjou
  2010-09-19  7:27 ` Julien Danjou
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2010-09-19  7:23 UTC (permalink / raw)
  To: ding; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---

I've been unable to test `gnus-html-prefetch-images' myself because I only
have IMAP, and it does not seems to work with IMAP.

 lisp/ChangeLog    |    5 +++++
 lisp/gnus-html.el |   47 +++++++++++++++++++----------------------------
 2 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 22cca6e..d3febc4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-19  Julien Danjou  <julien@danjou.info>
+
+	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
+	than curl.
+
 2010-09-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* gnus-agent.el (gnus-agent-auto-agentize-methods): Switch the default
diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el
index d3e8c48..4a4eb88 100644
--- a/lisp/gnus-html.el
+++ b/lisp/gnus-html.el
@@ -307,18 +307,20 @@ fit these criteria."
   (expand-file-name (sha1 url) gnus-html-cache-directory))
 
 (defun gnus-html-image-fetched (status buffer image)
-  (when (and (buffer-live-p buffer)
-             ;; If the position of the marker is 1, then that
-             ;; means that the text it was in has been deleted;
-             ;; i.e., that the user has selected a different
-             ;; article before the image arrived.
-             (not (= (marker-position (cadr image)) (point-min))))
-    (let ((file (gnus-html-image-id (car image))))
-      ;; Search the start of the image data
-      (search-forward "\n\n")
-      ;; Write region (image) silently
-      (write-region (point) (point-max) file nil 1)
-      (kill-buffer)
+  (let ((file (gnus-html-image-id (car image))))
+    ;; Search the start of the image data
+    (search-forward "\n\n")
+    ;; Write region (image data) silently
+    (write-region (point) (point-max) file nil 1)
+    (kill-buffer)
+    (when (and (buffer-live-p buffer)
+               ;; If the `image' has no marker, do not replace anything
+               (cadr image)
+               ;; If the position of the marker is 1, then that
+               ;; means that the text it was in has been deleted;
+               ;; i.e., that the user has selected a different
+               ;; article before the image arrived.
+               (not (= (marker-position (cadr image)) (point-min))))
       (with-current-buffer buffer
         (let ((inhibit-read-only t)
               (string (buffer-substring (cadr image) (caddr image))))
@@ -441,27 +443,16 @@ This only works if the article in question is HTML."
 
 ;;;###autoload
 (defun gnus-html-prefetch-images (summary)
-  (let (blocked-images urls)
-    (when (and (buffer-live-p summary)
-	       (executable-find "curl"))
-      (with-current-buffer summary
-	(setq blocked-images gnus-blocked-images))
+  (when (buffer-live-p summary)
+    (let ((blocked-images (with-current-buffer summary
+                            gnus-blocked-images)))
       (save-match-data
 	(while (re-search-forward "<img.*src=[\"']\\([^\"']+\\)" nil t)
 	  (let ((url (match-string 1)))
 	    (unless (gnus-html-image-url-blocked-p url blocked-images)
               (unless (file-exists-p (gnus-html-image-id url))
-                (push (mm-url-decode-entities-string url) urls)
-                (push (gnus-html-image-id url) urls)
-                (push "-o" urls)))))
-	(let ((process
-	       (apply 'start-process
-		      "images" nil "curl"
-		      "-s" "--create-dirs"
-		      "--location"
-		      "--max-time" "60"
-		      urls)))
-	  (gnus-set-process-query-on-exit-flag process nil))))))
+                (url-retrieve (mm-url-decode-entities-string url)
+                              'gnus-html-image-fetched)))))))))
 
 (provide 'gnus-html)
 
-- 
1.7.1




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-20 15:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-19  7:23 [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl Julien Danjou
2010-09-19  7:27 ` Julien Danjou
2010-09-20  4:25   ` Katsumi Yamaoka
2010-09-20  6:22     ` Adam Sjøgren
2010-09-20  8:20       ` Frank Schmitt
2010-09-20 15:43         ` Adam Sjøgren
2010-09-20  6:26     ` [PATCH] " Reiner Steib
2010-09-20 14:50       ` Ted Zlatanov
2010-09-20 15:42         ` Adam Sjøgren
2010-09-20 15:56         ` [PATCH] " Lars Magne Ingebrigtsen
2010-09-20  8:10     ` Lars Magne Ingebrigtsen
2010-09-20 10:22       ` Katsumi Yamaoka
2010-09-20 10:28         ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).