From f3b146e943cd733fb716c75048f24b73826e5f30 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 2 May 2011 22:41:38 +0000 Subject: [PATCH] Merge changes made in Gnus trunk. gnus-html.el (gnus-html-schedule-image-fetching): Use url-queue-retrieve, if it exists. shr.el (shr-tag-img): Ditto. gnus.el: Autoload more gnus-agent functions. gnus-art.el (gnus-request-article-this-buffer): Store articles in the agent if we haven't already (bug#8502). gnus-async.el (gnus-async-article-callback): Put prefetched articles into the Agent, too. gnus-agent.el (gnus-agent-store-article): New function. --- lisp/gnus/ChangeLog | 15 +++++++++++++++ lisp/gnus/gnus-agent.el | 9 +++++++++ lisp/gnus/gnus-art.el | 5 ++++- lisp/gnus/gnus-async.el | 6 ++++++ lisp/gnus/gnus-html.el | 16 +++++++--------- lisp/gnus/gnus.el | 3 ++- lisp/gnus/shr.el | 11 +++++++---- 7 files changed, 50 insertions(+), 15 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index e4a5aede155..784f374bafa 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,5 +1,20 @@ 2011-05-02 Lars Magne Ingebrigtsen + * gnus-html.el (gnus-html-schedule-image-fetching): Use + url-queue-retrieve, if it exists. + + * shr.el (shr-tag-img): Ditto. + + * gnus.el: Autoload more gnus-agent functions. + + * gnus-art.el (gnus-request-article-this-buffer): Store articles in the + agent if we haven't already (bug#8502). + + * gnus-async.el (gnus-async-article-callback): Put prefetched articles + into the Agent, too. + + * gnus-agent.el (gnus-agent-store-article): New function. + * nnheader.el (nnheader-insert-buffer-substring): Renamed from nntp- and moved from that file for reuse. diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el index 52fbe9da11f..b4f0dc38e7e 100644 --- a/lisp/gnus/gnus-agent.el +++ b/lisp/gnus/gnus-agent.el @@ -3876,6 +3876,15 @@ has been fetched." (insert-file-contents file)) t)))) +(defun gnus-agent-store-article (article group) + (let* ((gnus-command-method (gnus-find-method-for-group group)) + (file (gnus-agent-article-name (number-to-string article) group)) + (file-name-coding-system nnmail-pathname-coding-system) + (coding-system-for-write gnus-cache-coding-system)) + (when (not (file-exists-p file)) + (gnus-make-directory (file-name-directory file)) + (write-region (point-min) (point-max) file nil 'silent)))) + (defun gnus-agent-regenerate-group (group &optional reread) "Regenerate GROUP. If REREAD is t, all articles in the .overview are marked as unread. diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index e03c787d995..690e29cb65a 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -6841,7 +6841,10 @@ If given a prefix, show the hidden text instead." gnus-summary-buffer) (when gnus-keep-backlog (gnus-backlog-enter-article - group article (current-buffer)))) + group article (current-buffer))) + (when (and gnus-agent + (gnus-agent-group-covered-p group)) + (gnus-agent-store-article article group))) (setq result 'article)) (methods (setq gnus-override-method (pop methods))) diff --git a/lisp/gnus/gnus-async.el b/lisp/gnus/gnus-async.el index b7e24b8dcfd..ad85bc5cf76 100644 --- a/lisp/gnus/gnus-async.el +++ b/lisp/gnus/gnus-async.el @@ -237,6 +237,12 @@ that was fetched." (save-excursion (save-restriction (narrow-to-region mark (point-max)) + ;; Put the articles into the agent, if they aren't already. + (when (and gnus-agent + (gnus-agent-group-covered-p group)) + (save-restriction + (narrow-to-region mark (point-max)) + (gnus-agent-store-article article group))) ;; Prefetch images for the groups that want that. (when (fboundp 'gnus-html-prefetch-images) (gnus-html-prefetch-images summary)) diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el index 7c0d63fb246..f380d079d7b 100644 --- a/lisp/gnus/gnus-html.el +++ b/lisp/gnus/gnus-html.el @@ -386,16 +386,14 @@ Use ALT-TEXT for the image string." "Retrieve IMAGE, and place it into BUFFER on arrival." (gnus-message 8 "gnus-html-schedule-image-fetching: buffer %s, image %s" buffer image) - (let ((args (list (car image) - 'gnus-html-image-fetched - (list buffer image)))) - (when (> (length (if (featurep 'xemacs) - (cdr (split-string (function-arglist 'url-retrieve))) - (help-function-arglist 'url-retrieve))) - 4) - (setq args (nconc args (list t)))) + (if (fboundp 'url-queue-retrieve) + (url-queue-retrieve (car image) + 'gnus-html-image-fetched + (list buffer image) t) (ignore-errors - (push (apply #'url-retrieve args) gnus-buffers)))) + (url-retrieve (car image) + 'gnus-html-image-fetched + (list buffer image))))) (defun gnus-html-image-fetched (status buffer image) "Callback function called when image has been fetched." diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 5ff03572832..8797780251a 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -2910,7 +2910,8 @@ gnus-registry.el will populate this if it's loaded.") gnus-agent-save-active gnus-agent-method-p gnus-agent-get-undownloaded-list gnus-agent-fetch-session gnus-summary-set-agent-mark gnus-agent-save-group-info - gnus-agent-request-article gnus-agent-retrieve-headers) + gnus-agent-request-article gnus-agent-retrieve-headers + gnus-agent-store-article gnus-agent-group-covered-p) ("gnus-agent" :interactive t gnus-unplugged gnus-agentize gnus-agent-batch) ("gnus-vm" :interactive t gnus-summary-save-in-vm diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 20865bda5ac..b2e4f1dc61d 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -871,10 +871,13 @@ ones, in case fg and bg are nil." (shr-put-image (shr-get-image-data url) alt)) (t (insert alt) - (ignore-errors - (url-retrieve (shr-encode-url url) 'shr-image-fetched - (list (current-buffer) start (point-marker)) - t)))) + (funcall + (if (fboundp 'url-queue-retrieve) + 'url-queue-retrieve + 'url-retrieve) + (shr-encode-url url) 'shr-image-fetched + (list (current-buffer) start (point-marker)) + t))) (put-text-property start (point) 'keymap shr-map) (put-text-property start (point) 'shr-alt alt) (put-text-property start (point) 'image-url url) -- 2.39.2