*** empty log message ***
[gnus] / lisp / nndoc.el
index 0c22c54..6873dc5 100644 (file)
@@ -52,11 +52,7 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
      (article-begin . "^#! *rnews +\\([0-9]+\\) *\n")
      (body-end-function . nndoc-rnews-body-end))
     (mbox 
-     (article-begin . 
-                   ,(let ((delim (concat "^" message-unix-mail-delimiter)))
-                      (if (string-match "\n\\'" delim)
-                          (substring delim 0 (match-beginning 0))
-                        delim)))
+     (article-begin-function . nndoc-mbox-article-begin)
      (body-end-function . nndoc-mbox-body-end))
     (babyl 
      (article-begin . "\^_\^L *\n")
@@ -82,7 +78,7 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
      (subtype digest guess))
     (standard-digest
      (first-article . ,(concat "^" (make-string 70 ?-) "\n\n+"))
-     (article-begin . ,(concat "\n\n" (make-string 30 ?-) "\n\n+"))
+     (article-begin . ,(concat "^\n" (make-string 30 ?-) "\n\n+"))
      (prepare-body-function . nndoc-unquote-dashes)
      (body-end-function . nndoc-digest-body-end)
      (head-end . "^ ?$")
@@ -101,8 +97,8 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
       (article-begin . "^\\\\\\\\\n")
       (head-begin . "^Paper.*:")
       (head-end   . "\\(^\\\\\\\\.*\n\\|-----------------\\)")
-      (body-begin . "")  
-      (body-end   . "-------------------------------------------------")     
+      (body-begin . "")
+      (body-end   . "-------------------------------------------------")
       (file-end   . "^Title: Recent Seminal")
       (generate-head-function . nndoc-generate-lanl-gov-head)
       (article-transform-function . nndoc-transform-lanl-gov-announce)
@@ -136,6 +132,7 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
 (defvoo nndoc-prepare-body-function nil)
 (defvoo nndoc-generate-head-function nil)
 (defvoo nndoc-article-transform-function nil)
+(defvoo nndoc-article-begin-function nil)
 
 (defvoo nndoc-status-string "")
 (defvoo nndoc-group-alist nil)
@@ -169,7 +166,8 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
                (insert-buffer-substring
                 nndoc-current-buffer (car entry) (nth 1 entry)))
              (goto-char (point-max))
-             (or (= (char-after (1- (point))) ?\n) (insert "\n"))
+             (unless (= (char-after (1- (point))) ?\n)
+               (insert "\n"))
              (insert (format "Lines: %d\n" (nth 4 entry)))
              (insert ".\n")))
 
@@ -338,22 +336,27 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
   (when (looking-at message-unix-mail-delimiter)
     t))
 
+(defun nndoc-mbox-article-begin ()
+  (when (re-search-forward (concat "^" message-unix-mail-delimiter) nil t)
+    (goto-char (match-beginning 0))))
+
 (defun nndoc-mbox-body-end ()
   (let ((beg (point))
        len end)
     (when
        (save-excursion
-         (and (re-search-backward nndoc-article-begin nil t)
+         (and (re-search-backward 
+               (concat "^" message-unix-mail-delimiter) nil t)
               (setq end (point))
               (search-forward "\n\n" beg t)
               (re-search-backward
                "^Content-Length:[ \t]*\\([0-9]+\\) *$" end t)
               (setq len (string-to-int (match-string 1)))
               (search-forward "\n\n" beg t)
-              (or (= (setq len (+ (point) len)) (point-max))
-                  (and (< len (point-max))
-                       (goto-char len)
-                       (looking-at nndoc-article-begin)))))
+              (unless (= (setq len (+ (point) len)) (point-max))
+                (and (< len (point-max))
+                     (goto-char len)
+                     (looking-at message-unix-mail-delimiter)))))
       (goto-char len))))
 
 (defun nndoc-mmdf-type-p ()
@@ -434,23 +437,23 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
 (defun nndoc-mime-digest-type-p ()
   (let ((case-fold-search t)
        boundary-id b-delimiter entry)
-     (when (and
-           (re-search-forward
-            (concat "^Content-Type: *multipart/digest;[ \t\n]*[ \t]"
-                    "boundary=\"\\([^\"\n]*[^\" \t\n]\\)\"")
-            nil t)
-           (match-beginning 1))
-       (setq boundary-id (match-string 1)
-            b-delimiter (concat "\n--" boundary-id "[\n \t]+"))
-       (setq entry (assq 'mime-digest nndoc-type-alist))
-       (setcdr entry
-              (list
-               (cons 'head-end "^ ?$")
-               (cons 'body-begin "^ ?\n")
-               (cons 'article-begin b-delimiter)
-               (cons 'body-end-function 'nndoc-digest-body-end)
-               (cons 'file-end (concat "\n--" boundary-id "--[ \t]*$"))))
-       t)))
+    (when (and
+          (re-search-forward
+           (concat "^Content-Type: *multipart/digest;[ \t\n]*[ \t]"
+                   "boundary=\"\\([^\"\n]*[^\" \t\n]\\)\"")
+           nil t)
+          (match-beginning 1))
+      (setq boundary-id (match-string 1)
+           b-delimiter (concat "\n--" boundary-id "[\n \t]+"))
+      (setq entry (assq 'mime-digest nndoc-type-alist))
+      (setcdr entry
+             (list
+              (cons 'head-end "^ ?$")
+              (cons 'body-begin "^ ?\n")
+              (cons 'article-begin b-delimiter)
+              (cons 'body-end-function 'nndoc-digest-body-end)
+              (cons 'file-end (concat "\n--" boundary-id "--[ \t]*$"))))
+      t)))
 
 (defun nndoc-standard-digest-type-p ()
   (when (and (re-search-forward (concat "^" (make-string 70 ?-) "\n\n") nil t)
@@ -527,14 +530,15 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
       ;; Go through the file.
       (while (if (and first nndoc-first-article)
                 (nndoc-search nndoc-first-article)
-              (nndoc-search nndoc-article-begin))
+              (nndoc-article-begin))
        (setq first nil)
        (cond (nndoc-head-begin-function
               (funcall nndoc-head-begin-function))
              (nndoc-head-begin 
               (nndoc-search nndoc-head-begin)))
-       (if (or (>= (point) (point-max)) (and nndoc-file-end
-                (looking-at nndoc-file-end)))
+       (if (or (>= (point) (point-max))
+               (and nndoc-file-end
+                    (looking-at nndoc-file-end)))
            (goto-char (point-max))
          (setq head-begin (point))
          (nndoc-search (or nndoc-head-end "^$"))
@@ -547,7 +551,7 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
                   (funcall nndoc-body-end-function))
              (and nndoc-body-end
                   (nndoc-search nndoc-body-end))
-             (nndoc-search nndoc-article-begin)
+             (nndoc-article-begin)
              (progn
                (goto-char (point-max))
                (when nndoc-file-end
@@ -558,6 +562,13 @@ One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
                      (count-lines body-begin body-end))
                nndoc-dissection-alist))))))
 
+(defun nndoc-article-begin ()
+  (if nndoc-article-begin-function
+      (funcall nndoc-article-begin-function)
+    (condition-case ()
+       (nndoc-search nndoc-article-begin)
+      (error nil))))
+
 (defun nndoc-unquote-dashes ()
   "Unquote quoted non-separators in digests."
   (while (re-search-forward "^- -"nil t)