Function: nnmail-get-new-mail-1
nnmail-get-new-mail-1 is a byte-compiled function defined in
nnmail.el.gz.
Signature
(nnmail-get-new-mail-1 METHOD EXIT-FUNC TEMP GROUP IN-GROUP SPOOL-FUNC)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nnmail.el.gz
(defun nnmail-get-new-mail-1 (method exit-func temp
group in-group spool-func)
(let* ((sources mail-sources)
fetching-sources
(i 0)
(new 0)
(total 0)
source)
(when (and (nnmail-get-value "%s-get-new-mail" method)
sources)
(while (setq source (pop sources))
;; Use group's parameter
(when (and (eq (car source) 'group)
group)
(let ((mail-sources
(list
(gnus-group-find-parameter
(concat (symbol-name method) ":" group)
'mail-source t))))
(nnmail-get-new-mail-1 method exit-func temp
group group spool-func))
(setq source nil))
;; Hack to only fetch the contents of a single group's spool file.
(when (and (eq (car source) 'directory)
(null nnmail-scan-directory-mail-source-once)
group)
(mail-source-bind (directory source)
(setq source (append source
(list
:predicate
(let ((str (concat group suffix)))
(lambda (file)
(string-equal
str
(file-name-nondirectory file)))))))))
(when nnmail-fetched-sources
(if (member source nnmail-fetched-sources)
(setq source nil)
(push source nnmail-fetched-sources)
(push source fetching-sources)))))
(when fetching-sources
;; We first activate all the groups.
(nnmail-activate method)
;; Allow the user to hook.
(run-hooks 'nnmail-pre-get-new-mail-hook)
;; Open the message-id cache.
(nnmail-cache-open)
;; The we go through all the existing mail source specification
;; and fetch the mail from each.
(while (setq source (pop fetching-sources))
(when (setq new
(condition-case cond
(mail-source-fetch
source
(let ((smsym (intern (format "%s-save-mail" method)))
(ansym (intern (format "%s-active-number" method)))
(src source))
(lambda (file orig-file)
(nnmail-split-incoming
file smsym
spool-func
(or in-group
(if (equal file orig-file)
nil
(nnmail-get-split-group orig-file
src)))
ansym))))
((error quit)
(message "Mail source %s failed: %s" source cond)
0)))
(cl-incf total new)
(cl-incf i)))
;; If we did indeed read any incoming spools, we save all info.
(if (zerop total)
(when mail-source-plugged
(nnheader-message 4 "%s: Reading incoming mail (no new mail)...done"
method (car source)))
(nnmail-save-active
(nnmail-get-value "%s-group-alist" method)
(nnmail-get-value "%s-active-file" method))
(when exit-func
(funcall exit-func))
(run-hooks 'nnmail-read-incoming-hook)
(nnheader-message 4 "%s: Reading incoming mail (%d new)...done" method
total))
;; Close the message-id cache.
(nnmail-cache-close)
;; Allow the user to hook.
(run-hooks 'nnmail-post-get-new-mail-hook))))