Function: nnmail-split-incoming

nnmail-split-incoming is a byte-compiled function defined in nnmail.el.gz.

Signature

(nnmail-split-incoming INCOMING FUNC &optional EXIT-FUNC GROUP ARTNUM-FUNC JUNK-FUNC)

Documentation

Go through the entire INCOMING file and pick out each individual mail.

FUNC will be called with the buffer narrowed to each mail. INCOMING can also be a buffer object. In that case, the mail will be copied over from that buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmail.el.gz
(defun nnmail-split-incoming (incoming func &optional exit-func
				       group artnum-func junk-func)
  "Go through the entire INCOMING file and pick out each individual mail.
FUNC will be called with the buffer narrowed to each mail.
INCOMING can also be a buffer object.  In that case, the mail
will be copied over from that buffer."
  (let (;; If this is a group-specific split, we bind the split
	;; methods to just this group.
	(nnmail-split-methods (if (and group
				       (not nnmail-resplit-incoming))
				  (list (list group ""))
				nnmail-split-methods)))
    ;; Insert the incoming file.
    (with-current-buffer (gnus-get-buffer-create nnmail-article-buffer)
      (erase-buffer)
      (if (bufferp incoming)
	  (insert-buffer-substring incoming)
	;; The following coding system is set to
	;; `mm-text-coding-system', which is set to some flavor of
	;; 'raw-text "to get rid of ^Ms".  But it's going to do a lot
	;; more than that, right?  Shouldn't this also be 'undecided?
	(let ((coding-system-for-read nnmail-incoming-coding-system))
	  (mm-insert-file-contents incoming)))
      (prog1
	  (if (zerop (buffer-size))
	      0
	    (goto-char (point-min))
	    (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
	    ;; Handle both babyl, MMDF and unix mail formats, since
	    ;; movemail will use the former when fetching from a
	    ;; mailbox, the latter when fetching from a file.
	    (cond ((or (looking-at "\^L")
		       (looking-at "BABYL OPTIONS:"))
		   (nnmail-process-babyl-mail-format func artnum-func))
		  ((looking-at "\^A\^A\^A\^A")
		   (nnmail-process-mmdf-mail-format
		    func artnum-func junk-func))
		  ((looking-at "Return-Path:")
		   (nnmail-process-maildir-mail-format func artnum-func))
		  (t
		   (nnmail-process-unix-mail-format func artnum-func))))
	(when exit-func
	  (funcall exit-func))
	(kill-buffer (current-buffer))))))