Mercurial > emacs
annotate lisp/gnus/gnus-srvr.el @ 41015:987844bd98c9
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 13 Nov 2001 16:39:40 +0000 |
parents | 06ab5586085a |
children | 0d8b17d428b5 |
rev | line source |
---|---|
17493 | 1 ;;; gnus-srvr.el --- virtual server support for Gnus |
38384
2bdf0118b0a8
(gnus-browse-make-menu-bar): Changed one of the
Gerd Moellmann <gerd@gnu.org>
parents:
31716
diff
changeset
|
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 |
31716
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 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'gnus-spec) | |
33 (require 'gnus-group) | |
34 (require 'gnus-int) | |
35 (require 'gnus-range) | |
36 | |
37 (defvar gnus-server-mode-hook nil | |
38 "Hook run in `gnus-server-mode' buffers.") | |
39 | |
40 (defconst gnus-server-line-format " {%(%h:%w%)} %s\n" | |
41 "Format of server lines. | |
42 It works along the same lines as a normal formatting string, | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
43 with some simple extensions. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
44 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
45 The following specs are understood: |
17493 | 46 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
47 %h backend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
48 %n name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
49 %w address |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
50 %s status") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
51 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
52 (defvar gnus-server-mode-line-format "Gnus: %%b" |
17493 | 53 "The format specification for the server mode line.") |
54 | |
55 (defvar gnus-server-exit-hook nil | |
56 "*Hook run when exiting the server buffer.") | |
57 | |
58 ;;; Internal variables. | |
59 | |
60 (defvar gnus-inserted-opened-servers nil) | |
61 | |
62 (defvar gnus-server-line-format-alist | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
63 `((?h gnus-tmp-how ?s) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
64 (?n gnus-tmp-name ?s) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
65 (?w gnus-tmp-where ?s) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
66 (?s gnus-tmp-status ?s))) |
17493 | 67 |
68 (defvar gnus-server-mode-line-format-alist | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
69 `((?S gnus-tmp-news-server ?s) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
70 (?M gnus-tmp-news-method ?s) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
71 (?u gnus-tmp-user-defined ?s))) |
17493 | 72 |
73 (defvar gnus-server-line-format-spec nil) | |
74 (defvar gnus-server-mode-line-format-spec nil) | |
75 (defvar gnus-server-killed-servers nil) | |
76 | |
77 (defvar gnus-server-mode-map) | |
78 | |
79 (defvar gnus-server-menu-hook nil | |
80 "*Hook run after the creation of the server mode menu.") | |
81 | |
82 (defun gnus-server-make-menu-bar () | |
83 (gnus-turn-off-edit-menu 'server) | |
84 (unless (boundp 'gnus-server-server-menu) | |
85 (easy-menu-define | |
86 gnus-server-server-menu gnus-server-mode-map "" | |
87 '("Server" | |
88 ["Add" gnus-server-add-server t] | |
89 ["Browse" gnus-server-read-server t] | |
90 ["Scan" gnus-server-scan-server t] | |
91 ["List" gnus-server-list-servers t] | |
92 ["Kill" gnus-server-kill-server t] | |
93 ["Yank" gnus-server-yank-server t] | |
94 ["Copy" gnus-server-copy-server t] | |
95 ["Edit" gnus-server-edit-server t] | |
96 ["Regenerate" gnus-server-regenerate-server t] | |
97 ["Exit" gnus-server-exit t])) | |
98 | |
99 (easy-menu-define | |
100 gnus-server-connections-menu gnus-server-mode-map "" | |
101 '("Connections" | |
102 ["Open" gnus-server-open-server t] | |
103 ["Close" gnus-server-close-server t] | |
104 ["Deny" gnus-server-deny-server t] | |
105 "---" | |
106 ["Open All" gnus-server-open-all-servers t] | |
107 ["Close All" gnus-server-close-all-servers t] | |
108 ["Reset All" gnus-server-remove-denials t])) | |
109 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
110 (gnus-run-hooks 'gnus-server-menu-hook))) |
17493 | 111 |
112 (defvar gnus-server-mode-map nil) | |
113 (put 'gnus-server-mode 'mode-class 'special) | |
114 | |
115 (unless gnus-server-mode-map | |
116 (setq gnus-server-mode-map (make-sparse-keymap)) | |
117 (suppress-keymap gnus-server-mode-map) | |
118 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
119 (gnus-define-keys gnus-server-mode-map |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
120 " " gnus-server-read-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
121 "\r" gnus-server-read-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
122 gnus-mouse-2 gnus-server-pick-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
123 "q" gnus-server-exit |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
124 "l" gnus-server-list-servers |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
125 "k" gnus-server-kill-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
126 "y" gnus-server-yank-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
127 "c" gnus-server-copy-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
128 "a" gnus-server-add-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
129 "e" gnus-server-edit-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
130 "s" gnus-server-scan-server |
17493 | 131 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
132 "O" gnus-server-open-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
133 "\M-o" gnus-server-open-all-servers |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
134 "C" gnus-server-close-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
135 "\M-c" gnus-server-close-all-servers |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
136 "D" gnus-server-deny-server |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
137 "R" gnus-server-remove-denials |
17493 | 138 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
139 "n" next-line |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
140 "p" previous-line |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
141 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
142 "g" gnus-server-regenerate-server |
17493 | 143 |
144 "\C-c\C-i" gnus-info-find-node | |
145 "\C-c\C-b" gnus-bug)) | |
146 | |
147 (defun gnus-server-mode () | |
148 "Major mode for listing and editing servers. | |
149 | |
150 All normal editing commands are switched off. | |
151 \\<gnus-server-mode-map> | |
152 For more in-depth information on this mode, read the manual | |
39312
8da06f1bcda8
(gnus-server-mode): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents:
38413
diff
changeset
|
153 \(`\\[gnus-info-find-node]'). |
17493 | 154 |
155 The following commands are available: | |
156 | |
157 \\{gnus-server-mode-map}" | |
158 (interactive) | |
159 (when (gnus-visual-p 'server-menu 'menu) | |
160 (gnus-server-make-menu-bar)) | |
161 (kill-all-local-variables) | |
162 (gnus-simplify-mode-line) | |
163 (setq major-mode 'gnus-server-mode) | |
164 (setq mode-name "Server") | |
165 (gnus-set-default-directory) | |
166 (setq mode-line-process nil) | |
167 (use-local-map gnus-server-mode-map) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
168 (buffer-disable-undo) |
17493 | 169 (setq truncate-lines t) |
170 (setq buffer-read-only t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
171 (gnus-run-hooks 'gnus-server-mode-hook)) |
17493 | 172 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
173 (defun gnus-server-insert-server-line (gnus-tmp-name method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
174 (let* ((gnus-tmp-how (car method)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
175 (gnus-tmp-where (nth 1 method)) |
17493 | 176 (elem (assoc method gnus-opened-servers)) |
39322
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
177 (gnus-tmp-status |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
178 (if (eq (nth 1 elem) 'denied) |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
179 "(denied)" |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
180 (condition-case nil |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
181 (if (or (gnus-server-opened method) |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
182 (eq (nth 1 elem) 'ok)) |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
183 "(opened)" |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
184 "(closed)") |
06ab5586085a
(gnus-server-insert-server-line): Don't let an error querying a backend
Miles Bader <miles@gnu.org>
parents:
39312
diff
changeset
|
185 ((error) "(error)"))))) |
17493 | 186 (beginning-of-line) |
187 (gnus-add-text-properties | |
188 (point) | |
189 (prog1 (1+ (point)) | |
190 ;; Insert the text. | |
191 (eval gnus-server-line-format-spec)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
192 (list 'gnus-server (intern gnus-tmp-name))))) |
17493 | 193 |
194 (defun gnus-enter-server-buffer () | |
195 "Set up the server buffer." | |
196 (gnus-server-setup-buffer) | |
197 (gnus-configure-windows 'server) | |
198 (gnus-server-prepare)) | |
199 | |
200 (defun gnus-server-setup-buffer () | |
201 "Initialize the server buffer." | |
202 (unless (get-buffer gnus-server-buffer) | |
203 (save-excursion | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
204 (set-buffer (gnus-get-buffer-create gnus-server-buffer)) |
17493 | 205 (gnus-server-mode) |
206 (when gnus-carpal | |
207 (gnus-carpal-setup-buffer 'server))))) | |
208 | |
209 (defun gnus-server-prepare () | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
210 (gnus-set-format 'server-mode) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
211 (gnus-set-format 'server t) |
17493 | 212 (let ((alist gnus-server-alist) |
213 (buffer-read-only nil) | |
214 (opened gnus-opened-servers) | |
215 done server op-ser) | |
216 (erase-buffer) | |
217 (setq gnus-inserted-opened-servers nil) | |
218 ;; First we do the real list of servers. | |
219 (while alist | |
220 (unless (member (cdar alist) done) | |
221 (push (cdar alist) done) | |
222 (cdr (setq server (pop alist))) | |
223 (when (and server (car server) (cdr server)) | |
224 (gnus-server-insert-server-line (car server) (cdr server)))) | |
225 (when (member (cdar alist) done) | |
226 (pop alist))) | |
227 ;; Then we insert the list of servers that have been opened in | |
228 ;; this session. | |
229 (while opened | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
230 (when (and (not (member (caar opened) done)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
231 ;; Just ignore ephemeral servers. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
232 (not (member (caar opened) gnus-ephemeral-servers))) |
17493 | 233 (push (caar opened) done) |
234 (gnus-server-insert-server-line | |
235 (setq op-ser (format "%s:%s" (caaar opened) (nth 1 (caar opened)))) | |
236 (caar opened)) | |
237 (push (list op-ser (caar opened)) gnus-inserted-opened-servers)) | |
238 (setq opened (cdr opened)))) | |
239 (goto-char (point-min)) | |
240 (gnus-server-position-point)) | |
241 | |
242 (defun gnus-server-server-name () | |
243 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server))) | |
244 (and server (symbol-name server)))) | |
245 | |
246 (defalias 'gnus-server-position-point 'gnus-goto-colon) | |
247 | |
248 (defconst gnus-server-edit-buffer "*Gnus edit server*") | |
249 | |
250 (defun gnus-server-update-server (server) | |
251 (save-excursion | |
252 (set-buffer gnus-server-buffer) | |
253 (let* ((buffer-read-only nil) | |
254 (entry (assoc server gnus-server-alist)) | |
255 (oentry (assoc (gnus-server-to-method server) | |
256 gnus-opened-servers))) | |
257 (when entry | |
258 (gnus-dribble-enter | |
259 (concat "(gnus-server-set-info \"" server "\" '" | |
260 (prin1-to-string (cdr entry)) ")\n"))) | |
261 (when (or entry oentry) | |
262 ;; Buffer may be narrowed. | |
263 (save-restriction | |
264 (widen) | |
265 (when (gnus-server-goto-server server) | |
266 (gnus-delete-line)) | |
267 (if entry | |
268 (gnus-server-insert-server-line (car entry) (cdr entry)) | |
269 (gnus-server-insert-server-line | |
270 (format "%s:%s" (caar oentry) (nth 1 (car oentry))) | |
271 (car oentry))) | |
272 (gnus-server-position-point)))))) | |
273 | |
274 (defun gnus-server-set-info (server info) | |
275 ;; Enter a select method into the virtual server alist. | |
276 (when (and server info) | |
277 (gnus-dribble-enter | |
278 (concat "(gnus-server-set-info \"" server "\" '" | |
279 (prin1-to-string info) ")")) | |
280 (let* ((server (nth 1 info)) | |
281 (entry (assoc server gnus-server-alist))) | |
282 (if entry (setcdr entry info) | |
283 (setq gnus-server-alist | |
284 (nconc gnus-server-alist (list (cons server info)))))))) | |
285 | |
286 ;;; Interactive server functions. | |
287 | |
288 (defun gnus-server-kill-server (server) | |
289 "Kill the server on the current line." | |
290 (interactive (list (gnus-server-server-name))) | |
291 (unless (gnus-server-goto-server server) | |
292 (if server (error "No such server: %s" server) | |
293 (error "No server on the current line"))) | |
294 (unless (assoc server gnus-server-alist) | |
295 (error "Read-only server %s" server)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
296 (gnus-dribble-touch) |
17493 | 297 (let ((buffer-read-only nil)) |
298 (gnus-delete-line)) | |
299 (push (assoc server gnus-server-alist) gnus-server-killed-servers) | |
300 (setq gnus-server-alist (delq (car gnus-server-killed-servers) | |
301 gnus-server-alist)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
302 (let ((groups (gnus-groups-from-server server))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
303 (when (and groups |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
304 (gnus-yes-or-no-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
305 (format "Kill all %s groups from this server? " |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
306 (length groups)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
307 (dolist (group groups) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
308 (setq gnus-newsrc-alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
309 (delq (assoc group gnus-newsrc-alist) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
310 gnus-newsrc-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
311 (when gnus-group-change-level-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
312 (funcall gnus-group-change-level-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
313 group gnus-level-killed 3))))) |
17493 | 314 (gnus-server-position-point)) |
315 | |
316 (defun gnus-server-yank-server () | |
317 "Yank the previously killed server." | |
318 (interactive) | |
319 (unless gnus-server-killed-servers | |
320 (error "No killed servers to be yanked")) | |
321 (let ((alist gnus-server-alist) | |
322 (server (gnus-server-server-name)) | |
323 (killed (car gnus-server-killed-servers))) | |
324 (if (not server) | |
325 (setq gnus-server-alist (nconc gnus-server-alist (list killed))) | |
326 (if (string= server (caar gnus-server-alist)) | |
327 (push killed gnus-server-alist) | |
328 (while (and (cdr alist) | |
329 (not (string= server (caadr alist)))) | |
330 (setq alist (cdr alist))) | |
331 (if alist | |
332 (setcdr alist (cons killed (cdr alist))) | |
333 (setq gnus-server-alist (list killed))))) | |
334 (gnus-server-update-server (car killed)) | |
335 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers)) | |
336 (gnus-server-position-point))) | |
337 | |
338 (defun gnus-server-exit () | |
339 "Return to the group buffer." | |
340 (interactive) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
341 (gnus-run-hooks 'gnus-server-exit-hook) |
17493 | 342 (kill-buffer (current-buffer)) |
343 (gnus-configure-windows 'group t)) | |
344 | |
345 (defun gnus-server-list-servers () | |
346 "List all available servers." | |
347 (interactive) | |
348 (let ((cur (gnus-server-server-name))) | |
349 (gnus-server-prepare) | |
350 (if cur (gnus-server-goto-server cur) | |
351 (goto-char (point-max)) | |
352 (forward-line -1)) | |
353 (gnus-server-position-point))) | |
354 | |
355 (defun gnus-server-set-status (method status) | |
356 "Make METHOD have STATUS." | |
357 (let ((entry (assoc method gnus-opened-servers))) | |
358 (if entry | |
359 (setcar (cdr entry) status) | |
360 (push (list method status) gnus-opened-servers)))) | |
361 | |
362 (defun gnus-opened-servers-remove (method) | |
363 "Remove METHOD from the list of opened servers." | |
364 (setq gnus-opened-servers (delq (assoc method gnus-opened-servers) | |
365 gnus-opened-servers))) | |
366 | |
367 (defun gnus-server-open-server (server) | |
368 "Force an open of SERVER." | |
369 (interactive (list (gnus-server-server-name))) | |
370 (let ((method (gnus-server-to-method server))) | |
371 (unless method | |
372 (error "No such server: %s" server)) | |
373 (gnus-server-set-status method 'ok) | |
374 (prog1 | |
375 (or (gnus-open-server method) | |
376 (progn (message "Couldn't open %s" server) nil)) | |
377 (gnus-server-update-server server) | |
378 (gnus-server-position-point)))) | |
379 | |
380 (defun gnus-server-open-all-servers () | |
381 "Open all servers." | |
382 (interactive) | |
383 (let ((servers gnus-inserted-opened-servers)) | |
384 (while servers | |
385 (gnus-server-open-server (car (pop servers)))))) | |
386 | |
387 (defun gnus-server-close-server (server) | |
388 "Close SERVER." | |
389 (interactive (list (gnus-server-server-name))) | |
390 (let ((method (gnus-server-to-method server))) | |
391 (unless method | |
392 (error "No such server: %s" server)) | |
393 (gnus-server-set-status method 'closed) | |
394 (prog1 | |
395 (gnus-close-server method) | |
396 (gnus-server-update-server server) | |
397 (gnus-server-position-point)))) | |
398 | |
399 (defun gnus-server-close-all-servers () | |
400 "Close all servers." | |
401 (interactive) | |
402 (let ((servers gnus-inserted-opened-servers)) | |
403 (while servers | |
404 (gnus-server-close-server (car (pop servers)))))) | |
405 | |
406 (defun gnus-server-deny-server (server) | |
407 "Make sure SERVER will never be attempted opened." | |
408 (interactive (list (gnus-server-server-name))) | |
409 (let ((method (gnus-server-to-method server))) | |
410 (unless method | |
411 (error "No such server: %s" server)) | |
412 (gnus-server-set-status method 'denied)) | |
413 (gnus-server-update-server server) | |
414 (gnus-server-position-point) | |
415 t) | |
416 | |
417 (defun gnus-server-remove-denials () | |
418 "Make all denied servers into closed servers." | |
419 (interactive) | |
420 (let ((servers gnus-opened-servers)) | |
421 (while servers | |
422 (when (eq (nth 1 (car servers)) 'denied) | |
423 (setcar (nthcdr 1 (car servers)) 'closed)) | |
424 (setq servers (cdr servers)))) | |
425 (gnus-server-list-servers)) | |
426 | |
427 (defun gnus-server-copy-server (from to) | |
428 (interactive | |
429 (list | |
430 (or (gnus-server-server-name) | |
431 (error "No server on the current line")) | |
432 (read-string "Copy to: "))) | |
433 (unless from | |
434 (error "No server on current line")) | |
435 (unless (and to (not (string= to ""))) | |
436 (error "No name to copy to")) | |
437 (when (assoc to gnus-server-alist) | |
438 (error "%s already exists" to)) | |
439 (unless (gnus-server-to-method from) | |
440 (error "%s: no such server" from)) | |
441 (let ((to-entry (cons from (gnus-copy-sequence | |
442 (gnus-server-to-method from))))) | |
443 (setcar to-entry to) | |
444 (setcar (nthcdr 2 to-entry) to) | |
445 (push to-entry gnus-server-killed-servers) | |
446 (gnus-server-yank-server))) | |
447 | |
448 (defun gnus-server-add-server (how where) | |
449 (interactive | |
450 (list (intern (completing-read "Server method: " | |
451 gnus-valid-select-methods nil t)) | |
452 (read-string "Server name: "))) | |
453 (when (assq where gnus-server-alist) | |
454 (error "Server with that name already defined")) | |
455 (push (list where how where) gnus-server-killed-servers) | |
456 (gnus-server-yank-server)) | |
457 | |
458 (defun gnus-server-goto-server (server) | |
459 "Jump to a server line." | |
460 (interactive | |
461 (list (completing-read "Goto server: " gnus-server-alist nil t))) | |
462 (let ((to (text-property-any (point-min) (point-max) | |
463 'gnus-server (intern server)))) | |
464 (when to | |
465 (goto-char to) | |
466 (gnus-server-position-point)))) | |
467 | |
468 (defun gnus-server-edit-server (server) | |
469 "Edit the server on the current line." | |
470 (interactive (list (gnus-server-server-name))) | |
471 (unless server | |
472 (error "No server on current line")) | |
473 (unless (assoc server gnus-server-alist) | |
474 (error "This server can't be edited")) | |
475 (let ((info (cdr (assoc server gnus-server-alist)))) | |
476 (gnus-close-server info) | |
477 (gnus-edit-form | |
478 info "Editing the server." | |
479 `(lambda (form) | |
480 (gnus-server-set-info ,server form) | |
481 (gnus-server-list-servers) | |
482 (gnus-server-position-point))))) | |
483 | |
484 (defun gnus-server-scan-server (server) | |
485 "Request a scan from the current server." | |
486 (interactive (list (gnus-server-server-name))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
487 (let ((method (gnus-server-to-method server))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
488 (if (not (gnus-get-function method 'request-scan)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
489 (error "Server %s can't scan" (car method)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
490 (gnus-message 3 "Scanning %s..." server) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
491 (gnus-request-scan nil method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
492 (gnus-message 3 "Scanning %s...done" server)))) |
17493 | 493 |
494 (defun gnus-server-read-server (server) | |
495 "Browse a server." | |
496 (interactive (list (gnus-server-server-name))) | |
497 (let ((buf (current-buffer))) | |
498 (prog1 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
499 (gnus-browse-foreign-server server buf) |
17493 | 500 (save-excursion |
501 (set-buffer buf) | |
502 (gnus-server-update-server (gnus-server-server-name)) | |
503 (gnus-server-position-point))))) | |
504 | |
505 (defun gnus-server-pick-server (e) | |
506 (interactive "e") | |
507 (mouse-set-point e) | |
508 (gnus-server-read-server (gnus-server-server-name))) | |
509 | |
510 | |
511 ;;; | |
512 ;;; Browse Server Mode | |
513 ;;; | |
514 | |
515 (defvar gnus-browse-menu-hook nil | |
516 "*Hook run after the creation of the browse mode menu.") | |
517 | |
518 (defvar gnus-browse-mode-hook nil) | |
519 (defvar gnus-browse-mode-map nil) | |
520 (put 'gnus-browse-mode 'mode-class 'special) | |
521 | |
522 (unless gnus-browse-mode-map | |
523 (setq gnus-browse-mode-map (make-keymap)) | |
524 (suppress-keymap gnus-browse-mode-map) | |
525 | |
526 (gnus-define-keys | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
527 gnus-browse-mode-map |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
528 " " gnus-browse-read-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
529 "=" gnus-browse-select-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
530 "n" gnus-browse-next-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
531 "p" gnus-browse-prev-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
532 "\177" gnus-browse-prev-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
533 [delete] gnus-browse-prev-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
534 "N" gnus-browse-next-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
535 "P" gnus-browse-prev-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
536 "\M-n" gnus-browse-next-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
537 "\M-p" gnus-browse-prev-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
538 "\r" gnus-browse-select-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
539 "u" gnus-browse-unsubscribe-current-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
540 "l" gnus-browse-exit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
541 "L" gnus-browse-exit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
542 "q" gnus-browse-exit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
543 "Q" gnus-browse-exit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
544 "\C-c\C-c" gnus-browse-exit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
545 "?" gnus-browse-describe-briefly |
17493 | 546 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
547 "\C-c\C-i" gnus-info-find-node |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
548 "\C-c\C-b" gnus-bug)) |
17493 | 549 |
550 (defun gnus-browse-make-menu-bar () | |
551 (gnus-turn-off-edit-menu 'browse) | |
552 (unless (boundp 'gnus-browse-menu) | |
553 (easy-menu-define | |
554 gnus-browse-menu gnus-browse-mode-map "" | |
555 '("Browse" | |
556 ["Subscribe" gnus-browse-unsubscribe-current-group t] | |
557 ["Read" gnus-browse-read-group t] | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
558 ["Select" gnus-browse-select-group t] |
17493 | 559 ["Next" gnus-browse-next-group t] |
38384
2bdf0118b0a8
(gnus-browse-make-menu-bar): Changed one of the
Gerd Moellmann <gerd@gnu.org>
parents:
31716
diff
changeset
|
560 ["Prev" gnus-browse-prev-group t] |
17493 | 561 ["Exit" gnus-browse-exit t])) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
562 (gnus-run-hooks 'gnus-browse-menu-hook))) |
17493 | 563 |
564 (defvar gnus-browse-current-method nil) | |
565 (defvar gnus-browse-return-buffer nil) | |
566 | |
567 (defvar gnus-browse-buffer "*Gnus Browse Server*") | |
568 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
569 (defun gnus-browse-foreign-server (server &optional return-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
570 "Browse the server SERVER." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
571 (setq gnus-browse-current-method (gnus-server-to-method server)) |
17493 | 572 (setq gnus-browse-return-buffer return-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
573 (let* ((method gnus-browse-current-method) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
574 (gnus-select-method method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
575 groups group) |
17493 | 576 (gnus-message 5 "Connecting to %s..." (nth 1 method)) |
577 (cond | |
578 ((not (gnus-check-server method)) | |
579 (gnus-message | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
580 1 "Unable to contact server %s: %s" (nth 1 method) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
581 (gnus-status-message method)) |
17493 | 582 nil) |
583 ((not | |
584 (prog2 | |
585 (gnus-message 6 "Reading active file...") | |
586 (gnus-request-list method) | |
587 (gnus-message 6 "Reading active file...done"))) | |
588 (gnus-message | |
589 1 "Couldn't request list: %s" (gnus-status-message method)) | |
590 nil) | |
591 (t | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
592 (gnus-get-buffer-create gnus-browse-buffer) |
17493 | 593 (when gnus-carpal |
594 (gnus-carpal-setup-buffer 'browse)) | |
595 (gnus-configure-windows 'browse) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
596 (buffer-disable-undo) |
17493 | 597 (let ((buffer-read-only nil)) |
598 (erase-buffer)) | |
599 (gnus-browse-mode) | |
600 (setq mode-line-buffer-identification | |
601 (list | |
602 (format | |
603 "Gnus: %%b {%s:%s}" (car method) (cadr method)))) | |
604 (save-excursion | |
605 (set-buffer nntp-server-buffer) | |
606 (let ((cur (current-buffer))) | |
607 (goto-char (point-min)) | |
608 (unless (string= gnus-ignored-newsgroups "") | |
609 (delete-matching-lines gnus-ignored-newsgroups)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
610 (while (not (eobp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
611 (ignore-errors |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
612 (push (cons |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
613 (if (eq (char-after) ?\") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
614 (read cur) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
615 (let ((p (point)) (name "")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
616 (skip-chars-forward "^ \t\\\\") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
617 (setq name (buffer-substring p (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
618 (while (eq (char-after) ?\\) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
619 (setq p (1+ (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
620 (forward-char 2) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
621 (skip-chars-forward "^ \t\\\\") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
622 (setq name (concat name (buffer-substring |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
623 p (point))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
624 name)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
625 (max 0 (- (1+ (read cur)) (read cur)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
626 groups)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
627 (forward-line)))) |
17493 | 628 (setq groups (sort groups |
629 (lambda (l1 l2) | |
630 (string< (car l1) (car l2))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
631 (let ((buffer-read-only nil) charset) |
17493 | 632 (while groups |
633 (setq group (car groups)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
634 (setq charset (gnus-group-name-charset method group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
635 (gnus-add-text-properties |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
636 (point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
637 (prog1 (1+ (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
638 (insert |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
639 (format "K%7d: %s\n" (cdr group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
640 (gnus-group-name-decode (car group) charset)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
641 (list 'gnus-group (car group))) |
17493 | 642 (setq groups (cdr groups)))) |
643 (switch-to-buffer (current-buffer)) | |
644 (goto-char (point-min)) | |
645 (gnus-group-position-point) | |
646 (gnus-message 5 "Connecting to %s...done" (nth 1 method)) | |
647 t)))) | |
648 | |
649 (defun gnus-browse-mode () | |
650 "Major mode for browsing a foreign server. | |
651 | |
652 All normal editing commands are switched off. | |
653 | |
654 \\<gnus-browse-mode-map> | |
655 The only things you can do in this buffer is | |
656 | |
657 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group. | |
658 The group will be inserted into the group buffer upon exit from this | |
659 buffer. | |
660 | |
661 2) `\\[gnus-browse-read-group]' to read a group ephemerally. | |
662 | |
663 3) `\\[gnus-browse-exit]' to return to the group buffer." | |
664 (interactive) | |
665 (kill-all-local-variables) | |
666 (when (gnus-visual-p 'browse-menu 'menu) | |
667 (gnus-browse-make-menu-bar)) | |
668 (gnus-simplify-mode-line) | |
669 (setq major-mode 'gnus-browse-mode) | |
670 (setq mode-name "Browse Server") | |
671 (setq mode-line-process nil) | |
672 (use-local-map gnus-browse-mode-map) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
673 (buffer-disable-undo) |
17493 | 674 (setq truncate-lines t) |
675 (gnus-set-default-directory) | |
676 (setq buffer-read-only t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
677 (gnus-run-hooks 'gnus-browse-mode-hook)) |
17493 | 678 |
679 (defun gnus-browse-read-group (&optional no-article) | |
680 "Enter the group at the current line." | |
681 (interactive) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
682 (let ((group (gnus-browse-group-name))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
683 (if (or (not (gnus-get-info group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
684 (gnus-ephemeral-group-p group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
685 (unless (gnus-group-read-ephemeral-group |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
686 (gnus-group-real-name group) gnus-browse-current-method nil |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
687 (cons (current-buffer) 'browse)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
688 (error "Couldn't enter %s" group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
689 (unless (gnus-group-read-group nil no-article group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
690 (error "Couldn't enter %s" group))))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
691 |
17493 | 692 (defun gnus-browse-select-group () |
693 "Select the current group." | |
694 (interactive) | |
695 (gnus-browse-read-group 'no)) | |
696 | |
697 (defun gnus-browse-next-group (n) | |
698 "Go to the next group." | |
699 (interactive "p") | |
700 (prog1 | |
701 (forward-line n) | |
702 (gnus-group-position-point))) | |
703 | |
704 (defun gnus-browse-prev-group (n) | |
705 "Go to the next group." | |
706 (interactive "p") | |
707 (gnus-browse-next-group (- n))) | |
708 | |
709 (defun gnus-browse-unsubscribe-current-group (arg) | |
710 "(Un)subscribe to the next ARG groups." | |
711 (interactive "p") | |
712 (when (eobp) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
713 (error "No group at current line")) |
17493 | 714 (let ((ward (if (< arg 0) -1 1)) |
715 (arg (abs arg))) | |
716 (while (and (> arg 0) | |
717 (not (eobp)) | |
718 (gnus-browse-unsubscribe-group) | |
719 (zerop (gnus-browse-next-group ward))) | |
720 (decf arg)) | |
721 (gnus-group-position-point) | |
722 (when (/= 0 arg) | |
723 (gnus-message 7 "No more newsgroups")) | |
724 arg)) | |
725 | |
726 (defun gnus-browse-group-name () | |
727 (save-excursion | |
728 (beginning-of-line) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
729 (let ((name (get-text-property (point) 'gnus-group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
730 (when (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
731 (gnus-group-prefixed-name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
732 (or name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
733 (match-string-no-properties 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
734 gnus-browse-current-method))))) |
17493 | 735 |
736 (defun gnus-browse-unsubscribe-group () | |
737 "Toggle subscription of the current group in the browse buffer." | |
738 (let ((sub nil) | |
739 (buffer-read-only nil) | |
740 group) | |
741 (save-excursion | |
742 (beginning-of-line) | |
743 ;; If this group it killed, then we want to subscribe it. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
744 (when (eq (char-after) ?K) |
17493 | 745 (setq sub t)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
746 (setq group (gnus-browse-group-name)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
747 (when (and sub |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
748 (cadr (gnus-gethash group gnus-newsrc-hashtb))) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
749 (error "Group already subscribed")) |
17493 | 750 (delete-char 1) |
751 (if sub | |
752 (progn | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
753 ;; Make sure the group has been properly removed before we |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
754 ;; subscribe to it. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
755 (gnus-kill-ephemeral-group group) |
17493 | 756 (gnus-group-change-level |
757 (list t group gnus-level-default-subscribed | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
758 nil nil (if (gnus-server-equal |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
759 gnus-browse-current-method "native") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
760 nil |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
761 (gnus-method-simplify |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
762 gnus-browse-current-method))) |
17493 | 763 gnus-level-default-subscribed gnus-level-killed |
764 (and (car (nth 1 gnus-newsrc-alist)) | |
765 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) | |
766 gnus-newsrc-hashtb)) | |
767 t) | |
768 (insert ? )) | |
769 (gnus-group-change-level | |
770 group gnus-level-killed gnus-level-default-subscribed) | |
771 (insert ?K))) | |
772 t)) | |
773 | |
774 (defun gnus-browse-exit () | |
775 "Quit browsing and return to the group buffer." | |
776 (interactive) | |
777 (when (eq major-mode 'gnus-browse-mode) | |
778 (kill-buffer (current-buffer))) | |
779 ;; Insert the newly subscribed groups in the group buffer. | |
780 (save-excursion | |
781 (set-buffer gnus-group-buffer) | |
782 (gnus-group-list-groups nil)) | |
783 (if gnus-browse-return-buffer | |
784 (gnus-configure-windows 'server 'force) | |
785 (gnus-configure-windows 'group 'force))) | |
786 | |
787 (defun gnus-browse-describe-briefly () | |
788 "Give a one line description of the group mode commands." | |
789 (interactive) | |
790 (gnus-message 6 | |
791 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help"))) | |
792 | |
793 (defun gnus-server-regenerate-server () | |
794 "Issue a command to the server to regenerate all its data structures." | |
795 (interactive) | |
796 (let ((server (gnus-server-server-name))) | |
797 (unless server | |
798 (error "No server on the current line")) | |
799 (if (not (gnus-check-backend-function | |
800 'request-regenerate (car (gnus-server-to-method server)))) | |
801 (error "This backend doesn't support regeneration") | |
802 (gnus-message 5 "Requesting regeneration of %s..." server) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
803 (unless (gnus-open-server server) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
804 (error "Couldn't open server")) |
17493 | 805 (if (gnus-request-regenerate server) |
806 (gnus-message 5 "Requesting regeneration of %s...done" server) | |
807 (gnus-message 5 "Couldn't regenerate %s" server))))) | |
808 | |
809 (provide 'gnus-srvr) | |
810 | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
38384
diff
changeset
|
811 ;;; gnus-srvr.el ends here |