Function: gnus-read-descriptions-file

gnus-read-descriptions-file is a byte-compiled function defined in gnus-start.el.gz.

Signature

(gnus-read-descriptions-file &optional METHOD)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-start.el.gz
(defun gnus-read-descriptions-file (&optional method)
  (let ((method (or method gnus-select-method))
	group)
    (when (stringp method)
      (setq method (gnus-server-to-method method)))
    ;; We create the hashtable whether we manage to read the desc file
    ;; to avoid trying to re-read after a failed read.
    (unless gnus-description-hashtb
      (setq gnus-description-hashtb
	    (gnus-make-hashtable (hash-table-size gnus-active-hashtb))))
    ;; Mark this method's desc file as read.
    (puthash (gnus-group-prefixed-name "" method) "Has read"
	     gnus-description-hashtb)

    (gnus-message 5 "Reading descriptions file via %s..." (car method))
    (cond
     ((null (gnus-get-function method 'request-list-newsgroups t))
      t)
     ((not (gnus-check-server method))
      (gnus-message 1 "Couldn't open server")
      nil)
     ((not (gnus-request-list-newsgroups method))
      (gnus-message 1 "Couldn't read newsgroups descriptions")
      nil)
     (t
      (with-current-buffer nntp-server-buffer
	(save-excursion ;;FIXME: Not sure if it's needed!
	  (save-restriction
	    (goto-char (point-min))
	    (when (or (search-forward "\n.\n" nil t)
		      (goto-char (point-max)))
	      (beginning-of-line)
	      (narrow-to-region (point-min) (point)))
	    ;; If these are groups from a foreign select method, we insert the
	    ;; group prefix in front of the group names.
	    (and method (not (inline
			       (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 (insert prefix)
				      (zerop (forward-line 1)))))))
	    (goto-char (point-min))
	    (while (not (eobp))
	      (setq group
		    (condition-case ()
                        (read nntp-server-buffer)
		      (error nil)))
	      (skip-chars-forward " \t")
	      (when group
		(setq group (if (numberp group)
                                (number-to-string group)
			      (symbol-name group)))
		(let* ((str (buffer-substring
			     (point) (progn (end-of-line) (point))))
		       (charset
			(or (gnus-group-name-charset method group)
			    (gnus-parameter-charset group)
			    gnus-default-charset)))
		  ;; Fixme: Don't decode in unibyte mode.
		  ;; Double fixme: We're not in unibyte mode, are we?
		  (when (and str charset)
		    (setq str (decode-coding-string str charset)))
		  (puthash group str gnus-description-hashtb)))
	      (forward-line 1)))))
      (gnus-message 5 "Reading descriptions file...done")
      t))))