*** empty log message ***
[gnus] / lisp / nnml.el
index f151bca..0b14610 100644 (file)
@@ -33,7 +33,7 @@
 (require 'nnheader)
 (require 'nnmail)
 (require 'nnoo)
-(eval-when-compile (require 'cl))
+(require 'cl)
 
 (nnoo-declare nnml)
 
@@ -304,6 +304,7 @@ all. This may very well take some time.")
        (kill-buffer (current-buffer))
        result)
      (progn
+       (nnml-possibly-change-directory group server)
        (condition-case ()
           (funcall nnmail-delete-file-function
                    (concat nnml-current-directory 
@@ -543,6 +544,7 @@ all. This may very well take some time.")
        chars nov-line)
     (setq chars (nnmail-insert-lines))
     (nnmail-insert-xref group-art)
+    (run-hooks 'nnmail-prepare-save-mail-hook)
     (run-hooks 'nnml-prepare-save-mail-hook)
     (goto-char (point-min))
     (while (looking-at "From ")
@@ -580,10 +582,21 @@ all. This may very well take some time.")
   (let ((active (cadr (assoc group nnml-group-alist))))
     ;; The group wasn't known to nnml, so we just create an active
     ;; entry for it.   
-    (or active
-       (progn
-         (setq active (cons 1 0))
-         (setq nnml-group-alist (cons (list group active) nnml-group-alist))))
+    (unless active
+      ;; Perhaps the active file was corrupt?  See whether
+      ;; there are any articles in this group.
+      (nnml-possibly-change-directory group)
+      (unless nnml-article-file-alist
+       (setq nnml-article-file-alist
+             (sort
+              (nnheader-article-to-file-alist nnml-current-directory)
+              (lambda (a1 a2) (< (car a1) (car a2))))))
+      (setq active
+           (if nnml-article-file-alist
+               (cons (caar nnml-article-file-alist)
+                     (caar (last nnml-article-file-alist)))
+             (cons 1 0)))
+      (setq nnml-group-alist (cons (list group active) nnml-group-alist)))
     (setcdr active (1+ (cdr active)))
     (while (file-exists-p
            (concat (nnmail-group-pathname group nnml-directory)