From: yamaoka Date: Thu, 10 Jan 2002 22:44:09 +0000 (+0000) Subject: Synch with Oort Gnus. X-Git-Tag: t-gnus-6_15_5-02-quimby~18 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72d4e01800a11f08c04173e1868a8683070e0463;p=elisp%2Fgnus.git- Synch with Oort Gnus. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7f3f6c7..5cbef65 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,27 @@ +2002-01-10 ShengHuo ZHU + + * nnkiboze.el (nnkiboze-request-article): Use + gnus-agent-request-article. + + * nnagent.el (nnagent-retrieve-headers): Don't use nnml + function. Insert undownloaded NOV. + + * gnus-agent.el (gnus-agent-retrieve-headers): New function. + (gnus-agent-request-article): New function. + + * gnus.el (gnus-agent-cache): New variable. + + * gnus-int.el (gnus-retrieve-headers): Use + gnus-agent-retrieve-headers. + (gnus-request-head): Use gnus-agent-request-article. + (gnus-request-body): Ditto. + + * gnus-art.el (gnus-request-article-this-buffer): Use + gnus-agent-request-article. + + * gnus-sum.el (gnus-summary-read-group-1): Don't show the first + article if it is undownloaded. + 2002-01-10 Katsumi Yamaoka * gnus-spec.el (gnus-spec-tab): Deal with wide characters. diff --git a/lisp/gnus-agent.el b/lisp/gnus-agent.el index 8534895..e96308e 100644 --- a/lisp/gnus-agent.el +++ b/lisp/gnus-agent.el @@ -1021,7 +1021,7 @@ the actual number of articles toggled is returned." (len (length articles)) (gnus-decode-encoded-word-function 'identity) (file (gnus-agent-article-name ".overview" group)) - i) + i gnus-agent-cache) ;; Check the number of articles is not too large. (when (and (integerp gnus-agent-large-newsgroup) (< 0 gnus-agent-large-newsgroup)) @@ -1803,6 +1803,74 @@ The following commands are available: (gnus-group-send-queue) (gnus-agent-fetch-session)) +(defun gnus-agent-retrieve-headers (articles group &optional fetch-old) + (save-excursion + (gnus-agent-create-buffer) + (let ((gnus-decode-encoded-word-function 'identity) + (file (gnus-agent-article-name ".overview" group)) + cached-articles uncached-articles) + (gnus-make-directory (nnheader-translate-file-chars + (file-name-directory file) t)) + (when (file-exists-p file) + (with-current-buffer gnus-agent-overview-buffer + (erase-buffer) + (nnheader-insert-file-contents file) + (goto-char (point-min)) + (while (not (eobp)) + (when (looking-at "[0-9]") + (push (read (current-buffer)) cached-articles)) + (forward-line 1)) + (setq cached-articles (sort cached-articles '<)))) + (when (setq uncached-articles + (gnus-set-difference articles cached-articles)) + (let (gnus-agent-cache) + (unless (eq 'nov + (gnus-retrieve-headers + uncached-articles group fetch-old)) + (nnvirtual-convert-headers))) + (set-buffer nntp-server-buffer) + (with-current-buffer gnus-agent-overview-buffer + (erase-buffer)) + (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max)) + (when (and uncached-articles (file-exists-p file)) + (gnus-agent-braid-nov group uncached-articles file)) + (write-region-as-coding-system gnus-agent-file-coding-system + (point-min) (point-max) + file nil 'silent) + (gnus-agent-save-alist group uncached-articles nil) + (gnus-agent-open-history) + (setq gnus-agent-current-history (gnus-agent-history-buffer)) + (gnus-agent-enter-history + "last-header-fetched-for-session" + (list (cons group (nth (- (length articles) 1) articles))) + (time-to-days (current-time))) + (gnus-agent-save-history))) + (set-buffer nntp-server-buffer) + (insert-buffer-substring gnus-agent-overview-buffer) + (if (and fetch-old + (not (numberp fetch-old))) + t ; Don't remove anything. + (nnheader-nov-delete-outside-range + (if fetch-old (max 1 (- (car articles) fetch-old)) + (car articles)) + (car (last articles))) + t) + 'nov)) + +(defun gnus-agent-request-article (article group) + "Retrieve ARTICLE in GROUP from the agent cache." + (let* ((gnus-command-method (gnus-find-method-for-group group)) + (file (concat + (gnus-agent-directory) + (gnus-agent-group-path group) "/" + (number-to-string article))) + (buffer-read-only nil)) + (when (file-exists-p file) + (erase-buffer) + (gnus-kill-all-overlays) + (insert-file-contents-as-coding-system gnus-cache-coding-system file) + t))) + (provide 'gnus-agent) ;;; gnus-agent.el ends here diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index 899cc01..233d66f 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -5260,6 +5260,11 @@ T-gnus change: Insert an article into `gnus-original-article-buffer'." (numberp article) (gnus-cache-request-article article group)) 'article) + ;; Check the agent cache. + ((and gnus-agent gnus-agent-cache gnus-plugged + (numberp article) + (gnus-agent-request-article article group)) + 'article) ;; Get the article and put into the article buffer. ((or (stringp article) (numberp article)) diff --git a/lisp/gnus-int.el b/lisp/gnus-int.el index 2adb5c1..f1dec1a 100644 --- a/lisp/gnus-int.el +++ b/lisp/gnus-int.el @@ -301,11 +301,16 @@ this group uses will be queried." "Request headers for ARTICLES in GROUP. If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." (let ((gnus-command-method (gnus-find-method-for-group group))) - (if (and gnus-use-cache (numberp (car articles))) - (gnus-cache-retrieve-headers articles group fetch-old) + (cond + ((and gnus-use-cache (numberp (car articles))) + (gnus-cache-retrieve-headers articles group fetch-old)) + ((and gnus-agent gnus-agent-cache gnus-plugged + (gnus-agent-method-p gnus-command-method)) + (gnus-agent-retrieve-headers articles group fetch-old)) + (t (funcall (gnus-get-function gnus-command-method 'retrieve-headers) articles (gnus-group-real-name group) - (nth 1 gnus-command-method) fetch-old)))) + (nth 1 gnus-command-method) fetch-old))))) (defun gnus-retrieve-articles (articles group) "Request ARTICLES in GROUP." @@ -370,6 +375,11 @@ If BUFFER, insert the article in that group." (gnus-cache-request-article article group)) (setq res (cons group article) clean-up t)) + ((and gnus-agent gnus-agent-cache gnus-plugged + (numberp article) + (gnus-agent-request-article article group)) + (setq res (cons group article) + clean-up t)) ;; Use `head' function. ((fboundp head) (setq res (funcall head article (gnus-group-real-name group) @@ -399,6 +409,12 @@ If BUFFER, insert the article in that group." (gnus-cache-request-article article group)) (setq res (cons group article) clean-up t)) + ;; Check the agent cache. + ((and gnus-agent gnus-agent-cache gnus-plugged + (numberp article) + (gnus-agent-request-article article group)) + (setq res (cons group article) + clean-up t)) ;; Use `head' function. ((fboundp head) (setq res (funcall head article (gnus-group-real-name group) diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 8b999fc..5d0baf4 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -3313,7 +3313,9 @@ If SHOW-ALL is non-nil, already read articles are also listed." gnus-auto-select-first) (progn (gnus-configure-windows 'summary) - (gnus-summary-goto-article (gnus-summary-article-number))) + (let ((art (gnus-summary-article-number))) + (unless (memq art gnus-newsgroup-undownloaded) + (gnus-summary-goto-article art)))) ;; Don't select any articles. (gnus-summary-position-point) (gnus-configure-windows 'summary 'force) diff --git a/lisp/gnus.el b/lisp/gnus.el index 054b707..076002a 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -1798,6 +1798,9 @@ face." (defvar gnus-plugged t "Whether Gnus is plugged or not.") +(defvar gnus-agent-cache t + "Whether Gnus use agent cache.") + (defcustom gnus-default-charset 'iso-8859-1 "Default charset assumed to be used when viewing non-ASCII characters. This variable is overridden on a group-to-group basis by the @@ -2197,7 +2200,8 @@ gnus-newsrc-hashtb should be kept so that both hold the same information.") ("gnus-agent" gnus-open-agent gnus-agent-get-function gnus-agent-save-groups 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-summary-set-agent-mark gnus-agent-save-group-info + gnus-agent-request-article gnus-agent-retrieve-headers) ("gnus-agent" :interactive t gnus-unplugged gnus-agentize gnus-agent-batch) ("gnus-vm" :interactive t gnus-summary-save-in-vm diff --git a/lisp/nnagent.el b/lisp/nnagent.el index 6a3b7be..3d7ac9a 100644 --- a/lisp/nnagent.el +++ b/lisp/nnagent.el @@ -128,6 +128,43 @@ (append-to-file (point-min) (point-max) (gnus-agent-lib-file "flags"))) nil) +(deffoo nnagent-retrieve-headers (articles &optional group server fetch-old) + (let ((file (gnus-agent-article-name ".overview" group)) + (arts articles) n) + (save-excursion + (set-buffer nntp-server-buffer) + (erase-buffer) + (nnheader-insert-file-contents file) + (goto-char (point-min)) + (while (and arts (not (eobp))) + (cond + ((looking-at "[0-9]") + (setq n (read (current-buffer))) + (if (> n (car arts)) + (beginning-of-line)) + (while (and arts (> n (car arts))) + (insert (format + "%d\t[Undownloaded article %d]\tGnus Agent\t\t\t\n" + (car arts) (car arts))) + (pop arts)) + (if (= n (car arts)) + (pop arts)))) + (forward-line 1)) + (while (and arts) + (insert (format + "%d\t[Undownloaded article %d]\tGnus Agent\t\t\t\n" + (car arts) (car arts))) + (pop arts)) + (if (and fetch-old + (not (numberp fetch-old))) + t ; Don't remove anything. + (nnheader-nov-delete-outside-range + (if fetch-old (max 1 (- (car articles) fetch-old)) + (car articles)) + (car (last articles))) + t) + 'nov))) + (deffoo nnagent-request-group (group &optional server dont-check) (nnoo-parent-function 'nnagent 'nnml-request-group (list group (nnagent-server server) dont-check))) @@ -178,10 +215,6 @@ (nnoo-parent-function 'nnagent 'nnml-request-scan (list group (nnagent-server server)))) -(deffoo nnagent-retrieve-headers (sequence &optional group server fetch-old) - (nnoo-parent-function 'nnagent 'nnml-retrieve-headers - (list sequence group (nnagent-server server) fetch-old))) - (deffoo nnagent-set-status (article name value &optional group server) (nnoo-parent-function 'nnagent 'nnml-set-status (list article name value group (nnagent-server server)))) diff --git a/lisp/nnkiboze.el b/lisp/nnkiboze.el index b705d2e..f23c7a5 100644 --- a/lisp/nnkiboze.el +++ b/lisp/nnkiboze.el @@ -110,7 +110,8 @@ (setq num (string-to-int (match-string 2 xref)) group (match-string 1 xref)) (or (with-current-buffer buffer - (gnus-cache-request-article num group)) + (or (gnus-cache-request-article num group) + (gnus-agent-request-article num group))) (gnus-request-article num group buffer))))) (deffoo nnkiboze-request-scan (&optional group server)