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

* [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2010-09-19  7:27 UTC (permalink / raw)
  To: ding; +Cc: Julien Danjou

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




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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-19  7:27 ` Julien Danjou
@ 2010-09-20  4:25   ` Katsumi Yamaoka
  2010-09-20  6:22     ` Adam Sjøgren
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Katsumi Yamaoka @ 2010-09-20  4:25 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> wrote:
> +2010-09-19  Julien Danjou  <julien@danjou.info>
> +
> +	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
> +	than curl.

I'm ok but I think we'd better declare we drop Emacs 21.  Otherwise
we have to offer a substitute for `url-retrieve' for Emacs 21 users.
Currently another thing that stops Emacs 21 from running Gnus is:

While compiling nnimap-parse-response in file gnus/lisp/nnimap.el:
  ** split-string called with 3 arguments, but accepts only 1-2



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

* Re: (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  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  6:26     ` [PATCH] " Reiner Steib
  2010-09-20  8:10     ` Lars Magne Ingebrigtsen
  2 siblings, 1 reply; 13+ messages in thread
From: Adam Sjøgren @ 2010-09-20  6:22 UTC (permalink / raw)
  To: ding

On Mon, 20 Sep 2010 13:25:45 +0900, Katsumi wrote:

> Julien Danjou <julien@danjou.info> wrote:
>> +2010-09-19  Julien Danjou  <julien@danjou.info>
>> +
>> +	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
>> +	than curl.

> I'm ok but I think we'd better declare we drop Emacs 21.  Otherwise
> we have to offer a substitute for `url-retrieve' for Emacs 21 users.

How about XEmacs users?


   O:-),

    Adam

-- 
 "It's my chainsaw                                            Adam Sjøgren
  Division is mine"                                      asjo@koldfront.dk




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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20  4:25   ` Katsumi Yamaoka
  2010-09-20  6:22     ` Adam Sjøgren
@ 2010-09-20  6:26     ` Reiner Steib
  2010-09-20 14:50       ` Ted Zlatanov
  2010-09-20  8:10     ` Lars Magne Ingebrigtsen
  2 siblings, 1 reply; 13+ messages in thread
From: Reiner Steib @ 2010-09-20  6:26 UTC (permalink / raw)
  To: ding

On Mon, Sep 20 2010, Katsumi Yamaoka wrote:

> Julien Danjou <julien@danjou.info> wrote:
>> +2010-09-19  Julien Danjou  <julien@danjou.info>
>> +
>> +	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
>> +	than curl.
>
> I'm ok but I think we'd better declare we drop Emacs 21.  Otherwise
> we have to offer a substitute for `url-retrieve' for Emacs 21 users.

We may as well say that new stuff like gnus-html.el is not supported
on Emacs < 22.  (BTW, it also does not work on XEmacs 21.5 beta:
http://thread.gmane.org/87lj6ylqvl.fsf%40topper.koldfront.dk)

> Currently another thing that stops Emacs 21 from running Gnus is:
>
> While compiling nnimap-parse-response in file gnus/lisp/nnimap.el:
>   ** split-string called with 3 arguments, but accepts only 1-2

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20  4:25   ` Katsumi Yamaoka
  2010-09-20  6:22     ` Adam Sjøgren
  2010-09-20  6:26     ` [PATCH] " Reiner Steib
@ 2010-09-20  8:10     ` Lars Magne Ingebrigtsen
  2010-09-20 10:22       ` Katsumi Yamaoka
  2 siblings, 1 reply; 13+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-20  8:10 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> I'm ok but I think we'd better declare we drop Emacs 21.

I think it's OK to drop Emacs 21 support.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20  6:22     ` Adam Sjøgren
@ 2010-09-20  8:20       ` Frank Schmitt
  2010-09-20 15:43         ` Adam Sjøgren
  0 siblings, 1 reply; 13+ messages in thread
From: Frank Schmitt @ 2010-09-20  8:20 UTC (permalink / raw)
  To: ding

asjo@koldfront.dk (Adam Sjøgren) writes:

> On Mon, 20 Sep 2010 13:25:45 +0900, Katsumi wrote:
>
>> Julien Danjou <julien@danjou.info> wrote:
>>> +2010-09-19  Julien Danjou  <julien@danjou.info>
>>> +
>>> +	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
>>> +	than curl.
>
>> I'm ok but I think we'd better declare we drop Emacs 21.  Otherwise
>> we have to offer a substitute for `url-retrieve' for Emacs 21 users.
>
> How about XEmacs users?

Are there any left? :-)

-- 
Have you ever considered how much text can fit in eighty columns?  Given that a
signature typically contains up to four lines of text, this space allows you to
attach a tremendous amount of valuable information to your messages.  Seize the
opportunity and don't waste your signature on bullshit that nobody cares about.




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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20  8:10     ` Lars Magne Ingebrigtsen
@ 2010-09-20 10:22       ` Katsumi Yamaoka
  2010-09-20 10:28         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Katsumi Yamaoka @ 2010-09-20 10:22 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>> I'm ok but I think we'd better declare we drop Emacs 21.

> I think it's OK to drop Emacs 21 support.

Thanks.  I terminate supporting of Emacs 21.  But I keep supporting
XEmacs 21.4.22, 21.5-b29 and SXEmacs as much as possible.



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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20 10:22       ` Katsumi Yamaoka
@ 2010-09-20 10:28         ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-20 10:28 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> Thanks.  I terminate supporting of Emacs 21.  But I keep supporting
> XEmacs 21.4.22, 21.5-b29 and SXEmacs as much as possible.

Sounds good.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  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
  0 siblings, 2 replies; 13+ messages in thread
From: Ted Zlatanov @ 2010-09-20 14:50 UTC (permalink / raw)
  To: ding

On Mon, 20 Sep 2010 08:26:50 +0200 Reiner Steib <reinersteib+gmane@imap.cc> wrote: 

RS> On Mon, Sep 20 2010, Katsumi Yamaoka wrote:
>> Julien Danjou <julien@danjou.info> wrote:
>>> +2010-09-19  Julien Danjou  <julien@danjou.info>
>>> +
>>> +	* gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather
>>> +	than curl.
>> 
>> I'm ok but I think we'd better declare we drop Emacs 21.  Otherwise
>> we have to offer a substitute for `url-retrieve' for Emacs 21 users.

RS> We may as well say that new stuff like gnus-html.el is not supported
RS> on Emacs < 22.  (BTW, it also does not work on XEmacs 21.5 beta:
RS> http://thread.gmane.org/87lj6ylqvl.fsf%40topper.koldfront.dk)

This should definitely be in etc/NEWS and we should publicize it well
for the next Gnus release.  So the supported list will be:

Emacs 22 and above
XEmacs 21.4.22
XEmacs 21.5-b29
SXEmacs

I am a little worried that Katsumi Yamaoka is the only one fixing XEmacs
problems.

Ted




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

* Re: (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20 14:50       ` Ted Zlatanov
@ 2010-09-20 15:42         ` Adam Sjøgren
  2010-09-20 15:56         ` [PATCH] " Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 13+ messages in thread
From: Adam Sjøgren @ 2010-09-20 15:42 UTC (permalink / raw)
  To: ding

On Mon, 20 Sep 2010 09:50:36 -0500, Ted wrote:

> This should definitely be in etc/NEWS and we should publicize it well
> for the next Gnus release.  So the supported list will be:

> Emacs 22 and above
> XEmacs 21.4.22
> XEmacs 21.5-b29
> SXEmacs

Uh, gnus-html doesn't retrieve images in XEmacs due to different
versions/support of url-retrieve...


  Best regards,

    Adam

-- 
 "It's my chainsaw                                            Adam Sjøgren
  Division is mine"                                      asjo@koldfront.dk




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

* Re: (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20  8:20       ` Frank Schmitt
@ 2010-09-20 15:43         ` Adam Sjøgren
  0 siblings, 0 replies; 13+ messages in thread
From: Adam Sjøgren @ 2010-09-20 15:43 UTC (permalink / raw)
  To: ding

On Mon, 20 Sep 2010 10:20:15 +0200, Frank wrote:

> Are there any left? :-)

Yup.

And Katsumi Yamaoka usually is very quick and efficient in fixing things
so they work in XEmacs as well (yes, the few of us that are left are
spoiled :-)).

15+ years of habit is hard to change.

I have overcome some of the hurdles in trying to migrate to GNU Emacs
(cursor-width at end of line, minibuffer behaviour when opening a file
at typing ~ or /), but I still struggle with figuring out how to make
emacsclient behave as gnuclient does, and the different keybindings in
dired are hard to change in my hardwired fingers.


  Best regards,

    Adam

-- 
 "It's my chainsaw                                            Adam Sjøgren
  Division is mine"                                      asjo@koldfront.dk




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

* Re: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl
  2010-09-20 14:50       ` Ted Zlatanov
  2010-09-20 15:42         ` Adam Sjøgren
@ 2010-09-20 15:56         ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 13+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-20 15:56 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> This should definitely be in etc/NEWS and we should publicize it well
> for the next Gnus release.  So the supported list will be:
>
> Emacs 22 and above
> XEmacs 21.4.22
> XEmacs 21.5-b29
> SXEmacs

I've added this to gnus-news.texi.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ 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).