*** empty log message ***
[gnus] / lisp / nnfolder.el
1 ;;; nnfolder.el --- mail folder access for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3
4 ;; Author: Scott Byer <byer@mv.us.adobe.com>
5 ;;      Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;;      Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Keywords: news, mail
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26
27 ;; For an overview of what the interface functions do, please see the
28 ;; Gnus sources.  
29
30 ;; Various enhancements by byer@mv.us.adobe.com (Scott Byer).
31
32 ;;; Code:
33
34 (require 'nnheader)
35 (require 'rmail)
36 (require 'nnmail)
37
38 (defvar nnfolder-directory (expand-file-name "~/Mail/")
39   "The name of the mail box file in the users home directory.")
40
41 (defvar nnfolder-active-file (concat nnfolder-directory  "active")
42   "The name of the active file.")
43
44 ;; I renamed this variable to somehting more in keeping with the general GNU
45 ;; style. -SLB
46
47 (defvar nnfolder-ignore-active-file nil
48   "If non-nil, causes nnfolder to do some extra work in order to determine the true active ranges of an mbox file.  
49 Note that the active file is still saved, but it's values are not
50 used.  This costs some extra time when scanning an mbox when opening
51 it.")
52
53 ;; Note that this variable may not be completely implemented yet. -SLB
54
55 (defvar nnfolder-always-close nil
56   "If non-nil, nnfolder attempts to only ever have one mbox open at a time.  
57 This is a straight space/performance trade off, as the mboxes will have to 
58 be scaned every time they are read in.  If nil (default), nnfolder will
59 attempt to keep the buffers around (saving the nnfolder's buffer upon group 
60 close, but not killing it), speeding some things up tremendously, especially
61 such things as moving mail.  All buffers always get killed upon server close.")
62
63 (defvar nnfolder-newsgroups-file (concat nnfolder-directory "newsgroups")
64   "Mail newsgroups description file.")
65
66 (defvar nnfolder-get-new-mail t
67   "If non-nil, nnml will check the incoming mail file and split the mail.")
68
69 \f
70
71 (defconst nnfolder-version "nnfolder 0.2"
72   "nnfolder version.")
73
74 (defconst nnfolder-article-marker "X-Gnus-Article-Number: "
75   "String used to demarcate what the article number for a message is.")
76
77 (defvar nnfolder-current-group nil)
78 (defvar nnfolder-current-buffer nil)
79 (defvar nnfolder-status-string "")
80 (defvar nnfolder-group-alist nil)
81 (defvar nnfolder-buffer-alist nil)
82
83 (defmacro nnfolder-article-string (article)
84   (` (concat "\n" nnfolder-article-marker (int-to-string (, article)) " ")))
85
86 \f
87
88 (defvar nnfolder-current-server nil)
89 (defvar nnfolder-server-alist nil)
90 (defvar nnfolder-server-variables 
91   (list 
92    (list 'nnfolder-directory nnfolder-directory)
93    (list 'nnfolder-active-file nnfolder-active-file)
94    (list 'nnfolder-newsgroups-file nnfolder-newsgroups-file)
95    (list 'nnfolder-get-new-mail nnfolder-get-new-mail)
96    '(nnfolder-current-group nil)
97    '(nnfolder-current-buffer nil)
98    '(nnfolder-status-string "")
99    '(nnfolder-group-alist nil)
100    '(nnfolder-buffer-alist nil)))
101
102 \f
103
104 ;;; Interface functions
105
106 (defun nnfolder-retrieve-headers (sequence &optional newsgroup server)
107   (save-excursion
108     (set-buffer nntp-server-buffer)
109     (erase-buffer)
110     (let ((file nil)
111           (number (length sequence))
112           (delim-string (concat "^" rmail-unix-mail-delimiter))
113           beg article art-string start stop)
114       (nnfolder-possibly-change-group newsgroup)
115       (set-buffer nnfolder-current-buffer)
116       (goto-char (point-min))
117       (while sequence
118         (setq article (car sequence))
119         (setq art-string (nnfolder-article-string article))
120         (set-buffer nnfolder-current-buffer)
121         (if (or (search-forward art-string nil t)
122                 ;; Don't search the whole file twice!  Also, articles
123                 ;; probably have some locality by number, so searching
124                 ;; backwards will be faster.  Especially if we're at the
125                 ;; beginning of the buffer :-). -SLB
126                 (search-backward art-string nil t))
127             (progn
128               (setq start (or (re-search-backward delim-string nil t)
129                               (point)))
130               (search-forward "\n\n" nil t)
131               (setq stop (1- (point)))
132               (set-buffer nntp-server-buffer)
133               (insert (format "221 %d Article retrieved.\n" article))
134               (setq beg (point))
135               (insert-buffer-substring nnfolder-current-buffer start stop)
136               (goto-char (point-max))
137               (insert ".\n")))
138         (setq sequence (cdr sequence)))
139
140       ;; Fold continuation lines.
141       (set-buffer nntp-server-buffer)
142       (goto-char 1)
143       (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
144         (replace-match " " t t))
145       'headers)))
146
147 (defun nnfolder-open-server (server &optional defs)
148   (nnheader-init-server-buffer)
149   (if (equal server nnfolder-current-server)
150       t
151     (if nnfolder-current-server
152         (setq nnfolder-server-alist 
153               (cons (list nnfolder-current-server
154                           (nnheader-save-variables nnfolder-server-variables))
155                     nnfolder-server-alist)))
156     (let ((state (assoc server nnfolder-server-alist)))
157       (if state 
158           (progn
159             (nnheader-restore-variables (nth 1 state))
160             (setq nnfolder-server-alist (delq state nnfolder-server-alist)))
161         (nnheader-set-init-variables nnfolder-server-variables defs)))
162     (setq nnfolder-current-server server)))
163
164 (defun nnfolder-close-server (&optional server)
165   t)
166
167 (defun nnfolder-server-opened (&optional server)
168   (and (equal server nnfolder-current-server)
169        nntp-server-buffer
170        (buffer-name nntp-server-buffer)))
171
172 (defun nnfolder-request-close ()
173   (let ((alist nnfolder-buffer-alist))
174     (while alist
175       (nnfolder-close-group (car (car alist)) nil t)
176       (setq alist (cdr alist))))
177   (setq nnfolder-buffer-alist nil
178         nnfolder-group-alist nil))
179
180 (defun nnfolder-status-message (&optional server)
181   nnfolder-status-string)
182
183 (defun nnfolder-request-article (article &optional newsgroup server buffer)
184   (nnfolder-possibly-change-group newsgroup)
185   (if (stringp article)
186       nil
187     (save-excursion
188       (set-buffer nnfolder-current-buffer)
189       (goto-char (point-min))
190       (if (search-forward (nnfolder-article-string article) nil t)
191           (let (start stop)
192             (re-search-backward (concat "^" rmail-unix-mail-delimiter) nil t)
193             (setq start (point))
194             (forward-line 1)
195             (or (and (re-search-forward 
196                       (concat "^" rmail-unix-mail-delimiter) nil t)
197                      (forward-line -1))
198                 (goto-char (point-max)))
199             (setq stop (point))
200             (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
201               (set-buffer nntp-server-buffer)
202               (erase-buffer)
203               (insert-buffer-substring nnfolder-current-buffer start stop)
204               (goto-char (point-min))
205               (while (looking-at "From ")
206                 (delete-char 5)
207                 (insert "X-From-Line: ")
208                 (forward-line 1))
209               t))))))
210
211 (defun nnfolder-request-group (group &optional server dont-check)
212   (save-excursion
213     (nnfolder-possibly-change-group group)
214     (and (assoc group nnfolder-group-alist)
215          (save-excursion
216            (set-buffer nntp-server-buffer)
217            (erase-buffer)
218            (if dont-check
219                t
220              (nnfolder-get-new-mail)
221              (let ((active (assoc group nnfolder-group-alist)))
222                ;; I've been getting stray 211 lines in my nnfolder active
223                ;; file.  So, let's make sure that doesn't happen. -SLB
224                (set-buffer nntp-server-buffer)
225                (insert (format "211 %d %d %d %s\n" 
226                                (1+ (- (cdr (car (cdr active)))
227                                       (car (car (cdr active)))))
228                                (car (car (cdr active)))
229                                (cdr (car (cdr active)))
230                                (car active))))
231              t)))))
232
233 ;; Don't close the buffer if we're not shutting down the server.  This way,
234 ;; we can keep the buffer in the group buffer cache, and not have to grovel
235 ;; over the buffer again unless we add new mail to it or modify it in some
236 ;; way.
237
238 (defun nnfolder-close-group (group &optional server force)
239   (nnfolder-possibly-change-group group)
240   (save-excursion
241     (set-buffer nnfolder-current-buffer)
242     ;; If the buffer was modified, write the file out now.
243     (save-buffer)
244     (if (or force
245             nnfolder-always-close)
246         ;; If we're shutting the server down, we need to kill the buffer and
247         ;; remove it from the open buffer list.  Or, of course, if we're
248         ;; trying to minimize our space impact.
249         (progn
250           (kill-buffer (current-buffer))
251           (setq nnfolder-buffer-alist (delq (assoc group nnfolder-buffer-alist)
252                                             nnfolder-buffer-alist))))
253     (setq nnfolder-current-group nil
254           nnfolder-current-buffer nil))
255   t)
256
257 (defun nnfolder-request-list (&optional server)
258   (if server (nnfolder-get-new-mail))
259   (or nnfolder-group-alist
260       (nnmail-find-file nnfolder-active-file)
261       (progn
262         (setq nnfolder-group-alist (nnmail-get-active))
263         (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
264         (nnmail-find-file nnfolder-active-file))))
265
266 (defun nnfolder-request-newgroups (date &optional server)
267   (nnfolder-request-list server))
268
269 (defun nnfolder-request-list-newsgroups (&optional server)
270   (nnmail-find-file nnfolder-newsgroups-file))
271
272 (defun nnfolder-request-post (&optional server)
273   (mail-send-and-exit nil))
274
275 (fset 'nnfolder-request-post-buffer 'nnmail-request-post-buffer)
276
277 (defun nnfolder-request-expire-articles (articles newsgroup &optional server force)
278   (nnfolder-possibly-change-group newsgroup)
279   (let* ((days (or (and nnmail-expiry-wait-function
280                         (funcall nnmail-expiry-wait-function newsgroup))
281                    nnmail-expiry-wait))
282          article rest)
283     (save-excursion 
284       (set-buffer nnfolder-current-buffer)
285       (while articles
286         (goto-char 1)
287         (if (search-forward (nnfolder-article-string (car articles)) nil t)
288             (if (or force
289                     (> (nnmail-days-between 
290                         (current-time-string)
291                         (buffer-substring 
292                          (point) (progn (end-of-line) (point))))
293                        days))
294                 (progn
295                   (and gnus-verbose-backends
296                        (message "Deleting: %s" (car articles)))
297                   (nnfolder-delete-mail))
298               (setq rest (cons (car articles) rest))))
299         (setq articles (cdr articles)))
300       (save-buffer)
301       ;; Find the lowest active article in this group.
302       (let* ((active (car (cdr (assoc newsgroup nnfolder-group-alist))))
303              (marker (concat "\n" nnfolder-article-marker))
304              (number "[0-9]+")
305              (activemin (cdr active)))
306         (goto-char (point-min))
307         (while (and (search-forward marker nil t)
308                     (re-search-forward number nil t))
309           (setq activemin (min activemin
310                                (string-to-number (buffer-substring
311                                                   (match-beginning 0)
312                                                   (match-end 0))))))
313         (setcar active activemin))
314       (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
315       rest)))
316
317 (defun nnfolder-request-move-article
318   (article group server accept-form &optional last)
319   (nnfolder-possibly-change-group group)
320   (let ((buf (get-buffer-create " *nnfolder move*"))
321         result)
322     (and 
323      (nnfolder-request-article article group server)
324      (save-excursion
325        (set-buffer buf)
326        (buffer-disable-undo (current-buffer))
327        (erase-buffer)
328        (insert-buffer-substring nntp-server-buffer)
329        (goto-char (point-min))
330        (while (re-search-forward 
331                "^X-Gnus-Newsgroup:" 
332                (save-excursion (search-forward "\n\n" nil t) (point)) t)
333          (delete-region (progn (beginning-of-line) (point))
334                         (progn (forward-line 1) (point))))
335        (setq result (eval accept-form))
336        (kill-buffer buf)
337        result)
338      (save-excursion
339        (nnfolder-possibly-change-group group)
340        (set-buffer nnfolder-current-buffer)
341        (goto-char 1)
342        (if (search-forward (nnfolder-article-string article) nil t)
343            (nnfolder-delete-mail))
344        (and last (save-buffer))))
345     result))
346
347 (defun nnfolder-request-accept-article (group &optional last)
348   (nnfolder-possibly-change-group group)
349   (let ((buf (current-buffer))
350         result beg)
351     (goto-char (point-min))
352     (if (looking-at "X-From-Line: ")
353         (replace-match "From ")
354       (insert "From nobody " (current-time-string) "\n"))
355     (and 
356      (nnfolder-request-list)
357      (progn
358        (set-buffer buf)
359        (goto-char (point-min))
360        (search-forward "\n\n" nil t)
361        (forward-line -1)
362        (while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
363          (delete-region (point) (progn (forward-line 1) (point))))
364        (setq result (car (nnfolder-save-mail (and (stringp group) group)))))
365      (save-excursion
366        (set-buffer nnfolder-current-buffer)
367        (insert-buffer-substring buf)
368        (and last (save-buffer))
369        result)
370      (nnmail-save-active nnfolder-group-alist nnfolder-active-file))
371     result))
372
373 (defun nnfolder-request-replace-article (article group buffer)
374   (nnfolder-possibly-change-group group)
375   (save-excursion
376     (set-buffer nnfolder-current-buffer)
377     (goto-char 1)
378     (if (not (search-forward (nnfolder-article-string article) nil t))
379         nil
380       (nnfolder-delete-mail t t)
381       (insert-buffer-substring buffer)
382       (save-buffer)
383       t)))
384
385 \f
386 ;;; Internal functions.
387
388 (defun nnfolder-delete-mail (&optional force leave-delim)
389   ;; Beginning of the article.
390   (save-excursion
391     (save-restriction
392       (narrow-to-region
393        (save-excursion
394          (re-search-backward (concat "^" rmail-unix-mail-delimiter) nil t)
395          (if leave-delim (progn (forward-line 1) (point))
396            (match-beginning 0)))
397        (progn
398          (forward-line 1)
399          (or (and (re-search-forward (concat "^" rmail-unix-mail-delimiter) 
400                                      nil t)
401                   (if (and (not (bobp)) leave-delim)
402                       (progn (forward-line -2) (point))
403                     (match-beginning 0)))
404              (point-max))))
405       (delete-region (point-min) (point-max)))))
406
407 (defun nnfolder-possibly-change-group (group)
408   (or (file-exists-p nnfolder-directory)
409       (make-directory (directory-file-name nnfolder-directory)))
410   (if (not nnfolder-group-alist)
411       (progn
412         (nnfolder-request-list)
413         (setq nnfolder-group-alist (nnmail-get-active))))
414   (or (assoc group nnfolder-group-alist)
415       (not (file-exists-p (concat nnfolder-directory group)))
416       (progn
417         (setq nnfolder-group-alist 
418               (cons (list group (cons 1 0)) nnfolder-group-alist))
419         (nnmail-save-active nnfolder-group-alist nnfolder-active-file)))
420   (let (inf file)
421     (if (and (equal group nnfolder-current-group)
422              (buffer-name nnfolder-current-buffer))
423         ()
424       (setq nnfolder-current-group group)
425
426       ;; If we have to change groups, see if we don't already have the mbox
427       ;; in memory.  If we do, verify the modtime and destroy the mbox if
428       ;; needed so we can rescan it.
429       (if (setq inf (assoc group nnfolder-buffer-alist))
430           (setq nnfolder-current-buffer (nth 1 inf)))
431
432       ;; If the buffer is not live, make sure it isn't in the alist.  If it
433       ;; is live, verify that nobody else has touched the file since last
434       ;; time.
435       (if (or (not (buffer-name nnfolder-current-buffer))
436               (not (and (bufferp nnfolder-current-buffer)
437                         (verify-visited-file-modtime nnfolder-current-buffer))))
438           (progn
439             (if (and (buffer-name nnfolder-current-buffer)
440                      (bufferp nnfolder-current-buffer))
441                 (kill-buffer nnfolder-current-buffer))
442             (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist))
443             (setq inf nil)))
444       
445       (if inf
446           ()
447         (save-excursion
448           (setq file (concat nnfolder-directory group))
449           (if (not (file-exists-p file))
450               (write-region 1 1 file t 'nomesg))
451           (set-buffer (nnfolder-read-folder file))
452           (setq nnfolder-buffer-alist (cons (list group (current-buffer))
453                                             nnfolder-buffer-alist))))))
454   (setq nnfolder-current-group group))
455
456 (defun nnfolder-save-mail (&optional group)
457   "Called narrowed to an article."
458   (let* ((nnmail-split-methods 
459           (if group (list (list group "")) nnmail-split-methods))
460          (group-art-list
461           (nreverse (nnmail-article-group 'nnfolder-active-number)))
462          save-list group-art)
463     (setq save-list group-art-list)
464     (nnmail-insert-lines)
465     (nnmail-insert-xref group-art-list)
466
467     ;; Kill the previous newsgroup markers.
468     (goto-char (point-min))
469     (search-forward "\n\n" nil t)
470     (forward-line -1)
471     (while (re-search-backward (concat "^" nnfolder-article-marker) nil t)
472       (delete-region (point) (progn (forward-line 1) (point))))
473
474     ;; Insert the mail into each of the destination groups.
475     (while group-art-list
476       (setq group-art (car group-art-list)
477             group-art-list (cdr group-art-list))
478       (nnfolder-possibly-change-group (car group-art))
479       (nnfolder-insert-newsgroup-line group-art)
480       (let ((beg (point-min))
481             (end (point-max))
482             (obuf (current-buffer)))
483         (save-excursion
484           (set-buffer nnfolder-current-buffer)
485           (goto-char (point-max))
486           (insert-buffer-substring obuf beg end))))
487
488     ;; Did we save it anywhere?
489     save-list))
490
491 (defun nnfolder-insert-newsgroup-line (group-art)
492   (save-excursion
493     (goto-char (point-min))
494     (if (search-forward "\n\n" nil t)
495         (progn
496           (forward-char -1)
497           (insert (format (concat nnfolder-article-marker "%d   %s\n")
498                           (cdr group-art) (current-time-string)))))))
499
500 (defun nnfolder-active-number (group)
501   (if (not nnfolder-group-alist)
502       (save-excursion
503         (nnfolder-request-list)
504         (setq nnfolder-group-alist (nnmail-get-active))))
505   (let ((active (car (cdr (assoc group nnfolder-group-alist)))))
506     (setcdr active (1+ (cdr active)))
507     (cdr active)))
508
509
510 ;; This method has a problem if you've accidentally let the active list get
511 ;; out of sync with the files.  This could happen, say, if you've
512 ;; accidentally gotten new mail with something other than (ding) (but why
513 ;; would _that_ ever happen? :-).  In that case, we will be in the middle of
514 ;; processing the file, ready to add new X-Gnus article number markers, and
515 ;; we'll run accross a message with no ID yet - the active list _may_not_ be
516 ;; ready for us yet.
517
518 ;; To handle this, I'm modifying this routine to maintain the maximum ID seen
519 ;; so far, and when we hit a message with no ID, we will _manually_ scan the
520 ;; rest of the message looking for any more, possibly higher IDs.  We'll
521 ;; assume the maximum that we find is the highest active.  Note that this
522 ;; shouldn't cost us much extra time at all, but will be a lot less
523 ;; vulnerable to glitches between the mbox and the active file.
524
525 (defun nnfolder-read-folder (file)
526   (save-excursion
527     (if (not nnfolder-group-alist)
528         (progn
529           (nnfolder-request-list)
530           (setq nnfolder-group-alist (nnmail-get-active))))
531     ;; We should be paranoid here and make sure the group is in the alist,
532     ;; and add it if it isn't.
533     ;;(if (not (assoc nnfoler-current-group nnfolder-group-alist)
534     (set-buffer (setq nnfolder-current-buffer (find-file-noselect file)))
535     (buffer-disable-undo (current-buffer))
536     (let ((delim (concat "^" rmail-unix-mail-delimiter))
537           (marker (concat "\n" nnfolder-article-marker))
538           (number "[0-9]+")
539           (active (car (cdr (assoc nnfolder-current-group 
540                                    nnfolder-group-alist))))
541           activenumber activemin start end)
542       (goto-char (point-min))
543       ;;
544       ;; Anytime the active number is 1 or 0, it is supect.  In that case,
545       ;; search the file manually to find the active number.  Or, of course,
546       ;; if we're being paranoid.  (This would also be the place to build
547       ;; other lists from the header markers, such as expunge lists, etc., if
548       ;; we ever desired to abandon the active file entirely for mboxes.)
549       (setq activenumber (cdr active))
550       (if (or nnfolder-ignore-active-file
551               (< activenumber 2))
552           (progn
553             (setq activemin (max (1- (lsh 1 23)) 
554                                  (1- (lsh 1 24)) 
555                                  (1- (lsh 1 25))))
556             (while (and (search-forward marker nil t)
557                         (re-search-forward number nil t))
558               (let (newnum (string-to-number (buffer-substring
559                                               (match-beginning 0)
560                                               (match-end 0))))
561                 (setq activenumber (max activenumber newnum))
562                 (setq activemin (min activemin newnum))))
563             (setcar active (min activemin activenumber))
564             (setcdr active activenumber)
565             (goto-char (point-min))))
566
567       ;; Keep track of the active number on our own, and insert it back into
568       ;; the active list when we're done. Also, prime the pump to cut down on
569       ;; the number of searches we do.
570       (setq end (point-marker))
571       (set-marker end (or (and (re-search-forward delim nil t)
572                                (match-beginning 0))
573                           (point-max)))
574       (while (not (= end (point-max)))
575         (setq start (marker-position end))
576         (goto-char end)
577         (end-of-line)
578         (set-marker end (or (and (re-search-forward delim nil t)
579                                  (match-beginning 0))
580                             (point-max)))
581         (goto-char start)
582         (if (not (search-forward marker end t))
583             (progn
584               (narrow-to-region start end)
585               (nnmail-insert-lines)
586               (setq activenumber (1+ activenumber))
587               (nnfolder-insert-newsgroup-line (cons nil activenumber))
588               (widen))))
589
590       ;; Make absolutely sure that the active list reflects reality!
591       (setcdr active activenumber)
592       (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
593       (current-buffer))))
594
595 (defun nnfolder-get-new-mail ()
596   (let (incoming)
597     (if (and nnmail-spool-file
598              nnfolder-get-new-mail
599              (file-exists-p nnmail-spool-file)
600              (> (nth 7 (file-attributes nnmail-spool-file)) 0))
601         (progn
602           (and gnus-verbose-backends
603                (message "nnfolder: Reading incoming mail..."))
604           (setq incoming 
605                 (nnmail-move-inbox nnmail-spool-file
606                                    (concat nnfolder-directory "Incoming")))
607           (nnmail-split-incoming incoming 'nnfolder-save-mail)
608           (run-hooks 'nnmail-read-incoming-hook)
609           (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
610           (and gnus-verbose-backends
611                (message "nnfolder: Reading incoming mail...done"))))
612     (let ((bufs nnfolder-buffer-alist))
613       (save-excursion
614         (while bufs
615           (if (not (buffer-name (nth 1 (car bufs))))
616               (setq nnfolder-buffer-alist 
617                     (delq (car bufs) nnfolder-buffer-alist))
618             (set-buffer (nth 1 (car bufs)))
619             (and (buffer-modified-p)
620                  (save-buffer)))
621           (setq bufs (cdr bufs)))))
622     ;; (if incoming (delete-file incoming))
623     ))
624
625 (provide 'nnfolder)
626
627 ;;; nnfolder.el ends here