Function: nntp-retrieve-articles

nntp-retrieve-articles is a byte-compiled function defined in nntp.el.gz.

Signature

(nntp-retrieve-articles ARTICLES &optional GROUP SERVER)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nntp.el.gz
(deffoo nntp-retrieve-articles (articles &optional group server)
  (nntp-with-open-group
    group server
   (save-excursion
     (let ((number (length articles))
           (articles articles)
           (count 0)
           (received 0)
           (last-point (point-min))
           (buf (nntp-find-connection-buffer nntp-server-buffer))
           (nntp-inhibit-erase t)
           (map (apply #'vector articles))
           (point 1)
           article)
       (set-buffer buf)
       (erase-buffer)
       ;; Send ARTICLE command.
       (while (setq article (pop articles))
         (nntp-send-command
          nil
          "ARTICLE" (if (numberp article)
                        (int-to-string article)
                      ;; `articles' is either a list of article numbers
                      ;; or a list of article IDs.
                      article))
         (cl-incf count)
         ;; Every 400 requests we have to read the stream in
         ;; order to avoid deadlocks.
         (when (or (null articles)	;All requests have been sent.
                   (zerop (% count nntp-maximum-request)))
           (nntp-accept-response)
           (while (progn
                    (set-buffer buf)
                    (goto-char last-point)
                    ;; Count replies.
                    (while (nntp-next-result-arrived-p)
                      (aset map received (cons (aref map received) (point)))
                      (setq last-point (point))
                      (cl-incf received))
                    (< received count))
             ;; If number of headers is greater than 100, give
             ;;  informative messages.
             (and (numberp nntp-large-newsgroup)
                  (> number nntp-large-newsgroup)
                  (zerop (% received 20))
                  (nnheader-message 6 "NNTP: Receiving articles... %d%%"
                                    (floor (* received 100.0) number)))
             (nntp-accept-response))))
       (and (numberp nntp-large-newsgroup)
            (> number nntp-large-newsgroup)
            (nnheader-message 6 "NNTP: Receiving articles...done"))

       ;; Now we have all the responses.  We go through the results,
       ;; wash it and copy it over to the server buffer.
       (set-buffer nntp-server-buffer)
       (erase-buffer)
       (setq last-point (point-min))
       (mapcar
        (lambda (entry)
          (narrow-to-region
           (setq point (goto-char (point-max)))
           (progn
	     (nnheader-insert-buffer-substring buf last-point (cdr entry))
             (point-max)))
          (setq last-point (cdr entry))
          (nntp-decode-text)
          (widen)
          (cons (car entry) point))
        map)))))