I use Gnus to read Usenet. Sometimes Gnus fetches the news and shows me that there are groups with unread messages, but when I try to go into one of those groups, Gnus fetches more information and realizes that all of the unread articles have been scored down below the threshold of being visible.

This is slightly annoying—and Emacs is more than slightly configurable—so I would like to get Gnus to apply my scores in each group as soon as it has fetched news.

This is my attempt to get that behavior:

(defun enter-all-groups-to-force-scoring ()
  (gnus-message 5 "Scoring...")
  (catch 'done-looping
    (let ((seen-newsgroups '())
          (most-recent-newsgroup nil))
      (while t
        (setq most-recent-newsgroup gnus-newsgroup-name)
        (if (seq-contains-p seen-newsgroups most-recent-newsgroup)
          (throw 'done-looping nil)
          (setq seen-newsgroups (cons most-recent-newsgroup seen-newsgroups))))))
  (gnus-message 5 "Scoring... done"))

(add-hook 'gnus-group-prepare-hook 'enter-all-groups-to-force-scoring)
(add-hook 'gnus-after-getting-new-news-hook 'enter-all-groups-to-force-scoring)

This seems to work sometimes—I can watch as groups that had unread articles are reduced to zero unread articles. Other times, though, it seems that scores in a particular group were not applied, and I run into the sequence of events described at the top of this question.

This solution also opens the last newsgroup twice, because I wasn’t sure how else to determine that it’s done looping through the groups!

Is there a better way of accomplishing this bit of configuration?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.