Function: gnus-agent-retrieve-headers
gnus-agent-retrieve-headers is an autoloaded and byte-compiled
function defined in gnus-agent.el.gz.
Signature
(gnus-agent-retrieve-headers ARTICLES GROUP &optional FETCH-OLD)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-agent.el.gz
(defun gnus-agent-retrieve-headers (articles group &optional fetch-old)
(save-excursion
(gnus-agent-create-buffer)
(let ((gnus-decode-encoded-word-function 'identity)
(gnus-decode-encoded-address-function 'identity)
(file (gnus-agent-article-name ".overview" group))
uncached-articles
(file-name-coding-system nnmail-pathname-coding-system))
(gnus-make-directory (nnheader-translate-file-chars
(file-name-directory file) t))
(when fetch-old
(setq articles (range-uncompress
(cons (if (numberp fetch-old)
(max 1 (- (car articles) fetch-old))
1)
(car (last articles))))))
;; Populate temp buffer with known headers
(when (file-exists-p file)
(with-current-buffer gnus-agent-overview-buffer
(erase-buffer)
(let ((nnheader-file-coding-system
gnus-agent-file-coding-system))
(nnheader-insert-nov-file file (car articles)))))
(if (setq uncached-articles (gnus-agent-uncached-articles articles group
t))
(progn
;; Populate nntp-server-buffer with uncached headers
(set-buffer nntp-server-buffer)
(erase-buffer)
(cond ((not (eq 'nov (let (gnus-agent) ; Turn off agent
(gnus-retrieve-headers
uncached-articles group))))
(nnvirtual-convert-headers))
((eq 'nntp (car gnus-current-select-method))
;; The author of gnus-get-newsgroup-headers-xover
;; reports that the XOVER command is commonly
;; unreliable. The problem is that recently
;; posted articles may not be entered into the
;; NOV database in time to respond to my XOVER
;; query.
;;
;; I'm going to use his assumption that the NOV
;; database is updated in order of ascending
;; article ID. Therefore, a response containing
;; article ID N implies that all articles from 1
;; to N-1 are up-to-date. Therefore, missing
;; articles in that range have expired.
(set-buffer nntp-server-buffer)
(let* ((fetched-articles (list nil))
(tail-fetched-articles fetched-articles)
(min (car articles))
(max (car (last articles))))
;; Get the list of articles that were fetched
(goto-char (point-min))
(let ((pm (point-max))
art)
(while (< (point) pm)
(when (setq art (gnus-agent-read-article-number))
(gnus-agent-append-to-list tail-fetched-articles art))
(forward-line 1)))
;; Clip this list to the headers that will
;; actually be returned
(setq fetched-articles (range-list-intersection
(cdr fetched-articles)
(cons min max)))
;; Clip the uncached articles list to exclude
;; IDs after the last FETCHED header. The
;; excluded IDs may be fetchable using HEAD.
(if (car tail-fetched-articles)
(setq uncached-articles
(range-list-intersection
uncached-articles
(cons (car uncached-articles)
(car tail-fetched-articles)))))
;; Create the list of articles that were
;; "successfully" fetched. Success, in this
;; case, means that the ID should not be
;; fetched again. In the case of an expired
;; article, the header will not be fetched.
(setq uncached-articles
(gnus-sorted-nunion fetched-articles
uncached-articles))
)))
;; Erase the temp buffer
(set-buffer gnus-agent-overview-buffer)
(erase-buffer)
;; Copy the nntp-server-buffer to the temp buffer
(set-buffer nntp-server-buffer)
(copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
;; Merge the temp buffer with the known headers (found on
;; disk in FILE) into the nntp-server-buffer
(when uncached-articles
(gnus-agent-braid-nov uncached-articles file))
;; Save the new set of known headers to FILE
(set-buffer nntp-server-buffer)
(let ((coding-system-for-write
gnus-agent-file-coding-system))
(gnus-agent-check-overview-buffer)
(write-region (point-min) (point-max) file nil 'silent))
(gnus-agent-update-view-total-fetched-for group t)
;; Update the group's article alist to include the newly
;; fetched articles.
(gnus-agent-load-alist group)
(gnus-agent-save-alist group uncached-articles nil)
)
;; Copy the temp buffer to the nntp-server-buffer
(set-buffer nntp-server-buffer)
(erase-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
(car articles)
(car (last articles)))
t)
'nov))