Mercurial > emacs
annotate lisp/gnus/gnus-move.el @ 50677:152c21ba1618
(emacs-lisp-mode-syntax-table): Give @ prefix syntax.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 24 Apr 2003 01:36:13 +0000 |
parents | 9968f55ad26e |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
17493 | 1 ;;; gnus-move.el --- commands for moving Gnus from one server to another |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
17493 | 4 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 6 ;; Keywords: news |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
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) | |
13 ;; any later version. | |
14 | |
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. | |
19 | |
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. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
19634
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'gnus-start) | |
33 (require 'gnus-int) | |
34 (require 'gnus-range) | |
35 | |
36 ;;; | |
37 ;;; Moving by comparing Message-ID's. | |
38 ;;; | |
39 | |
40 ;;;###autoload | |
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." | |
44 (interactive | |
45 (list gnus-select-method (gnus-read-method "Move to method: "))) | |
46 | |
47 ;; First start Gnus. | |
48 (let ((gnus-activate-level 0) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
49 (mail-sources nil) |
17493 | 50 (nnmail-spool-file nil)) |
51 (gnus)) | |
52 | |
53 (save-excursion | |
54 ;; Go through all groups and translate. | |
55 (let ((newsrc gnus-newsrc-alist) | |
56 (nntp-nov-gap nil) | |
57 info) | |
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)))))) | |
61 | |
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 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
66 to-article to-reads to-marks article |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
67 act-articles) |
17493 | 68 (gnus-message 7 "Translating %s..." group) |
69 (when (gnus-request-group group nil to-server) | |
70 (setq to-active (gnus-parse-active) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
71 hashtb (gnus-make-hashtable 1024) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
72 act-articles (gnus-uncompress-range to-active)) |
17493 | 73 ;; Fetch the headers from the `to-server'. |
74 (when (and to-active | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
75 act-articles |
17493 | 76 (setq type (gnus-retrieve-headers |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
77 act-articles |
17493 | 78 group to-server))) |
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)) | |
85 (while (looking-at | |
86 "^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t") | |
87 (gnus-sethash | |
88 (buffer-substring (match-beginning 1) (match-end 1)) | |
89 (read (current-buffer)) | |
90 hashtb) | |
91 (forward-line 1)) | |
92 ;; Then we read the headers from the `from-server'. | |
93 (when (and (gnus-request-group group nil from-server) | |
94 (gnus-active group) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
95 (gnus-uncompress-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
96 (gnus-active group)) |
17493 | 97 (setq type (gnus-retrieve-headers |
98 (gnus-uncompress-range | |
99 (gnus-active group)) | |
100 group from-server))) | |
101 ;; Make it easier to map marks. | |
102 (let ((mark-lists (gnus-info-marks info)) | |
103 ms type m) | |
104 (while mark-lists | |
105 (setq type (caar mark-lists) | |
106 ms (gnus-uncompress-range (cdr (pop mark-lists)))) | |
107 (while ms | |
108 (if (setq m (assq (car ms) marks)) | |
109 (setcdr m (cons type (cdr m))) | |
110 (push (list (car ms) type) marks)) | |
111 (pop ms)))) | |
112 ;; Convert. | |
113 (when (eq type 'headers) | |
114 (nnvirtual-convert-headers)) | |
115 ;; Go through the headers and map away. | |
116 (set-buffer nntp-server-buffer) | |
117 (goto-char (point-min)) | |
118 (while (looking-at | |
119 "^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
120 (when (setq to-article |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
121 (gnus-gethash |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
122 (buffer-substring (match-beginning 1) (match-end 1)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
123 hashtb)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
124 ;; Add this article to the list of read articles. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
125 (push to-article to-reads) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
126 ;; See if there are any marks and then add them. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
127 (when (setq mark (assq (read (current-buffer)) marks)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
128 (setq marks (delq mark marks)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
129 (setcar mark to-article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
130 (push mark to-marks)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
131 (forward-line 1))) |
17493 | 132 ;; Now we know what the read articles are and what the |
133 ;; article marks are. We transform the information | |
134 ;; into the Gnus info format. | |
135 (setq to-reads | |
136 (gnus-range-add | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
137 (gnus-compress-sequence |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
138 (and (setq to-reads (delq nil to-reads)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
139 (sort to-reads '<)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
140 t) |
17493 | 141 (cons 1 (1- (car to-active))))) |
142 (gnus-info-set-read info to-reads) | |
143 ;; Do the marks. I'm sure y'all understand what's | |
144 ;; going on down below, so I won't bother with any | |
145 ;; further comments. <duck> | |
146 (let ((mlists gnus-article-mark-lists) | |
147 lists ms a) | |
148 (while mlists | |
149 (push (list (cdr (pop mlists))) lists)) | |
150 (while (setq ms (pop marks)) | |
151 (setq article (pop ms)) | |
152 (while ms | |
153 (setcdr (setq a (assq (pop ms) lists)) | |
154 (cons article (cdr a))))) | |
155 (setq a lists) | |
156 (while a | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
157 (setcdr (car a) (gnus-compress-sequence |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
158 (and (cdar a) (sort (cdar a) '<)))) |
17493 | 159 (pop a)) |
160 (gnus-info-set-marks info lists t))))) | |
161 (gnus-message 7 "Translating %s...done" group))) | |
162 | |
163 (defun gnus-group-move-group-to-server (info from-server to-server) | |
164 "Move the group on the current line from FROM-SERVER to TO-SERVER." | |
165 (interactive | |
166 (let ((info (gnus-get-info (gnus-group-group-name)))) | |
167 (list info (gnus-find-method-for-group (gnus-info-group info)) | |
168 (gnus-read-method (format "Move group %s to method: " | |
169 (gnus-info-group info)))))) | |
170 (save-excursion | |
171 (gnus-move-group-to-server info from-server to-server) | |
172 ;; We have to update the group info to point use the right server. | |
173 (gnus-info-set-method info to-server t) | |
174 ;; We also have to change the name of the group and stuff. | |
175 (let* ((group (gnus-info-group info)) | |
176 (new-name (gnus-group-prefixed-name | |
177 (gnus-group-real-name group) to-server))) | |
178 (gnus-info-set-group info new-name) | |
179 (gnus-sethash new-name (gnus-gethash group gnus-newsrc-hashtb) | |
180 gnus-newsrc-hashtb) | |
181 (gnus-sethash group nil gnus-newsrc-hashtb)))) | |
182 | |
183 (provide 'gnus-move) | |
184 | |
185 ;;; gnus-move.el ends here |