Importing Pterodactyl Gnus v0.98.
[elisp/gnus.git-] / lisp / nnfolder.el
index a45f4f7..e989080 100644 (file)
@@ -119,8 +119,9 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
            (set-buffer nnfolder-current-buffer)
            (when (nnfolder-goto-article article)
              (setq start (point))
-             (search-forward "\n\n" nil t)
-             (setq stop (1- (point)))
+             (setq stop (if (search-forward "\n\n" nil t)
+                            (1- (point))
+                          (point-max)))
              (set-buffer nntp-server-buffer)
              (insert (format "221 %d Article retrieved.\n" article))
              (insert-buffer-substring nnfolder-current-buffer start stop)
@@ -368,7 +369,8 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
         (goto-char (point-min))
         (while (re-search-forward
                 (concat "^" nnfolder-article-marker)
-                (save-excursion (search-forward "\n\n" nil t) (point)) t)
+                (save-excursion (and (search-forward "\n\n" nil t) (point))) 
+                t)
           (delete-region (progn (beginning-of-line) (point))
                          (progn (forward-line 1) (point))))
         (setq result (eval accept-form))
@@ -400,8 +402,9 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
        (save-excursion
         (set-buffer buf)
         (goto-char (point-min))
-        (search-forward "\n\n" nil t)
-        (forward-line -1)
+        (if (search-forward "\n\n" nil t)
+            (forward-line -1)
+          (goto-char (point-max)))
         (while (re-search-backward (concat "^" nnfolder-article-marker) nil t)
           (delete-region (point) (progn (forward-line 1) (point))))
         (when nnmail-cache-accepted-message-ids
@@ -647,8 +650,9 @@ deleted.  Point is left where the deleted region was."
     (while (setq group-art (pop group-art-list))
       ;; Kill any previous newsgroup markers.
       (goto-char (point-min))
-      (search-forward "\n\n" nil t)
-      (forward-line -1)
+      (if (search-forward "\n\n" nil t)
+         (forward-line -1)
+       (goto-char (point-max)))
       (while (search-backward (concat "\n" nnfolder-article-marker) nil t)
        (delete-region (1+ (point)) (progn (forward-line 2) (point))))
 
@@ -677,10 +681,12 @@ deleted.  Point is left where the deleted region was."
 (defun nnfolder-insert-newsgroup-line (group-art)
   (save-excursion
     (goto-char (point-min))
-    (when (search-forward "\n\n" nil t)
-      (forward-char -1)
-      (insert (format (concat nnfolder-article-marker "%d   %s\n")
-                     (cdr group-art) (current-time-string))))))
+    (unless (search-forward "\n\n" nil t)
+      (goto-char (point-max))
+      (insert "\n"))
+    (forward-char -1)
+    (insert (format (concat nnfolder-article-marker "%d   %s\n")
+                   (cdr group-art) (current-time-string)))))
 
 (defun nnfolder-active-number (group)
   ;; Find the next article number in GROUP.