Revision: miles@gnu.org--gnu-2005/gnus--devo--0--patch-182
[gnus] / lisp / gnus-move.el
1 ;;; gnus-move.el --- commands for moving Gnus from one server to another
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004,
4 ;;   2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)
33 (require 'gnus-start)
34 (require 'gnus-int)
35 (require 'gnus-range)
36
37 ;;;
38 ;;; Moving by comparing Message-ID's.
39 ;;;
40
41 ;;;###autoload
42 (defun gnus-change-server (from-server to-server)
43   "Move from FROM-SERVER to TO-SERVER.
44 Update the .newsrc.eld file to reflect the change of nntp server."
45   (interactive
46    (list gnus-select-method (gnus-read-method "Move to method: ")))
47
48   ;; First start Gnus.
49   (let ((gnus-activate-level 0)
50         (mail-sources nil)
51         (nnmail-spool-file nil))
52     (gnus))
53
54   (save-excursion
55     ;; Go through all groups and translate.
56     (let ((nntp-nov-gap nil))
57       (dolist (info gnus-newsrc-alist)
58         (when (gnus-group-native-p (gnus-info-group info))
59           (gnus-move-group-to-server info from-server to-server))))))
60