* gnus-art.el (gnus-header-from, gnus-header-subject, gnus-header-name)
[gnus] / lisp / nnml.el
index d30ae28..08610c1 100644 (file)
@@ -1,7 +1,7 @@
 ;;; nnml.el --- mail spool access for Gnus
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Authors: Didier Verna <didier@xemacs.org> (adding compaction)
 ;;     Simon Josefsson <simon@josefsson.org> (adding MARKS)
@@ -88,7 +88,7 @@ marks file will be regenerated properly by Gnus.")
   "If non-nil, allow using compressed message files.
 
 If it is a string, use it as the file extension which specifies
-the comression program.  You can set it to \".bz2\" if your Emacs
+the compression program.  You can set it to \".bz2\" if your Emacs
 supports auto-compression using the bzip2 program.  A value of t
 is equivalent to \".gz\".")
 
@@ -265,12 +265,16 @@ non-nil.")
   (nnml-possibly-change-directory nil server)
   (nnmail-activate 'nnml)
   (cond
+   ((let ((file (directory-file-name
+                (nnmail-group-pathname group nnml-directory))))
+      (and (file-exists-p file)
+          (not (file-directory-p file))))
+    (nnheader-report 'nnml "%s is a file"
+                    (directory-file-name
+                     (let ((nnmail-pathname-coding-system nil))
+                       (nnmail-group-pathname group nnml-directory)))))
    ((assoc group nnml-group-alist)
     t)
-   ((and (file-exists-p (nnmail-group-pathname group nnml-directory))
-        (not (file-directory-p (nnmail-group-pathname group nnml-directory))))
-    (nnheader-report 'nnml "%s is a file"
-                    (nnmail-group-pathname group nnml-directory)))
    (t
     (let (active)
       (push (list group (setq active (cons 1 0)))
@@ -304,7 +308,7 @@ non-nil.")
   (let ((active-articles
         (nnml-directory-articles nnml-current-directory))
        (is-old t)
-       article rest mod-time number)
+       article rest mod-time number target)
     (nnmail-activate 'nnml)
 
     (setq active-articles (sort active-articles '<))
@@ -321,23 +325,33 @@ non-nil.")
                                                      nnml-inhibit-expiry)))
          (progn
            ;; Allow a special target group.
-           (unless (eq nnmail-expiry-target 'delete)
+           (setq target nnmail-expiry-target)
+           (unless (eq target 'delete)
              (with-temp-buffer
                (nnml-request-article number group server (current-buffer))
                (let (nnml-current-directory
                      nnml-current-group
                      nnml-article-file-alist)
-                 (nnmail-expiry-target-group nnmail-expiry-target group)))
+                 (when (functionp target)
+                   (setq target (funcall target group)))
+                 (if (and target
+                          (or (gnus-request-group target)
+                              (gnus-request-create-group target)))
+                     (nnmail-expiry-target-group target group)
+                   (setq target nil))))
              ;; Maybe directory is changed during nnmail-expiry-target-group.
              (nnml-possibly-change-directory group server))
-           (nnheader-message 5 "Deleting article %s in %s"
-                             number group)
-           (condition-case ()
-               (funcall nnmail-delete-file-function article)
-             (file-error
-              (push number rest)))
-           (setq active-articles (delq number active-articles))
-           (nnml-nov-delete-article group number))
+           (if target
+               (progn
+                 (nnheader-message 5 "Deleting article %s in %s"
+                                   number group)
+                 (condition-case ()
+                     (funcall nnmail-delete-file-function article)
+                   (file-error
+                    (push number rest)))
+                 (setq active-articles (delq number active-articles))
+                 (nnml-nov-delete-article group number))
+             (push number rest)))
        (push number rest)))
     (let ((active (nth 1 (assoc group nnml-group-alist))))
       (when active
@@ -770,12 +784,14 @@ non-nil.")
     (nnml-open-server server))
   (setq nnml-directory (expand-file-name nnml-directory))
   ;; Recurse down the directories.
-  (nnml-generate-nov-databases-1 nnml-directory nil t)
+  (nnml-generate-nov-databases-directory nnml-directory nil t)
   ;; Save the active file.
   (nnmail-save-active nnml-group-alist nnml-active-file))
 
-(defun nnml-generate-nov-databases-1 (dir &optional seen no-active)
-  "Regenerate the NOV database in DIR."
+(defun nnml-generate-nov-databases-directory (dir &optional seen no-active)
+  "Regenerate the NOV database in DIR.
+
+Unless no-active is non-nil, update the active file too."
   (interactive "DRegenerate NOV in: ")
   (setq dir (file-name-as-directory dir))
   ;; Only scan this sub-tree if we haven't been here yet.
@@ -785,7 +801,7 @@ non-nil.")
     (dolist (dir (directory-files dir t nil t))
       (when (and (not (string-match "^\\." (file-name-nondirectory dir)))
                 (file-directory-p dir))
-       (nnml-generate-nov-databases-1 dir seen)))
+       (nnml-generate-nov-databases-directory dir seen)))
     ;; Do this directory.
     (let ((files (sort (nnheader-article-to-file-alist dir)
                       'car-less-than-car)))
@@ -1044,6 +1060,8 @@ Use the nov database for the current group if available."
 ;; #### other backends get a compaction feature. Also, note that invalidating
 ;; #### the "original article buffer" is already done at an upper level.
 
+;; Shouldn't `nnml-request-compact-group' be interactive? --rsteib
+
 (defun nnml-request-compact-group (group &optional server save)
   (nnml-possibly-change-directory group server)
   (unless nnml-article-file-alist
@@ -1080,9 +1098,15 @@ Use the nov database for the current group if available."
                (let* ((oldfile (nnml-article-to-file old-number))
                       (newfile
                        (gnus-replace-in-string
-                        oldfile (concat "\\("
-                                        old-number-string
-                                        "\\)\\(\\(\\.gz\\)?\\)$")
+                        oldfile
+                        ;; nnml-use-compressed-files might be any string, but
+                        ;; probably it's sufficient to take into account only
+                        ;; "\\.[a-z0-9]+".  Note that we can't only use the
+                        ;; value of nnml-use-compressed-files because old
+                        ;; articles might have been saved with a different
+                        ;; value.
+                        (concat
+                         "\\(" old-number-string "\\)\\(\\(\\.[a-z0-9]+\\)?\\)$")
                         (concat new-number-string "\\2"))))
                  (with-current-buffer nntp-server-buffer
                    (nnmail-find-file oldfile)