- (unless (file-exists-p nnfolder-directory)
- (make-directory (directory-file-name nnfolder-directory) t))
- (nnfolder-possibly-activate-groups nil)
- (or (assoc group nnfolder-group-alist)
- (not (file-exists-p (concat (file-name-as-directory nnfolder-directory)
- group)))
- (progn
- (setq nnfolder-group-alist
- (cons (list group (cons 1 0)) nnfolder-group-alist))
- (nnmail-save-active nnfolder-group-alist nnfolder-active-file)))
- (let (inf file)
- (if (and (equal group nnfolder-current-group)
- nnfolder-current-buffer
- (buffer-name nnfolder-current-buffer))
- ()
- (setq nnfolder-current-group group)
-
- ;; If we have to change groups, see if we don't already have the mbox
- ;; in memory. If we do, verify the modtime and destroy the mbox if
- ;; needed so we can rescan it.
- (if (setq inf (assoc group nnfolder-buffer-alist))
- (setq nnfolder-current-buffer (nth 1 inf)))
-
- ;; If the buffer is not live, make sure it isn't in the alist. If it
- ;; is live, verify that nobody else has touched the file since last
- ;; time.
- (if (or (not (and nnfolder-current-buffer
- (buffer-name nnfolder-current-buffer)))
- (not (and (bufferp nnfolder-current-buffer)
- (verify-visited-file-modtime
- nnfolder-current-buffer))))
- (progn
- (if (and nnfolder-current-buffer
- (buffer-name nnfolder-current-buffer)
- (bufferp nnfolder-current-buffer))
- (kill-buffer nnfolder-current-buffer))
- (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist))
- (setq inf nil)))
-
- (if inf
- ()
- (save-excursion
- (setq file (concat (file-name-as-directory nnfolder-directory)
- group))
- (if (file-directory-p (file-truename file))
- ()
- (if (not (file-exists-p file))
- (write-region 1 1 file t 'nomesg))
- (setq nnfolder-current-buffer
- (set-buffer (nnfolder-read-folder file)))
- (setq nnfolder-buffer-alist (cons (list group (current-buffer))
- nnfolder-buffer-alist)))))))
- (setq nnfolder-current-group group))
-
-(defun nnfolder-save-mail (&optional group)
+ (unless (gnus-buffer-live-p nnfolder-current-buffer)
+ (setq nnfolder-current-buffer nil
+ nnfolder-current-group nil))
+ ;; Change group.
+ (when (and group
+ (not (equal group nnfolder-current-group)))
+ (let ((pathname-coding-system 'binary))
+ (nnmail-activate 'nnfolder)
+ (when (and (not (assoc group nnfolder-group-alist))
+ (not (file-exists-p
+ (nnfolder-group-pathname group))))
+ ;; The group doesn't exist, so we create a new entry for it.
+ (push (list group (cons 1 0)) nnfolder-group-alist)
+ (nnmail-save-active nnfolder-group-alist nnfolder-active-file))
+
+ (if dont-check
+ (setq nnfolder-current-group group
+ nnfolder-current-buffer nil)
+ (let (inf file)
+ ;; If we have to change groups, see if we don't already have the
+ ;; folder in memory. If we do, verify the modtime and destroy
+ ;; the folder if needed so we can rescan it.
+ (setq nnfolder-current-buffer
+ (nth 1 (assoc group nnfolder-buffer-alist)))
+
+ ;; If the buffer is not live, make sure it isn't in the alist. If it
+ ;; is live, verify that nobody else has touched the file since last
+ ;; time.
+ (when (and nnfolder-current-buffer
+ (not (gnus-buffer-live-p nnfolder-current-buffer)))
+ (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist)
+ nnfolder-current-buffer nil))
+
+ (setq nnfolder-current-group group)
+
+ (when (or (not nnfolder-current-buffer)
+ (not (verify-visited-file-modtime
+ nnfolder-current-buffer)))
+ (save-excursion
+ (setq file (nnfolder-group-pathname group))
+ ;; See whether we need to create the new file.
+ (unless (file-exists-p file)
+ (gnus-make-directory (file-name-directory file))
+ (nnmail-write-region 1 1 file t 'nomesg))
+ (when (setq nnfolder-current-buffer (nnfolder-read-folder group))
+ (set-buffer nnfolder-current-buffer)
+ (push (list group nnfolder-current-buffer)
+ nnfolder-buffer-alist)))))))))
+
+(defun nnfolder-save-mail (group-art-list)