- (function <)))
- (nov (concat dir "/.nov"))
- (nov-buffer (get-buffer-create "*nov*"))
- nov-line chars)
- (if files
- (setq nnml-group-alist
- (cons (list (nnmail-replace-chars-in-string
- (substring (expand-file-name dir)
- (length (expand-file-name
- nnml-directory)))
- ?/ ?.)
- (cons (car files)
- (let ((f files))
- (while (cdr f) (setq f (cdr f)))
- (car f))))
- nnml-group-alist)))
- (if files
- (save-excursion
- (set-buffer nntp-server-buffer)
- (if (file-exists-p nov)
- (delete-file nov))
- (save-excursion
- (set-buffer nov-buffer)
- (buffer-disable-undo (current-buffer))
- (erase-buffer))
- (while files
- (erase-buffer)
- (insert-file-contents (concat dir "/" (int-to-string (car files))))
- (goto-char 1)
- (narrow-to-region 1 (save-excursion (search-forward "\n\n" nil t)
- (setq chars (- (point-max)
- (point)))
- (point)))
- (if (not (= 0 chars)) ; none of them empty files...
- (progn
- (setq nov-line (nnml-make-nov-line chars))
- (save-excursion
- (set-buffer nov-buffer)
- (goto-char (point-max))
- (insert (int-to-string (car files)) nov-line))))
- (widen)
- (setq files (cdr files)))
- (save-excursion
- (set-buffer nov-buffer)
- (write-region 1 (point-max) (expand-file-name nov) nil
- 'nomesg)
- (kill-buffer (current-buffer)))))
- (nnmail-save-active nnml-group-alist nnml-active-file)))
+ '<)))
+ (when files
+ (funcall nnml-generate-active-function dir)
+ ;; Generate the nov file.
+ (nnml-generate-nov-file dir files))))
+
+(defun nnml-generate-active-info (dir)
+ ;; Update the active info for this group.
+ (let ((group (nnheader-file-to-group
+ (directory-file-name dir) nnml-directory)))
+ (setq nnml-group-alist
+ (delq (assoc group nnml-group-alist) nnml-group-alist))
+ (push (list group
+ (cons (car files)
+ (let ((f files))
+ (while (cdr f) (setq f (cdr f)))
+ (car f))))
+ nnml-group-alist)))
+
+(defun nnml-generate-nov-file (dir files)
+ (let* ((dir (file-name-as-directory dir))
+ (nov (concat dir nnml-nov-file-name))
+ (nov-buffer (get-buffer-create " *nov*"))
+ nov-line chars file)
+ (save-excursion
+ ;; Init the nov buffer.
+ (set-buffer nov-buffer)
+ (buffer-disable-undo (current-buffer))
+ (erase-buffer)
+ (set-buffer nntp-server-buffer)
+ ;; Delete the old NOV file.
+ (when (file-exists-p nov)
+ (funcall nnmail-delete-file-function nov))
+ (while files
+ (unless (file-directory-p
+ (setq file (concat dir (int-to-string (car files)))))
+ (erase-buffer)
+ (insert-file-contents file)
+ (narrow-to-region
+ (goto-char (point-min))
+ (progn
+ (search-forward "\n\n" nil t)
+ (setq chars (- (point-max) (point)))
+ (max 1 (1- (point)))))
+ (when (and (not (= 0 chars)) ; none of them empty files...
+ (not (= (point-min) (point-max))))
+ (goto-char (point-min))
+ (setq nov-line (nnml-make-nov-line chars))
+ (save-excursion
+ (set-buffer nov-buffer)
+ (goto-char (point-max))
+ (insert (int-to-string (car files)) nov-line)))
+ (widen)
+ (setq files (cdr files))))
+ (save-excursion
+ (set-buffer nov-buffer)
+ (write-region 1 (point-max) (expand-file-name nov) nil
+ 'nomesg)
+ (kill-buffer (current-buffer))))))