Function: gnus-update-read-articles
gnus-update-read-articles is an autoloaded and byte-compiled function
defined in gnus-sum.el.gz.
Signature
(gnus-update-read-articles GROUP UNREAD &optional COMPUTE)
Documentation
Update the list of read articles in GROUP.
UNREAD is a sorted list.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-update-read-articles (group unread &optional compute)
"Update the list of read articles in GROUP.
UNREAD is a sorted list."
(let ((active (or gnus-newsgroup-active (gnus-active group)))
(info (gnus-get-info group))
(prev 1)
read)
(if (or (not info) (not active))
;; There is no info on this group if it was, in fact,
;; killed. Gnus stores no information on killed groups, so
;; there's nothing to be done.
;; One could store the information somewhere temporarily,
;; perhaps... Hmmm...
()
;; Remove any negative articles numbers.
(while (and unread (< (car unread) 0))
(setq unread (cdr unread)))
;; Remove any expired article numbers
(while (and unread (< (car unread) (car active)))
(setq unread (cdr unread)))
;; Compute the ranges of read articles by looking at the list of
;; unread articles.
(while unread
(when (/= (car unread) prev)
(push (if (= prev (1- (car unread))) prev
(cons prev (1- (car unread))))
read))
(setq prev (1+ (car unread)))
(setq unread (cdr unread)))
(when (<= prev (cdr active))
(push (cons prev (cdr active)) read))
(setq read (if (> (length read) 1) (nreverse read) read))
(if compute
read
(save-excursion
(let (setmarkundo)
;; Propagate the read marks to the backend.
(when (and (gnus-method-option-p
(gnus-find-method-for-group group)
'server-marks)
(gnus-check-backend-function 'request-set-mark group))
(let ((del (range-remove (gnus-info-read info) read))
(add (range-remove read (gnus-info-read info))))
(when (or add del)
(unless (gnus-check-group group)
(error "Can't open server for %s" group))
(gnus-request-set-mark
group (delq nil (list (if add (list add 'add '(read)))
(if del (list del 'del '(read))))))
(setq setmarkundo
(delq nil (list
(if del (list del 'add '(read)))
(if add (list add 'del '(read)))))))))
(set-buffer gnus-group-buffer)
(gnus-undo-register
;; FIXME: In `gnus-info-clear-data' we do almost the same,
;; but we call (gnus-active group) when build the closure rather
;; than when calling it!
(let ((gim (gnus-info-marks info))
(gir (gnus-info-read info)))
(lambda ()
(gnus-info-set-marks info gim t)
(setf (gnus-info-read info) gir)
(gnus-group-jump-to-group group)
(gnus-get-unread-articles-in-group info
(gnus-active group))
(gnus-group-update-group group t)
(when setmarkundo
(gnus-request-set-mark
group setmarkundo)))))))
;; Enter this list into the group info.
(setf (gnus-info-read info) read)
;; Set the number of unread articles in gnus-newsrc-hashtb.
(gnus-get-unread-articles-in-group info (gnus-active group))
t))))