From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/71057 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] (gnus-html-prefetch-images): Use `url-retrieve' rather than curl Date: Sun, 19 Sep 2010 09:27:00 +0200 Message-ID: <1284881220-16526-1-git-send-email-julien@danjou.info> References: <1284881014-16025-1-git-send-email-julien@danjou.info> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1284881271 8421 80.91.229.12 (19 Sep 2010 07:27:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 19 Sep 2010 07:27:51 +0000 (UTC) Cc: Julien Danjou To: ding@gnus.org Original-X-From: ding-owner+M19430@lists.math.uh.edu Sun Sep 19 09:27:49 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OxEJQ-0006sV-F7 for ding-account@gmane.org; Sun, 19 Sep 2010 09:27:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1OxEJM-0006wh-Dd; Sun, 19 Sep 2010 02:27:44 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1OxEJK-0006wU-UY for ding@lists.math.uh.edu; Sun, 19 Sep 2010 02:27:42 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1OxEJG-0005oX-OH for ding@lists.math.uh.edu; Sun, 19 Sep 2010 02:27:42 -0500 Original-Received: from prometheus.naquadah.org ([212.85.154.174] helo=mx1.naquadah.org) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1OxEJE-0005os-00 for ; Sun, 19 Sep 2010 09:27:36 +0200 Original-Received: by mx1.naquadah.org (Postfix, from userid 8) id 2E8A25C154; Sun, 19 Sep 2010 09:27:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on prometheus.naquadah.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=4.5 tests=ALL_TRUSTED,BAYES_00, URIBL_RHS_DOB autolearn=no version=3.3.1 Original-Received: from keller.adm.naquadah.org (unknown [IPv6:2a01:e35:2e39:e900:222:faff:fe9d:ce44]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.naquadah.org (Postfix) with ESMTPSA id C48BB5C142; Sun, 19 Sep 2010 09:27:01 +0200 (CEST) Original-Received: from jd by keller.adm.naquadah.org with local (Exim 4.72) (envelope-from ) id 1OxEIf-0004K6-7G; Sun, 19 Sep 2010 09:27:01 +0200 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1284881014-16025-1-git-send-email-julien@danjou.info> X-Spam-Score: -0.4 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:71057 Archived-At: Signed-off-by: Julien Danjou --- 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 + + * gnus-html.el (gnus-html-prefetch-images): Use `url-retrieve' rather + than curl. + 2010-09-19 Lars Magne Ingebrigtsen * 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 "