Function: gnus-select-newsgroup
gnus-select-newsgroup is a byte-compiled function defined in
gnus-sum.el.gz.
Signature
(gnus-select-newsgroup GROUP &optional READ-ALL SELECT-ARTICLES)
Documentation
Select newsgroup GROUP.
If READ-ALL is non-nil, all articles in the group are selected. If SELECT-ARTICLES, only select those articles from GROUP.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-select-newsgroup (group &optional read-all select-articles)
"Select newsgroup GROUP.
If READ-ALL is non-nil, all articles in the group are selected.
If SELECT-ARTICLES, only select those articles from GROUP."
(let* ((entry (gnus-group-entry group))
;;!!! Dirty hack; should be removed.
(gnus-summary-ignore-duplicates
(if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
t
gnus-summary-ignore-duplicates))
(info (nth 1 entry))
articles fetched-articles cached)
(unless (gnus-check-server
(setq-local gnus-current-select-method
(gnus-find-method-for-group group)))
(error "Couldn't open server"))
(or (and entry (not (eq (car entry) t))) ; Either it's active...
(gnus-activate-group group) ; Or we can activate it...
(progn ; Or we bug out.
(when (derived-mode-p 'gnus-summary-mode)
(gnus-kill-buffer (current-buffer)))
(error
"Couldn't activate group %s: %s" group (gnus-status-message group))))
(unless (gnus-request-group group t nil info)
(when (derived-mode-p 'gnus-summary-mode)
(gnus-kill-buffer (current-buffer)))
(error "Couldn't request group %s: %s" group (gnus-status-message group)))
(when (and gnus-agent
(gnus-active group))
(gnus-agent-possibly-alter-active group (gnus-active group) info)
(setq gnus-summary-use-undownloaded-faces
(gnus-agent-find-parameter
group
'agent-enable-undownloaded-faces)))
(setq gnus-newsgroup-name group
gnus-newsgroup-unselected nil
gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
(let ((display (gnus-group-find-parameter group 'display)))
(setq gnus-newsgroup-display
(cond
((not (zerop (or (car-safe read-all) 0)))
;; The user entered the group with C-u SPC/RET, let's show
;; all articles.
#'gnus-not-ignore)
((eq display 'all)
#'gnus-not-ignore)
((arrayp display)
(gnus-summary-display-make-predicate (mapcar #'identity display)))
((numberp display)
;; The following is probably the "correct" solution, but
;; it makes Gnus fetch all headers and then limit the
;; articles (which is slow), so instead we hack the
;; select-articles parameter instead. -- Simon Josefsson
;; <jas@kth.se>
;;
;; (let ((n (cdr (gnus-active group))))
;; (lambda () (> number (- n display))))
(setq select-articles
(range-uncompress
(cons (let ((tmp (- (cdr (gnus-active group)) display)))
(if (> tmp 0)
tmp
1))
(cdr (gnus-active group)))))
nil)
(t
nil))))
(gnus-summary-setup-default-charset)
;; Kludge to avoid having cached articles nixed out in virtual groups.
(when (gnus-virtual-group-p group)
(setq cached gnus-newsgroup-cached))
(setq gnus-newsgroup-unreads
(gnus-sorted-ndifference
(gnus-sorted-ndifference gnus-newsgroup-unreads
gnus-newsgroup-marked)
gnus-newsgroup-dormant))
(setq gnus-newsgroup-processable nil)
(gnus-update-read-articles group gnus-newsgroup-unreads t)
;; Adjust and set lists of article marks.
(when info
(gnus-adjust-marked-articles info))
(if (setq articles select-articles)
(setq gnus-newsgroup-unselected
(gnus-sorted-difference gnus-newsgroup-unreads articles))
(setq articles (gnus-articles-to-read group read-all)))
(cond
((null articles)
;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
'quit)
((eq articles 0) nil)
(t
;; Init the dependencies hash table.
(setq gnus-newsgroup-dependencies
(gnus-make-hashtable (length articles)))
(if (gnus-buffer-live-p gnus-group-buffer)
(gnus-set-global-variables)
(set-default 'gnus-newsgroup-name gnus-newsgroup-name))
;; Retrieve the headers and read them in.
(setq gnus-newsgroup-headers (gnus-fetch-headers articles))
;; Kludge to avoid having cached articles nixed out in virtual groups.
(when cached
(setq gnus-newsgroup-cached cached))
;; Suppress duplicates?
(when gnus-suppress-duplicates
(gnus-dup-suppress-articles))
;; Set the initial limit.
(setq gnus-newsgroup-limit (copy-sequence articles))
;; Remove canceled articles from the list of unread articles.
(setq fetched-articles
(mapcar #'mail-header-number gnus-newsgroup-headers))
(setq gnus-newsgroup-articles fetched-articles)
(setq gnus-newsgroup-unreads
(gnus-sorted-nintersection
gnus-newsgroup-unreads fetched-articles))
(gnus-compute-unseen-list)
;; Removed marked articles that do not exist.
(gnus-update-missing-marks
(gnus-sorted-difference articles fetched-articles))
;; We might want to build some more threads first.
(when (and gnus-fetch-old-headers
(eq gnus-headers-retrieved-by 'nov))
(if (eq gnus-fetch-old-headers 'invisible)
(gnus-build-all-threads)
(gnus-build-old-threads)))
;; Let the Gnus agent mark articles as read.
(when gnus-agent
(gnus-agent-get-undownloaded-list))
;; Remove list identifiers from subject
(gnus-summary-remove-list-identifiers)
;; Check whether auto-expire is to be done in this group.
(setq gnus-newsgroup-auto-expire
(and (gnus-group-auto-expirable-p group)
(not (gnus-group-read-only-p group))))
;; Set up the article buffer now, if necessary.
(unless (and gnus-single-article-buffer
(equal gnus-article-buffer "*Article*"))
(gnus-article-setup-buffer))
;; First and last article in this newsgroup.
(when gnus-newsgroup-headers
(setq gnus-newsgroup-begin
(mail-header-number (car gnus-newsgroup-headers))
gnus-newsgroup-end
(mail-header-number
(car (last gnus-newsgroup-headers)))))
;; GROUP is successfully selected.
(or gnus-newsgroup-headers t)))))