From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/70997 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Use `url' rather than curl Date: Sat, 18 Sep 2010 20:22:42 +0200 Message-ID: <1284834162-24257-1-git-send-email-julien@danjou.info> References: <87eicrmaly.fsf@keller.adm.naquadah.org> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1284834220 28727 80.91.229.12 (18 Sep 2010 18:23:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 18 Sep 2010 18:23:40 +0000 (UTC) Cc: Julien Danjou To: ding@gnus.org Original-X-From: ding-owner+M19370@lists.math.uh.edu Sat Sep 18 20:23:38 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 1Ox24W-0001fb-Ny for ding-account@gmane.org; Sat, 18 Sep 2010 20:23:37 +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 1Ox24N-0001om-O6; Sat, 18 Sep 2010 13:23:27 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Ox24M-0001oa-Bo for ding@lists.math.uh.edu; Sat, 18 Sep 2010 13:23:26 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1Ox24I-0007EV-36 for ding@lists.math.uh.edu; Sat, 18 Sep 2010 13:23:26 -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 1Ox24H-000581-00 for ; Sat, 18 Sep 2010 20:23:21 +0200 Original-Received: by mx1.naquadah.org (Postfix, from userid 8) id 58C085C159; Sat, 18 Sep 2010 20:22:50 +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 E59285C110; Sat, 18 Sep 2010 20:22:45 +0200 (CEST) Original-Received: from jd by keller.adm.naquadah.org with local (Exim 4.72) (envelope-from ) id 1Ox23h-0006Jx-7u; Sat, 18 Sep 2010 20:22:45 +0200 X-Mailer: git-send-email 1.7.1 In-Reply-To: <87eicrmaly.fsf@keller.adm.naquadah.org> X-Spam-Score: -0.4 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:70997 Archived-At: Signed-off-by: Julien Danjou --- lisp/ChangeLog | 5 ++++ lisp/gnus-html.el | 55 +++++++++++++++++++++++----------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cf95e15..832458f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-18 Julien Danjou + + * gnus-html.el (gnus-html-schedule-image-fetching): Use `url' rather + than curl to retrieve images. + 2010-09-18 Lars Magne Ingebrigtsen * nnimap.el (nnimap-update-info): Extend the info so that we can set diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el index e74fd5b..40b74c2 100644 --- a/lisp/gnus-html.el +++ b/lisp/gnus-html.el @@ -33,6 +33,7 @@ (require 'gnus-art) (require 'mm-url) +(require 'url) (defcustom gnus-html-cache-directory (nnheader-concat gnus-directory "html-cache/") "Where Gnus will cache images it downloads from the web." @@ -296,42 +297,34 @@ fit these criteria." (defun gnus-html-schedule-image-fetching (buffer images) (gnus-message 8 "gnus-html-schedule-image-fetching: buffer %s, images %s" buffer images) - (when (executable-find "curl") - (let* ((url (caar images)) - (process (start-process - "images" nil "curl" - "-s" "--create-dirs" - "--location" - "--max-time" "60" - "-o" (gnus-html-image-id url) - (mm-url-decode-entities-string url)))) - (gnus-set-process-query-on-exit-flag process nil) - (set-process-sentinel process 'gnus-html-curl-sentinel) - (gnus-set-process-plist process (list 'images images - 'buffer buffer))))) + (url-retrieve (caar images) + 'gnus-html-image-fetched + (list buffer images))) (defun gnus-html-image-id (url) (expand-file-name (sha1 url) gnus-html-cache-directory)) -(defun gnus-html-curl-sentinel (process event) - (when (string-match "finished" event) - (let* ((images (gnus-process-get process 'images)) - (buffer (gnus-process-get process 'buffer)) - (spec (pop images)) - (file (gnus-html-image-id (car spec)))) - (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 spec)) (point-min)))) - (with-current-buffer buffer - (let ((inhibit-read-only t) - (string (buffer-substring (cadr spec) (caddr spec)))) - (delete-region (cadr spec) (caddr spec)) - (gnus-html-put-image file (cadr spec) string)))) +(defun gnus-html-image-fetched (status buffer images) + (let ((spec (pop images))) + (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 spec)) (point-min)))) + (let ((file (gnus-html-image-id (car spec)))) + ;; 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) + (with-current-buffer buffer + (let ((inhibit-read-only t) + (string (buffer-substring (cadr spec) (caddr spec)))) + (delete-region (cadr spec) (caddr spec)) + (gnus-html-put-image file (cadr spec) string)))) (when images - (gnus-html-schedule-image-fetching buffer images))))) + (gnus-html-schedule-image-fetching buffer images))))) (defun gnus-html-put-image (file point string &optional url alt-text) (when (gnus-graphic-display-p) -- 1.7.1