+
+(defun nnsoup-make-active ()
+ "(Re-)create the SOUP active file."
+ (interactive)
+ (let ((files (sort (directory-files nnsoup-directory t "IDX$")
+ (lambda (f1 f2)
+ (< (progn (string-match "/\\([0-9]+\\)\\." f1)
+ (string-to-int (match-string 1 f1)))
+ (progn (string-match "/\\([0-9]+\\)\\." f2)
+ (string-to-int (match-string 1 f2)))))))
+ active group lines ident elem min)
+ (set-buffer (get-buffer-create " *nnsoup work*"))
+ (while files
+ (nnheader-message 5 "Doing %s..." (car files))
+ (erase-buffer)
+ (nnheader-insert-file-contents (car files))
+ (goto-char (point-min))
+ (if (not (re-search-forward "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t *\\(Xref: \\)? *[^ ]* \\([^ ]+\\):[0-9]" nil t))
+ (setq group "unknown")
+ (setq group (match-string 2)))
+ (setq lines (count-lines (point-min) (point-max)))
+ (setq ident (progn (string-match
+ "/\\([0-9]+\\)\\." (car files))
+ (substring
+ (car files) (match-beginning 1)
+ (match-end 1))))
+ (if (not (setq elem (assoc group active)))
+ (push (list group (cons 1 lines)
+ (list (cons 1 lines)
+ (vector ident group "ucm" "" lines)))
+ active)
+ (nconc elem
+ (list
+ (list (cons (1+ (setq min (cdadr elem)))
+ (+ min lines))
+ (vector ident group "ucm" "" lines))))
+ (setcdr (cadr elem) (+ min lines)))
+ (setq files (cdr files)))
+ (nnheader-message 5 "")
+ (setq nnsoup-group-alist active)
+ (nnsoup-write-active-file t)))
+
+(defun nnsoup-delete-unreferenced-message-files ()
+ "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
+ (interactive)
+ (let* ((known (apply 'nconc (mapcar
+ (lambda (ga)
+ (mapcar
+ (lambda (area)
+ (gnus-soup-area-prefix (cadr area)))
+ (cddr ga)))
+ nnsoup-group-alist)))
+ (regexp "\\.MSG$\\|\\.IDX$")
+ (files (directory-files nnsoup-directory nil regexp))
+ non-files file)
+ ;; Find all files that aren't known by nnsoup.
+ (while (setq file (pop files))
+ (string-match regexp file)
+ (unless (member (substring file 0 (match-beginning 0)) known)
+ (push file non-files)))
+ ;; Sort and delete the files.
+ (setq non-files (sort non-files 'string<))
+ (map-y-or-n-p "Delete file %s? "
+ (lambda (file) (delete-file
+ (expand-file-name file nnsoup-directory)))
+ non-files)))
+