| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 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 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 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 |
|
|---|
| 49 |
(let ((gnus-activate-level 0) |
|---|
| 50 |
(mail-sources nil) |
|---|
| 51 |
(nnmail-spool-file nil)) |
|---|
| 52 |
(gnus)) |
|---|
| 53 |
|
|---|
| 54 |
(save-excursion |
|---|
| 55 |
|
|---|
| 56 |
(let ((newsrc gnus-newsrc-alist) |
|---|
| 57 |
(nntp-nov-gap nil) |
|---|
| 58 |
info) |
|---|
| 59 |
(while (setq info (pop newsrc)) |
|---|
| 60 |
(when (gnus-group-native-p (gnus-info-group info)) |
|---|
| 61 |
(gnus-move-group-to-server info from-server to-server)))))) |
|---|
| 62 |
|
|---|
| 63 |
(defun gnus-move-group-to-server (info from-server to-server) |
|---|
| 64 |
"Move group INFO from FROM-SERVER to TO-SERVER." |
|---|
| 65 |
(let ((group (gnus-info-group info)) |
|---|
| 66 |
to-active hashtb type mark marks |
|---|
| 67 |
to-article to-reads to-marks article |
|---|
| 68 |
act-articles) |
|---|
| 69 |
(gnus-message 7 "Translating %s..." group) |
|---|
| 70 |
(when (gnus-request-group group nil to-server) |
|---|
| 71 |
(setq to-active (gnus-parse-active) |
|---|
| 72 |
hashtb (gnus-make-hashtable 1024) |
|---|
| 73 |
act-articles (gnus-uncompress-range to-active)) |
|---|
| 74 |
|
|---|
| 75 |
(when (and to-active |
|---|
| 76 |
act-articles |
|---|
| 77 |
(setq type (gnus-retrieve-headers |
|---|
| 78 |
act-articles |
|---|
| 79 |
group to-server))) |
|---|
| 80 |
|
|---|
| 81 |
(when (eq type 'headers) |
|---|
| 82 |
(nnvirtual-convert-headers)) |
|---|
| 83 |
|
|---|
| 84 |
(set-buffer nntp-server-buffer) |
|---|
| 85 |
(goto-char (point-min)) |
|---|
| 86 |
(while (looking-at |
|---|
| 87 |
"^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t") |
|---|
| 88 |
(gnus-sethash |
|---|
| 89 |
(buffer-substring (match-beginning 1) (match-end 1)) |
|---|
| 90 |
(read (current-buffer)) |
|---|
| 91 |
hashtb) |
|---|
| 92 |
(forward-line 1)) |
|---|
| 93 |
|
|---|
| 94 |
(when (and (gnus-request-group group nil from-server) |
|---|
| 95 |
(gnus-active group) |
|---|
| 96 |
(gnus-uncompress-range |
|---|
| 97 |
(gnus-active group)) |
|---|
| 98 |
(setq type (gnus-retrieve-headers |
|---|
| 99 |
(gnus-uncompress-range |
|---|
| 100 |
(gnus-active group)) |
|---|
| 101 |
group from-server))) |
|---|
| 102 |
|
|---|
| 103 |
(let ((mark-lists (gnus-info-marks info)) |
|---|
| 104 |
ms type m) |
|---|
| 105 |
(while mark-lists |
|---|
| 106 |
(setq type (caar mark-lists) |
|---|
| 107 |
ms (gnus-uncompress-range (cdr (pop mark-lists)))) |
|---|
| 108 |
(while ms |
|---|
| 109 |
(if (setq m (assq (car ms) marks)) |
|---|
| 110 |
(setcdr m (cons type (cdr m))) |
|---|
| 111 |
(push (list (car ms) type) marks)) |
|---|
| 112 |
(pop ms)))) |
|---|
| 113 |
|
|---|
| 114 |
(when (eq type 'headers) |
|---|
| 115 |
(nnvirtual-convert-headers)) |
|---|
| 116 |
|
|---|
| 117 |
(set-buffer nntp-server-buffer) |
|---|
| 118 |
(goto-char (point-min)) |
|---|
| 119 |
(while (looking-at |
|---|
| 120 |
"^[0-9]+\t[^\t]*\t[^\t]*\t[^\t]*\t\\([^\t]*\\)\t") |
|---|
| 121 |
(when (setq to-article |
|---|
| 122 |
(gnus-gethash |
|---|
| 123 |
(buffer-substring (match-beginning 1) (match-end 1)) |
|---|
| 124 |
hashtb)) |
|---|
| 125 |
|
|---|
| 126 |
(push to-article to-reads) |
|---|
| 127 |
|
|---|
| 128 |
(when (setq mark (assq (read (current-buffer)) marks)) |
|---|
| 129 |
(setq marks (delq mark marks)) |
|---|
| 130 |
(setcar mark to-article) |
|---|
| 131 |
(push mark to-marks)) |
|---|
| 132 |
(forward-line 1))) |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
(setq to-reads |
|---|
| 137 |
(gnus-range-add |
|---|
| 138 |
(gnus-compress-sequence |
|---|
| 139 |
(and (setq to-reads (delq nil to-reads)) |
|---|
| 140 |
(sort to-reads '<)) |
|---|
| 141 |
t) |
|---|
| 142 |
(cons 1 (1- (car to-active))))) |
|---|
| 143 |
(gnus-info-set-read info to-reads) |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
(let ((mlists gnus-article-mark-lists) |
|---|
| 148 |
lists ms a) |
|---|
| 149 |
(while mlists |
|---|
| 150 |
(push (list (cdr (pop mlists))) lists)) |
|---|
| 151 |
(while (setq ms (pop marks)) |
|---|
| 152 |
(setq article (pop ms)) |
|---|
| 153 |
(while ms |
|---|
| 154 |
(setcdr (setq a (assq (pop ms) lists)) |
|---|
| 155 |
(cons article (cdr a))))) |
|---|
| 156 |
(setq a lists) |
|---|
| 157 |
(while a |
|---|
| 158 |
(setcdr (car a) (gnus-compress-sequence |
|---|
| 159 |
(and (cdar a) (sort (cdar a) '<)))) |
|---|
| 160 |
(pop a)) |
|---|
| 161 |
(gnus-info-set-marks info lists t))))) |
|---|
| 162 |
(gnus-message 7 "Translating %s...done" group))) |
|---|
| 163 |
|
|---|
| 164 |
(defun gnus-group-move-group-to-server (info from-server to-server) |
|---|
| 165 |
"Move the group on the current line from FROM-SERVER to TO-SERVER." |
|---|
| 166 |
(interactive |
|---|
| 167 |
(let ((info (gnus-get-info (gnus-group-group-name)))) |
|---|
| 168 |
(list info (gnus-find-method-for-group (gnus-info-group info)) |
|---|
| 169 |
(gnus-read-method (format "Move group %s to method: " |
|---|
| 170 |
(gnus-info-group info)))))) |
|---|
| 171 |
(save-excursion |
|---|
| 172 |
(gnus-move-group-to-server info from-server to-server) |
|---|
| 173 |
|
|---|
| 174 |
(gnus-info-set-method info to-server t) |
|---|
| 175 |
|
|---|
| 176 |
(let* ((group (gnus-info-group info)) |
|---|
| 177 |
(new-name (gnus-group-prefixed-name |
|---|
| 178 |
(gnus-group-real-name group) to-server))) |
|---|
| 179 |
(gnus-info-set-group info new-name) |
|---|
| 180 |
(gnus-sethash new-name (gnus-gethash group gnus-newsrc-hashtb) |
|---|
| 181 |
gnus-newsrc-hashtb) |
|---|
| 182 |
(gnus-sethash group nil gnus-newsrc-hashtb)))) |
|---|
| 183 |
|
|---|
| 184 |
(provide 'gnus-move) |
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|