+2002-01-10 ShengHuo ZHU <zsh@cs.rochester.edu>
+
+ * 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 <yamaoka@jpl.org>
* gnus-spec.el (gnus-spec-tab): Deal with wide characters.
(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))
(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
(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))
"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."
(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)
(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)
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)
(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
("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
(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)))
(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))))
(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)