-(defun nnml-request-rename-group (group new-name &optional server)
- (nnml-possibly-change-directory group)
- ;; Rename directory.
- (and (file-writable-p nnml-current-directory)
- (condition-case ()
- (progn
- (rename-file
- (directory-file-name nnml-current-directory)
- (directory-file-name
- (nnmail-group-pathname new-name nnml-directory)))
- t)
- (error nil))
- ;; That went ok, so we change the internal structures.
- (let ((entry (assoc group nnml-group-alist)))
- (and entry (setcar entry new-name))
- (setq nnml-current-directory nil
- nnml-current-group nil)
- ;; Save the new group alist.
- (nnmail-save-active nnml-group-alist nnml-active-file)
- t)))
+(deffoo nnml-request-rename-group (group new-name &optional server)
+ (nnml-possibly-change-directory group server)
+ (let ((new-dir (nnmail-group-pathname new-name nnml-directory))
+ (old-dir (nnmail-group-pathname group nnml-directory)))
+ (when (ignore-errors
+ (make-directory new-dir t)
+ t)
+ ;; 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)))
+ ;; Move .overview file.
+ (let ((overview (concat old-dir nnml-nov-file-name)))
+ (when (file-exists-p overview)
+ (rename-file overview (concat new-dir nnml-nov-file-name))))
+ (when (<= (length (directory-files old-dir)) 2)
+ (ignore-errors (delete-directory old-dir)))
+ ;; That went ok, so we change the internal structures.
+ (let ((entry (assoc group nnml-group-alist)))
+ (when entry
+ (setcar entry new-name))
+ (setq nnml-current-directory nil
+ nnml-current-group nil)
+ ;; Save the new group alist.
+ (nnmail-save-active nnml-group-alist nnml-active-file)
+ t))))
+
+(deffoo nnml-set-status (article name value &optional group server)
+ (nnml-possibly-change-directory group server)
+ (let ((file (nnml-article-to-file article)))
+ (cond
+ ((not (file-exists-p file))
+ (nnheader-report 'nnml "File %s does not exist" file))
+ (t
+ (with-temp-file file
+ (nnheader-insert-file-contents file)
+ (nnmail-replace-status name value))
+ t))))