Fix my last change.
[gnus] / lisp / nnfolder.el
index a72690e..4b474b4 100644 (file)
@@ -1,5 +1,6 @@
 ;;; nnfolder.el --- mail folder access for Gnus
-;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+;;        Free Software Foundation, Inc.
 
 ;; Author: Scott Byer <byer@mv.us.adobe.com>
 ;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
   "The name of the nnfolder directory.")
 
 (defvoo nnfolder-active-file
-  (nnheader-concat nnfolder-directory "active")
+    (nnheader-concat nnfolder-directory "active")
   "The name of the active file.")
 
 ;; I renamed this variable to something more in keeping with the general GNU
 ;; style. -SLB
 
 (defvoo nnfolder-ignore-active-file nil
-  "If non-nil, causes nnfolder to do some extra work in order to determine
-the true active ranges of an mbox file.  Note that the active file is still
-saved, but it's values are not used.  This costs some extra time when
-scanning an mbox when opening it.")
+  "If non-nil, the active file is ignored.
+This causes nnfolder to do some extra work in order to determine the
+true active ranges of an mbox file.  Note that the active file is
+still saved, but its values are not used.  This costs some extra time
+when scanning an mbox when opening it.")
 
 (defvoo nnfolder-distrust-mbox nil
-  "If non-nil, causes nnfolder to not trust the user with respect to
-inserting unaccounted for mail in the middle of an mbox file.  This can greatly
-slow down scans, which now must scan the entire file for unmarked messages.
-When nil, scans occur forward from the last marked message, a huge
-time saver for large mailboxes.")
+  "If non-nil, the folder will be distrusted.
+This means that nnfolder will not trust the user with respect to
+inserting unaccounted for mail in the middle of an mbox file.  This
+can greatly slow down scans, which now must scan the entire file for
+unmarked messages.  When nil, scans occur forward from the last marked
+message, a huge time saver for large mailboxes.")
 
 (defvoo nnfolder-newsgroups-file
-  (concat (file-name-as-directory nnfolder-directory) "newsgroups")
+    (concat (file-name-as-directory nnfolder-directory) "newsgroups")
   "Mail newsgroups description file.")
 
 (defvoo nnfolder-get-new-mail t
@@ -184,11 +187,13 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
          (if (numberp article)
              (cons nnfolder-current-group article)
            (goto-char (point-min))
-           (search-forward (concat "\n" nnfolder-article-marker))
            (cons nnfolder-current-group
-                 (string-to-int
-                  (buffer-substring
-                   (point) (progn (end-of-line) (point)))))))))))
+                 (if (search-forward (concat "\n" nnfolder-article-marker) 
+                                     nil t)
+                     (string-to-int
+                      (buffer-substring
+                       (point) (progn (end-of-line) (point))))
+                   -1))))))))
 
 (deffoo nnfolder-request-group (group &optional server dont-check)
   (nnfolder-possibly-change-group group server t)
@@ -316,13 +321,15 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
        numbers))))
 
 (deffoo nnfolder-request-expire-articles
-  (articles newsgroup &optional server force)
+    (articles newsgroup &optional server force)
   (nnfolder-possibly-change-group newsgroup server)
   (let* ((is-old t)
         ;; The articles we have deleted so far.
         (deleted-articles nil)
-        ;; The articles that really exist and will be expired if they are old enough.
-        (maybe-expirable (gnus-intersection articles (nnfolder-existing-articles))))
+        ;; The articles that really exist and will
+        ;; be expired if they are old enough.
+        (maybe-expirable
+         (gnus-intersection articles (nnfolder-existing-articles))))
     (nnmail-activate 'nnfolder)
 
     (save-excursion
@@ -337,12 +344,12 @@ If NIL, NNFOLDER-FILE-CODING-SYSTEM is used.")
                                   nil t))
          (forward-sexp)
          (when (setq is-old
-                   (nnmail-expired-article-p
-                    newsgroup
-                    (buffer-substring
-                     (point) (progn (end-of-line) (point)))
-                    force nnfolder-inhibit-expiry))
-               (nnheader-message 5 "Deleting article %d..."
+                     (nnmail-expired-article-p
+                      newsgroup
+                      (buffer-substring
+                       (point) (progn (end-of-line) (point)))
+                      force nnfolder-inhibit-expiry))
+           (nnheader-message 5 "Deleting article %d..."
                              (car maybe-expirable) newsgroup)
            (nnfolder-delete-mail)
            ;; Must remember which articles were actually deleted
@@ -577,7 +584,7 @@ deleted.  Point is left where the deleted region was."
   ;; Change group.
   (when (and group
             (not (equal group nnfolder-current-group)))
-    (let ((pathname-coding-system nnmail-pathname-coding-system))
+    (let ((file-name-coding-system nnmail-pathname-coding-system))
       (nnmail-activate 'nnfolder)
       (when (and (not (assoc group nnfolder-group-alist))
                 (not (file-exists-p
@@ -681,9 +688,10 @@ deleted.  Point is left where the deleted region was."
 (defun nnfolder-insert-newsgroup-line (group-art)
   (save-excursion
     (goto-char (point-min))
-    (if (search-forward "\n\n" nil t)
-       (forward-char -1)
-      (goto-char (point-max)))
+    (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)))))
 
@@ -739,7 +747,7 @@ deleted.  Point is left where the deleted region was."
            buffer
          (push (list group buffer) nnfolder-buffer-alist)
          (set-buffer-modified-p t)
-         (save-buffer))
+         (nnfolder-save-buffer))
       ;; Parse the damn thing.
       (save-excursion
        (goto-char (point-min))