*** empty log message ***
[gnus] / lisp / nnmail.el
index d9464d2..ec8b82a 100644 (file)
@@ -151,7 +151,7 @@ to be moved to.")
   "*Hook that will be run after the incoming mail has been transferred.
 The incoming mail is moved from `nnmail-spool-file' (which normally is
 something like \"/usr/spool/mail/$user\") to the user's home
-directory. This hook is called after the incoming mail box has been
+directory.  This hook is called after the incoming mail box has been
 emptied, and can be used to call any mail box programs you have
 running (\"xwatch\", etc.)
 
@@ -244,7 +244,7 @@ Example:
 
 \(setq nnmail-split-methods 'nnmail-split-fancy
       nnmail-split-fancy
-      ;; Messages from the mailer deamon are not crossposted to any of
+      ;; Messages from the mailer daemon are not crossposted to any of
       ;; the ordinary groups.  Warnings are put in a separate group
       ;; from real errors.
       '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
@@ -514,20 +514,16 @@ nn*-request-list should have been called before calling this function."
 (defun nnmail-save-active (group-assoc file-name)
   "Save GROUP-ASSOC in ACTIVE-FILE."
   (when file-name
-    (let (group)
-      (save-excursion
-       (set-buffer (get-buffer-create " *nnmail active*"))
-       (buffer-disable-undo (current-buffer))
-       (erase-buffer)
-       (while group-assoc
-         (setq group (pop group-assoc))
-         (insert (format "%s %d %d y\n" (car group) (cdadr group) 
-                         (caadr group))))
-       (unless (file-exists-p (file-name-directory file-name))
-         (make-directory (file-name-directory file-name) t))
-       (nnmail-write-region
-        1 (point-max) (expand-file-name file-name) nil 'nomesg)
-       (kill-buffer (current-buffer))))))
+    (nnheader-temp-write file-name
+      (nnmail-generate-active group-assoc))))
+
+(defun nnmail-generate-active (alist)
+  "Generate an active file from group-alist ALIST."
+  (erase-buffer)
+  (let (group)
+    (while (setq group (pop alist))
+      (insert (format "%s %d %d y\n" (car group) (cdadr group) 
+                     (caadr group))))))
 
 (defun nnmail-get-split-group (file group)
   "Find out whether this FILE is to be split into GROUP only.
@@ -1022,7 +1018,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
                             (> (nnheader-file-size
                                 (file-truename nnmail-crash-box)) 0))
                    (list nnmail-crash-box))))
-      ;; Remove any directories that inadvertantly match the procmail
+      ;; Remove any directories that inadvertently match the procmail
       ;; suffix, which might happen if the suffix is "". 
       (while p
        (when (file-directory-p (car p))
@@ -1147,6 +1143,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
   (run-hooks 'nnmail-prepare-incoming-message-hook)
   ;; If this is a duplicate message, then we do not save it.
   (let* ((duplication (nnmail-cache-id-exists-p message-id))
+        (case-fold-search t)
         (action (when duplication
                   (cond
                    ((memq nnmail-treat-duplicates '(warn delete))
@@ -1155,16 +1152,14 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
                     (funcall nnmail-treat-duplicates message-id))
                    (t
                     nnmail-treat-duplicates))))
-        (group-art (nreverse (nnmail-article-group artnum-func))))
+        group-art)
     ;; Let the backend save the article (or not).
     (cond
-     ((null group-art)
-      (delete-region (point-min) (point-max)))
      ((not duplication)
       (nnmail-cache-insert message-id)
-      (funcall func group-art))
+      (funcall func (setq group-art
+                         (nreverse (nnmail-article-group artnum-func)))))
      ((eq action 'delete)
-      (delete-region (point-min) (point-max))
       (setq group-art nil))
      ((eq action 'warn)
       ;; We insert a warning.
@@ -1179,11 +1174,15 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
         "Message-ID: " newid "\n"
         "Gnus-Warning: This is a duplicate of message " message-id "\n")
        (nnmail-cache-insert newid)
-       (funcall func group-art)))
+       (funcall func (setq group-art
+                           (nreverse (nnmail-article-group artnum-func))))))
      (t
-      (funcall func group-art)))
+      (funcall func (setq group-art
+                         (nreverse (nnmail-article-group artnum-func))))))
     ;; Add the group-art list to the history list.
-    (push group-art nnmail-split-history)))
+    (if group-art
+       (push group-art nnmail-split-history)
+      (delete-region (point-min) (point-max)))))
 
 ;;; Get new mail.
 
@@ -1214,7 +1213,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
        (setq spool (pop spools))
        ;; We read each spool file if either the spool is a POP-mail
        ;; spool, or the file exists.  We can't check for the
-       ;; existance of POPped mail.
+       ;; existence of POPped mail.
        (when (or (string-match "^po:" spool)
                  (and (file-exists-p spool)
                       (> (nnheader-file-size (file-truename spool)) 0)))
@@ -1297,7 +1296,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
   (save-restriction
     (message-narrow-to-head)
     (let ((case-fold-search t))
-      (unless (re-search-forward "^Message-Id:" nil t)
+      (unless (re-search-forward "^Message-ID:" nil t)
        (insert "Message-ID: " (nnmail-message-id) "\n")))))
 
 (defun nnmail-write-region (start end filename &optional append visit lockname)
@@ -1375,10 +1374,10 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
   (let ((history nnmail-split-history)
        elem ga)
     (while (setq elem (pop history))
-      (insert (mapcar (lambda (ga)
-                       (concat (car ga) ":" (int-to-string (cdr ga))))
-                     elem
-                     ", ")
+      (insert (mapconcat (lambda (ga)
+                          (concat (car ga) ":" (int-to-string (cdr ga))))
+                        elem
+                        ", ")
              "\n"))
     (goto-char (point-min))))