Sync with Oort Gnus (Translating gnus-ja.texi has not been done yet).
[elisp/gnus.git-] / lisp / nnml.el
index 817ea15..710c882 100644 (file)
@@ -86,6 +86,13 @@ marks file will be regenerated properly by Gnus.
 
 This variable is a virtual server slot.  See the Gnus manual for details.")
 
+(defvoo nnml-filenames-are-evil t
+  "If non-nil, Gnus will not assume that the articles file name 
+is the same as the article number listed in the nov database.  This 
+variable should be set if any of the files are compressed.
+
+This variable is a virtual server slot.  See the Gnus manual for details.")
+
 (defvoo nnml-prepare-save-mail-hook nil
   "Hook run narrowed to an article before saving.
 
@@ -121,8 +128,9 @@ This variable is a virtual server slot.  See the Gnus manual for details.")
 
 (defvoo nnml-marks nil)
 
-\f
+(defvar nnml-marks-modtime (gnus-make-hashtable))
 
+\f
 ;;; Interface functions.
 
 (nnoo-define-basics nnml)
@@ -204,7 +212,7 @@ This variable is a virtual server slot.  See the Gnus manual for details.")
        (when (and (setq group-num (nnml-find-group-number id))
                   (cdr
                    (assq (cdr group-num)
-                         (nnml-article-to-file-alist
+                         (nnheader-article-to-file-alist
                           (setq gpath
                                 (nnmail-group-pathname
                                  (car group-num)
@@ -484,7 +492,7 @@ This variable is a virtual server slot.  See the Gnus manual for details.")
       ;; We move the articles file by file instead of renaming
       ;; the directory -- there may be subgroups in this group.
       ;; One might be more clever, I guess.
-      (let ((files (nnml-article-to-file-alist old-dir)))
+      (let ((files (nnheader-article-to-file-alist old-dir)))
        (while files
          (rename-file
           (concat old-dir (cdar files))
@@ -679,7 +687,7 @@ This variable is a virtual server slot.  See the Gnus manual for details.")
       (unless nnml-article-file-alist
        (setq nnml-article-file-alist
              (sort
-              (nnml-article-to-file-alist nnml-current-directory)
+              (nnml-current-group-article-to-file-alist)
               'car-less-than-car)))
       (setq active
            (if nnml-article-file-alist
@@ -874,7 +882,7 @@ This variable is a virtual server slot.  See the Gnus manual for details.")
   (when (or (not nnml-article-file-alist)
            force)
     (setq nnml-article-file-alist
-         (nnml-article-to-file-alist nnml-current-directory))))
+         (nnml-current-group-article-to-file-alist))))
 
 (defun nnml-directory-articles (dir)
   "Return a list of all article files in a directory.
@@ -898,10 +906,12 @@ Use the nov database for that directory if available."
          (forward-line 1))
        list))))
 
-(defun nnml-article-to-file-alist (dir)
-  "Return an alist of article/file pairs in DIR.
-Use the nov database for that directory if available."
-  (if (or gnus-nov-is-evil nnml-nov-is-evil
+(defun nnml-current-group-article-to-file-alist ()
+  "Return an alist of article/file pairs in the current group.
+Use the nov database for the current group if available."
+  (if (or gnus-nov-is-evil 
+         nnml-nov-is-evil
+         nnml-filenames-are-evil
          (not (file-exists-p
                (expand-file-name nnml-nov-file-name
                                  nnml-current-directory))))
@@ -942,7 +952,7 @@ Use the nov database for that directory if available."
 
 (deffoo nnml-request-update-info (group info &optional server)
   (nnml-possibly-change-directory group server)
-  (unless nnml-marks-is-evil
+  (when (and (not nnml-marks-is-evil) (nnml-marks-changed-p group))
     (nnheader-message 8 "Updating marks for %s..." group)
     (nnml-open-marks group server)
     ;; Update info using `nnml-marks'.
@@ -964,6 +974,14 @@ Use the nov database for that directory if available."
     (nnheader-message 8 "Updating marks for %s...done" group))
   info)
 
+(defun nnml-marks-changed-p (group)
+  (let ((file (expand-file-name nnml-marks-file-name
+                               (nnmail-group-pathname group nnml-directory))))
+    (if (null (gnus-gethash file nnml-marks-modtime))
+       t ;; never looked at marks file, assume it has changed
+      (not (eq (gnus-gethash file nnml-marks-modtime)
+            (nth 5 (file-attributes file)))))))
+
 (defun nnml-save-marks (group server)
   (let ((file-name-coding-system nnmail-pathname-coding-system)
        (file (expand-file-name nnml-marks-file-name
@@ -974,7 +992,10 @@ Use the nov database for that directory if available."
          (with-temp-file file
            (erase-buffer)
            (princ nnml-marks (current-buffer))
-           (insert "\n")))
+           (insert "\n"))
+         (gnus-sethash file
+                       (nth 5 (file-attributes file))
+                       nnml-marks-modtime))
       (error (or (gnus-yes-or-no-p
                  (format "Could not write to %s (%s).  Continue? " file err))
                 (error "Cannot write to %s (%s)" err))))))
@@ -986,6 +1007,9 @@ Use the nov database for that directory if available."
     (if (file-exists-p file)
        (setq nnml-marks (condition-case err
                             (with-temp-buffer
+                              (gnus-sethash file
+                                            (nth 5 (file-attributes file))
+                                            nnml-marks-modtime)
                               (nnheader-insert-file-contents file)
                               (read (current-buffer)))
                           (error (or (gnus-yes-or-no-p