Function: gnus-agent-save-alist

gnus-agent-save-alist is a byte-compiled function defined in gnus-agent.el.gz.

Signature

(gnus-agent-save-alist GROUP &optional ARTICLES STATE)

Documentation

Save the article-state alist for GROUP.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-agent.el.gz
(defun gnus-agent-save-alist (group &optional articles state)
  "Save the article-state alist for GROUP."
  (let* ((file-name-coding-system nnmail-pathname-coding-system)
	 (prev (cons nil gnus-agent-article-alist))
	 (all prev)
	 print-level print-length article)
    (while (setq article (pop articles))
      (while (and (cdr prev)
                  (< (caadr prev) article))
	(setq prev (cdr prev)))
      (cond
       ((not (cdr prev))
	(setcdr prev (list (cons article state))))
       ((> (caadr prev) article)
	(setcdr prev (cons (cons article state) (cdr prev))))
       ((= (caadr prev) article)
	(setcdr (cadr prev) state)))
      (setq prev (cdr prev)))
    (setq gnus-agent-article-alist (cdr all))

    (gnus-agent-set-local group
                          (caar gnus-agent-article-alist)
                          (caar (last gnus-agent-article-alist)))

    (gnus-make-directory (gnus-agent-article-name "" group))
    (with-temp-file (gnus-agent-article-name ".agentview" group)
      (cond ((eq gnus-agent-article-alist-save-format 1)
             (princ gnus-agent-article-alist (current-buffer)))
            ((eq gnus-agent-article-alist-save-format 2)
             (let ((alist gnus-agent-article-alist)
		   article-id day-of-download comp-list compressed)
	       (while alist
		 (setq article-id (caar alist)
		       day-of-download (cdar alist)
		       comp-list (assq day-of-download compressed)
		       alist (cdr alist))
		 (if comp-list
		     (setcdr comp-list (cons article-id (cdr comp-list)))
		   (push (list day-of-download article-id) compressed)))
	       (setq alist compressed)
	       (while alist
		 (setq comp-list (pop alist))
		 (setcdr comp-list
			 (gnus-compress-sequence (nreverse (cdr comp-list)))))
               (princ compressed (current-buffer)))))
      (insert "\n")
      (princ gnus-agent-article-alist-save-format (current-buffer))
      (insert "\n"))

    (gnus-agent-update-view-total-fetched-for group nil)))