-(defun nnbabyl-get-new-mail (&optional group)
- "Read new incoming mail."
- (let* ((spools (nnmail-get-spool-files group))
- (all-spools spools)
- (group-in 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
- (setq group (nnmail-get-split-group (car spools) group-in))
- (let* ((nnmail-prepare-incoming-hook
- (cons 'nnbabyl-remove-incoming-delims
- nnmail-prepare-incoming-hook))
- in-buf)
- (setq 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)))
- (if incomings (run-hooks 'nnmail-read-incoming-hook))
- (while incomings
- (and nnmail-delete-incoming
- (file-writable-p incoming)
- (delete-file incoming))
- (setq incomings (cdr incomings))))))
-