Function: nnmaildir-retrieve-headers

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

Signature

(nnmaildir-retrieve-headers ARTICLES &optional GNAME SERVER FETCH-OLD)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmaildir.el.gz
(defun nnmaildir-retrieve-headers (articles &optional gname server fetch-old)
  (let ((group (nnmaildir--prepare server gname))
	nlist mlist article num start stop nov insert-nov
	deactivate-mark)
    (setq insert-nov
	  (lambda (article)
	    (setq nov (nnmaildir--update-nov nnmaildir--cur-server group
					     article))
	    (when nov
	      (nnmaildir--cache-nov group article nov)
	      (setq num (nnmaildir--art-num article))
	      (princ num nntp-server-buffer)
	      (insert "\t" (nnmaildir--nov-get-beg nov) "\t"
		      (nnmaildir--art-msgid article) "\t"
		      (nnmaildir--nov-get-mid nov) "\tXref: nnmaildir "
		      (string-replace " " "\\ " gname) ":")
	      (princ num nntp-server-buffer)
	      (insert "\t" (nnmaildir--nov-get-end nov) "\n"))))
    (catch 'return
      (unless group
	(setf (nnmaildir--srv-error nnmaildir--cur-server)
	      (if gname (concat "No such group: " gname) "No current group"))
	(throw 'return nil))
      (nnmaildir--with-nntp-buffer
	(erase-buffer)
	(setq mlist (nnmaildir--grp-mlist group)
	      nlist (nnmaildir--grp-nlist group)
	      gname (nnmaildir--grp-name group))
	(cond
	 ((null nlist))
	 ((and fetch-old (not (numberp fetch-old)))
	  (nnmaildir--nlist-iterate nlist 'all insert-nov))
	 ((null articles))
	 ((stringp (car articles))
	  (dolist (msgid articles)
	    (setq article (nnmaildir--mlist-art mlist msgid))
	    (if article (funcall insert-nov article))))
	 (t
	  (if fetch-old
	      ;; Assume the article range list is sorted ascending
	      (setq stop (car articles)
		    start (car (last articles))
		    stop  (if (numberp stop)  stop  (car stop))
		    start (if (numberp start) start (cdr start))
		    stop (- stop fetch-old)
		    stop (if (< stop 1) 1 stop)
		    articles (list (cons stop start))))
	  (nnmaildir--nlist-iterate nlist articles insert-nov)))
	(sort-numeric-fields 1 (point-min) (point-max))
	'nov))))