-(defun nnfolder-read-folder (file)
- (save-excursion
- (if (not nnfolder-group-alist)
- (progn
- (nnfolder-request-list)
- (setq nnfolder-group-alist (nnmail-get-active))))
- ;; We should be paranoid here and make sure the group is in the alist,
- ;; and add it if it isn't.
- ;;(if (not (assoc nnfoler-current-group nnfolder-group-alist)
- (set-buffer (setq nnfolder-current-buffer (find-file-noselect file)))
- (buffer-disable-undo (current-buffer))
- (let ((delim (concat "^" rmail-unix-mail-delimiter))
- (marker (concat "\n" nnfolder-article-marker))
- (number "[0-9]+")
- (active (car (cdr (assoc nnfolder-current-group
- nnfolder-group-alist))))
- activenumber activemin start end)
- (goto-char (point-min))
- ;;
- ;; Anytime the active number is 1 or 0, it is supect. In that case,
- ;; search the file manually to find the active number. Or, of course,
- ;; if we're being paranoid. (This would also be the place to build
- ;; other lists from the header markers, such as expunge lists, etc., if
- ;; we ever desired to abandon the active file entirely for mboxes.)
- (setq activenumber (cdr active))
- (if (or nnfolder-ignore-active-file
- (< activenumber 2))
- (progn
- (setq activemin (max (1- (lsh 1 23))
- (1- (lsh 1 24))
- (1- (lsh 1 25))))
+(defun nnfolder-read-folder (file &optional scanning)
+ ;; This is an attempt at a serious shortcut - don't even read in the file
+ ;; if we know we've seen it since the last time it was touched.
+ (let ((scantime (cadr (assoc nnfolder-current-group
+ nnfolder-scantime-alist)))
+ (modtime (nth 5 (or (file-attributes file) '(nil nil nil nil nil)))))
+ (if (and scanning scantime
+ (eq (car scantime) (car modtime))
+ (eq (cdr scantime) (cadr modtime)))
+ nil
+ (save-excursion
+ (nnfolder-possibly-activate-groups nil)
+ ;; Read in the file.
+ (set-buffer (setq nnfolder-current-buffer
+ (nnheader-find-file-noselect file nil 'raw)))
+ (buffer-disable-undo (current-buffer))
+ ;; If the file hasn't been touched since the last time we scanned it,
+ ;; don't bother doing anything with it.
+ (let ((delim (concat "^" message-unix-mail-delimiter))
+ (marker (concat "\n" nnfolder-article-marker))
+ (number "[0-9]+")
+ (active (or (cadr (assoc nnfolder-current-group
+ nnfolder-group-alist))
+ (cons 1 0)))
+ (scantime (assoc nnfolder-current-group nnfolder-scantime-alist))
+ (minid (lsh -1 -1))
+ maxid start end newscantime)
+
+ (setq maxid (or (cdr active) 0))
+ (goto-char (point-min))
+
+ ;; Anytime the active number is 1 or 0, it is suspect. In that
+ ;; case, search the file manually to find the active number. Or,
+ ;; of course, if we're being paranoid. (This would also be the
+ ;; place to build other lists from the header markers, such as
+ ;; expunge lists, etc., if we ever desired to abandon the active
+ ;; file entirely for mboxes.)
+ (when (or nnfolder-ignore-active-file
+ (< maxid 2))