Function: gnus-articles-to-read

gnus-articles-to-read is a byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-articles-to-read GROUP &optional READ-ALL)

Documentation

Find out what articles the user wants to read.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-articles-to-read (group &optional read-all)
  "Find out what articles the user wants to read."
  (let* ((only-read-p t)
	 (articles
	  (range-list-difference
	  ;; Select all articles if `read-all' is non-nil, or if there
	  ;; are no unread articles.
	  (if (or read-all
		  (and (zerop (length gnus-newsgroup-marked))
		       (zerop (length gnus-newsgroup-unreads)))
		  ;; Fetch all if the predicate is non-nil.
		  gnus-newsgroup-display)
	      ;; We want to select the headers for all the articles in
	      ;; the group, so we select either all the active
	      ;; articles in the group, or (if that's nil), the
	      ;; articles in the cache.
	      (or
	       (if gnus-newsgroup-maximum-articles
		   (let ((active (gnus-active group)))
		     (range-uncompress
		      (cons (max (car active)
				 (- (cdr active)
				    gnus-newsgroup-maximum-articles
				    -1))
			    (cdr active))))
		 (range-uncompress (gnus-active group)))
	       (gnus-cache-articles-in-group group))
	    ;; Select only the "normal" subset of articles.
	    (setq only-read-p nil)
	    (gnus-sorted-nunion
	     (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
	     gnus-newsgroup-unreads))
	  (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
	 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
	 (scored (length scored-list))
	 (number (length articles))
	 (marked (+ (length gnus-newsgroup-marked)
		    (length gnus-newsgroup-dormant)))
	 (select
	  (cond
	   ((numberp read-all)
	    read-all)
	   ((numberp gnus-newsgroup-display)
	    gnus-newsgroup-display)
	   (t
	    (condition-case ()
		(cond
		 ((and (or (<= scored marked) (= scored number))
		       (numberp gnus-large-newsgroup)
		       (> number gnus-large-newsgroup))
		  (let* ((cursor-in-echo-area nil)
			 (initial (gnus-parameter-large-newsgroup-initial
				   gnus-newsgroup-name))
			 (default (if only-read-p
				      (if (eq initial 'all)
					  nil
					(or initial gnus-large-newsgroup))
				    number))
			 (input
			  (read-string
			   (if only-read-p
			       (format-prompt
				    "How many articles from %s (available %d)"
				    default
				    (gnus-group-real-name gnus-newsgroup-name)
				    number)
			     (format-prompt
			      "How many articles from %s"
			      default
			      (gnus-group-real-name gnus-newsgroup-name)))
			   nil
			   nil
			   (number-to-string default))))
		    (if (string-match "^[ \t]*$" input) number input)))
		 ((and (> scored marked) (< scored number)
		       (> (- scored number) 20))
		  (let ((input
			 (read-string
			  (format "%s %s (%d scored, %d total): "
				  "How many articles from"
				  (gnus-group-real-name gnus-newsgroup-name)
				  scored number))))
		    (if (string-match "^[ \t]*$" input)
			number input)))
		 (t number))
	      (quit
	       (message "Quit getting the articles to read")
	       nil))))))
    (setq select (if (stringp select) (string-to-number select) select))
    (if (or (null select) (zerop select))
	select
      (if (and (not (zerop scored)) (<= (abs select) scored))
	  (progn
	    (setq articles (sort scored-list #'<))
	    (setq number (length articles)))
	(setq articles (copy-sequence articles)))

      (when (< (abs select) number)
	(if (< select 0)
	    ;; Select the N oldest articles.
	    (setcdr (nthcdr (1- (abs select)) articles) nil)
	  ;; Select the N most recent articles.
	  (setq articles (nthcdr (- number select) articles))))
      (setq gnus-newsgroup-unselected
	    (gnus-sorted-difference gnus-newsgroup-unreads articles))
      (when (functionp gnus-alter-articles-to-read-function)
	(setq articles
	      (sort
	       (funcall gnus-alter-articles-to-read-function
			gnus-newsgroup-name articles)
	       #'<)))
      articles)))