Mercurial > emacs
annotate lisp/gnus/gnus-move.el @ 111602:f44b93254721
Fix some ls-lisp oddness.
* lisp/ls-lisp.el (ls-lisp-dired-ignore-case): Make it an obsolete alias.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 10 Nov 2010 19:48:46 -0800 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
17493 | 1 ;;; gnus-move.el --- commands for moving Gnus from one server to another |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
74547 | 3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
17493 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
17493 | 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 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17493 | 19 ;; GNU General Public License for more details. |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
17493 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
19634
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 |
17493 | 30 (require 'gnus) |
31 (require 'gnus-start) | |
32 (require 'gnus-int) | |
33 (require 'gnus-range) | |
34 | |
35 ;;; | |
36 ;;; Moving by comparing Message-ID's. | |
37 ;;; | |
38 | |
39 ;;;###autoload | |
40 (defun gnus-change-server (from-server to-server) | |
41 "Move from FROM-SERVER to TO-SERVER. | |
42 Update the .newsrc.eld file to reflect the change of nntp server." | |
43 (interactive | |
44 (list gnus-select-method (gnus-read-method "Move to method: "))) | |
45 | |
46 ;; First start Gnus. | |
47 (let ((gnus-activate-level 0) | |
87097 | 48 (mail-sources nil)) |
17493 | 49 (gnus)) |
50 | |
51 (save-excursion | |
52 ;; Go through all groups and translate. | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
53 (let ((nntp-nov-gap nil)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
54 (dolist (info gnus-newsrc-alist) |
17493 | 55 (when (gnus-group-native-p (gnus-info-group info)) |
56 (gnus-move-group-to-server info from-server to-server)))))) | |
57 | |
58 (defun gnus-move-group-to-server (info from-server to-server) | |
59 "Move group INFO from FROM-SERVER to TO-SERVER." | |
60 (let ((group (gnus-info-group info)) | |
61 to-active hashtb type mark marks | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
62 to-article to-reads to-marks article |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
63 act-articles) |
17493 | 64 (gnus-message 7 "Translating %s..." group) |
65 (when (gnus-request-group group nil to-server) | |
66 (setq to-active (gnus-parse-active) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
67 hashtb (gnus-make-hashtable 1024) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
68 act-articles (gnus-uncompress-range to-active)) |
17493 | 69 ;; Fetch the headers from the `to-server'. |
70 (when (and to-active | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
71 act-articles |
17493 | 72 (setq type (gnus-retrieve-headers |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
73 act-articles |
17493 | 74 group to-server))) |
75 ;; Convert HEAD headers. I don't care. | |
76 (when (eq type 'headers) | |
77 (nnvirtual-convert-headers)) | |
78 ;; Create a mapping from Message-ID to article number. | |
79 (set-buffer nntp-server-buffer) | |
80 (goto-char (point-min)) | |
81 (while (looking-at | |
82 "^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t") | |
83 (gnus-sethash | |
84 (buffer-substring (match-beginning 1) (match-end 1)) | |
85 (read (current-buffer)) | |
86 hashtb) | |
87 (forward-line 1)) | |
88 ;; Then we read the headers from the `from-server'. | |
89 (when (and (gnus-request-group group nil from-server) | |
90 (gnus-active group) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
91 (gnus-uncompress-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
92 (gnus-active group)) |
17493 | 93 (setq type (gnus-retrieve-headers |
94 (gnus-uncompress-range | |
95 (gnus-active group)) | |
96 group from-server))) | |
97 ;; Make it easier to map marks. | |
98 (let ((mark-lists (gnus-info-marks info)) | |
99 ms type m) | |
100 (while mark-lists | |
101 (setq type (caar mark-lists) | |
102 ms (gnus-uncompress-range (cdr (pop mark-lists)))) | |
103 (while ms | |
104 (if (setq m (assq (car ms) marks)) | |
105 (setcdr m (cons type (cdr m))) | |
106 (push (list (car ms) type) marks)) | |
107 (pop ms)))) | |
108 ;; Convert. | |
109 (when (eq type 'headers) | |
110 (nnvirtual-convert-headers)) | |
111 ;; Go through the headers and map away. | |
112 (set-buffer nntp-server-buffer) | |
113 (goto-char (point-min)) | |
114 (while (looking-at | |
115 "^[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
|
116 (when (setq to-article |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
117 (gnus-gethash |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
118 (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
|
119 hashtb)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
120 ;; 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
|
121 (push to-article to-reads) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
122 ;; 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
|
123 (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
|
124 (setq marks (delq mark marks)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
125 (setcar mark to-article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
126 (push mark to-marks)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
127 (forward-line 1))) |
17493 | 128 ;; Now we know what the read articles are and what the |
129 ;; article marks are. We transform the information | |
130 ;; into the Gnus info format. | |
131 (setq to-reads | |
132 (gnus-range-add | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
133 (gnus-compress-sequence |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
134 (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
|
135 (sort to-reads '<)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
136 t) |
17493 | 137 (cons 1 (1- (car to-active))))) |
138 (gnus-info-set-read info to-reads) | |
139 ;; Do the marks. I'm sure y'all understand what's | |
140 ;; going on down below, so I won't bother with any | |
141 ;; further comments. <duck> | |
142 (let ((mlists gnus-article-mark-lists) | |
143 lists ms a) | |
144 (while mlists | |
145 (push (list (cdr (pop mlists))) lists)) | |
146 (while (setq ms (pop marks)) | |
147 (setq article (pop ms)) | |
148 (while ms | |
149 (setcdr (setq a (assq (pop ms) lists)) | |
150 (cons article (cdr a))))) | |
151 (setq a lists) | |
152 (while a | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
153 (setcdr (car a) (gnus-compress-sequence |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
154 (and (cdar a) (sort (cdar a) '<)))) |
17493 | 155 (pop a)) |
156 (gnus-info-set-marks info lists t))))) | |
157 (gnus-message 7 "Translating %s...done" group))) | |
158 | |
159 (defun gnus-group-move-group-to-server (info from-server to-server) | |
160 "Move the group on the current line from FROM-SERVER to TO-SERVER." | |
161 (interactive | |
162 (let ((info (gnus-get-info (gnus-group-group-name)))) | |
163 (list info (gnus-find-method-for-group (gnus-info-group info)) | |
164 (gnus-read-method (format "Move group %s to method: " | |
165 (gnus-info-group info)))))) | |
166 (save-excursion | |
167 (gnus-move-group-to-server info from-server to-server) | |
168 ;; We have to update the group info to point use the right server. | |
169 (gnus-info-set-method info to-server t) | |
170 ;; We also have to change the name of the group and stuff. | |
171 (let* ((group (gnus-info-group info)) | |
172 (new-name (gnus-group-prefixed-name | |
173 (gnus-group-real-name group) to-server))) | |
174 (gnus-info-set-group info new-name) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
175 (gnus-sethash new-name (gnus-group-entry group) gnus-newsrc-hashtb) |
17493 | 176 (gnus-sethash group nil gnus-newsrc-hashtb)))) |
177 | |
178 (provide 'gnus-move) | |
179 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
180 ;; arch-tag: 503742b8-7d66-4d79-bb31-4a698070707b |
17493 | 181 ;;; gnus-move.el ends here |