Function: nnml-request-rename-group

nnml-request-rename-group is a byte-compiled function defined in nnml.el.gz.

Signature

(nnml-request-rename-group GROUP NEW-NAME &optional SERVER)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnml.el.gz
(deffoo nnml-request-rename-group (group new-name &optional server)
  (nnml-possibly-change-directory group server)
  (let ((new-dir (nnml-group-pathname new-name nil server))
	(old-dir (nnml-group-pathname group nil server))
	(file-name-coding-system nnmail-pathname-coding-system))
    (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.
      (dolist (file (nnheader-article-to-file-alist old-dir))
	(rename-file
	 (concat old-dir (cdr file))
	 (concat new-dir (cdr file))))
      ;; 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-string 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))))