Function: gnus-cache-generate-active

gnus-cache-generate-active is an autoloaded, interactive and byte-compiled function defined in gnus-cache.el.gz.

Signature

(gnus-cache-generate-active &optional DIRECTORY)

Documentation

Generate the cache active file.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-cache.el.gz
;;;###autoload
(defun gnus-cache-generate-active (&optional directory)
  "Generate the cache active file."
  (interactive)
  (let* ((top (null directory))
	 (directory (expand-file-name (or directory gnus-cache-directory)))
	 (file-name-coding-system nnmail-pathname-coding-system)
	 (files (directory-files directory 'full))
	 (group
	  (if top
	      ""
	    (string-match
	     (concat "^" (regexp-quote
			  (file-name-as-directory
			   (expand-file-name gnus-cache-directory))))
	     (directory-file-name directory))
	    (url-unhex-string
             (nnheader-replace-chars-in-string
	      (substring (directory-file-name directory) (match-end 0))
	      ?/ ?.))))
	 nums alphs)
    (when top
      (gnus-message 5 "Generating the cache active file...")
      (setq gnus-cache-active-hashtb (gnus-make-hashtable 123)))
    (when (string-match "^\\(nn[^_]+\\)_" group)
      (setq group (replace-match "\\1:" t nil group)))
    ;; Separate articles from all other files and directories.
    (while files
      (if (string-match "^[0-9]+$" (file-name-nondirectory (car files)))
	  (push (string-to-number (file-name-nondirectory (pop files))) nums)
	(push (pop files) alphs)))
    ;; If we have nums, then this is probably a valid group.
    (when (setq nums (sort nums #'<))
      (puthash group
	       (cons (car nums) (car (last nums)))
	       gnus-cache-active-hashtb))
    ;; Go through all the other files.
    (dolist (file alphs)
      (when (and (file-directory-p file)
		 (not (string-match "^\\."
				    (file-name-nondirectory file))))
	;; We descend directories.
	(gnus-cache-generate-active file)))
    ;; Write the new active file.
    (when top
      (gnus-cache-write-active t)
      (gnus-message 5 "Generating the cache active file...done"))))