Function: gnus-agent-possibly-alter-active
gnus-agent-possibly-alter-active is an autoloaded and byte-compiled
function defined in gnus-agent.el.gz.
Signature
(gnus-agent-possibly-alter-active GROUP ACTIVE &optional INFO)
Documentation
Possibly expand a group's active range to include articles downloaded into the agent.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-agent.el.gz
;;;###autoload
(defun gnus-agent-possibly-alter-active (group active &optional info)
"Possibly expand a group's active range to include articles
downloaded into the agent."
(let* ((gnus-command-method (or gnus-command-method
(gnus-find-method-for-group group))))
(when (gnus-agent-method-p gnus-command-method)
(let* ((local (gnus-agent-get-local group))
(active-min (or (car active) 0))
(active-max (or (cdr active) 0))
(agent-min (or (car local) active-min))
(agent-max (or (cdr local) active-max)))
(when (< agent-min active-min)
(setcar active agent-min))
(when (> agent-max active-max)
(setcdr active agent-max))
(when (and info (< agent-max (- active-min 100)))
;; I'm expanding the active range by such a large amount
;; that there is a gap of more than 100 articles between the
;; last article known to the agent and the first article
;; currently available on the server. This gap contains
;; articles that have been lost, mark them as read so that
;; gnus doesn't waste resources trying to fetch them.
;; NOTE: I don't do this for smaller gaps (< 100) as I don't
;; want to modify the local file every time someone restarts
;; gnus. The small gap will cause a tiny performance hit
;; when gnus tries, and fails, to retrieve the articles.
;; Still that should be smaller than opening a buffer,
;; printing this list to the buffer, and then writing it to a
;; file.
(let ((read (gnus-info-read info)))
(setf (gnus-info-read info)
(gnus-range-add
read
(list (cons (1+ agent-max)
(1- active-min))))))
;; Lie about the agent's local range for this group to
;; disable the set read each time this server is opened.
;; NOTE: Opening this group will restore the valid local
;; range but it will also expand the local range to
;; encompass the new active range.
(gnus-agent-set-local group agent-min (1- active-min)))))))