*** empty log message ***
[gnus] / lisp / nnmail.el
index 6eb6442..b65dad2 100644 (file)
@@ -106,7 +106,9 @@ Eg.:
 This variable is \"/usr/spool/mail/$user\" by default.
 If this variable is nil, no mail backends will read incoming mail.
 If this variable is a list, all files mentioned in this list will be
-used as incoming mailboxes.")
+used as incoming mailboxes.
+If this variable is a directory (i. e., it's name ends with a \"/\"),
+treat all files in that directory as incoming spool files.")
 
 (defvar nnmail-crash-box "~/.gnus-crash-box"
   "*File where Gnus will store mail while processing it.")
@@ -347,15 +349,18 @@ parameter.  It should return nil, `warn' or `delete'.")
   
 (defun nnmail-date-to-time (date)
   "Convert DATE into time."
-  (let* ((d1 (timezone-parse-date date))
-        (t1 (timezone-parse-time (aref d1 3))))
-    (apply 'encode-time
-          (mapcar (lambda (el)
-                    (and el (string-to-number el)))
-                  (list
-                   (aref t1 2) (aref t1 1) (aref t1 0)
-                   (aref d1 2) (aref d1 1) (aref d1 0)
-                   (aref d1 4))))))
+  (condition-case ()
+      (let* ((d1 (timezone-parse-date date))
+            (t1 (timezone-parse-time (aref d1 3))))
+       (apply 'encode-time
+              (mapcar (lambda (el)
+                        (and el (string-to-number el)))
+                      (list
+                       (aref t1 2) (aref t1 1) (aref t1 0)
+                       (aref d1 2) (aref d1 1) (aref d1 0)
+                       (aref d1 4)))))
+    ;; If we get an error, then we just return a 0 time.
+    (error (list 0 0))))
 
 (defun nnmail-time-less (t1 t2)
   "Say whether time T1 is less than time T2."
@@ -623,26 +628,35 @@ is a spool.  If not using procmail, return GROUP."
       (goto-char end))))
 
 (defun nnmail-search-unix-mail-delim ()
-  "Put point at the beginning of the next message."
-  (let ((case-fold-search t)
-       (delim (concat "^" message-unix-mail-delimiter))
+  "Put point at the beginning of the next Unix mbox message."
+  ;; Algorithm used to find the the next article in the
+  ;; brain-dead Unix mbox format:
+  ;;
+  ;; 1) Search for "^From ".
+  ;; 2) If we find it, then see whether the previous
+  ;;    line is blank and the next line looks like a header.
+  ;; Then it's possible that this is a mail delim, and we use it.
+  (let ((case-fold-search nil)
        found)
     (while (not found)
-      (if (re-search-forward delim nil t)
-         (when (or (looking-at "[^\n :]+ *:")
-                   (looking-at delim)
-                   (looking-at (concat ">" message-unix-mail-delimiter)))
-           (forward-line -1)
-           (setq found 'yes))
-       (setq found 'no)))
+      (if (not (re-search-forward "^From " nil t))
+         (setq found 'no)
+       (beginning-of-line)
+       (when (and (or (bobp)
+                      (save-excursion
+                        (forward-line -1)
+                        (= (following-char) ?\n)))
+                  (save-excursion
+                    (forward-line 1)
+                    (looking-at "[^ \t:]+[ \t]*:")))
+         (setq found 'yes))))
     (eq found 'yes)))
 
 (defun nnmail-process-unix-mail-format (func artnum-func)
-  (let ((case-fold-search t)
-       (delim (concat "^" message-unix-mail-delimiter))
+  (let ((case-fold-search nil)
        start message-id content-length end skip head-end)
     (goto-char (point-min))
-    (if (not (and (re-search-forward delim nil t)
+    (if (not (and (re-search-forward "^From " nil t)
                  (goto-char (match-beginning 0))))
        ;; Possibly wrong format?
        (error "Error, unknown mail format! (Possibly corrupted.)")
@@ -701,10 +715,9 @@ is a spool.  If not using procmail, return GROUP."
          (cond ((or (= skip (point-max))
                     (= (1+ skip) (point-max)))
                 (setq end (point-max)))
-               ((looking-at delim)
+               ((looking-at "From ")
                 (setq end skip))
-               ((looking-at
-                 (concat "[ \t]*\n\\(" delim "\\)"))
+               ((looking-at "[ \t]*\n\\(From \\)")
                 (setq end (match-beginning 1)))
                (t (setq end nil))))
        (if end
@@ -1041,9 +1054,24 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
                   (eq nnmail-spool-file 'procmail))
              nil)
             ((listp nnmail-spool-file)
-             (append nnmail-spool-file procmails))
-            ((stringp nnmail-spool-file)
+             (nconc
+              (apply 
+               'nconc
+               (mapcar 
+                (lambda (file)
+                  (if (file-directory-p file)
+                      (nnheader-directory-regular-files file)
+                    (list file)))
+                nnmail-spool-file))
+              procmails))
+            ((and (stringp nnmail-spool-file)
+                  (not (file-directory-p nnmail-spool-file)))
              (cons nnmail-spool-file procmails))
+            ((and (stringp nnmail-spool-file)
+                  (file-directory-p nnmail-spool-file))
+             (nconc
+              (nnheader-directory-regular-files nnmail-spool-file)
+              procmails))
             ((eq nnmail-spool-file 'pop)
              (cons (format "po:%s" (user-login-name)) procmails))
             (t
@@ -1298,13 +1326,19 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
             (nnmail-time-less days (nnmail-time-since time)))))))
 
 (defvar nnmail-read-passwd nil)
-(defun nnmail-read-passwd (prompt)
-  (unless nnmail-read-passwd
-    (if (load "passwd" t)
-       (setq nnmail-read-passwd 'read-passwd)
-      (autoload 'ange-ftp-read-passwd "ange-ftp")
-      (setq nnmail-read-passwd 'ange-ftp-read-passwd)))
-  (funcall nnmail-read-passwd prompt))
+(defun nnmail-read-passwd (prompt &rest args)
+  "Read a password using PROMPT.
+If ARGS, PROMPT is used as an argument to `format'."
+  (let ((prompt
+        (if args
+            (apply 'format prompt args)
+          prompt)))
+    (unless nnmail-read-passwd
+      (if (load "passwd" t)
+         (setq nnmail-read-passwd 'read-passwd)
+       (autoload 'ange-ftp-read-passwd "ange-ftp")
+       (setq nnmail-read-passwd 'ange-ftp-read-passwd)))
+    (funcall nnmail-read-passwd prompt)))
 
 (defun nnmail-check-syntax ()
   "Check (and modify) the syntax of the message in the current buffer."