Gnus-update-marks

Non-HTML version.

(defun gnus-update-marks ()
  "Enter the various lists of marked articles into the newsgroup info list."
  (let ((types gnus-article-mark-lists)
	(info (gnus-get-info gnus-newsgroup-name))
	(uncompressed '(score bookmark killed))
	type list newmarked symbol delta-marks)
    (when info
      ;; Add all marks lists to the list of marks lists.
      (while (setq type (pop types))
	(setq list (symbol-value
			  (setq symbol
				(intern (format "gnus-newsgroup-%s"
						(car type))))))

	(when list
	  ;; Get rid of the entries of the articles that have the
	  ;; default score.
	  (when (and (eq (cdr type) 'score)
		     gnus-save-score
		     list)
	    (let* ((arts list)
		   (prev (cons nil list))
		   (all prev))
	      (while arts
		(if (or (not (consp (car arts)))
			(= (cdar arts) gnus-summary-default-score))
		    (setcdr prev (cdr arts))
		  (setq prev arts))
		(setq arts (cdr arts)))
	      (setq list (cdr all)))))

	(or (memq (cdr type) uncompressed)
	    (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
	
	(when (gnus-check-backend-function 'request-set-mark
					   gnus-newsgroup-name)
	  ;; uncompressed:s are not proper flags (they are cons cells)
	  ;; cache is a internal gnus flag
	  (unless (memq (cdr type) (cons 'cache uncompressed))
	    (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
		   (del (gnus-remove-from-range (gnus-copy-sequence old) list))
		   (add (gnus-remove-from-range
			 (gnus-copy-sequence list) old)))
	      (if add
		  (push (list add 'add (list (cdr type))) delta-marks))
	      (if del
		  (push (list del 'del (list (cdr type))) delta-marks)))))
	  
	(when list
	  (push (cons (cdr type) list) newmarked)))

      (when delta-marks
	(unless (gnus-check-group gnus-newsgroup-name)
	  (error "Can't open server for %s" gnus-newsgroup-name))
	(gnus-request-set-mark gnus-newsgroup-name delta-marks))
	  
      ;; Enter these new marks into the info of the group.
      (if (nthcdr 3 info)
	  (setcar (nthcdr 3 info) newmarked)
	;; Add the marks lists to the end of the info.
	(when newmarked
	  (setcdr (nthcdr 2 info) (list newmarked))))

      ;; Cut off the end of the info if there's nothing else there.
      (let ((i 5))
	(while (and (> i 2)
		    (not (nth i info)))
	  (when (nthcdr (decf i) info)
	    (setcdr (nthcdr i info) nil)))))))

Last modified: Mon May 24 19:16:41 MET DST 1999