+(deffoo nnmh-request-create-group (group &optional server)
+ (nnmail-activate 'nnmh)
+ (unless (assoc group nnmh-group-alist)
+ (let (active)
+ (push (list group (setq active (cons 1 0)))
+ nnmh-group-alist)
+ (nnmh-possibly-create-directory group)
+ (nnmh-possibly-change-directory group server)
+ (let ((articles (mapcar
+ (lambda (file)
+ (string-to-int file))
+ (directory-files
+ nnmh-current-directory nil "^[0-9]+$"))))
+ (when articles
+ (setcar active (apply 'min articles))
+ (setcdr active (apply 'max articles))))))
+ t)
+
+(deffoo nnmh-request-delete-group (group &optional force server)
+ (nnmh-possibly-change-directory group server)
+ ;; Delete all articles in GROUP.
+ (if (not force)
+ () ; Don't delete the articles.
+ (let ((articles (directory-files nnmh-current-directory t "^[0-9]+$")))
+ (while articles
+ (and (file-writable-p (car articles))
+ (progn
+ (nnheader-message 5 "Deleting article %s in %s..."
+ (car articles) group)
+ (funcall nnmail-delete-file-function (car articles))))
+ (setq articles (cdr articles))))
+ ;; Try to delete the directory itself.
+ (condition-case ()
+ (delete-directory nnmh-current-directory)
+ (error nil)))
+ ;; Remove the group from all structures.
+ (setq nnmh-group-alist
+ (delq (assoc group nnmh-group-alist) nnmh-group-alist)
+ nnmh-current-directory nil)
+ t)
+
+(deffoo nnmh-request-rename-group (group new-name &optional server)
+ (nnmh-possibly-change-directory group server)
+ (let ((new-dir (nnmail-group-pathname new-name nnmh-directory))
+ (old-dir (nnmail-group-pathname group nnmh-directory)))
+ (when (condition-case ()
+ (progn
+ (make-directory new-dir t)
+ t)
+ (error nil))
+ ;; We move the articles file by file instead of renaming
+ ;; the directory -- there may be subgroups in this group.
+ ;; One might be more clever, I guess.
+ (let ((files (nnheader-article-to-file-alist old-dir)))
+ (while files
+ (rename-file
+ (concat old-dir (cdar files))
+ (concat new-dir (cdar files)))
+ (pop files)))
+ (when (<= (length (directory-files old-dir)) 2)
+ (condition-case ()
+ (delete-directory old-dir)
+ (error nil)))
+ ;; That went ok, so we change the internal structures.
+ (let ((entry (assoc group nnmh-group-alist)))
+ (and entry (setcar entry new-name))
+ (setq nnmh-current-directory nil)
+ t))))
+