1 ;;; gnus-move.el --- commands for moving Gnus from one server to another
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
37 ;;; Moving by comparing Message-ID's.
41 (defun gnus-change-server (from-server to-server)
42 "Move from FROM-SERVER to TO-SERVER.
43 Update the .newsrc.eld file to reflect the change of nntp server."
45 (list gnus-select-method (gnus-read-method "Move to method: ")))
48 (let ((gnus-activate-level 0)
50 (nnmail-spool-file nil))
54 ;; Go through all groups and translate.
55 (let ((newsrc gnus-newsrc-alist)
58 (while (setq info (pop newsrc))
59 (when (gnus-group-native-p (gnus-info-group info))
60 (gnus-move-group-to-server info from-server to-server))))))
62 (defun gnus-move-group-to-server (info from-server to-server)
63 "Move group INFO from FROM-SERVER to TO-SERVER."
64 (let ((group (gnus-info-group info))
65 to-active hashtb type mark marks
66 to-article to-reads to-marks article
68 (gnus-message 7 "Translating %s..." group)
69 (when (gnus-request-group group nil to-server)
70 (setq to-active (gnus-parse-active)
71 hashtb (gnus-make-hashtable 1024)
72 act-articles (gnus-uncompress-range to-active))
73 ;; Fetch the headers from the `to-server'.
76 (setq type (gnus-retrieve-headers
79 ;; Convert HEAD headers. I don't care.
80 (when (eq type 'headers)
81 (nnvirtual-convert-headers))
82 ;; Create a mapping from Message-ID to article number.
83 (set-buffer nntp-server-buffer)
84 (goto-char (point-min))
86 "^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t")
88 (buffer-substring (match-beginning 1) (match-end 1))
89 (read (current-buffer))
92 ;; Then we read the headers from the `from-server'.
93 (when (and (gnus-request-group group nil from-server)
95 (gnus-uncompress-range
97 (setq type (gnus-retrieve-headers
98 (gnus-uncompress-range
101 ;; Make it easier to map marks.
102 (let ((mark-lists (gnus-info-marks info))
105 (setq type (caar mark-lists)
106 ms (gnus-uncompress-range (cdr (pop mark-lists))))
108 (if (setq m (assq (car ms) marks))
109 (setcdr m (cons type (cdr m)))
110 (push (list (car ms) type) marks))