Gnus development mailing list
 help / color / mirror / Atom feed
From: Julien Danjou <julien@danjou.info>
To: ding@gnus.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
Date: Sun, 19 Sep 2010 09:27:00 +0200	[thread overview]
Message-ID: <1284881220-16526-1-git-send-email-julien@danjou.info> (raw)
In-Reply-To: <1284881014-16025-1-git-send-email-julien@danjou.info>

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

A second version with ignore-error, like Lars added in schedule function.

 lisp/ChangeLog    |    5 +++++
 lisp/gnus-html.el |   48 ++++++++++++++++++++----------------------------
 2 files changed, 25 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..1bd9ed4 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,17 @@ 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))))))
+                (ignore-errors
+                  (url-retrieve (mm-url-decode-entities-string url)
+                                'gnus-html-image-fetched))))))))))
 
 (provide 'gnus-html)
 
-- 
1.7.1




  reply	other threads:[~2010-09-19  7:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-19  7:23 Julien Danjou
2010-09-19  7:27 ` Julien Danjou [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1284881220-16526-1-git-send-email-julien@danjou.info \
    --to=julien@danjou.info \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).