Function: nnmaildir-request-scan

nnmaildir-request-scan is a byte-compiled function defined in nnmaildir.el.gz.

Signature

(nnmaildir-request-scan &optional SCAN-GROUP SERVER)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmaildir.el.gz
(defun nnmaildir-request-scan (&optional scan-group server)
  (let ((coding-system-for-write nnheader-file-coding-system)
	(buffer-file-coding-system nil)
	(file-coding-system-alist nil)
	(nnmaildir-get-new-mail t)
	(nnmaildir-group-alist nil)
	(nnmaildir-active-file nil)
	x srv-ls srv-dir method groups target-prefix dirs seen
	deactivate-mark)
    (nnmaildir--prepare server nil)
    (setq srv-ls (nnmaildir--srv-ls nnmaildir--cur-server)
	  srv-dir (nnmaildir--srv-dir nnmaildir--cur-server)
	  method (nnmaildir--srv-method nnmaildir--cur-server)
	  groups (nnmaildir--srv-groups nnmaildir--cur-server)
	  target-prefix (nnmaildir--srv-target-prefix nnmaildir--cur-server))
    (nnmaildir--with-work-buffer
     (save-match-data
       (if (stringp scan-group)
	   (if (nnmaildir--scan scan-group t groups method srv-dir srv-ls)
	       (when (nnmaildir--srv-gnm nnmaildir--cur-server)
		 (nnmail-get-new-mail 'nnmaildir nil nil scan-group))
	     (remhash scan-group groups))
	 (setq x (file-attribute-modification-time (file-attributes srv-dir))
	       scan-group (null scan-group))
	 (if (equal x (nnmaildir--srv-mtime nnmaildir--cur-server))
	     (when scan-group
	       (maphash (lambda (group-name _group)
			  (nnmaildir--scan group-name t groups
					   method srv-dir srv-ls))
			groups))
	   (setq dirs (funcall srv-ls srv-dir nil "\\`[^.]" 'nosort)
		 dirs (if (zerop (length target-prefix))
			  dirs
			(seq-remove
			 (lambda (dir)
			   (and (>= (length dir) (length target-prefix))
				(string= (substring dir 0
						    (length target-prefix))
					 target-prefix)))
			 dirs)))
	   (dolist (grp-dir dirs)
	     (when (nnmaildir--scan grp-dir scan-group groups
				    method srv-dir srv-ls)
	       (push grp-dir seen)))
	   (setq x nil)
	   (maphash (lambda (gname _group)
		      (unless (member gname seen)
			(push gname x)))
		    groups)
	   (dolist (grp x)
	     (remhash grp groups))
	   (setf (nnmaildir--srv-mtime nnmaildir--cur-server)
		 (file-attribute-modification-time (file-attributes srv-dir))))
	 (and scan-group
	      (nnmaildir--srv-gnm nnmaildir--cur-server)
	      (nnmail-get-new-mail 'nnmaildir nil nil))))))
  t)