*** 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          (progn
216            (if dont-check
217                t
218              (nnfolder-get-new-mail))
219            (let* ((active (assoc group nnfolder-group-alist))
220                   (group (car active))
221                   (range (car (cdr active)))
222                   (minactive (car range))
223                   (maxactive (cdr range)))
224              ;; I've been getting stray 211 lines in my nnfolder active
225              ;; file.  So, let's make sure that doesn't happen. -SLB
226              (set-buffer nntp-server-buffer)
227              (erase-buffer)
228              (insert (format "211 %d %d %d %s\n" 
229                              (1+ (- maxactive minactive))
230                              minactive maxactive group))
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     (and (buffer-modified-p) (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   (save-excursion
260     (or nnfolder-group-alist
261         (nnmail-find-file nnfolder-active-file)
262         (progn
263           (setq nnfolder-group-alist (nnmail-get-active))
264           (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
265           (nnmail-find-file nnfolder-active-file)))))
266
267 (defun nnfolder-request-newgroups (date &optional server)
268   (nnfolder-request-list server))
269
270 (defun nnfolder-request-list-newsgroups (&optional server)
271   (save-excursion
272     (nnmail-find-file nnfolder-newsgroups-file)))
273
274 (defun nnfolder-request-post (&optional server)
275   (mail-send-and-exit nil))
276
277 (fset 'nnfolder-request-post-buffer 'nnmail-request-post-buffer)
278
279 (defun nnfolder-request-expire-articles (articles newsgroup &optional server force)
280   (nnfolder-possibly-change-group newsgroup)
281   (let* ((days (or (and nnmail-expiry-wait-function
282                         (funcall nnmail-expiry-wait-function newsgroup))
283                    nnmail-expiry-wait))
284          article rest)
285     (save-excursion 
286       (set-buffer nnfolder-current-buffer)
287       (while articles
288         (goto-char 1)
289         (if (search-forward (nnfolder-article-string (car articles)) nil t)
290             (if (or force
291                     (> (nnmail-days-between 
292                         (current-time-string)
293                         (buffer-substring 
294                          (point) (progn (end-of-line) (point))))
295                        days))
296                 (progn
297                   (and gnus-verbose-backends
298                        (message "Deleting: %s" (car articles)))
299                   (nnfolder-delete-mail))
300               (setq rest (cons (car articles) rest))))
301         (setq articles (cdr articles)))
302       (and (buffer-modified-p) (save-buffer))
303       ;; Find the lowest active article in this group.
304       (let* ((active (car (cdr (assoc newsgroup nnfolder-group-alist))))
305              (marker (concat "\n" nnfolder-article-marker))
306              (number "[0-9]+")
307              (activemin (cdr active)))
308         (goto-char (point-min))
309         (while (and (search-forward marker nil t)
310                     (re-search-forward number nil t))
311           (setq activemin (min activemin
312                                (string-to-number (buffer-substring
313                                                   (match-beginning 0)
314                                                   (match-end 0))))))
315         (setcar active activemin))
316       (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
317       rest)))
318
319 (defun nnfolder-request-move-article
320   (article group server accept-form &optional last)
321   (nnfolder-possibly-change-group group)
322   (let ((buf (get-buffer-create " *nnfolder move*"))
323         result)
324     (and 
325      (nnfolder-request-article article group server)
326      (save-excursion
327        (set-buffer buf)
328        (buffer-disable-undo (current-buffer))
329        (erase-buffer)
330        (insert-buffer-substring nntp-server-buffer)
331        (goto-char (point-min))
332        (while (re-search-forward 
333                "^X-Gnus-Newsgroup:" 
334                (save-excursion (search-forward "\n\n" nil t) (point)) t)
335          (delete-region (progn (beginning-of-line) (point))
336                         (progn (forward-line 1) (point))))
337        (setq result (eval accept-form))
338        (kill-buffer buf)
339        result)
340      (save-excursion
341        (nnfolder-possibly-change-group group)
342        (set-buffer nnfolder-current-buffer)
343        (goto-char 1)
344        (if (search-forward (nnfolder-article-string article) nil t)
345            (nnfolder-delete-mail))
346        (and last 
347             (buffer-modified-p)
348             (save-buffer))))
349     result))
350
351 (defun nnfolder-request-accept-article (group &optional last)
352   (nnfolder-possibly-change-group group)
353   (let ((buf (current-buffer))
354         result beg)
355     (goto-char (point-min))
356     (if (looking-at "X-From-Line: ")
357         (replace-match "From ")
358       (insert "From nobody " (current-time-string) "\n"))
359     (and 
360      (nnfolder-request-list)
361      (progn
362        (set-buffer buf)
363        (goto-char (point-min))
364        (search-forward "\n\n" nil t)
365        (forward-line -1)
366        (while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
367          (delete-region (point) (progn (forward-line 1) (point))))
368        (setq result (car (nnfolder-save-mail (and (stringp group) group)))))
369      (save-excursion
370        (set-buffer nnfolder-current-buffer)
371        (insert-buffer-substring buf)
372        (and last (buffer-modified-p) (save-buffer))
373        result)
374      (nnmail-save-active nnfolder-group-alist nnfolder-active-file))
375     result))
376
377 (defun nnfolder-request-replace-article (article group buffer)
378   (nnfolder-possibly-change-group group)
379   (save-excursion
380     (set-buffer nnfolder-current-buffer)
381     (goto-char 1)
382     (if (not (search-forward (nnfolder-article-string article) nil t))
383         nil
384       (nnfolder-delete-mail t t)
385       (insert-buffer-substring buffer)
386       (and (buffer-modified-p) (save-buffer))
387       t)))
388
389 \f
390 ;;; Internal functions.
391
392 (defun nnfolder-delete-mail (&optional force leave-delim)
393   ;; Beginning of the article.
394   (save-excursion
395     (save-restriction
396       (narrow-to-region
397        (save-excursion
398          (re-search-backward (concat "^" rmail-unix-mail-delimiter) nil t)
399          (if leave-delim (progn (forward-line 1) (point))
400            (match-beginning 0)))
401        (progn
402          (forward-line 1)
403          (or (and (re-search-forward (concat "^" rmail-unix-mail-delimiter) 
404                                      nil t)
405                   (if (and (not (bobp)) leave-delim)
406                       (progn (forward-line -2) (point))
407                     (match-beginning 0)))
408              (point-max))))
409       (delete-region (point-min) (point-max)))))
410
411 (defun nnfolder-possibly-change-group (group)
412   (or (file-exists-p nnfolder-directory)
413       (make-directory (directory-file-name nnfolder-directory)))
414   (if (not nnfolder-group-alist)
415       (progn
416         (nnfolder-request-list)
417         (setq nnfolder-group-alist (nnmail-get-active))))
418   (or (assoc group nnfolder-group-alist)
419       (not (file-exists-p (concat nnfolder-directory group)))
420       (progn
421         (setq nnfolder-group-alist 
422               (cons (list group (cons 1 0)) nnfolder-group-alist))
423         (nnmail-save-active nnfolder-group-alist nnfolder-active-file)))
424   (let (inf file)
425     (if (and (equal group nnfolder-current-group)
426              (buffer-name nnfolder-current-buffer))
427         ()
428       (setq nnfolder-current-group group)
429
430       ;; If we have to change groups, see if we don't already have the mbox
431       ;; in memory.  If we do, verify the modtime and destroy the mbox if
432       ;; needed so we can rescan it.
433       (if (setq inf (assoc group nnfolder-buffer-alist))
434           (setq nnfolder-current-buffer (nth 1 inf)))
435
436       ;; If the buffer is not live, make sure it isn't in the alist.  If it
437       ;; is live, verify that nobody else has touched the file since last
438       ;; time.
439       (if (or (not (buffer-name nnfolder-current-buffer))
440               (not (and (bufferp nnfolder-current-buffer)
441                         (verify-visited-file-modtime nnfolder-current-buffer))))
442           (progn
443             (if (and (buffer-name nnfolder-current-buffer)
444                      (bufferp nnfolder-current-buffer))
445                 (kill-buffer nnfolder-current-buffer))
446             (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist))
447             (setq inf nil)))
448       
449       (if inf
450           ()
451         (save-excursion
452           (setq file (concat nnfolder-directory group))
453           (if (not (file-exists-p file))
454               (write-region 1 1 file t 'nomesg))
455           (set-buffer (nnfolder-read-folder file))
456           (setq nnfolder-buffer-alist (cons (list group (current-buffer))
457                                             nnfolder-buffer-alist))))))
458   (setq nnfolder-current-group group))
459
460 (defun nnfolder-save-mail (&optional group)
461   "Called narrowed to an article."
462   (let* ((nnmail-split-methods 
463           (if group (list (list group "")) nnmail-split-methods))
464          (group-art-list
465           (nreverse (nnmail-article-group 'nnfolder-active-number)))
466          save-list group-art)
467     (setq save-list group-art-list)
468     (nnmail-insert-lines)
469     (nnmail-insert-xref group-art-list)
470
471     ;; Insert the mail into each of the destination groups.
472     (while group-art-list
473       (setq group-art (car group-art-list)
474             group-art-list (cdr group-art-list))
475
476       ;; Kill the previous newsgroup markers.
477       (goto-char (point-min))
478       (search-forward "\n\n" nil t)
479       (forward-line -1)
480       (while (search-backward (concat "\n" nnfolder-article-marker) nil t)
481         (delete-region (point) (progn (forward-line 1) (point))))
482
483       ;; Insert the new newsgroup marker.
484       (nnfolder-possibly-change-group (car group-art))
485       (nnfolder-insert-newsgroup-line group-art)
486       (let ((beg (point-min))
487             (end (point-max))
488             (obuf (current-buffer)))
489         (set-buffer nnfolder-current-buffer)
490         (goto-char (point-max))
491         (insert-buffer-substring obuf beg end)
492         (set-buffer obuf)))
493
494     ;; Did we save it anywhere?
495     save-list))
496
497 (defun nnfolder-insert-newsgroup-line (group-art)
498   (save-excursion
499     (goto-char (point-min))
500     (if (search-forward "\n\n" nil t)
501         (progn
502           (forward-char -1)
503           (insert (format (concat nnfolder-article-marker "%d   %s\n")
504                           (cdr group-art) (current-time-string)))))))
505
506 (defun nnfolder-active-number (group)
507   (if (not nnfolder-group-alist)
508       (save-excursion
509         (nnfolder-request-list)
510         (setq nnfolder-group-alist (nnmail-get-active))))
511   (let ((active (car (cdr (assoc group nnfolder-group-alist)))))
512     (setcdr active (1+ (cdr active)))
513     (cdr active)))
514
515
516 ;; This method has a problem if you've accidentally let the active list get
517 ;; out of sync with the files.  This could happen, say, if you've
518 ;; accidentally gotten new mail with something other than (ding) (but why
519 ;; would _that_ ever happen? :-).  In that case, we will be in the middle of
520 ;; processing the file, ready to add new X-Gnus article number markers, and
521 ;; we'll run accross a message with no ID yet - the active list _may_not_ be
522 ;; ready for us yet.
523
524 ;; To handle this, I'm modifying this routine to maintain the maximum ID seen
525 ;; so far, and when we hit a message with no ID, we will _manually_ scan the
526 ;; rest of the message looking for any more, possibly higher IDs.  We'll
527 ;; assume the maximum that we find is the highest active.  Note that this
528 ;; shouldn't cost us much extra time at all, but will be a lot less
529 ;; vulnerable to glitches between the mbox and the active file.
530
531 (defun nnfolder-read-folder (file)
532   (save-excursion
533     (if (not nnfolder-group-alist)
534         (progn
535           (nnfolder-request-list)
536           (setq nnfolder-group-alist (nnmail-get-active))))
537     ;; We should be paranoid here and make sure the group is in the alist,
538     ;; and add it if it isn't.
539     ;;(if (not (assoc nnfoler-current-group nnfolder-group-alist)
540     (set-buffer (setq nnfolder-current-buffer (find-file-noselect file)))
541     (buffer-disable-undo (current-buffer))
542     (let ((delim (concat "^" rmail-unix-mail-delimiter))
543           (marker (concat "\n" nnfolder-article-marker))
544           (number "[0-9]+")
545           (active (car (cdr (assoc nnfolder-current-group 
546                                    nnfolder-group-alist))))
547           activenumber activemin start end)
548       (goto-char (point-min))
549       ;;
550       ;; Anytime the active number is 1 or 0, it is supect.  In that case,
551       ;; search the file manually to find the active number.  Or, of course,
552       ;; if we're being paranoid.  (This would also be the place to build
553       ;; other lists from the header markers, such as expunge lists, etc., if
554       ;; we ever desired to abandon the active file entirely for mboxes.)
555       (setq activenumber (cdr active))
556       (if (or nnfolder-ignore-active-file
557               (< activenumber 2))
558           (progn
559             (setq activemin (max (1- (lsh 1 23)) 
560                                  (1- (lsh 1 24)) 
561                                  (1- (lsh 1 25))))
562             (while (and (search-forward marker nil t)
563                         (re-search-forward number nil t))
564               (let ((newnum (string-to-number (buffer-substring
565                                               (match-beginning 0)
566                                               (match-end 0)))))
567                 (setq activenumber (max activenumber newnum))
568                 (setq activemin (min activemin newnum))))
569             (setcar active (min activemin activenumber))
570             (setcdr active activenumber)
571             (goto-char (point-min))))
572
573       ;; Keep track of the active number on our own, and insert it back into
574       ;; the active list when we're done. Also, prime the pump to cut down on
575       ;; the number of searches we do.
576       (setq end (point-marker))
577       (set-marker end (or (and (re-search-forward delim nil t)
578                                (match-beginning 0))
579                           (point-max)))
580       (while (not (= end (point-max)))
581         (setq start (marker-position end))
582         (goto-char end)
583         (end-of-line)
584         (set-marker end (or (and (re-search-forward delim nil t)
585                                  (match-beginning 0))
586                             (point-max)))
587         (goto-char start)
588         (if (not (search-forward marker end t))
589             (progn
590               (narrow-to-region start end)
591               (nnmail-insert-lines)
592               (setq activenumber (1+ activenumber))
593               (nnfolder-insert-newsgroup-line (cons nil activenumber))
594               (widen))))
595
596       ;; Make absolutely sure that the active list reflects reality!
597       (setcdr active activenumber)
598       (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
599       (current-buffer))))
600
601 (defun nnfolder-get-new-mail ()
602   (let (incoming)
603     (if (and nnmail-spool-file
604              nnfolder-get-new-mail
605              (file-exists-p nnmail-spool-file)
606              (> (nth 7 (file-attributes nnmail-spool-file)) 0))
607         (progn
608           (and gnus-verbose-backends
609                (message "nnfolder: Reading incoming mail..."))
610           (setq incoming 
611                 (nnmail-move-inbox nnmail-spool-file
612                                    (concat nnfolder-directory "Incoming")))
613           (nnmail-split-incoming incoming 'nnfolder-save-mail)
614           (run-hooks 'nnmail-read-incoming-hook)
615           (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
616           (and gnus-verbose-backends
617                (message "nnfolder: Reading incoming mail...done"))))
618     (let ((bufs nnfolder-buffer-alist))
619       (save-excursion
620         (while bufs
621           (if (not (buffer-name (nth 1 (car bufs))))
622               (setq nnfolder-buffer-alist 
623                     (delq (car bufs) nnfolder-buffer-alist))
624             (set-buffer (nth 1 (car bufs)))
625             (and (buffer-modified-p) (save-buffer)))
626           (setq bufs (cdr bufs)))))
627     ;; (if incoming (delete-file incoming))
628     ))
629
630 (provide 'nnfolder)
631
632 ;;; nnfolder.el ends here