Function: mail-source-fetch-maildir

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

Signature

(mail-source-fetch-maildir SOURCE CALLBACK)

Documentation

Fetcher for maildir sources.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mail-source.el.gz
(defun mail-source-fetch-maildir (source callback)
  "Fetcher for maildir sources."
  (mail-source-bind (maildir source)
    (let ((found 0)
	  mail-source-string)
      (unless (string-match "/$" path)
	(setq path (concat path "/")))
      (dolist (subdir subdirs)
	(when (file-directory-p (concat path subdir))
	  (setq mail-source-string (format "maildir:%s%s" path subdir))
	  (dolist (file (directory-files (concat path subdir) t))
	    (when (and (not (file-directory-p file))
		       (not (if function
				;; `function' should return nil if successful.
				(funcall function file mail-source-crash-box)
			      (let ((coding-system-for-write
				     mm-text-coding-system)
				    (coding-system-for-read
				     mm-text-coding-system))
				(with-temp-file mail-source-crash-box
				  (insert-file-contents file)
				  (goto-char (point-min))
;;;				  ;; Unix mail format
;;;				  (unless (looking-at "\n*From ")
;;;				    (insert "From maildir "
;;;					    (current-time-string) "\n"))
;;;				  (while (re-search-forward "^From " nil t)
;;;				    (replace-match ">From "))
;;;				  (goto-char (point-max))
;;;				  (insert "\n\n")
				  ;; MMDF mail format
				  (insert "\001\001\001\001\n"))
				(delete-file file)
				nil))))
	      (cl-incf found (mail-source-callback callback file))
	      (mail-source-delete-crash-box)))))
      found)))