Function: mail-source-fetch

mail-source-fetch is a byte-compiled function defined in mail-source.el.gz.

Signature

(mail-source-fetch SOURCE CALLBACK &optional METHOD)

Documentation

Fetch mail from SOURCE and call CALLBACK zero or more times.

CALLBACK will be called with the name of the file where (some of) the mail from SOURCE is put. Return the number of files that were found.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mail-source.el.gz
(defun mail-source-fetch (source callback &optional method)
  "Fetch mail from SOURCE and call CALLBACK zero or more times.
CALLBACK will be called with the name of the file where (some of)
the mail from SOURCE is put.
Return the number of files that were found."
  (mail-source-bind-common source
    (if (or mail-source-plugged plugged)
	(save-excursion
	  ;; Special-case the `file' handler since it's so common and
	  ;; just adds noise.
	  (when (or (not (eq (car source) 'file))
		    (mail-source-bind (file source)
		      (file-exists-p path)))
	    (nnheader-message 4 "%sReading incoming mail from %s..."
			      (if method
				  (format "%s: " method)
				"")
			      (car source)))
	  (let ((function (cadr (assq (car source) mail-source-fetcher-alist)))
		(found 0))
	    (unless function
	      (error "%S is an invalid mail source specification" source))
	    ;; If there's anything in the crash box, we do it first.
	    (when (file-exists-p mail-source-crash-box)
	      (message "Processing mail from %s..." mail-source-crash-box)
	      (setq found (mail-source-callback
			   callback mail-source-crash-box))
	      (mail-source-delete-crash-box))
	    (+ found
	       (if (or debug-on-quit debug-on-error)
		   (funcall function source callback)
		 (condition-case err
		     (funcall function source callback)
		   (error
                    (gnus-error
                     5
                     (format "Mail source %s error (%s)"
				       (if (memq ':password source)
					   (let ((s (copy-sequence source)))
					     (setcar (cdr (memq ':password s))
						     "********")
					     s)
					 source)
				       (cadr err)))
		    0)))))))))