+ (goto-char (point-min))
+ (when (search-forward (nnfolder-article-string article) nil t)
+ (let (start stop)
+ (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
+ (setq start (point))
+ (forward-line 1)
+ (unless (and (re-search-forward
+ (concat "^" message-unix-mail-delimiter) nil t)
+ (forward-line -1))
+ (goto-char (point-max)))
+ (setq stop (point))
+ (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
+ (set-buffer nntp-server-buffer)
+ (erase-buffer)
+ (insert-buffer-substring nnfolder-current-buffer start stop)
+ (goto-char (point-min))
+ (while (looking-at "From ")
+ (delete-char 5)
+ (insert "X-From-Line: ")
+ (forward-line 1))
+ (if (numberp article)
+ (cons nnfolder-current-group article)
+ (goto-char (point-min))
+ (search-forward (concat "\n" nnfolder-article-marker))
+ (cons nnfolder-current-group
+ (string-to-int
+ (buffer-substring
+ (point) (progn (end-of-line) (point)))))))))))
+
+(deffoo nnfolder-request-group (group &optional server dont-check)
+ (save-excursion
+ (nnmail-activate 'nnfolder)
+ (if (not (assoc group nnfolder-group-alist))
+ (nnheader-report 'nnfolder "No such group: %s" group)
+ (nnfolder-possibly-change-group group server)
+ (if dont-check
+ (progn
+ (nnheader-report 'nnfolder "Selected group %s" group)
+ t)
+ (let* ((active (assoc group nnfolder-group-alist))
+ (group (car active))
+ (range (cadr active)))
+ (cond
+ ((null active)
+ (nnheader-report 'nnfolder "No such group: %s" group))
+ ((null nnfolder-current-group)
+ (nnheader-report 'nnfolder "Empty group: %s" group))
+ (t
+ (nnheader-report 'nnfolder "Selected group %s" group)
+ (nnheader-insert "211 %d %d %d %s\n"
+ (1+ (- (cdr range) (car range)))
+ (car range) (cdr range) group))))))))
+
+(deffoo nnfolder-request-scan (&optional group server)
+ (nnfolder-possibly-change-group group server t)
+ (nnmail-get-new-mail
+ 'nnfolder
+ (lambda ()
+ (let ((bufs nnfolder-buffer-alist))
+ (save-excursion
+ (while bufs
+ (if (not (buffer-name (nth 1 (car bufs))))
+ (setq nnfolder-buffer-alist
+ (delq (car bufs) nnfolder-buffer-alist))
+ (set-buffer (nth 1 (car bufs)))
+ (nnfolder-save-buffer)
+ (kill-buffer (current-buffer)))
+ (setq bufs (cdr bufs))))))
+ nnfolder-directory
+ group))
+
+;; Don't close the buffer if we're not shutting down the server. This way,
+;; we can keep the buffer in the group buffer cache, and not have to grovel
+;; over the buffer again unless we add new mail to it or modify it in some
+;; way.
+
+(deffoo nnfolder-close-group (group &optional server force)
+ ;; Make sure we _had_ the group open.
+ (when (or (assoc group nnfolder-buffer-alist)
+ (equal group nnfolder-current-group))
+ (let ((inf (assoc group nnfolder-buffer-alist)))
+ (when inf
+ (when nnfolder-current-group
+ (push (list nnfolder-current-group nnfolder-current-buffer)
+ nnfolder-buffer-alist))
+ (setq nnfolder-buffer-alist
+ (delq inf nnfolder-buffer-alist))
+ (setq nnfolder-current-buffer (cadr inf)
+ nnfolder-current-group (car inf))))
+ (when (and nnfolder-current-buffer
+ (buffer-name nnfolder-current-buffer))
+ (save-excursion
+ (set-buffer nnfolder-current-buffer)
+ ;; If the buffer was modified, write the file out now.
+ (nnfolder-save-buffer)
+ ;; If we're shutting the server down, we need to kill the
+ ;; buffer and remove it from the open buffer list. Or, of
+ ;; course, if we're trying to minimize our space impact.
+ (kill-buffer (current-buffer))
+ (setq nnfolder-buffer-alist (delq (assoc group nnfolder-buffer-alist)
+ nnfolder-buffer-alist)))))