Support www.mail-archive.com.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 7 Dec 1999 05:09:43 +0000 (05:09 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 7 Dec 1999 05:09:43 +0000 (05:09 +0000)
A bit speed up for nnmail-get-new-mail.

lisp/ChangeLog
lisp/nnmail.el
lisp/nnwarchive.el

index 81b3315..95043a8 100644 (file)
@@ -1,3 +1,12 @@
+1999-12-06 23:57:47  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * nnwarchive.el: Support www.mail-archive.com.
+
+1999-12-06 23:55:55  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * nnmail.el (nnmail-get-new-mail): Remove fetched sources before
+       do anything.
+
 1999-12-06  Simon Josefsson  <jas@pdc.kth.se>
 
        * utf7.el: New file, written by Jon K Hellan.
index 6e928a6..9329646 100644 (file)
@@ -1393,6 +1393,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
   (let* ((sources (or mail-sources
                      (if (listp nnmail-spool-file) nnmail-spool-file
                        (list nnmail-spool-file))))
+        fetching-sources
         (group-in group)
         (i 0)
         (new 0)
@@ -1400,14 +1401,6 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
         incoming incomings source)
     (when (and (nnmail-get-value "%s-get-new-mail" method)
               nnmail-spool-file)
-      ;; We first activate all the groups.
-      (nnmail-activate method)
-      ;; Allow the user to hook.
-      (run-hooks 'nnmail-pre-get-new-mail-hook)
-      ;; Open the message-id cache.
-      (nnmail-cache-open)
-      ;; The we go through all the existing mail source specification
-      ;; and fetch the mail from each.
       (while (setq source (pop sources))
        ;; Be compatible with old values.
        (cond
@@ -1439,21 +1432,31 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
        (when nnmail-fetched-sources
          (if (member source nnmail-fetched-sources)
              (setq source nil)
-           (push source nnmail-fetched-sources)))
-       (when source
-         (nnheader-message 4 "%s: Reading incoming mail from %s..."
-                           method (car source))
-         (when (setq new
-                     (mail-source-fetch
-                      source
-                      `(lambda (file orig-file)
-                         (nnmail-split-incoming
-                          file ',(intern (format "%s-save-mail" method))
-                          ',spool-func
-                          (nnmail-get-split-group orig-file source)
-                          ',(intern (format "%s-active-number" method))))))
-           (incf total new)
-           (incf i))))
+           (push source nnmail-fetched-sources)
+           (push source fetching-sources)))))
+    (when fetching-sources
+      ;; We first activate all the groups.
+      (nnmail-activate method)
+      ;; Allow the user to hook.
+      (run-hooks 'nnmail-pre-get-new-mail-hook)
+      ;; Open the message-id cache.
+      (nnmail-cache-open)
+      ;; The we go through all the existing mail source specification
+      ;; and fetch the mail from each.
+      (while (setq source (pop fetching-sources))
+       (nnheader-message 4 "%s: Reading incoming mail from %s..."
+                         method (car source))
+       (when (setq new
+                   (mail-source-fetch
+                    source
+                    `(lambda (file orig-file)
+                       (nnmail-split-incoming
+                        file ',(intern (format "%s-save-mail" method))
+                        ',spool-func
+                        (nnmail-get-split-group orig-file source)
+                        ',(intern (format "%s-active-number" method))))))
+         (incf total new)
+         (incf i)))
       ;; If we did indeed read any incoming spools, we save all info.
       (if (zerop total)
          (nnheader-message 4 "%s: Reading incoming mail (no new mail)...done"
index 46f6174..dc06c9d 100644 (file)
 
 ;; A lot of codes stolen from mail-source, nnslashdot, nnweb.
 
-;; Todo: To support more web archives.
+;; Todo: 
+;; 1. To support more web archives.
+;; 2. Support nnwarchive-xover-is-evil.
 
 ;; Known bugs: in w3 0.44, there are two copies of url-maybe-relative.
-;; If it is loaded from w3.el, (load-library "url").  w3 0.45 should
-;; work.
+;; If it is loaded from w3.el, (load-library "url").  Update to w3 0.46 
+;; or greater version.
 
 ;;; Code:
 
 
 (nnoo-declare nnwarchive)
 
-(eval-and-compile
-  (defvar nnwarchive-type-definition
-    '((egroups
-       (open-url 
-       "http://www.egroups.com/register?method=loginAction&email=%s&password=%s" 
-       login passwd)
-       (list-url 
-       "http://www.egroups.com/UserGroupsPage?")
-       (list-dissect . nnwarchive-egroups-list)
-       (list-groups . nnwarchive-egroups-list-groups)
-       (xover-url 
-       "http://www.egroups.com/group/%s/?fetchForward=1&start=%d" group start)
-       (xover-last-url 
-       "http://www.egroups.com/group/%s/?fetchForward=1" group)
-       (xover-page-size . 13)
-       (xover-dissect . nnwarchive-egroups-xover)
-       (article-url 
-       "http://www.egroups.com/group/%s/%d.html?raw=1" group article)
-       (article-dissect . nnwarchive-egroups-article)))))
-  
-(eval-and-compile
-  (defvar nnwarchive-short-names
-    '(login passwd)))
+(defvar nnwarchive-type-definition
+  '((egroups
+     (address . "www.egroups.com")
+     (open-url 
+      "http://www.egroups.com/register?method=loginAction&email=%s&password=%s" 
+      nnwarchive-login nnwarchive-passwd)
+     (list-url 
+      "http://www.egroups.com/UserGroupsPage?")
+     (list-dissect . nnwarchive-egroups-list)
+     (list-groups . nnwarchive-egroups-list-groups)
+     (xover-url 
+      "http://www.egroups.com/group/%s/?fetchForward=1&start=%d" group aux)
+     (xover-last-url 
+      "http://www.egroups.com/group/%s/?fetchForward=1" group)
+     (xover-page-size . 13)
+     (xover-dissect . nnwarchive-egroups-xover)
+     (article-url 
+      "http://www.egroups.com/group/%s/%d.html?raw=1" group article)
+     (article-dissect . nnwarchive-egroups-article)
+     (authentication . t)
+     (xover-files . nnwarchive-egroups-xover-files))
+    (mail-archive
+     (address . "www.mail-archive.com")
+     (list-url 
+      "http://www.mail-archive.com/lists.html")
+     (list-dissect . nnwarchive-mail-archive-list)
+     (list-groups . nnwarchive-mail-archive-list-groups)
+     (xover-url 
+      "http://www.mail-archive.com/%s/mail%d.html" group aux)
+     (xover-last-url 
+      "http://www.mail-archive.com/%s/maillist.html" group)
+     (xover-dissect . nnwarchive-mail-archive-xover)
+     (article-url 
+      "http://www.mail-archive.com/%s/msg%05d.html" group article1)
+     (article-dissect . nnwarchive-mail-archive-article)
+     (xover-files . nnwarchive-mail-archive-xover-files)
+     (article-offset . 1))))
+
+(defvar nnwarchive-default-type 'egroups)
 
 (defvoo nnwarchive-directory (nnheader-concat gnus-directory "warchive/")
   "Where nnwarchive will save its files.")
 
 (eval-and-compile
-  (defvoo nnwarchive-type 'egroups
+  (defvoo nnwarchive-type nil
     "The type of nnwarchive."))
 
-(defvoo nnwarchive-address "egroups.com"
+(defvoo nnwarchive-address ""
   "The address of nnwarchive.")
 
 (defvoo nnwarchive-login nil
 
 (defvoo nnwarchive-opened nil)
 
+(defvoo nnwarchive-authentication nil)
+
+(defvoo nnwarchive-xover-is-evil nil) ;; not implemented
+
 (defconst nnwarchive-version "nnwarchive 1.0")
 
 ;;; Internal variables
 
-(defvar nnwarchive-open-url nil)
-(defvar nnwarchive-open-dissect nil)
+(defvoo nnwarchive-open-url nil)
+(defvoo nnwarchive-open-dissect nil)
 
-(defvar nnwarchive-list-url nil)
-(defvar nnwarchive-list-dissect nil)
-(defvar nnwarchive-list-groups nil)
+(defvoo nnwarchive-list-url nil)
+(defvoo nnwarchive-list-dissect nil)
+(defvoo nnwarchive-list-groups nil)
 
-(defvar nnwarchive-xover-url nil)
-(defvar nnwarchive-xover-last-url nil)
-(defvar nnwarchive-xover-dissect nil)
-(defvar nnwarchive-xover-page-size nil)
+(defvoo nnwarchive-xover-files nil)
+(defvoo nnwarchive-xover-url nil)
+(defvoo nnwarchive-xover-last-url nil)
+(defvoo nnwarchive-xover-dissect nil)
+(defvoo nnwarchive-xover-page-size nil)
 
-(defvar nnwarchive-article-url nil)
-(defvar nnwarchive-article-dissect nil)
+(defvoo nnwarchive-article-url nil)
+(defvoo nnwarchive-article-dissect nil)
+(defvoo nnwarchive-xover-files nil)
+(defvoo nnwarchive-article-offset 0)
 
-(defvar nnwarchive-buffer nil)
+(defvoo nnwarchive-buffer nil)
 
 (defvar nnwarchive-headers nil)
 
+
 ;;; Interface functions
 
 (nnoo-define-basics nnwarchive)
 
-(eval-and-compile
-  (defun nnwarchive-bind-1 ()
-    (let ((defaults (cdr (assq nnwarchive-type nnwarchive-type-definition)))
-         (short-names nnwarchive-short-names)
-         default bind)
-      (while (setq default (pop defaults))
-       (push (list (intern (concat "nnwarchive-" (symbol-name (car default))))
-                   (list 'quote (cdr default))) bind))
-      (while (setq default (pop short-names))
-       (push (list default
-                   (intern (concat "nnwarchive-" 
-                                   (symbol-name default)))) 
-             bind))
-      bind)))
-
-(defmacro nnwarchive-bind (&rest body)
-  "Return a `let' form that binds all variables in TYPE.
-Read `mail-source-bind' for details."
-  `(let ,(nnwarchive-bind-1)
-     ,@body))
-
-(put 'nnwarchive-bind 'lisp-indent-function 0)
-(put 'nnwarchive-bind 'edebug-form-spec '(form body))
+(defun nnwarchive-set-default (type)
+  (let ((defs (cdr (assq type nnwarchive-type-definition)))
+       def)
+    (dolist (def defs)
+      (set (intern (concat "nnwarchive-" (symbol-name (car def)))) 
+          (cdr def)))))
 
 (deffoo nnwarchive-retrieve-headers (articles &optional group server fetch-old)
   (nnwarchive-possibly-change-server group server)
-  (nnwarchive-bind 
-   (setq nnwarchive-headers (cdr (assoc group nnwarchive-headers-cache)))
-   (save-excursion
-     (set-buffer nnwarchive-buffer)
-     (erase-buffer)
-     (let (point start starts)
-       (setq starts (nnwarchive-paged (sort articles '<)))
-       (while (setq start (pop starts))
-        (goto-char (point-max))
-        (nnwarchive-url nnwarchive-xover-url))
-       (if nnwarchive-xover-dissect
-          (funcall nnwarchive-xover-dissect))))
-   (save-excursion
-     (set-buffer nntp-server-buffer)
-     (erase-buffer)
-     (let (header)
-       (dolist (art articles)
-        (if (setq header (assq art nnwarchive-headers))
-            (nnheader-insert-nov (cdr header))))))
-   (let ((elem (assoc group nnwarchive-headers-cache)))
-     (if elem
-        (setcdr elem nnwarchive-headers)
-       (push (cons group nnwarchive-headers) nnwarchive-headers-cache)))
-   'nov))
+  (setq nnwarchive-headers (cdr (assoc group nnwarchive-headers-cache)))
+  (save-excursion
+    (set-buffer nnwarchive-buffer)
+    (erase-buffer)
+    (funcall nnwarchive-xover-files group articles))
+  (save-excursion
+    (set-buffer nntp-server-buffer)
+    (erase-buffer)
+    (let (header)
+      (dolist (art articles)
+       (if (setq header (assq art nnwarchive-headers))
+           (nnheader-insert-nov (cdr header))))))
+  (let ((elem (assoc group nnwarchive-headers-cache)))
+    (if elem
+       (setcdr elem nnwarchive-headers)
+      (push (cons group nnwarchive-headers) nnwarchive-headers-cache)))
+  'nov)
 
 (deffoo nnwarchive-retrieve-groups (groups &optional server)
   "Retrieve group info on GROUPS."
   (nnwarchive-possibly-change-server nil server)
-  (nnwarchive-bind 
-   (if nnwarchive-list-groups
-       (funcall nnwarchive-list-groups groups))
-   (nnwarchive-write-groups)
-   (nnwarchive-generate-active)
-   'active))
+  (if nnwarchive-list-groups
+      (funcall nnwarchive-list-groups groups))
+  (nnwarchive-write-groups)
+  (nnwarchive-generate-active)
+  'active)
 
 (deffoo nnwarchive-request-group (group &optional server dont-check)
   (nnwarchive-possibly-change-server nil server)
-  (nnwarchive-bind 
-   (if nnwarchive-list-groups
-       (funcall nnwarchive-list-groups (list group)))
-   (nnwarchive-write-groups)
-   (let ((elem (assoc group nnwarchive-groups)))
-     (cond
-      ((not elem)
-       (nnheader-report 'nnwarchive "Group does not exist"))
-      (t
-       (nnheader-report 'nnwarchive "Opened group %s" group)
-       (nnheader-insert
-       "211 %d %d %d %s\n" (or (cadr elem) 0) 1 (or (cadr elem) 0)
-       (prin1-to-string group))
-       t)))))
+  (if nnwarchive-list-groups
+      (funcall nnwarchive-list-groups (list group)))
+  (nnwarchive-write-groups)
+  (let ((elem (assoc group nnwarchive-groups)))
+    (cond
+     ((not elem)
+      (nnheader-report 'nnwarchive "Group does not exist"))
+     (t
+      (nnheader-report 'nnwarchive "Opened group %s" group)
+      (nnheader-insert
+       "211 %d %d %d %s\n" (or (cadr elem) 0) 1 (or (cadr elem) 0)
+       (prin1-to-string group))
+      t))))
 
 (deffoo nnwarchive-close-group (group &optional server)
   (nnwarchive-possibly-change-server group server)
-  (nnwarchive-bind
-   (when (gnus-buffer-live-p nnwarchive-buffer)
-     (save-excursion
-       (set-buffer nnwarchive-buffer)
-       (kill-buffer nnwarchive-buffer)))
-   t))
+  (when (gnus-buffer-live-p nnwarchive-buffer)
+    (save-excursion
+      (set-buffer nnwarchive-buffer)
+      (kill-buffer nnwarchive-buffer)))
+  t)
 
 (deffoo nnwarchive-request-article (article &optional group server buffer)
   (nnwarchive-possibly-change-server group server)
-  (nnwarchive-bind 
-   (let (contents)
-     (save-excursion
-       (set-buffer nnwarchive-buffer)
-       (goto-char (point-min))
-       (nnwarchive-url nnwarchive-article-url)
-       (setq contents (funcall nnwarchive-article-dissect)))
-     (when contents
-       (save-excursion
-        (set-buffer (or buffer nntp-server-buffer))
-        (erase-buffer)
-        (insert contents)
-        (nnheader-report 'nnwarchive "Fetched article %s" article)
-        (cons group article))))))
+  (let (contents)
+    (save-excursion
+      (set-buffer nnwarchive-buffer)
+      (goto-char (point-min))
+      (let ((article1 (- article nnwarchive-article-offset)))
+       (nnwarchive-url nnwarchive-article-url))
+      (setq contents (funcall nnwarchive-article-dissect group article)))
+    (when contents
+      (save-excursion
+       (set-buffer (or buffer nntp-server-buffer))
+       (erase-buffer)
+       (insert contents)
+       (nnheader-report 'nnwarchive "Fetched article %s" article)
+       (cons group article)))))
 
 (deffoo nnwarchive-close-server (&optional server)
   (when (and (nnwarchive-server-opened server)
@@ -247,23 +246,21 @@ Read `mail-source-bind' for details."
 
 (deffoo nnwarchive-request-list (&optional server)
   (nnwarchive-possibly-change-server nil server)
-  (nnwarchive-bind
-   (save-excursion
-     (set-buffer nnwarchive-buffer)
-     (erase-buffer)
-     (if nnwarchive-list-url
-        (nnwarchive-url nnwarchive-list-url))
-     (if nnwarchive-list-dissect
-        (funcall nnwarchive-list-dissect))
-     (nnwarchive-write-groups)
-     (nnwarchive-generate-active)))
+  (save-excursion
+    (set-buffer nnwarchive-buffer)
+    (erase-buffer)
+    (if nnwarchive-list-url
+       (nnwarchive-url nnwarchive-list-url))
+    (if nnwarchive-list-dissect
+       (funcall nnwarchive-list-dissect))
+    (nnwarchive-write-groups)
+    (nnwarchive-generate-active))
   'active)
 
 (deffoo nnwarchive-request-newgroups (date &optional server)
   (nnwarchive-possibly-change-server nil server)
-  (nnwarchive-bind
-   (nnwarchive-write-groups)
-   (nnwarchive-generate-active))
+  (nnwarchive-write-groups)
+  (nnwarchive-generate-active)
   'active)
 
 (deffoo nnwarchive-asynchronous-p ()
@@ -274,29 +271,29 @@ Read `mail-source-bind' for details."
 
 (deffoo nnwarchive-open-server (server &optional defs connectionless)
   (nnwarchive-init server)
-  (if (nnwarchive-server-opened server)
-      t
-    (setq nnwarchive-login
-         (or nnwarchive-login
-             (read-string
-              (format "Login at %s: " server)
-              user-mail-address)))
-    (setq nnwarchive-passwd
-         (or nnwarchive-passwd
-             (mail-source-read-passwd
-              (format "Password for %s at %s: " nnwarchive-login server))))
-    (nnwarchive-bind 
-     (unless nnwarchive-groups
-       (nnwarchive-read-groups))
-     (save-excursion
-       (set-buffer nnwarchive-buffer)
-       (erase-buffer)
-       (if nnwarchive-open-url
-          (nnwarchive-url nnwarchive-open-url))
-       (if nnwarchive-open-dissect
-          (funcall nnwarchive-open-dissect))
-       (setq nnwarchive-opened t)))
-    t))
+  (unless (nnwarchive-server-opened server)
+    (when nnwarchive-authentication
+      (setq nnwarchive-login
+           (or nnwarchive-login
+               (read-string
+                (format "Login at %s: " server)
+                user-mail-address)))
+      (setq nnwarchive-passwd
+           (or nnwarchive-passwd
+               (mail-source-read-passwd
+                (format "Password for %s at %s: " 
+                        nnwarchive-login server)))))
+    (unless nnwarchive-groups
+      (nnwarchive-read-groups))
+    (save-excursion
+      (set-buffer nnwarchive-buffer)
+      (erase-buffer)
+      (if nnwarchive-open-url
+         (nnwarchive-url nnwarchive-open-url))
+      (if nnwarchive-open-dissect
+         (funcall nnwarchive-open-dissect))
+      (setq nnwarchive-opened t)))
+  t)
 
 (nnoo-define-skeleton nnwarchive)
 
@@ -324,13 +321,28 @@ Read `mail-source-bind' for details."
 
 (defun nnwarchive-init (server)
   "Initialize buffers and such."
+  (let ((type (intern server)) (defs nnwarchive-type-definition) def)
+    (cond 
+     ((equal server "")
+      (setq type nnwarchive-default-type))
+     ((assq type nnwarchive-type-definition) t)
+     (t
+      (setq type nil)
+      (while (setq def (pop defs))
+       (when (equal (cdr (assq 'address (cdr def))) server)
+         (setq defs nil)
+         (setq type (car def))))
+      (unless type
+       (error "Undefined server %s" server))))
+    (setq nnwarchive-type type))
   (unless (file-exists-p nnwarchive-directory)
     (gnus-make-directory nnwarchive-directory))
   (unless (gnus-buffer-live-p nnwarchive-buffer)
     (setq nnwarchive-buffer
          (save-excursion
            (nnheader-set-temp-buffer
-            (format " *nnwarchive %s %s*" nnwarchive-type server))))))
+            (format " *nnwarchive %s %s*" nnwarchive-type server)))))
+  (nnwarchive-set-default nnwarchive-type))
 
 (defun nnwarchive-encode-www-form-urlencoded (pairs)
   "Return PAIRS encoded for forms."
@@ -437,7 +449,7 @@ Read `mail-source-bind' for details."
              (setcar (cdr elem) articles)
            (push (list group articles "") nnwarchive-groups)))
        (setq nnwarchive-headers (cdr (assoc group nnwarchive-headers-cache)))
-       (nnwarchive-egroups-xover)
+       (nnwarchive-egroups-xover group)
        (let ((elem (assoc group nnwarchive-headers-cache)))
          (if elem
              (setcdr elem nnwarchive-headers)
@@ -462,8 +474,8 @@ Read `mail-source-bind' for details."
     (nnwarchive-egroups-list-groups (mapcar 'identity nnwarchive-groups)))
   t)
 
-(defun nnwarchive-egroups-xover()
-  (let (article subject from date group)
+(defun nnwarchive-egroups-xover (group)
+  (let (article subject from date)
     (goto-char (point-min))
     (while (re-search-forward
            "<a href=\"/group/\\([^/]+\\)/\\([0-9]+\\)\\.html[^>]+>\\([^<]+\\)<"
@@ -492,7 +504,7 @@ Read `mail-source-bind' for details."
                0 0 "")) nnwarchive-headers))))
   nnwarchive-headers)
 
-(defun nnwarchive-egroups-article ()
+(defun nnwarchive-egroups-article (group articles)
   (goto-char (point-min))
   (if (search-forward "<pre>" nil t)
       (delete-region (point-min) (point)))
@@ -505,6 +517,165 @@ Read `mail-source-bind' for details."
   (nnwarchive-decode-entities)
   (buffer-substring (point-min) (point-max)))
 
+(defun nnwarchive-egroups-xover-files (group articles)
+  (let (aux auxs)
+    (setq auxs (nnwarchive-paged (sort articles '<)))
+    (while (setq aux (pop auxs))
+      (goto-char (point-max))
+      (nnwarchive-url nnwarchive-xover-url))
+    (if nnwarchive-xover-dissect
+       (nnwarchive-egroups-xover group))))
+
+;; mail-archive
+
+(defun nnwarchive-mail-archive-list-groups (groups)
+  (save-excursion
+    (let (articles)
+      (set-buffer nnwarchive-buffer)
+      (dolist (group groups)
+       (erase-buffer)
+       (nnwarchive-url nnwarchive-xover-last-url)
+       (goto-char (point-min))
+       (when (re-search-forward "msg\\([0-9]+\\)\\.html" nil t)
+         (setq articles (1+ (string-to-number (match-string 1)))))
+       (let ((elem (assoc group nnwarchive-groups)))
+         (if elem
+             (setcar (cdr elem) articles)
+           (push (list group articles "") nnwarchive-groups)))
+       (setq nnwarchive-headers (cdr (assoc group nnwarchive-headers-cache)))
+       (nnwarchive-mail-archive-xover group)
+       (let ((elem (assoc group nnwarchive-headers-cache)))
+         (if elem
+             (setcdr elem nnwarchive-headers)
+           (push (cons group nnwarchive-headers) 
+                 nnwarchive-headers-cache)))))))
+
+(defun nnwarchive-mail-archive-list ()
+  (let ((case-fold-search t)
+       group description elem articles)
+    (goto-char (point-min))
+    (while (re-search-forward "<a href=\"\\([^/]+\\)/\">\\([^>]+\\)<" nil t)
+      (setq group (match-string 1)
+           description (match-string 2))
+      (forward-line 1)
+      (setq articles 0)
+      (if (setq elem (assoc group nnwarchive-groups))
+         (setcar (cdr elem) articles)
+       (push (list group articles description) nnwarchive-groups))))
+  t)
+
+(defun nnwarchive-mail-archive-xover (group)
+  (let (article subject from date)
+    (goto-char (point-min))
+    (while (re-search-forward
+           "<A[^>]*HREF=\"msg\\([0-9]+\\)\\.html[^>]+>\\([^<]+\\)<"
+           nil t)
+      (setq article (1+ (string-to-number (match-string 1)))
+           subject (match-string 2))
+      (forward-line 1)
+      (unless (assq article nnwarchive-headers)
+       (if (looking-at "<UL><LI><EM>From</EM>:\\([^&]+\\)&lt;\\([^&]+\\)&gt;")
+           (progn
+             (setq from (match-string 1)
+                   date (identity (match-string 2))))
+         (setq from "" date ""))
+       (push (cons
+              article
+              (make-full-mail-header
+               article 
+               (nnwarchive-decode-entities-string subject)
+               (nnwarchive-decode-entities-string from)
+               date
+               (format "<%05d%%%s>\n" (1- article) group)
+               ""
+               0 0 "")) nnwarchive-headers))))
+  nnwarchive-headers)
+
+(defun nnwarchive-mail-archive-xover-files (group articles)
+  (unless nnwarchive-headers
+    (erase-buffer)
+    (nnwarchive-url nnwarchive-xover-last-url)
+    (goto-char (point-min))
+    (nnwarchive-mail-archive-xover group))
+  (let ((minart (apply 'min articles))
+       (min (apply 'min (mapcar 'car nnwarchive-headers)))
+       (aux 2))
+    (while (> min minart)
+      (erase-buffer)
+      (nnwarchive-url nnwarchive-xover-url)
+      (nnwarchive-mail-archive-xover group)
+      (setq min (apply 'min (mapcar 'car nnwarchive-headers))))))
+
+(defun nnwarchive-mail-archive-article (group article)
+  (let (p refs url mime file)
+    (save-restriction
+      (goto-char (point-min))
+      (when (search-forward "<ul>" nil t)
+       (forward-line)
+       (delete-region (point-min) (point))
+       (search-forward "</ul>" nil t)
+       (forward-line)
+       (narrow-to-region (point-min) (point))
+       (nnwarchive-remove-markup)
+       (nnwarchive-decode-entities)
+       (goto-char (point-min))
+       (delete-blank-lines)
+       (goto-char (point-max))
+       (widen)
+       (insert "\n"))
+      (setq p (point)) 
+      (when (search-forward "X-Body-of-Message" nil t)
+         (forward-line)
+         (delete-region p (point))
+         (search-forward "X-Body-of-Message-End" nil t)
+         (beginning-of-line)
+         (save-restriction
+           (narrow-to-region p (point))
+           (goto-char (point-min))
+           (if (looking-at "<PRE>") 
+               (progn
+                 (delete-char 5)
+                 (setq p (point))
+                 (when (search-forward "</PRE>" nil t)
+                   (goto-char (match-beginning 0))
+                   (delete-char 6)
+                   (save-restriction
+                     (narrow-to-region p (point))
+                     (nnwarchive-remove-markup)
+                     (nnwarchive-decode-entities)
+                     (goto-char (point-max))))
+                 (while (looking-at
+                         "[\040\n\r\t]*<P><A HREF=\"\\([^\"]+\\)[^>]*><[^>]*>\\([^<]+\\)")
+                   (setq url (match-string 1)
+                         file (match-string 2))
+                   (goto-char (match-beginning 1))
+                   (beginning-of-line)
+                   (setq p (point))
+                   (delete-region p (progn (forward-line) (point)))
+                   (insert (format "http://www.mail-archive.com/%s/%s\n"
+                                   group url))))
+             (setq mime t))
+           (goto-char (point-max))))
+      (setq p (point))
+      (when (search-forward "X-References-End" nil t)
+       (narrow-to-region p (point))
+       (goto-char (point-min))
+       (while (re-search-forward "msg\\([0-9]+\\)\\.html" nil t)
+         (push (concat "<" (match-string 1) "%" group ">") refs))
+       (widen))
+      (delete-region p (point-max))
+      (goto-char (point-min))
+      (insert (format "Message-ID: <%05d%%%s>\n" (1- article) group))
+      (when refs
+       (insert "References:")
+       (while refs
+         (insert " " (pop refs)))
+       (insert "\n"))
+      (when mime
+       (insert "MIME-Version: 1.0\n"
+               "Content-Type: text/html\n")))
+    (buffer-string (point-min) (point-max))))
+
 (provide 'nnwarchive)
 
 ;;; nnwarchive.el ends here