Applied a bunch of patches:
[gnus] / lisp / nnmail.el
index 9af078b..aef026f 100644 (file)
@@ -453,7 +453,7 @@ parameter.  It should return nil, `warn' or `delete'."
         (after-insert-file-functions nil))
     (condition-case ()
        (let ((coding-system-for-read nnmail-file-coding-system)
-             (auto-mode-alist (nnheader-auto-mode-alist))
+             (auto-mode-alist (mm-auto-mode-alist))
              (pathname-coding-system nnmail-pathname-coding-system))
          (insert-file-contents file)
          t)
@@ -463,6 +463,9 @@ parameter.  It should return nil, `warn' or `delete'."
   "Make pathname for GROUP."
   (concat
    (let ((dir (file-name-as-directory (expand-file-name dir))))
+     (setq group (nnheader-replace-duplicate-chars-in-string
+                 (nnheader-replace-chars-in-string group ?/ ?_)
+                 ?. ?_))
      (setq group (nnheader-translate-file-chars group))
      ;; If this directory exists, we use it directly.
      (if (or nnmail-use-long-file-names
@@ -814,8 +817,8 @@ If SOURCE is a directory spec, try to return the group name component."
        ;; if there is no head-body delimiter, we search a bit manually.
        (while (and (looking-at "From \\|[^ \t]+:")
                   (not (eobp)))
-        (forward-line 1)
-        (point))))
+        (forward-line 1))
+       (point)))
     ;; Find the Message-ID header.
     (goto-char (point-min))
     (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t)
@@ -849,7 +852,7 @@ FUNC will be called with the buffer narrowed to each mail."
       ;; Insert the incoming file.
       (set-buffer (get-buffer-create " *nnmail incoming*"))
       (erase-buffer)
-      (let ((nnheader-file-coding-system nnmail-incoming-coding-system))
+      (let ((coding-system-for-read nnmail-incoming-coding-system))
        (mm-insert-file-contents incoming))
       (prog1
          (if (zerop (buffer-size))
@@ -999,35 +1002,39 @@ Return the number of characters in the body."
   (let (lines chars)
     (save-excursion
       (goto-char (point-min))
-      (when (search-forward "\n\n" nil t)
-       (setq chars (- (point-max) (point)))
-       (setq lines (count-lines (point) (point-max)))
-       (forward-char -1)
-       (save-excursion
-         (when (re-search-backward "^Lines: " nil t)
-           (delete-region (point) (progn (forward-line 1) (point)))))
-       (beginning-of-line)
-       (insert (format "Lines: %d\n" (max lines 0)))
-       chars))))
+      (unless (search-forward "\n\n" nil t) 
+       (goto-char (point-max))
+       (insert "\n"))
+      (setq chars (- (point-max) (point)))
+      (setq lines (count-lines (point) (point-max)))
+      (forward-char -1)
+      (save-excursion
+       (when (re-search-backward "^Lines: " nil t)
+         (delete-region (point) (progn (forward-line 1) (point)))))
+      (beginning-of-line)
+      (insert (format "Lines: %d\n" (max lines 0)))
+      chars)))
 
 (defun nnmail-insert-xref (group-alist)
   "Insert an Xref line based on the (group . article) alist."
   (save-excursion
     (goto-char (point-min))
-    (when (search-forward "\n\n" nil t)
-      (forward-char -1)
-      (when (re-search-backward "^Xref: " nil t)
-       (delete-region (match-beginning 0)
-                      (progn (forward-line 1) (point))))
-      (insert (format "Xref: %s" (system-name)))
-      (while group-alist
-       (insert (format " %s:%d"
-                       (mm-encode-coding-string
-                        (caar group-alist)
-                        nnmail-pathname-coding-system)
-                       (cdar group-alist)))
-       (setq group-alist (cdr group-alist)))
-      (insert "\n"))))
+    (unless (search-forward "\n\n" nil t)
+      (goto-char (point-max))
+      (insert "\n"))
+    (forward-char -1)
+    (when (re-search-backward "^Xref: " nil t)
+      (delete-region (match-beginning 0)
+                    (progn (forward-line 1) (point))))
+    (insert (format "Xref: %s" (system-name)))
+    (while group-alist
+      (insert (format " %s:%d"
+                     (mm-encode-coding-string
+                      (caar group-alist)
+                      nnmail-pathname-coding-system)
+                     (cdar group-alist)))
+      (setq group-alist (cdr group-alist)))
+    (insert "\n")))
 
 ;;; Message washing functions
 
@@ -1040,11 +1047,11 @@ Return the number of characters in the body."
 (defun nnmail-remove-list-identifiers ()
   "Remove list identifiers from Subject headers."
   (let ((regexp (if (stringp nnmail-list-identifiers) nnmail-list-identifiers
-                 (mapconcat 'identity nnmail-list-identifiers "\\|"))))
+                 (mapconcat 'identity nnmail-list-identifiers " *\\|"))))
     (when regexp
       (goto-char (point-min))
       (when (re-search-forward
-            (concat "^Subject: +\\(Re: +\\)?\\(" regexp "\\) *")
+            (concat "^Subject: +\\(Re: +\\)?\\(" regexp " *\\)")
             nil t)
        (delete-region (match-beginning 2) (match-end 0))))))
 
@@ -1174,7 +1181,8 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
             partial regexp)
        (if (symbolp value)
            (setq value (cdr (assq value nnmail-split-abbrev-alist))))
-       (if (string= ".*" (substring value 0 2))
+       (if (and (>= (length value) 2)
+                (string= ".*" (substring value 0 2)))
            (setq value (substring value 2)
                  partial ""))
        (setq regexp (concat "^\\(\\("
@@ -1274,7 +1282,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
        (setq nnmail-cache-buffer
             (get-buffer-create " *nnmail message-id cache*")))
       (when (file-exists-p nnmail-message-id-cache-file)
-       (mm-insert-file-contents nnmail-message-id-cache-file))
+       (nnheader-insert-file-contents nnmail-message-id-cache-file))
       (set-buffer-modified-p nil)
       (current-buffer))))
 
@@ -1447,7 +1455,9 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
            (incf total new)
            (incf i))))
       ;; If we did indeed read any incoming spools, we save all info.
-      (unless (zerop total)
+      (if (zerop total)
+         (nnheader-message 4 "%s: Reading incoming mail (no new mail)...done"
+                           method (car source))
        (nnmail-save-active
         (nnmail-get-value "%s-group-alist" method)
         (nnmail-get-value "%s-active-file" method))