Function: gnus-make-hashtable-from-newsrc-alist

gnus-make-hashtable-from-newsrc-alist is a byte-compiled function defined in gnus-start.el.gz.

Signature

(gnus-make-hashtable-from-newsrc-alist)

Documentation

Create a hash table from gnus-newsrc-alist.

The keys are group names, and values are a cons of (unread info), where unread is an integer count of calculated unread messages (or nil), and info is a regular gnus info entry.

The info element is shared with the same element of gnus-newrc-alist, so as to conserve space.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-start.el.gz
(defun gnus-make-hashtable-from-newsrc-alist ()
  "Create a hash table from `gnus-newsrc-alist'.
The keys are group names, and values are a cons of (unread info),
where unread is an integer count of calculated unread
messages (or nil), and info is a regular gnus info entry.

The info element is shared with the same element of
`gnus-newrc-alist', so as to conserve space."
  (let ((alist gnus-newsrc-alist)
	(ohashtb gnus-newsrc-hashtb)
	info method gname rest methods)
    (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))
	  gnus-group-list nil)
    (setq alist
	  (setq gnus-newsrc-alist
		(if (equal (caar gnus-newsrc-alist)
			   "dummy.group")
		    gnus-newsrc-alist
		  (cons (gnus-info-make "dummy.group" 0 nil) alist))))
    (while alist
      (setq info (car alist))
      ;; Make the same select-methods identical Lisp objects.
      (when (setq method (gnus-info-method info))
	(if (setq rest (member method methods))
	    (setf (gnus-info-method info) (car rest))
	  (push method methods)))
      ;; Check for encoded group names and decode them.
      (when (string-match-p "[^[:ascii:]]" (setq gname (gnus-info-group info)))
	(let ((decoded (gnus-group-decoded-name gname)))
	 (setf gname decoded
	       (gnus-info-group info) decoded)))
      ;; Check for duplicates.
      (if (gethash gname gnus-newsrc-hashtb)
	  ;; Remove this entry from the alist.
	  (setcdr alist (cddr alist))
	(puthash
	 gname
	 ;; Preserve number of unread articles in groups.
	 (list (and ohashtb (car (gethash gname ohashtb)))
	       info)
	 gnus-newsrc-hashtb)
	(push gname gnus-group-list))
      (setq alist (cdr alist)))
    (setq gnus-group-list (nreverse gnus-group-list))
    ;; Make the same select-methods in `gnus-server-alist' identical
    ;; as well.
    (while methods
      (setq method (pop methods))
      (when (setq rest (rassoc method gnus-server-alist))
	(setcdr rest method)))))