Function: gnus-active-to-gnus-format

gnus-active-to-gnus-format is a byte-compiled function defined in gnus-start.el.gz.

Signature

(gnus-active-to-gnus-format &optional METHOD HASHTB IGNORE-ERRORS REAL-ACTIVE)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-start.el.gz
;; Read an active file and place the results in `gnus-active-hashtb'.
(defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors
					     real-active)
  (unless method
    (setq method gnus-select-method))
  (let ((cur (current-buffer))
	(hashtb (or hashtb
		    (if (and gnus-active-hashtb
			     (not (equal method gnus-select-method)))
			gnus-active-hashtb
		      (setq gnus-active-hashtb
			    (gnus-make-hashtable
			     (if (equal method gnus-select-method)
				 (count-lines (point-min) (point-max))
			       4000))))))
	group max min)
    (unless gnus-moderated-hashtb
      (setq gnus-moderated-hashtb (gnus-make-hashtable 100)))
    ;; Delete unnecessary lines.
    (goto-char (point-min))
    (cond
     ((string= gnus-ignored-newsgroups "")
      (delete-matching-lines "^to\\."))
     (t
      ;; relint suppression: Duplicated alternative branch
      (delete-matching-lines (concat "^to\\.\\|" gnus-ignored-newsgroups))))

    (goto-char (point-min))

    ;; Let the Gnus agent save the active file.
    (when (and gnus-agent real-active (gnus-online method))
      (gnus-agent-save-active method))

    ;; If these are groups from a foreign select method, we insert the
    ;; group prefix in front of the group names.
    (when (not (gnus-server-equal
		(gnus-server-get-method nil method)
		(gnus-server-get-method nil gnus-select-method)))
      (let ((prefix (gnus-group-prefixed-name "" method)))
	(goto-char (point-min))
	(while (and (not (eobp))
		    (progn
		      (when (= (following-char) ?\")
			(forward-char 1))
		      (insert prefix)
		      (zerop (forward-line 1)))))))
    ;; Store the active file in a hash table.

    (with-temp-buffer
      (insert-buffer-substring cur)
      (setq cur (current-buffer))
      (goto-char (point-min))
      (while (not (eobp))
	(condition-case ()
	    (if (and (stringp (progn
				(setq group (read cur)
				      group
				      (cond ((numberp group)
					     (number-to-string group))
					    ((symbolp group)
					     (symbol-name group))
					    ((stringp group)
					     group)))))
		     (numberp (setq max (read cur)))
		     (numberp (setq min (read cur)))
		     (null (progn
			     (skip-chars-forward " \t")
			     (memq (char-after)
				   '(?= ?x ?j)))))
		(progn (when (string-match-p "[^[:ascii:]]" group)
			 ;; NNTP servers may give us encoded group
			 ;; names.
			 (setq group (gnus-group-decoded-name group)))
		       (puthash group (cons min max) hashtb)
		       ;; If group is moderated, stick it in the
		       ;; moderation cache.
		       (when (eq (char-after) ?m)
			 (puthash group t gnus-moderated-hashtb)))
	      (setq group nil))
	  (error
	   (unless ignore-errors
	     (gnus-message 3 "Warning - invalid active: %s"
			   (buffer-substring
                            (line-beginning-position) (line-end-position))))))
	(forward-line 1)))))