Function: nntp-retrieve-headers

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

Signature

(nntp-retrieve-headers ARTICLES &optional GROUP SERVER FETCH-OLD)

Documentation

Retrieve the headers of ARTICLES.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nntp.el.gz
(deffoo nntp-retrieve-headers (articles &optional group server fetch-old)
  "Retrieve the headers of ARTICLES."
  (nntp-with-open-group
   group server
   (with-current-buffer (nntp-find-connection-buffer nntp-server-buffer)
     (erase-buffer)
     (if (and (not gnus-nov-is-evil)
              (not nntp-nov-is-evil)
              (nntp-retrieve-headers-with-xover articles fetch-old))
         ;; We successfully retrieved the headers via XOVER.
         'nov
       ;; XOVER didn't work, so we do it the hard, slow and inefficient
       ;; way.
       (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)
             article)
         ;; Send HEAD commands.
         (while (setq article (pop articles))
           (nntp-send-command
            nil
            "HEAD" (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)
                        (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 headers... %d%%"
                                      (floor (* received 100.0) number)))
               (nntp-accept-response))))
         (and (numberp nntp-large-newsgroup)
              (> number nntp-large-newsgroup)
              (nnheader-message 6 "NNTP: Receiving headers...done"))

         ;; Now all of replies are received.  Fold continuation lines.
         (nnheader-fold-continuation-lines)
         ;; Remove all "\r"'s.
         (nnheader-strip-cr)
	 (nntp-copy-to-buffer nntp-server-buffer (point-min) (point-max))
         'headers)))))