-(defun nnbabyl-get-new-mail (&optional group)
- "Read new incoming mail."
- (let ((spools (nnmail-get-spool-files group))
- incoming incomings)
- (nnbabyl-read-mbox)
- (if (or (not nnbabyl-get-new-mail) (not nnmail-spool-file))
- ()
- ;; We go through all the existing spool files and split the
- ;; mail from each.
- (while spools
- (and
- (file-exists-p (car spools))
- (> (nth 7 (file-attributes (car spools))) 0)
- (progn
- (and gnus-verbose-backends
- (message "nnbabyl: Reading incoming mail..."))
- (setq incoming
- (nnmail-move-inbox
- (car spools) (concat nnbabyl-mbox-file "-Incoming")))
- (setq incomings (cons incoming incomings))
- (save-excursion
- (let ((in-buf (nnmail-split-incoming
- incoming 'nnbabyl-save-mail t group)))
- (set-buffer in-buf)
- (goto-char (point-min))
- (while (search-forward "\n\^_\n" nil t)
- (delete-char -1))
- (set-buffer nnbabyl-mbox-buffer)
- (goto-char (point-max))
- (search-backward "\n\^_" nil t)
- (goto-char (match-end 0))
- (insert-buffer-substring in-buf)
- (kill-buffer in-buf)))))
- (setq spools (cdr spools)))
- ;; If we did indeed read any incoming spools, we save all info.
- (and (buffer-modified-p nnbabyl-mbox-buffer)
- (save-excursion
- (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
- (set-buffer nnbabyl-mbox-buffer)
- (save-buffer)))
- (while incomings
- ;; The following has been commented away, just to make sure
- ;; that nobody ever loses any mail. If you feel safe that
- ;; nnfolder will never do anything strange, just remove those
- ;; two semicolons, and avoid having lots of "Incoming*"
- ;; files.
- ;; (and (file-writable-p incoming) (delete-file incoming))
- (setq incomings (cdr incomings))))))