Function: gnus-agent-rename-group

gnus-agent-rename-group is an autoloaded and byte-compiled function defined in gnus-agent.el.gz.

Signature

(gnus-agent-rename-group OLD-GROUP NEW-GROUP)

Documentation

Rename fully-qualified OLD-GROUP as NEW-GROUP.

Always updates the agent, even when disabled, as the old agent files would corrupt gnus when the agent was next enabled. Depends upon the caller to determine whether group renaming is supported.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-agent.el.gz
;;;###autoload
(defun gnus-agent-rename-group (old-group new-group)
  "Rename fully-qualified OLD-GROUP as NEW-GROUP.
Always updates the agent, even when disabled, as the old agent
files would corrupt gnus when the agent was next enabled.
Depends upon the caller to determine whether group renaming is
supported."
  (let* ((old-command-method (gnus-find-method-for-group old-group))
	 (old-path           (directory-file-name
			      (let ((gnus-command-method old-command-method))
				(gnus-agent-group-pathname old-group))))
	 (new-command-method (gnus-find-method-for-group new-group))
	 (new-path           (directory-file-name
			      (let ((gnus-command-method new-command-method))
				(gnus-agent-group-pathname new-group))))
	 (file-name-coding-system nnmail-pathname-coding-system))
    (gnus-rename-file old-path new-path t)

    (let* ((old-real-group (gnus-group-real-name old-group))
	   (new-real-group (gnus-group-real-name new-group))
	   (old-active (gnus-agent-get-group-info old-command-method old-real-group)))
      (gnus-agent-save-group-info old-command-method old-real-group nil)
      (gnus-agent-save-group-info new-command-method new-real-group old-active)

      (let ((old-local (gnus-agent-get-local old-group
					     old-real-group old-command-method)))
	(gnus-agent-set-local old-group
			      nil nil
			      old-real-group old-command-method)
	(gnus-agent-set-local new-group
			      (car old-local) (cdr old-local)
			      new-real-group new-command-method)))))