Mercurial > emacs
annotate lisp/gnus/gnus-start.el @ 22694:a2f15d33df57
(texinfo-environment-regexp): Add smalldisplay and smallformat.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 06 Jul 1998 00:07:54 +0000 |
parents | 518f3a9e5812 |
children | 39f23890e482 |
rev | line source |
---|---|
17493 | 1 ;;; gnus-start.el --- startup functions for Gnus |
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
5 ;; Keywords: news | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
28 (require 'gnus) | |
29 (require 'gnus-win) | |
30 (require 'gnus-int) | |
31 (require 'gnus-spec) | |
32 (require 'gnus-range) | |
33 (require 'gnus-util) | |
34 (require 'message) | |
19520
6496595d79b8
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
35 (eval-when-compile (require 'cl)) |
17493 | 36 |
37 (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc") | |
38 "Your `.newsrc' file. | |
39 `.newsrc-SERVER' will be used instead if that exists." | |
40 :group 'gnus-start | |
41 :type 'file) | |
42 | |
43 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus") | |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
44 "Your Gnus Emacs-Lisp startup file name. |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
45 If a file with the `.el' or `.elc' suffixes exists, it will be read instead." |
17493 | 46 :group 'gnus-start |
47 :type 'file) | |
48 | |
49 (defcustom gnus-site-init-file | |
19520
6496595d79b8
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
50 (condition-case nil |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
51 (concat (file-name-directory |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
52 (directory-file-name installation-directory)) |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
53 "site-lisp/gnus-init") |
19520
6496595d79b8
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
54 (error nil)) |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
55 "The site-wide Gnus Emacs-Lisp startup file name, or nil if none. |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
56 If a file with the `.el' or `.elc' suffixes exists, it will be read instead." |
17493 | 57 :group 'gnus-start |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
58 :type '(choice file (const nil))) |
17493 | 59 |
60 (defcustom gnus-default-subscribed-newsgroups nil | |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
61 "List of newsgroups to subscribe, when a user runs Gnus the first time. |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
62 The value should be a list of strings. |
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
63 If it is t, Gnus will not do anything special the first time it is |
17493 | 64 started; it'll just use the normal newsgroups subscription methods." |
65 :group 'gnus-start | |
19910
103cd29aea6f
(gnus-default-subscribed-newsgroups): Fix custom type. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19520
diff
changeset
|
66 :type '(choice (repeat string) (const :tag "Nothing special" t))) |
17493 | 67 |
68 (defcustom gnus-use-dribble-file t | |
69 "*Non-nil means that Gnus will use a dribble file to store user updates. | |
70 If Emacs should crash without saving the .newsrc files, complete | |
71 information can be restored from the dribble file." | |
72 :group 'gnus-dribble-file | |
73 :type 'boolean) | |
74 | |
75 (defcustom gnus-dribble-directory nil | |
76 "*The directory where dribble files will be saved. | |
77 If this variable is nil, the directory where the .newsrc files are | |
78 saved will be used." | |
79 :group 'gnus-dribble-file | |
80 :type '(choice directory (const nil))) | |
81 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
82 (defcustom gnus-check-new-newsgroups 'ask-server |
17493 | 83 "*Non-nil means that Gnus will run gnus-find-new-newsgroups at startup. |
84 This normally finds new newsgroups by comparing the active groups the | |
85 servers have already reported with those Gnus already knows, either alive | |
86 or killed. | |
87 | |
88 When any of the following are true, gnus-find-new-newsgroups will instead | |
89 ask the servers (primary, secondary, and archive servers) to list new | |
90 groups since the last time it checked: | |
91 1. This variable is `ask-server'. | |
92 2. This variable is a list of select methods (see below). | |
93 3. `gnus-read-active-file' is nil or `some'. | |
94 4. A prefix argument is given to gnus-find-new-newsgroups interactively. | |
95 | |
96 Thus, if this variable is `ask-server' or a list of select methods or | |
97 `gnus-read-active-file' is nil or `some', then the killed list is no | |
98 longer necessary, so you could safely set `gnus-save-killed-list' to nil. | |
99 | |
100 This variable can be a list of select methods which Gnus will query with | |
101 the `ask-server' method in addition to the primary, secondary, and archive | |
102 servers. | |
103 | |
104 Eg. | |
105 (setq gnus-check-new-newsgroups | |
106 '((nntp \"some.server\") (nntp \"other.server\"))) | |
107 | |
108 If this variable is nil, then you have to tell Gnus explicitly to | |
109 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups]." | |
110 :group 'gnus-start | |
111 :type '(choice (const :tag "no" nil) | |
112 (const :tag "by brute force" t) | |
113 (const :tag "ask servers" ask-server) | |
114 (repeat :menu-tag "ask additional servers" | |
115 :tag "ask additional servers" | |
116 :value ((nntp "")) | |
117 (sexp :format "%v")))) | |
118 | |
119 (defcustom gnus-check-bogus-newsgroups nil | |
120 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup. | |
121 If this variable is nil, then you have to tell Gnus explicitly to | |
122 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups]." | |
123 :group 'gnus-start-server | |
124 :type 'boolean) | |
125 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
126 (defcustom gnus-read-active-file 'some |
17493 | 127 "*Non-nil means that Gnus will read the entire active file at startup. |
128 If this variable is nil, Gnus will only know about the groups in your | |
129 `.newsrc' file. | |
130 | |
131 If this variable is `some', Gnus will try to only read the relevant | |
132 parts of the active file from the server. Not all servers support | |
133 this, and it might be quite slow with other servers, but this should | |
134 generally be faster than both the t and nil value. | |
135 | |
136 If you set this variable to nil or `some', you probably still want to | |
137 be told about new newsgroups that arrive. To do that, set | |
138 `gnus-check-new-newsgroups' to `ask-server'. This may not work | |
139 properly with all servers." | |
140 :group 'gnus-start-server | |
141 :type '(choice (const nil) | |
142 (const some) | |
143 (const t))) | |
144 | |
145 (defcustom gnus-level-subscribed 5 | |
146 "*Groups with levels less than or equal to this variable are subscribed." | |
147 :group 'gnus-group-levels | |
148 :type 'integer) | |
149 | |
150 (defcustom gnus-level-unsubscribed 7 | |
151 "*Groups with levels less than or equal to this variable are unsubscribed. | |
152 Groups with levels less than `gnus-level-subscribed', which should be | |
153 less than this variable, are subscribed." | |
154 :group 'gnus-group-levels | |
155 :type 'integer) | |
156 | |
157 (defcustom gnus-level-zombie 8 | |
158 "*Groups with this level are zombie groups." | |
159 :group 'gnus-group-levels | |
160 :type 'integer) | |
161 | |
162 (defcustom gnus-level-killed 9 | |
163 "*Groups with this level are killed." | |
164 :group 'gnus-group-levels | |
165 :type 'integer) | |
166 | |
167 (defcustom gnus-level-default-subscribed 3 | |
168 "*New subscribed groups will be subscribed at this level." | |
169 :group 'gnus-group-levels | |
170 :type 'integer) | |
171 | |
172 (defcustom gnus-level-default-unsubscribed 6 | |
173 "*New unsubscribed groups will be unsubscribed at this level." | |
174 :group 'gnus-group-levels | |
175 :type 'integer) | |
176 | |
177 (defcustom gnus-activate-level (1+ gnus-level-subscribed) | |
178 "*Groups higher than this level won't be activated on startup. | |
179 Setting this variable to something low might save lots of time when | |
180 you have many groups that you aren't interested in." | |
181 :group 'gnus-group-levels | |
182 :type 'integer) | |
183 | |
184 (defcustom gnus-activate-foreign-newsgroups 4 | |
185 "*If nil, Gnus will not check foreign newsgroups at startup. | |
186 If it is non-nil, it should be a number between one and nine. Foreign | |
187 newsgroups that have a level lower or equal to this number will be | |
188 activated on startup. For instance, if you want to active all | |
189 subscribed newsgroups, but not the rest, you'd set this variable to | |
190 `gnus-level-subscribed'. | |
191 | |
192 If you subscribe to lots of newsgroups from different servers, startup | |
193 might take a while. By setting this variable to nil, you'll save time, | |
194 but you won't be told how many unread articles there are in the | |
195 groups." | |
196 :group 'gnus-group-levels | |
197 :type 'integer) | |
198 | |
199 (defcustom gnus-save-newsrc-file t | |
200 "*Non-nil means that Gnus will save the `.newsrc' file. | |
201 Gnus always saves its own startup file, which is called | |
202 \".newsrc.eld\". The file called \".newsrc\" is in a format that can | |
203 be readily understood by other newsreaders. If you don't plan on | |
204 using other newsreaders, set this variable to nil to save some time on | |
205 exit." | |
206 :group 'gnus-newsrc | |
207 :type 'boolean) | |
208 | |
209 (defcustom gnus-save-killed-list t | |
210 "*If non-nil, save the list of killed groups to the startup file. | |
211 If you set this variable to nil, you'll save both time (when starting | |
212 and quitting) and space (both memory and disk), but it will also mean | |
213 that Gnus has no record of which groups are new and which are old, so | |
214 the automatic new newsgroups subscription methods become meaningless. | |
215 | |
216 You should always set `gnus-check-new-newsgroups' to `ask-server' or | |
217 nil if you set this variable to nil. | |
218 | |
219 This variable can also be a regexp. In that case, all groups that do | |
220 not match this regexp will be removed before saving the list." | |
221 :group 'gnus-newsrc | |
222 :type 'boolean) | |
223 | |
224 (defcustom gnus-ignored-newsgroups | |
225 (purecopy (mapconcat 'identity | |
226 '("^to\\." ; not "real" groups | |
227 "^[0-9. \t]+ " ; all digits in name | |
228 "[][\"#'()]" ; bogus characters | |
229 ) | |
230 "\\|")) | |
231 "A regexp to match uninteresting newsgroups in the active file. | |
232 Any lines in the active file matching this regular expression are | |
233 removed from the newsgroup list before anything else is done to it, | |
234 thus making them effectively non-existent." | |
235 :group 'gnus-group-new | |
236 :type 'regexp) | |
237 | |
238 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies | |
239 "*Function called with a group name when new group is detected. | |
240 A few pre-made functions are supplied: `gnus-subscribe-randomly' | |
241 inserts new groups at the beginning of the list of groups; | |
242 `gnus-subscribe-alphabetically' inserts new groups in strict | |
243 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups | |
244 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks | |
245 for your decision; `gnus-subscribe-killed' kills all new groups; | |
246 `gnus-subscribe-zombies' will make all new groups into zombies." | |
247 :group 'gnus-group-new | |
248 :type '(radio (function-item gnus-subscribe-randomly) | |
249 (function-item gnus-subscribe-alphabetically) | |
250 (function-item gnus-subscribe-hierarchically) | |
251 (function-item gnus-subscribe-interactively) | |
252 (function-item gnus-subscribe-killed) | |
253 (function-item gnus-subscribe-zombies) | |
254 function)) | |
255 | |
256 ;; Suggested by a bug report by Hallvard B Furuseth. | |
257 ;; <h.b.furuseth@usit.uio.no>. | |
258 (defcustom gnus-subscribe-options-newsgroup-method | |
259 'gnus-subscribe-alphabetically | |
260 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines. | |
261 If, for instance, you want to subscribe to all newsgroups in the | |
262 \"no\" and \"alt\" hierarchies, you'd put the following in your | |
263 .newsrc file: | |
264 | |
265 options -n no.all alt.all | |
266 | |
267 Gnus will the subscribe all new newsgroups in these hierarchies with | |
268 the subscription method in this variable." | |
269 :group 'gnus-group-new | |
270 :type '(radio (function-item gnus-subscribe-randomly) | |
271 (function-item gnus-subscribe-alphabetically) | |
272 (function-item gnus-subscribe-hierarchically) | |
273 (function-item gnus-subscribe-interactively) | |
274 (function-item gnus-subscribe-killed) | |
275 (function-item gnus-subscribe-zombies) | |
276 function)) | |
277 | |
278 (defcustom gnus-subscribe-hierarchical-interactive nil | |
279 "*If non-nil, Gnus will offer to subscribe hierarchically. | |
280 When a new hierarchy appears, Gnus will ask the user: | |
281 | |
282 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys): | |
283 | |
284 If the user pressed `d', Gnus will descend the hierarchy, `y' will | |
285 subscribe to all newsgroups in the hierarchy and `s' will skip this | |
286 hierarchy in its entirety." | |
287 :group 'gnus-group-new | |
288 :type 'boolean) | |
289 | |
290 (defcustom gnus-auto-subscribed-groups | |
291 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl" | |
292 "*All new groups that match this regexp will be subscribed automatically. | |
293 Note that this variable only deals with new groups. It has no effect | |
294 whatsoever on old groups. | |
295 | |
296 New groups that match this regexp will not be handled by | |
297 `gnus-subscribe-newsgroup-method'. Instead, they will | |
298 be subscribed using `gnus-subscribe-options-newsgroup-method'." | |
299 :group 'gnus-group-new | |
300 :type 'regexp) | |
301 | |
302 (defcustom gnus-options-subscribe nil | |
303 "*All new groups matching this regexp will be subscribed unconditionally. | |
304 Note that this variable deals only with new newsgroups. This variable | |
305 does not affect old newsgroups. | |
306 | |
307 New groups that match this regexp will not be handled by | |
308 `gnus-subscribe-newsgroup-method'. Instead, they will | |
309 be subscribed using `gnus-subscribe-options-newsgroup-method'." | |
310 :group 'gnus-group-new | |
311 :type '(choice regexp | |
312 (const :tag "none" nil))) | |
313 | |
314 (defcustom gnus-options-not-subscribe nil | |
315 "*All new groups matching this regexp will be ignored. | |
316 Note that this variable deals only with new newsgroups. This variable | |
317 does not affect old (already subscribed) newsgroups." | |
318 :group 'gnus-group-new | |
319 :type '(choice regexp | |
320 (const :tag "none" nil))) | |
321 | |
322 (defcustom gnus-modtime-botch nil | |
323 "*Non-nil means .newsrc should be deleted prior to save. | |
324 Its use is due to the bogus appearance that .newsrc was modified on | |
325 disc." | |
326 :group 'gnus-newsrc | |
327 :type 'boolean) | |
328 | |
329 (defcustom gnus-check-bogus-groups-hook nil | |
330 "A hook run after removing bogus groups." | |
331 :group 'gnus-start-server | |
332 :type 'hook) | |
333 | |
334 (defcustom gnus-startup-hook nil | |
335 "A hook called at startup. | |
336 This hook is called after Gnus is connected to the NNTP server." | |
337 :group 'gnus-start | |
338 :type 'hook) | |
339 | |
340 (defcustom gnus-started-hook nil | |
341 "A hook called as the last thing after startup." | |
342 :group 'gnus-start | |
343 :type 'hook) | |
344 | |
345 (defcustom gnus-get-new-news-hook nil | |
346 "A hook run just before Gnus checks for new news." | |
347 :group 'gnus-group-new | |
348 :type 'hook) | |
349 | |
350 (defcustom gnus-after-getting-new-news-hook | |
351 (when (gnus-boundp 'display-time-timer) | |
352 '(display-time-event-handler)) | |
353 "A hook run after Gnus checks for new news." | |
354 :group 'gnus-group-new | |
355 :type 'hook) | |
356 | |
357 (defcustom gnus-save-newsrc-hook nil | |
358 "A hook called before saving any of the newsrc files." | |
359 :group 'gnus-newsrc | |
360 :type 'hook) | |
361 | |
362 (defcustom gnus-save-quick-newsrc-hook nil | |
363 "A hook called just before saving the quick newsrc file. | |
364 Can be used to turn version control on or off." | |
365 :group 'gnus-newsrc | |
366 :type 'hook) | |
367 | |
368 (defcustom gnus-save-standard-newsrc-hook nil | |
369 "A hook called just before saving the standard newsrc file. | |
370 Can be used to turn version control on or off." | |
371 :group 'gnus-newsrc | |
372 :type 'hook) | |
373 | |
374 ;;; Internal variables | |
375 | |
376 (defvar gnus-newsrc-file-version nil) | |
377 (defvar gnus-override-subscribe-method nil) | |
378 (defvar gnus-dribble-buffer nil) | |
379 (defvar gnus-newsrc-options nil | |
380 "Options line in the .newsrc file.") | |
381 | |
382 (defvar gnus-newsrc-options-n nil | |
383 "List of regexps representing groups to be subscribed/ignored unconditionally.") | |
384 | |
385 (defvar gnus-newsrc-last-checked-date nil | |
386 "Date Gnus last asked server for new newsgroups.") | |
387 | |
388 (defvar gnus-current-startup-file nil | |
389 "Startup file for the current host.") | |
390 | |
391 ;; Byte-compiler warning. | |
392 (defvar gnus-group-line-format) | |
393 | |
394 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
395 (defvar gnus-init-inhibit nil) | |
396 (defun gnus-read-init-file (&optional inhibit-next) | |
397 ;; Don't load .gnus if the -q option was used. | |
398 (when init-file-user | |
399 (if gnus-init-inhibit | |
400 (setq gnus-init-inhibit nil) | |
401 (setq gnus-init-inhibit inhibit-next) | |
402 (let ((files (list gnus-site-init-file gnus-init-file)) | |
403 file) | |
404 (while files | |
405 (and (setq file (pop files)) | |
406 (or (and (file-exists-p file) | |
407 ;; Don't try to load a directory. | |
408 (not (file-directory-p file))) | |
409 (file-exists-p (concat file ".el")) | |
410 (file-exists-p (concat file ".elc"))) | |
411 (condition-case var | |
412 (load file nil t) | |
413 (error | |
414 (error "Error in %s: %s" file var))))))))) | |
415 | |
416 ;; For subscribing new newsgroup | |
417 | |
418 (defun gnus-subscribe-hierarchical-interactive (groups) | |
419 (let ((groups (sort groups 'string<)) | |
420 prefixes prefix start ans group starts) | |
421 (while groups | |
422 (setq prefixes (list "^")) | |
423 (while (and groups prefixes) | |
424 (while (not (string-match (car prefixes) (car groups))) | |
425 (setq prefixes (cdr prefixes))) | |
426 (setq prefix (car prefixes)) | |
427 (setq start (1- (length prefix))) | |
428 (if (and (string-match "[^\\.]\\." (car groups) start) | |
429 (cdr groups) | |
430 (setq prefix | |
431 (concat "^" (substring (car groups) 0 (match-end 0)))) | |
432 (string-match prefix (cadr groups))) | |
433 (progn | |
434 (push prefix prefixes) | |
435 (message "Descend hierarchy %s? ([y]nsq): " | |
436 (substring prefix 1 (1- (length prefix)))) | |
437 (while (not (memq (setq ans (read-char)) '(?y ?\n ?\r ?n ?s ?q))) | |
438 (ding) | |
439 (message "Descend hierarchy %s? ([y]nsq): " | |
440 (substring prefix 1 (1- (length prefix))))) | |
441 (cond ((= ans ?n) | |
442 (while (and groups | |
443 (string-match prefix | |
444 (setq group (car groups)))) | |
445 (push group gnus-killed-list) | |
446 (gnus-sethash group group gnus-killed-hashtb) | |
447 (setq groups (cdr groups))) | |
448 (setq starts (cdr starts))) | |
449 ((= ans ?s) | |
450 (while (and groups | |
451 (string-match prefix | |
452 (setq group (car groups)))) | |
453 (gnus-sethash group group gnus-killed-hashtb) | |
454 (gnus-subscribe-alphabetically (car groups)) | |
455 (setq groups (cdr groups))) | |
456 (setq starts (cdr starts))) | |
457 ((= ans ?q) | |
458 (while groups | |
459 (setq group (car groups)) | |
460 (push group gnus-killed-list) | |
461 (gnus-sethash group group gnus-killed-hashtb) | |
462 (setq groups (cdr groups)))) | |
463 (t nil))) | |
464 (message "Subscribe %s? ([n]yq)" (car groups)) | |
465 (while (not (memq (setq ans (read-char)) '(?y ?\n ?\r ?q ?n))) | |
466 (ding) | |
467 (message "Subscribe %s? ([n]yq)" (car groups))) | |
468 (setq group (car groups)) | |
469 (cond ((= ans ?y) | |
470 (gnus-subscribe-alphabetically (car groups)) | |
471 (gnus-sethash group group gnus-killed-hashtb)) | |
472 ((= ans ?q) | |
473 (while groups | |
474 (setq group (car groups)) | |
475 (push group gnus-killed-list) | |
476 (gnus-sethash group group gnus-killed-hashtb) | |
477 (setq groups (cdr groups)))) | |
478 (t | |
479 (push group gnus-killed-list) | |
480 (gnus-sethash group group gnus-killed-hashtb))) | |
481 (setq groups (cdr groups))))))) | |
482 | |
483 (defun gnus-subscribe-randomly (newsgroup) | |
484 "Subscribe new NEWSGROUP by making it the first newsgroup." | |
485 (gnus-subscribe-newsgroup newsgroup)) | |
486 | |
487 (defun gnus-subscribe-alphabetically (newgroup) | |
488 "Subscribe new NEWSGROUP and insert it in alphabetical order." | |
489 (let ((groups (cdr gnus-newsrc-alist)) | |
490 before) | |
491 (while (and (not before) groups) | |
492 (if (string< newgroup (caar groups)) | |
493 (setq before (caar groups)) | |
494 (setq groups (cdr groups)))) | |
495 (gnus-subscribe-newsgroup newgroup before))) | |
496 | |
497 (defun gnus-subscribe-hierarchically (newgroup) | |
498 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order." | |
499 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) | |
500 (save-excursion | |
501 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file)) | |
502 (let ((groupkey newgroup) | |
503 before) | |
504 (while (and (not before) groupkey) | |
505 (goto-char (point-min)) | |
506 (let ((groupkey-re | |
507 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) | |
508 (while (and (re-search-forward groupkey-re nil t) | |
509 (progn | |
510 (setq before (match-string 1)) | |
511 (string< before newgroup))))) | |
512 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) | |
513 (setq groupkey | |
514 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey) | |
515 (substring groupkey (match-beginning 1) (match-end 1))))) | |
516 (gnus-subscribe-newsgroup newgroup before)) | |
517 (kill-buffer (current-buffer)))) | |
518 | |
519 (defun gnus-subscribe-interactively (group) | |
520 "Subscribe the new GROUP interactively. | |
521 It is inserted in hierarchical newsgroup order if subscribed. If not, | |
522 it is killed." | |
523 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group)) | |
524 (gnus-subscribe-hierarchically group) | |
525 (push group gnus-killed-list))) | |
526 | |
527 (defun gnus-subscribe-zombies (group) | |
528 "Make the new GROUP into a zombie group." | |
529 (push group gnus-zombie-list)) | |
530 | |
531 (defun gnus-subscribe-killed (group) | |
532 "Make the new GROUP a killed group." | |
533 (push group gnus-killed-list)) | |
534 | |
535 (defun gnus-subscribe-newsgroup (newsgroup &optional next) | |
536 "Subscribe new NEWSGROUP. | |
537 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made | |
538 the first newsgroup." | |
539 (save-excursion | |
540 (goto-char (point-min)) | |
541 ;; We subscribe the group by changing its level to `subscribed'. | |
542 (gnus-group-change-level | |
543 newsgroup gnus-level-default-subscribed | |
544 gnus-level-killed (gnus-gethash (or next "dummy.group") | |
545 gnus-newsrc-hashtb)) | |
546 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))) | |
547 | |
548 (defun gnus-read-active-file-p () | |
549 "Say whether the active file has been read from `gnus-select-method'." | |
550 (memq gnus-select-method gnus-have-read-active-file)) | |
551 | |
552 ;;; General various misc type functions. | |
553 | |
554 ;; Silence byte-compiler. | |
555 (defvar gnus-current-headers) | |
556 (defvar gnus-thread-indent-array) | |
557 (defvar gnus-newsgroup-name) | |
558 (defvar gnus-newsgroup-headers) | |
559 (defvar gnus-group-list-mode) | |
560 (defvar gnus-group-mark-positions) | |
561 (defvar gnus-newsgroup-data) | |
562 (defvar gnus-newsgroup-unreads) | |
563 (defvar nnoo-state-alist) | |
564 (defvar gnus-current-select-method) | |
565 (defun gnus-clear-system () | |
566 "Clear all variables and buffers." | |
567 ;; Clear Gnus variables. | |
568 (let ((variables gnus-variable-list)) | |
569 (while variables | |
570 (set (car variables) nil) | |
571 (setq variables (cdr variables)))) | |
572 ;; Clear other internal variables. | |
573 (setq gnus-list-of-killed-groups nil | |
574 gnus-have-read-active-file nil | |
575 gnus-newsrc-alist nil | |
576 gnus-newsrc-hashtb nil | |
577 gnus-killed-list nil | |
578 gnus-zombie-list nil | |
579 gnus-killed-hashtb nil | |
580 gnus-active-hashtb nil | |
581 gnus-moderated-hashtb nil | |
582 gnus-description-hashtb nil | |
583 gnus-current-headers nil | |
584 gnus-thread-indent-array nil | |
585 gnus-newsgroup-headers nil | |
586 gnus-newsgroup-name nil | |
587 gnus-server-alist nil | |
588 gnus-group-list-mode nil | |
589 gnus-opened-servers nil | |
590 gnus-group-mark-positions nil | |
591 gnus-newsgroup-data nil | |
592 gnus-newsgroup-unreads nil | |
593 nnoo-state-alist nil | |
594 gnus-current-select-method nil) | |
595 (gnus-shutdown 'gnus) | |
596 ;; Kill the startup file. | |
597 (and gnus-current-startup-file | |
598 (get-file-buffer gnus-current-startup-file) | |
599 (kill-buffer (get-file-buffer gnus-current-startup-file))) | |
600 ;; Clear the dribble buffer. | |
601 (gnus-dribble-clear) | |
602 ;; Kill global KILL file buffer. | |
603 (when (get-file-buffer (gnus-newsgroup-kill-file nil)) | |
604 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil)))) | |
605 (gnus-kill-buffer nntp-server-buffer) | |
606 ;; Kill Gnus buffers. | |
607 (while gnus-buffer-list | |
608 (gnus-kill-buffer (pop gnus-buffer-list))) | |
609 ;; Remove Gnus frames. | |
610 (gnus-kill-gnus-frames)) | |
611 | |
612 (defun gnus-no-server-1 (&optional arg slave) | |
613 "Read network news. | |
614 If ARG is a positive number, Gnus will use that as the | |
615 startup level. If ARG is nil, Gnus will be started at level 2. | |
616 If ARG is non-nil and not a positive number, Gnus will | |
617 prompt the user for the name of an NNTP server to use. | |
618 As opposed to `gnus', this command will not connect to the local server." | |
619 (interactive "P") | |
620 (let ((val (or arg (1- gnus-level-default-subscribed)))) | |
621 (gnus val t slave) | |
622 (make-local-variable 'gnus-group-use-permanent-levels) | |
623 (setq gnus-group-use-permanent-levels val))) | |
624 | |
625 (defun gnus-1 (&optional arg dont-connect slave) | |
626 "Read network news. | |
627 If ARG is non-nil and a positive number, Gnus will use that as the | |
628 startup level. If ARG is non-nil and not a positive number, Gnus will | |
629 prompt the user for the name of an NNTP server to use." | |
630 (interactive "P") | |
631 | |
632 (if (and (get-buffer gnus-group-buffer) | |
633 (save-excursion | |
634 (set-buffer gnus-group-buffer) | |
635 (eq major-mode 'gnus-group-mode))) | |
636 (progn | |
637 (switch-to-buffer gnus-group-buffer) | |
638 (gnus-group-get-new-news | |
639 (and (numberp arg) | |
640 (> arg 0) | |
641 (max (car gnus-group-list-mode) arg)))) | |
642 | |
643 (gnus-splash) | |
644 (gnus-clear-system) | |
645 (nnheader-init-server-buffer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
646 (setq gnus-slave slave) |
17493 | 647 (gnus-read-init-file) |
648 | |
649 (when (and (string-match "XEmacs" (emacs-version)) | |
650 gnus-simple-splash) | |
651 (setq gnus-simple-splash nil) | |
652 (gnus-xmas-splash)) | |
653 | |
654 (let ((level (and (numberp arg) (> arg 0) arg)) | |
655 did-connect) | |
656 (unwind-protect | |
657 (progn | |
658 (unless dont-connect | |
659 (setq did-connect | |
660 (gnus-start-news-server (and arg (not level)))))) | |
661 (if (and (not dont-connect) | |
662 (not did-connect)) | |
663 (gnus-group-quit) | |
664 (run-hooks 'gnus-startup-hook) | |
665 ;; NNTP server is successfully open. | |
666 | |
667 ;; Find the current startup file name. | |
668 (setq gnus-current-startup-file | |
669 (gnus-make-newsrc-file gnus-startup-file)) | |
670 | |
671 ;; Read the dribble file. | |
672 (when (or gnus-slave gnus-use-dribble-file) | |
673 (gnus-dribble-read-file)) | |
674 | |
675 ;; Allow using GroupLens predictions. | |
676 (when gnus-use-grouplens | |
677 (bbb-login) | |
678 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode)) | |
679 | |
680 ;; Do the actual startup. | |
681 (gnus-setup-news nil level dont-connect) | |
682 ;; Generate the group buffer. | |
683 (gnus-group-list-groups level) | |
684 (gnus-group-first-unread-group) | |
685 (gnus-configure-windows 'group) | |
686 (gnus-group-set-mode-line) | |
687 (run-hooks 'gnus-started-hook)))))) | |
688 | |
689 ;;;###autoload | |
690 (defun gnus-unload () | |
691 "Unload all Gnus features." | |
692 (interactive) | |
693 (unless (boundp 'load-history) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
694 (error "Sorry, `gnus-unload' is not implemented in this Emacs version")) |
17493 | 695 (let ((history load-history) |
696 feature) | |
697 (while history | |
698 (and (string-match "^\\(gnus\\|nn\\)" (caar history)) | |
699 (setq feature (cdr (assq 'provide (car history)))) | |
700 (unload-feature feature 'force)) | |
701 (setq history (cdr history))))) | |
702 | |
703 | |
704 ;;; | |
705 ;;; Dribble file | |
706 ;;; | |
707 | |
708 (defvar gnus-dribble-ignore nil) | |
709 (defvar gnus-dribble-eval-file nil) | |
710 | |
711 (defun gnus-dribble-file-name () | |
712 "Return the dribble file for the current .newsrc." | |
713 (concat | |
714 (if gnus-dribble-directory | |
715 (concat (file-name-as-directory gnus-dribble-directory) | |
716 (file-name-nondirectory gnus-current-startup-file)) | |
717 gnus-current-startup-file) | |
718 "-dribble")) | |
719 | |
720 (defun gnus-dribble-enter (string) | |
721 "Enter STRING into the dribble buffer." | |
722 (when (and (not gnus-dribble-ignore) | |
723 gnus-dribble-buffer | |
724 (buffer-name gnus-dribble-buffer)) | |
725 (let ((obuf (current-buffer))) | |
726 (set-buffer gnus-dribble-buffer) | |
727 (goto-char (point-max)) | |
728 (insert string "\n") | |
729 (set-window-point (get-buffer-window (current-buffer)) (point-max)) | |
730 (bury-buffer gnus-dribble-buffer) | |
731 (set-buffer obuf)))) | |
732 | |
733 (defun gnus-dribble-touch () | |
734 "Touch the dribble buffer." | |
735 (gnus-dribble-enter "")) | |
736 | |
737 (defun gnus-dribble-read-file () | |
738 "Read the dribble file from disk." | |
739 (let ((dribble-file (gnus-dribble-file-name))) | |
740 (save-excursion | |
741 (set-buffer (setq gnus-dribble-buffer | |
742 (get-buffer-create | |
743 (file-name-nondirectory dribble-file)))) | |
744 (gnus-add-current-to-buffer-list) | |
745 (erase-buffer) | |
746 (setq buffer-file-name dribble-file) | |
747 (auto-save-mode t) | |
748 (buffer-disable-undo (current-buffer)) | |
749 (bury-buffer (current-buffer)) | |
750 (set-buffer-modified-p nil) | |
751 (let ((auto (make-auto-save-file-name)) | |
752 (gnus-dribble-ignore t) | |
753 modes) | |
754 (when (or (file-exists-p auto) (file-exists-p dribble-file)) | |
755 ;; Load whichever file is newest -- the auto save file | |
756 ;; or the "real" file. | |
757 (if (file-newer-than-file-p auto dribble-file) | |
758 (nnheader-insert-file-contents auto) | |
759 (nnheader-insert-file-contents dribble-file)) | |
760 (unless (zerop (buffer-size)) | |
761 (set-buffer-modified-p t)) | |
762 ;; Set the file modes to reflect the .newsrc file modes. | |
763 (save-buffer) | |
764 (when (and (file-exists-p gnus-current-startup-file) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
765 (file-exists-p dribble-file) |
17493 | 766 (setq modes (file-modes gnus-current-startup-file))) |
767 (set-file-modes dribble-file modes)) | |
768 ;; Possibly eval the file later. | |
769 (when (gnus-y-or-n-p | |
770 "Gnus auto-save file exists. Do you want to read it? ") | |
771 (setq gnus-dribble-eval-file t))))))) | |
772 | |
773 (defun gnus-dribble-eval-file () | |
774 (when gnus-dribble-eval-file | |
775 (setq gnus-dribble-eval-file nil) | |
776 (save-excursion | |
777 (let ((gnus-dribble-ignore t)) | |
778 (set-buffer gnus-dribble-buffer) | |
779 (eval-buffer (current-buffer)))))) | |
780 | |
781 (defun gnus-dribble-delete-file () | |
782 (when (file-exists-p (gnus-dribble-file-name)) | |
783 (delete-file (gnus-dribble-file-name))) | |
784 (when gnus-dribble-buffer | |
785 (save-excursion | |
786 (set-buffer gnus-dribble-buffer) | |
787 (let ((auto (make-auto-save-file-name))) | |
788 (when (file-exists-p auto) | |
789 (delete-file auto)) | |
790 (erase-buffer) | |
791 (set-buffer-modified-p nil))))) | |
792 | |
793 (defun gnus-dribble-save () | |
794 (when (and gnus-dribble-buffer | |
795 (buffer-name gnus-dribble-buffer)) | |
796 (save-excursion | |
797 (set-buffer gnus-dribble-buffer) | |
798 (save-buffer)))) | |
799 | |
800 (defun gnus-dribble-clear () | |
801 (when (gnus-buffer-exists-p gnus-dribble-buffer) | |
802 (save-excursion | |
803 (set-buffer gnus-dribble-buffer) | |
804 (erase-buffer) | |
805 (set-buffer-modified-p nil) | |
806 (setq buffer-saved-size (buffer-size))))) | |
807 | |
808 | |
809 ;;; | |
810 ;;; Active & Newsrc File Handling | |
811 ;;; | |
812 | |
813 (defun gnus-setup-news (&optional rawfile level dont-connect) | |
814 "Setup news information. | |
815 If RAWFILE is non-nil, the .newsrc file will also be read. | |
816 If LEVEL is non-nil, the news will be set up at level LEVEL." | |
817 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))) | |
818 | |
819 (when init | |
820 ;; Clear some variables to re-initialize news information. | |
821 (setq gnus-newsrc-alist nil | |
822 gnus-active-hashtb nil) | |
823 ;; Read the newsrc file and create `gnus-newsrc-hashtb'. | |
824 (gnus-read-newsrc-file rawfile)) | |
825 | |
826 (when (and (not (assoc "archive" gnus-server-alist)) | |
827 (gnus-archive-server-wanted-p)) | |
828 (push (cons "archive" gnus-message-archive-method) | |
829 gnus-server-alist)) | |
830 | |
831 ;; If we don't read the complete active file, we fill in the | |
832 ;; hashtb here. | |
833 (when (or (null gnus-read-active-file) | |
834 (eq gnus-read-active-file 'some)) | |
835 (gnus-update-active-hashtb-from-killed)) | |
836 | |
837 ;; Read the active file and create `gnus-active-hashtb'. | |
838 ;; If `gnus-read-active-file' is nil, then we just create an empty | |
839 ;; hash table. The partial filling out of the hash table will be | |
840 ;; done in `gnus-get-unread-articles'. | |
841 (and gnus-read-active-file | |
842 (not level) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
843 (gnus-read-active-file nil dont-connect)) |
17493 | 844 |
845 (unless gnus-active-hashtb | |
846 (setq gnus-active-hashtb (gnus-make-hashtable 4096))) | |
847 | |
848 ;; Initialize the cache. | |
849 (when gnus-use-cache | |
850 (gnus-cache-open)) | |
851 | |
852 ;; Possibly eval the dribble file. | |
853 (and init | |
854 (or gnus-use-dribble-file gnus-slave) | |
855 (gnus-dribble-eval-file)) | |
856 | |
857 ;; Slave Gnusii should then clear the dribble buffer. | |
858 (when (and init gnus-slave) | |
859 (gnus-dribble-clear)) | |
860 | |
861 (gnus-update-format-specifications) | |
862 | |
863 ;; See whether we need to read the description file. | |
864 (when (and (boundp 'gnus-group-line-format) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
865 (let ((case-fold-search nil)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
866 (string-match "%[-,0-9]*D" gnus-group-line-format)) |
17493 | 867 (not gnus-description-hashtb) |
868 (not dont-connect) | |
869 gnus-read-active-file) | |
870 (gnus-read-all-descriptions-files)) | |
871 | |
872 ;; Find new newsgroups and treat them. | |
873 (when (and init gnus-check-new-newsgroups (not level) | |
874 (gnus-check-server gnus-select-method) | |
875 (not gnus-slave)) | |
876 (gnus-find-new-newsgroups)) | |
877 | |
878 ;; We might read in new NoCeM messages here. | |
879 (when (and gnus-use-nocem | |
880 (not level) | |
881 (not dont-connect)) | |
882 (gnus-nocem-scan-groups)) | |
883 | |
884 ;; Read any slave files. | |
885 (gnus-master-read-slave-newsrc) | |
886 | |
887 ;; Find the number of unread articles in each non-dead group. | |
888 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) | |
889 (gnus-get-unread-articles level)) | |
890 | |
891 (when (and init gnus-check-bogus-newsgroups | |
892 gnus-read-active-file (not level) | |
893 (gnus-server-opened gnus-select-method)) | |
894 (gnus-check-bogus-newsgroups)))) | |
895 | |
896 (defun gnus-find-new-newsgroups (&optional arg) | |
897 "Search for new newsgroups and add them. | |
898 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.' | |
899 The `-n' option line from .newsrc is respected. | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
900 If ARG (the prefix), use the `ask-server' method to query the server |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
901 for new groups." |
17493 | 902 (interactive "P") |
903 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups))) | |
904 (null gnus-read-active-file) | |
905 (eq gnus-read-active-file 'some)) | |
906 'ask-server gnus-check-new-newsgroups))) | |
907 (unless (gnus-check-first-time-used) | |
908 (if (or (consp check) | |
909 (eq check 'ask-server)) | |
910 ;; Ask the server for new groups. | |
911 (gnus-ask-server-for-new-groups) | |
912 ;; Go through the active hashtb and look for new groups. | |
913 (let ((groups 0) | |
914 group new-newsgroups) | |
915 (gnus-message 5 "Looking for new newsgroups...") | |
916 (unless gnus-have-read-active-file | |
917 (gnus-read-active-file)) | |
918 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
919 (unless gnus-killed-hashtb | |
920 (gnus-make-hashtable-from-killed)) | |
921 ;; Go though every newsgroup in `gnus-active-hashtb' and compare | |
922 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. | |
923 (mapatoms | |
924 (lambda (sym) | |
925 (if (or (null (setq group (symbol-name sym))) | |
926 (not (boundp sym)) | |
927 (null (symbol-value sym)) | |
928 (gnus-gethash group gnus-killed-hashtb) | |
929 (gnus-gethash group gnus-newsrc-hashtb)) | |
930 () | |
931 (let ((do-sub (gnus-matches-options-n group))) | |
932 (cond | |
933 ((eq do-sub 'subscribe) | |
934 (setq groups (1+ groups)) | |
935 (gnus-sethash group group gnus-killed-hashtb) | |
936 (funcall gnus-subscribe-options-newsgroup-method group)) | |
937 ((eq do-sub 'ignore) | |
938 nil) | |
939 (t | |
940 (setq groups (1+ groups)) | |
941 (gnus-sethash group group gnus-killed-hashtb) | |
942 (if gnus-subscribe-hierarchical-interactive | |
943 (push group new-newsgroups) | |
944 (funcall gnus-subscribe-newsgroup-method group))))))) | |
945 gnus-active-hashtb) | |
946 (when new-newsgroups | |
947 (gnus-subscribe-hierarchical-interactive new-newsgroups)) | |
948 (if (> groups 0) | |
949 (gnus-message 5 "%d new newsgroup%s arrived." | |
950 groups (if (> groups 1) "s have" " has")) | |
951 (gnus-message 5 "No new newsgroups."))))))) | |
952 | |
953 (defun gnus-matches-options-n (group) | |
954 ;; Returns `subscribe' if the group is to be unconditionally | |
955 ;; subscribed, `ignore' if it is to be ignored, and nil if there is | |
956 ;; no match for the group. | |
957 | |
958 ;; First we check the two user variables. | |
959 (cond | |
960 ((and gnus-options-subscribe | |
961 (string-match gnus-options-subscribe group)) | |
962 'subscribe) | |
963 ((and gnus-auto-subscribed-groups | |
964 (string-match gnus-auto-subscribed-groups group)) | |
965 'subscribe) | |
966 ((and gnus-options-not-subscribe | |
967 (string-match gnus-options-not-subscribe group)) | |
968 'ignore) | |
969 ;; Then we go through the list that was retrieved from the .newsrc | |
970 ;; file. This list has elements on the form | |
971 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list | |
972 ;; is in the reverse order of the options line) is returned. | |
973 (t | |
974 (let ((regs gnus-newsrc-options-n)) | |
975 (while (and regs | |
976 (not (string-match (caar regs) group))) | |
977 (setq regs (cdr regs))) | |
978 (and regs (cdar regs)))))) | |
979 | |
980 (defun gnus-ask-server-for-new-groups () | |
981 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string))) | |
982 (methods (cons gnus-select-method | |
983 (nconc | |
984 (when (gnus-archive-server-wanted-p) | |
985 (list "archive")) | |
986 (append | |
987 (and (consp gnus-check-new-newsgroups) | |
988 gnus-check-new-newsgroups) | |
989 gnus-secondary-select-methods)))) | |
990 (groups 0) | |
991 (new-date (current-time-string)) | |
992 group new-newsgroups got-new method hashtb | |
993 gnus-override-subscribe-method) | |
994 ;; Go through both primary and secondary select methods and | |
995 ;; request new newsgroups. | |
996 (while (setq method (gnus-server-get-method nil (pop methods))) | |
997 (setq new-newsgroups nil) | |
998 (setq gnus-override-subscribe-method method) | |
999 (when (and (gnus-check-server method) | |
1000 (gnus-request-newgroups date method)) | |
1001 (save-excursion | |
1002 (setq got-new t) | |
1003 (setq hashtb (gnus-make-hashtable 100)) | |
1004 (set-buffer nntp-server-buffer) | |
1005 ;; Enter all the new groups into a hashtable. | |
1006 (gnus-active-to-gnus-format method hashtb 'ignore)) | |
1007 ;; Now all new groups from `method' are in `hashtb'. | |
1008 (mapatoms | |
1009 (lambda (group-sym) | |
1010 (if (or (null (setq group (symbol-name group-sym))) | |
1011 (not (boundp group-sym)) | |
1012 (null (symbol-value group-sym)) | |
1013 (gnus-gethash group gnus-newsrc-hashtb) | |
1014 (member group gnus-zombie-list) | |
1015 (member group gnus-killed-list)) | |
1016 ;; The group is already known. | |
1017 () | |
1018 ;; Make this group active. | |
1019 (when (symbol-value group-sym) | |
1020 (gnus-set-active group (symbol-value group-sym))) | |
1021 ;; Check whether we want it or not. | |
1022 (let ((do-sub (gnus-matches-options-n group))) | |
1023 (cond | |
1024 ((eq do-sub 'subscribe) | |
1025 (incf groups) | |
1026 (gnus-sethash group group gnus-killed-hashtb) | |
1027 (funcall gnus-subscribe-options-newsgroup-method group)) | |
1028 ((eq do-sub 'ignore) | |
1029 nil) | |
1030 (t | |
1031 (incf groups) | |
1032 (gnus-sethash group group gnus-killed-hashtb) | |
1033 (if gnus-subscribe-hierarchical-interactive | |
1034 (push group new-newsgroups) | |
1035 (funcall gnus-subscribe-newsgroup-method group))))))) | |
1036 hashtb)) | |
1037 (when new-newsgroups | |
1038 (gnus-subscribe-hierarchical-interactive new-newsgroups))) | |
1039 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
1040 (when (> groups 0) | |
1041 (gnus-message 6 "%d new newsgroup%s arrived." | |
1042 groups (if (> groups 1) "s have" " has"))) | |
1043 (when got-new | |
1044 (setq gnus-newsrc-last-checked-date new-date)) | |
1045 got-new)) | |
1046 | |
1047 (defun gnus-check-first-time-used () | |
1048 (if (or (> (length gnus-newsrc-alist) 1) | |
1049 (file-exists-p gnus-startup-file) | |
1050 (file-exists-p (concat gnus-startup-file ".el")) | |
1051 (file-exists-p (concat gnus-startup-file ".eld"))) | |
1052 nil | |
1053 (gnus-message 6 "First time user; subscribing you to default groups") | |
1054 (unless (gnus-read-active-file-p) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1055 (let ((gnus-read-active-file t)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1056 (gnus-read-active-file))) |
17493 | 1057 (setq gnus-newsrc-last-checked-date (current-time-string)) |
1058 (let ((groups gnus-default-subscribed-newsgroups) | |
1059 group) | |
1060 (if (eq groups t) | |
1061 nil | |
1062 (setq groups (or groups gnus-backup-default-subscribed-newsgroups)) | |
1063 (mapatoms | |
1064 (lambda (sym) | |
1065 (if (null (setq group (symbol-name sym))) | |
1066 () | |
1067 (let ((do-sub (gnus-matches-options-n group))) | |
1068 (cond | |
1069 ((eq do-sub 'subscribe) | |
1070 (gnus-sethash group group gnus-killed-hashtb) | |
1071 (funcall gnus-subscribe-options-newsgroup-method group)) | |
1072 ((eq do-sub 'ignore) | |
1073 nil) | |
1074 (t | |
1075 (push group gnus-killed-list)))))) | |
1076 gnus-active-hashtb) | |
1077 (while groups | |
1078 (when (gnus-active (car groups)) | |
1079 (gnus-group-change-level | |
1080 (car groups) gnus-level-default-subscribed gnus-level-killed)) | |
1081 (setq groups (cdr groups))) | |
1082 (gnus-group-make-help-group) | |
1083 (when gnus-novice-user | |
1084 (gnus-message 7 "`A k' to list killed groups")))))) | |
1085 | |
1086 (defun gnus-subscribe-group (group previous &optional method) | |
1087 (gnus-group-change-level | |
1088 (if method | |
1089 (list t group gnus-level-default-subscribed nil nil method) | |
1090 group) | |
1091 gnus-level-default-subscribed gnus-level-killed previous t)) | |
1092 | |
1093 ;; `gnus-group-change-level' is the fundamental function for changing | |
1094 ;; subscription levels of newsgroups. This might mean just changing | |
1095 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back | |
1096 ;; again, which subscribes/unsubscribes a group, which is equally | |
1097 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and | |
1098 ;; from 8-9 to 1-7 means that you remove the group from the list of | |
1099 ;; killed (or zombie) groups and add them to the (kinda) subscribed | |
1100 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8, | |
1101 ;; which is trivial. | |
1102 ;; ENTRY can either be a string (newsgroup name) or a list (if | |
1103 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST), | |
1104 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb' | |
1105 ;; entries. | |
1106 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and | |
1107 ;; PREVIOUS is the group (in hashtb entry format) to insert this group | |
1108 ;; after. | |
1109 (defun gnus-group-change-level (entry level &optional oldlevel | |
1110 previous fromkilled) | |
1111 (let (group info active num) | |
1112 ;; Glean what info we can from the arguments | |
1113 (if (consp entry) | |
1114 (if fromkilled (setq group (nth 1 entry)) | |
1115 (setq group (car (nth 2 entry)))) | |
1116 (setq group entry)) | |
1117 (when (and (stringp entry) | |
1118 oldlevel | |
1119 (< oldlevel gnus-level-zombie)) | |
1120 (setq entry (gnus-gethash entry gnus-newsrc-hashtb))) | |
1121 (if (and (not oldlevel) | |
1122 (consp entry)) | |
1123 (setq oldlevel (gnus-info-level (nth 2 entry))) | |
1124 (setq oldlevel (or oldlevel 9))) | |
1125 (when (stringp previous) | |
1126 (setq previous (gnus-gethash previous gnus-newsrc-hashtb))) | |
1127 | |
1128 (if (and (>= oldlevel gnus-level-zombie) | |
1129 (gnus-gethash group gnus-newsrc-hashtb)) | |
1130 ;; We are trying to subscribe a group that is already | |
1131 ;; subscribed. | |
1132 () ; Do nothing. | |
1133 | |
1134 (unless (gnus-ephemeral-group-p group) | |
1135 (gnus-dribble-enter | |
1136 (format "(gnus-group-change-level %S %S %S %S %S)" | |
1137 group level oldlevel (car (nth 2 previous)) fromkilled))) | |
1138 | |
1139 ;; Then we remove the newgroup from any old structures, if needed. | |
1140 ;; If the group was killed, we remove it from the killed or zombie | |
1141 ;; list. If not, and it is in fact going to be killed, we remove | |
1142 ;; it from the newsrc hash table and assoc. | |
1143 (cond | |
1144 ((>= oldlevel gnus-level-zombie) | |
1145 (if (= oldlevel gnus-level-zombie) | |
1146 (setq gnus-zombie-list (delete group gnus-zombie-list)) | |
1147 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
1148 (t | |
1149 (when (and (>= level gnus-level-zombie) | |
1150 entry) | |
1151 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb) | |
1152 (when (nth 3 entry) | |
1153 (setcdr (gnus-gethash (car (nth 3 entry)) | |
1154 gnus-newsrc-hashtb) | |
1155 (cdr entry))) | |
1156 (setcdr (cdr entry) (cdddr entry))))) | |
1157 | |
1158 ;; Finally we enter (if needed) the list where it is supposed to | |
1159 ;; go, and change the subscription level. If it is to be killed, | |
1160 ;; we enter it into the killed or zombie list. | |
1161 (cond | |
1162 ((>= level gnus-level-zombie) | |
1163 ;; Remove from the hash table. | |
1164 (gnus-sethash group nil gnus-newsrc-hashtb) | |
1165 ;; We do not enter foreign groups into the list of dead | |
1166 ;; groups. | |
1167 (unless (gnus-group-foreign-p group) | |
1168 (if (= level gnus-level-zombie) | |
1169 (push group gnus-zombie-list) | |
1170 (push group gnus-killed-list)))) | |
1171 (t | |
1172 ;; If the list is to be entered into the newsrc assoc, and | |
1173 ;; it was killed, we have to create an entry in the newsrc | |
1174 ;; hashtb format and fix the pointers in the newsrc assoc. | |
1175 (if (< oldlevel gnus-level-zombie) | |
1176 ;; It was alive, and it is going to stay alive, so we | |
1177 ;; just change the level and don't change any pointers or | |
1178 ;; hash table entries. | |
1179 (setcar (cdaddr entry) level) | |
1180 (if (listp entry) | |
1181 (setq info (cdr entry) | |
1182 num (car entry)) | |
1183 (setq active (gnus-active group)) | |
1184 (setq num | |
1185 (if active (- (1+ (cdr active)) (car active)) t)) | |
1186 ;; Check whether the group is foreign. If so, the | |
1187 ;; foreign select method has to be entered into the | |
1188 ;; info. | |
1189 (let ((method (or gnus-override-subscribe-method | |
1190 (gnus-group-method group)))) | |
1191 (if (eq method gnus-select-method) | |
1192 (setq info (list group level nil)) | |
1193 (setq info (list group level nil nil method))))) | |
1194 (unless previous | |
1195 (setq previous | |
1196 (let ((p gnus-newsrc-alist)) | |
1197 (while (cddr p) | |
1198 (setq p (cdr p))) | |
1199 p))) | |
1200 (setq entry (cons info (cddr previous))) | |
1201 (if (cdr previous) | |
1202 (progn | |
1203 (setcdr (cdr previous) entry) | |
1204 (gnus-sethash group (cons num (cdr previous)) | |
1205 gnus-newsrc-hashtb)) | |
1206 (setcdr previous entry) | |
1207 (gnus-sethash group (cons num previous) | |
1208 gnus-newsrc-hashtb)) | |
1209 (when (cdr entry) | |
1210 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)) | |
1211 (gnus-dribble-enter | |
1212 (format | |
1213 "(gnus-group-set-info '%S)" info))))) | |
1214 (when gnus-group-change-level-function | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1215 (funcall gnus-group-change-level-function |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1216 group level oldlevel previous))))) |
17493 | 1217 |
1218 (defun gnus-kill-newsgroup (newsgroup) | |
1219 "Obsolete function. Kills a newsgroup." | |
1220 (gnus-group-change-level | |
1221 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed)) | |
1222 | |
1223 (defun gnus-check-bogus-newsgroups (&optional confirm) | |
1224 "Remove bogus newsgroups. | |
1225 If CONFIRM is non-nil, the user has to confirm the deletion of every | |
1226 newsgroup." | |
1227 (let ((newsrc (cdr gnus-newsrc-alist)) | |
1228 bogus group entry info) | |
1229 (gnus-message 5 "Checking bogus newsgroups...") | |
1230 (unless (gnus-read-active-file-p) | |
1231 (gnus-read-active-file t)) | |
1232 (when (gnus-read-active-file-p) | |
1233 ;; Find all bogus newsgroup that are subscribed. | |
1234 (while newsrc | |
1235 (setq info (pop newsrc) | |
1236 group (gnus-info-group info)) | |
1237 (unless (or (gnus-active group) ; Active | |
1238 (gnus-info-method info)) ; Foreign | |
1239 ;; Found a bogus newsgroup. | |
1240 (push group bogus))) | |
1241 (if confirm | |
1242 (map-y-or-n-p | |
1243 "Remove bogus group %s? " | |
1244 (lambda (group) | |
1245 ;; Remove all bogus subscribed groups by first killing them, and | |
1246 ;; then removing them from the list of killed groups. | |
1247 (when (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
1248 (gnus-group-change-level entry gnus-level-killed) | |
1249 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
1250 bogus '("group" "groups" "remove")) | |
1251 (while (setq group (pop bogus)) | |
1252 ;; Remove all bogus subscribed groups by first killing them, and | |
1253 ;; then removing them from the list of killed groups. | |
1254 (when (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
1255 (gnus-group-change-level entry gnus-level-killed) | |
1256 (setq gnus-killed-list (delete group gnus-killed-list))))) | |
1257 ;; Then we remove all bogus groups from the list of killed and | |
1258 ;; zombie groups. They are removed without confirmation. | |
1259 (let ((dead-lists '(gnus-killed-list gnus-zombie-list)) | |
1260 killed) | |
1261 (while dead-lists | |
1262 (setq killed (symbol-value (car dead-lists))) | |
1263 (while killed | |
1264 (unless (gnus-active (setq group (pop killed))) | |
1265 ;; The group is bogus. | |
1266 ;; !!!Slow as hell. | |
1267 (set (car dead-lists) | |
1268 (delete group (symbol-value (car dead-lists)))))) | |
1269 (setq dead-lists (cdr dead-lists)))) | |
1270 (run-hooks 'gnus-check-bogus-groups-hook) | |
1271 (gnus-message 5 "Checking bogus newsgroups...done")))) | |
1272 | |
1273 (defun gnus-check-duplicate-killed-groups () | |
1274 "Remove duplicates from the list of killed groups." | |
1275 (interactive) | |
1276 (let ((killed gnus-killed-list)) | |
1277 (while killed | |
1278 (gnus-message 9 "%d" (length killed)) | |
1279 (setcdr killed (delete (car killed) (cdr killed))) | |
1280 (setq killed (cdr killed))))) | |
1281 | |
1282 ;; We want to inline a function from gnus-cache, so we cheat here: | |
1283 (eval-when-compile | |
1284 (defvar gnus-cache-active-hashtb) | |
1285 (defun gnus-cache-possibly-alter-active (group active) | |
1286 "Alter the ACTIVE info for GROUP to reflect the articles in the cache." | |
1287 (when gnus-cache-active-hashtb | |
1288 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1289 (when cache-active |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1290 (when (< (car cache-active) (car active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1291 (setcar active (car cache-active))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1292 (when (> (cdr cache-active) (cdr active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1293 (setcdr active (cdr cache-active)))))))) |
17493 | 1294 |
1295 (defun gnus-activate-group (group &optional scan dont-check method) | |
1296 ;; Check whether a group has been activated or not. | |
1297 ;; If SCAN, request a scan of that group as well. | |
1298 (let ((method (or method (inline (gnus-find-method-for-group group)))) | |
1299 active) | |
1300 (and (inline (gnus-check-server method)) | |
1301 ;; We escape all bugs and quit here to make it possible to | |
1302 ;; continue if a group is so out-there that it reports bugs | |
1303 ;; and stuff. | |
1304 (progn | |
1305 (and scan | |
1306 (gnus-check-backend-function 'request-scan (car method)) | |
1307 (gnus-request-scan group method)) | |
1308 t) | |
1309 (condition-case () | |
1310 (inline (gnus-request-group group dont-check method)) | |
1311 (error nil) | |
1312 (quit nil)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1313 (setq active (gnus-parse-active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1314 ;; If there are no articles in the group, the GROUP |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1315 ;; command may have responded with the `(0 . 0)'. We |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1316 ;; ignore this if we already have an active entry |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1317 ;; for the group. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1318 (if (and (zerop (car active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1319 (zerop (cdr active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1320 (gnus-active group)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1321 (gnus-active group) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1322 (gnus-set-active group active) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1323 ;; Return the new active info. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1324 active)))) |
17493 | 1325 |
1326 (defun gnus-get-unread-articles-in-group (info active &optional update) | |
1327 (when active | |
1328 ;; Allow the backend to update the info in the group. | |
1329 (when (and update | |
1330 (gnus-request-update-info | |
1331 info (inline (gnus-find-method-for-group | |
1332 (gnus-info-group info))))) | |
1333 (gnus-activate-group (gnus-info-group info) nil t)) | |
1334 (let* ((range (gnus-info-read info)) | |
1335 (num 0)) | |
1336 ;; If a cache is present, we may have to alter the active info. | |
1337 (when (and gnus-use-cache info) | |
1338 (inline (gnus-cache-possibly-alter-active | |
1339 (gnus-info-group info) active))) | |
1340 ;; Modify the list of read articles according to what articles | |
1341 ;; are available; then tally the unread articles and add the | |
1342 ;; number to the group hash table entry. | |
1343 (cond | |
1344 ((zerop (cdr active)) | |
1345 (setq num 0)) | |
1346 ((not range) | |
1347 (setq num (- (1+ (cdr active)) (car active)))) | |
1348 ((not (listp (cdr range))) | |
1349 ;; Fix a single (num . num) range according to the | |
1350 ;; active hash table. | |
1351 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>. | |
1352 (and (< (cdr range) (car active)) (setcdr range (1- (car active)))) | |
1353 (and (> (cdr range) (cdr active)) (setcdr range (cdr active))) | |
1354 ;; Compute number of unread articles. | |
1355 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range)))))) | |
1356 (t | |
1357 ;; The read list is a list of ranges. Fix them according to | |
1358 ;; the active hash table. | |
1359 ;; First peel off any elements that are below the lower | |
1360 ;; active limit. | |
1361 (while (and (cdr range) | |
1362 (>= (car active) | |
1363 (or (and (atom (cadr range)) (cadr range)) | |
1364 (caadr range)))) | |
1365 (if (numberp (car range)) | |
1366 (setcar range | |
1367 (cons (car range) | |
1368 (or (and (numberp (cadr range)) | |
1369 (cadr range)) | |
1370 (cdadr range)))) | |
1371 (setcdr (car range) | |
1372 (or (and (numberp (nth 1 range)) (nth 1 range)) | |
1373 (cdadr range)))) | |
1374 (setcdr range (cddr range))) | |
1375 ;; Adjust the first element to be the same as the lower limit. | |
1376 (when (and (not (atom (car range))) | |
1377 (< (cdar range) (car active))) | |
1378 (setcdr (car range) (1- (car active)))) | |
1379 ;; Then we want to peel off any elements that are higher | |
1380 ;; than the upper active limit. | |
1381 (let ((srange range)) | |
1382 ;; Go past all legal elements. | |
1383 (while (and (cdr srange) | |
1384 (<= (or (and (atom (cadr srange)) | |
1385 (cadr srange)) | |
1386 (caadr srange)) | |
1387 (cdr active))) | |
1388 (setq srange (cdr srange))) | |
1389 (when (cdr srange) | |
1390 ;; Nuke all remaining illegal elements. | |
1391 (setcdr srange nil)) | |
1392 | |
1393 ;; Adjust the final element. | |
1394 (when (and (not (atom (car srange))) | |
1395 (> (cdar srange) (cdr active))) | |
1396 (setcdr (car srange) (cdr active)))) | |
1397 ;; Compute the number of unread articles. | |
1398 (while range | |
1399 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range)) | |
1400 (cdar range))) | |
1401 (or (and (atom (car range)) (car range)) | |
1402 (caar range))))) | |
1403 (setq range (cdr range))) | |
1404 (setq num (max 0 (- (cdr active) num))))) | |
1405 ;; Set the number of unread articles. | |
1406 (when info | |
1407 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)) | |
1408 num))) | |
1409 | |
1410 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' | |
1411 ;; and compute how many unread articles there are in each group. | |
1412 (defun gnus-get-unread-articles (&optional level) | |
1413 (let* ((newsrc (cdr gnus-newsrc-alist)) | |
1414 (level (or level gnus-activate-level (1+ gnus-level-subscribed))) | |
1415 (foreign-level | |
1416 (min | |
1417 (cond ((and gnus-activate-foreign-newsgroups | |
1418 (not (numberp gnus-activate-foreign-newsgroups))) | |
1419 (1+ gnus-level-subscribed)) | |
1420 ((numberp gnus-activate-foreign-newsgroups) | |
1421 gnus-activate-foreign-newsgroups) | |
1422 (t 0)) | |
1423 level)) | |
1424 info group active method) | |
1425 (gnus-message 5 "Checking new news...") | |
1426 | |
1427 (while newsrc | |
1428 (setq active (gnus-active (setq group (gnus-info-group | |
1429 (setq info (pop newsrc)))))) | |
1430 | |
1431 ;; Check newsgroups. If the user doesn't want to check them, or | |
1432 ;; they can't be checked (for instance, if the news server can't | |
1433 ;; be reached) we just set the number of unread articles in this | |
1434 ;; newsgroup to t. This means that Gnus thinks that there are | |
1435 ;; unread articles, but it has no idea how many. | |
1436 (if (and (setq method (gnus-info-method info)) | |
1437 (not (inline | |
1438 (gnus-server-equal | |
1439 gnus-select-method | |
1440 (setq method (gnus-server-get-method nil method))))) | |
1441 (not (gnus-secondary-method-p method))) | |
1442 ;; These groups are foreign. Check the level. | |
1443 (when (<= (gnus-info-level info) foreign-level) | |
1444 (setq active (gnus-activate-group group 'scan)) | |
1445 (unless (inline (gnus-virtual-group-p group)) | |
1446 (inline (gnus-close-group group))) | |
1447 (when (fboundp (intern (concat (symbol-name (car method)) | |
1448 "-request-update-info"))) | |
1449 (inline (gnus-request-update-info info method)))) | |
1450 ;; These groups are native or secondary. | |
1451 (when (and (<= (gnus-info-level info) level) | |
1452 (not gnus-read-active-file)) | |
1453 (setq active (gnus-activate-group group 'scan)) | |
1454 (inline (gnus-close-group group)))) | |
1455 | |
1456 ;; Get the number of unread articles in the group. | |
1457 (if active | |
1458 (inline (gnus-get-unread-articles-in-group info active t)) | |
1459 ;; The group couldn't be reached, so we nix out the number of | |
1460 ;; unread articles and stuff. | |
1461 (gnus-set-active group nil) | |
1462 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))) | |
1463 | |
1464 (gnus-message 5 "Checking new news...done"))) | |
1465 | |
1466 ;; Create a hash table out of the newsrc alist. The `car's of the | |
1467 ;; alist elements are used as keys. | |
1468 (defun gnus-make-hashtable-from-newsrc-alist () | |
1469 (let ((alist gnus-newsrc-alist) | |
1470 (ohashtb gnus-newsrc-hashtb) | |
1471 prev) | |
1472 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))) | |
1473 (setq alist | |
1474 (setq prev (setq gnus-newsrc-alist | |
1475 (if (equal (caar gnus-newsrc-alist) | |
1476 "dummy.group") | |
1477 gnus-newsrc-alist | |
1478 (cons (list "dummy.group" 0 nil) alist))))) | |
1479 (while alist | |
1480 (gnus-sethash | |
1481 (caar alist) | |
1482 ;; Preserve number of unread articles in groups. | |
1483 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb))) | |
1484 prev) | |
1485 gnus-newsrc-hashtb) | |
1486 (setq prev alist | |
1487 alist (cdr alist))))) | |
1488 | |
1489 (defun gnus-make-hashtable-from-killed () | |
1490 "Create a hash table from the killed and zombie lists." | |
1491 (let ((lists '(gnus-killed-list gnus-zombie-list)) | |
1492 list) | |
1493 (setq gnus-killed-hashtb | |
1494 (gnus-make-hashtable | |
1495 (+ (length gnus-killed-list) (length gnus-zombie-list)))) | |
1496 (while lists | |
1497 (setq list (symbol-value (pop lists))) | |
1498 (while list | |
1499 (gnus-sethash (car list) (pop list) gnus-killed-hashtb))))) | |
1500 | |
1501 (defun gnus-parse-active () | |
1502 "Parse active info in the nntp server buffer." | |
1503 (save-excursion | |
1504 (set-buffer nntp-server-buffer) | |
1505 (goto-char (point-min)) | |
1506 ;; Parse the result we got from `gnus-request-group'. | |
1507 (when (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+") | |
1508 (goto-char (match-beginning 1)) | |
1509 (cons (read (current-buffer)) | |
1510 (read (current-buffer)))))) | |
1511 | |
1512 (defun gnus-make-articles-unread (group articles) | |
1513 "Mark ARTICLES in GROUP as unread." | |
1514 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb) | |
1515 (gnus-gethash (gnus-group-real-name group) | |
1516 gnus-newsrc-hashtb)))) | |
1517 (ranges (gnus-info-read info)) | |
1518 news article) | |
1519 (while articles | |
1520 (when (gnus-member-of-range | |
1521 (setq article (pop articles)) ranges) | |
1522 (push article news))) | |
1523 (when news | |
1524 (gnus-info-set-read | |
1525 info (gnus-remove-from-range (gnus-info-read info) (nreverse news))) | |
1526 (gnus-group-update-group group t)))) | |
1527 | |
1528 ;; Enter all dead groups into the hashtb. | |
1529 (defun gnus-update-active-hashtb-from-killed () | |
1530 (let ((hashtb (setq gnus-active-hashtb (gnus-make-hashtable 4096))) | |
1531 (lists (list gnus-killed-list gnus-zombie-list)) | |
1532 killed) | |
1533 (while lists | |
1534 (setq killed (car lists)) | |
1535 (while killed | |
1536 (gnus-sethash (car killed) nil hashtb) | |
1537 (setq killed (cdr killed))) | |
1538 (setq lists (cdr lists))))) | |
1539 | |
1540 (defun gnus-get-killed-groups () | |
1541 "Go through the active hashtb and mark all unknown groups as killed." | |
1542 ;; First make sure active file has been read. | |
1543 (unless (gnus-read-active-file-p) | |
1544 (let ((gnus-read-active-file t)) | |
1545 (gnus-read-active-file))) | |
1546 (unless gnus-killed-hashtb | |
1547 (gnus-make-hashtable-from-killed)) | |
1548 ;; Go through all newsgroups that are known to Gnus - enlarge kill list. | |
1549 (mapatoms | |
1550 (lambda (sym) | |
1551 (let ((groups 0) | |
1552 (group (symbol-name sym))) | |
1553 (if (or (null group) | |
1554 (gnus-gethash group gnus-killed-hashtb) | |
1555 (gnus-gethash group gnus-newsrc-hashtb)) | |
1556 () | |
1557 (let ((do-sub (gnus-matches-options-n group))) | |
1558 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore)) | |
1559 () | |
1560 (setq groups (1+ groups)) | |
1561 (push group gnus-killed-list) | |
1562 (gnus-sethash group group gnus-killed-hashtb)))))) | |
1563 gnus-active-hashtb) | |
1564 (gnus-dribble-touch)) | |
1565 | |
1566 ;; Get the active file(s) from the backend(s). | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1567 (defun gnus-read-active-file (&optional force not-native) |
17493 | 1568 (gnus-group-set-mode-line) |
1569 (let ((methods | |
1570 (append | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1571 (if (and (not not-native) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1572 (gnus-check-server gnus-select-method)) |
17493 | 1573 ;; The native server is available. |
1574 (cons gnus-select-method gnus-secondary-select-methods) | |
1575 ;; The native server is down, so we just do the | |
1576 ;; secondary ones. | |
1577 gnus-secondary-select-methods) | |
1578 ;; Also read from the archive server. | |
1579 (when (gnus-archive-server-wanted-p) | |
1580 (list "archive")))) | |
1581 list-type) | |
1582 (setq gnus-have-read-active-file nil) | |
1583 (save-excursion | |
1584 (set-buffer nntp-server-buffer) | |
1585 (while methods | |
1586 (let* ((method (if (stringp (car methods)) | |
1587 (gnus-server-get-method nil (car methods)) | |
1588 (car methods))) | |
1589 (where (nth 1 method)) | |
1590 (mesg (format "Reading active file%s via %s..." | |
1591 (if (and where (not (zerop (length where)))) | |
1592 (concat " from " where) "") | |
1593 (car method)))) | |
1594 (gnus-message 5 mesg) | |
1595 (when (gnus-check-server method) | |
1596 ;; Request that the backend scan its incoming messages. | |
1597 (when (gnus-check-backend-function 'request-scan (car method)) | |
1598 (gnus-request-scan nil method)) | |
1599 (cond | |
1600 ((and (eq gnus-read-active-file 'some) | |
1601 (gnus-check-backend-function 'retrieve-groups (car method)) | |
1602 (not force)) | |
1603 (let ((newsrc (cdr gnus-newsrc-alist)) | |
1604 (gmethod (gnus-server-get-method nil method)) | |
1605 groups info) | |
1606 (while (setq info (pop newsrc)) | |
1607 (when (inline | |
1608 (gnus-server-equal | |
1609 (inline | |
1610 (gnus-find-method-for-group | |
1611 (gnus-info-group info) info)) | |
1612 gmethod)) | |
1613 (push (gnus-group-real-name (gnus-info-group info)) | |
1614 groups))) | |
1615 (when groups | |
1616 (gnus-check-server method) | |
1617 (setq list-type (gnus-retrieve-groups groups method)) | |
1618 (cond | |
1619 ((not list-type) | |
1620 (gnus-error | |
1621 1.2 "Cannot read partial active file from %s server." | |
1622 (car method))) | |
1623 ((eq list-type 'active) | |
1624 (gnus-active-to-gnus-format method gnus-active-hashtb)) | |
1625 (t | |
1626 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))) | |
1627 ((null method) | |
1628 t) | |
1629 (t | |
1630 (if (not (gnus-request-list method)) | |
1631 (unless (equal method gnus-message-archive-method) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1632 (gnus-error 1 "Cannot read active file from %s server" |
17493 | 1633 (car method))) |
1634 (gnus-message 5 mesg) | |
1635 (gnus-active-to-gnus-format method gnus-active-hashtb) | |
1636 ;; We mark this active file as read. | |
1637 (push method gnus-have-read-active-file) | |
1638 (gnus-message 5 "%sdone" mesg)))))) | |
1639 (setq methods (cdr methods)))))) | |
1640 | |
1641 | |
1642 (defun gnus-ignored-newsgroups-has-to-p () | |
1643 "T only when gnus-ignored-newsgroups includes \"^to\\\\.\" as an element." | |
1644 ;; note this regexp is the same as: | |
1645 ;; (concat (regexp-quote "^to\\.") "\\($\\|" (regexp-quote "\\|") "\\)") | |
1646 (string-match "\\^to\\\\\\.\\($\\|\\\\|\\)" | |
1647 gnus-ignored-newsgroups)) | |
1648 | |
1649 ;; Read an active file and place the results in `gnus-active-hashtb'. | |
1650 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors) | |
1651 (unless method | |
1652 (setq method gnus-select-method)) | |
1653 (let ((cur (current-buffer)) | |
1654 (hashtb (or hashtb | |
1655 (if (and gnus-active-hashtb | |
1656 (not (equal method gnus-select-method))) | |
1657 gnus-active-hashtb | |
1658 (setq gnus-active-hashtb | |
1659 (if (equal method gnus-select-method) | |
1660 (gnus-make-hashtable | |
1661 (count-lines (point-min) (point-max))) | |
1662 (gnus-make-hashtable 4096))))))) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1663 ;; Delete unnecessary lines. |
17493 | 1664 (goto-char (point-min)) |
1665 (cond ((gnus-ignored-newsgroups-has-to-p) | |
1666 (delete-matching-lines gnus-ignored-newsgroups)) | |
1667 ((string= gnus-ignored-newsgroups "") | |
1668 (delete-matching-lines "^to\\.")) | |
1669 (t | |
1670 (delete-matching-lines (concat "^to\\.\\|" | |
1671 gnus-ignored-newsgroups)))) | |
1672 | |
1673 ;; Make the group names readable as a lisp expression even if they | |
1674 ;; contain special characters. | |
1675 (goto-char (point-max)) | |
1676 (while (re-search-backward "[][';?()#]" nil t) | |
1677 (insert ?\\)) | |
1678 | |
1679 ;; If these are groups from a foreign select method, we insert the | |
1680 ;; group prefix in front of the group names. | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1681 (when (not (gnus-server-equal |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1682 (gnus-server-get-method nil method) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1683 (gnus-server-get-method nil gnus-select-method))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1684 (let ((prefix (gnus-group-prefixed-name "" method))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1685 (goto-char (point-min)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1686 (while (and (not (eobp)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1687 (progn (insert prefix) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
1688 (zerop (forward-line 1))))))) |
17493 | 1689 ;; Store the active file in a hash table. |
1690 (goto-char (point-min)) | |
1691 (let (group max min) | |
1692 (while (not (eobp)) | |
1693 (condition-case () | |
1694 (progn | |
1695 (narrow-to-region (point) (gnus-point-at-eol)) | |
1696 ;; group gets set to a symbol interned in the hash table | |
1697 ;; (what a hack!!) - jwz | |
1698 (setq group (let ((obarray hashtb)) (read cur))) | |
1699 (if (and (numberp (setq max (read cur))) | |
1700 (numberp (setq min (read cur))) | |
1701 (progn | |
1702 (skip-chars-forward " \t") | |
1703 (not | |
1704 (or (= (following-char) ?=) | |
1705 (= (following-char) ?x) | |
1706 (= (following-char) ?j))))) | |
1707 (progn | |
1708 (set group (cons min max)) | |
1709 ;; if group is moderated, stick in moderation table | |
1710 (when (= (following-char) ?m) | |
1711 (unless gnus-moderated-hashtb | |
1712 (setq gnus-moderated-hashtb (gnus-make-hashtable))) | |
1713 (gnus-sethash (symbol-name group) t | |
1714 gnus-moderated-hashtb))) | |
1715 (set group nil))) | |
1716 (error | |
1717 (and group | |
1718 (symbolp group) | |
1719 (set group nil)) | |
1720 (unless ignore-errors | |
1721 (gnus-message 3 "Warning - illegal active: %s" | |
1722 (buffer-substring | |
1723 (gnus-point-at-bol) (gnus-point-at-eol)))))) | |
1724 (widen) | |
1725 (forward-line 1))))) | |
1726 | |
1727 (defun gnus-groups-to-gnus-format (method &optional hashtb) | |
1728 ;; Parse a "groups" active file. | |
1729 (let ((cur (current-buffer)) | |
1730 (hashtb (or hashtb | |
1731 (if (and method gnus-active-hashtb) | |
1732 gnus-active-hashtb | |
1733 (setq gnus-active-hashtb | |
1734 (gnus-make-hashtable | |
1735 (count-lines (point-min) (point-max))))))) | |
1736 (prefix (and method | |
1737 (not (gnus-server-equal | |
1738 (gnus-server-get-method nil method) | |
1739 (gnus-server-get-method nil gnus-select-method))) | |
1740 (gnus-group-prefixed-name "" method)))) | |
1741 | |
1742 (goto-char (point-min)) | |
1743 ;; We split this into to separate loops, one with the prefix | |
1744 ;; and one without to speed the reading up somewhat. | |
1745 (if prefix | |
1746 (let (min max opoint group) | |
1747 (while (not (eobp)) | |
1748 (condition-case () | |
1749 (progn | |
1750 (read cur) (read cur) | |
1751 (setq min (read cur) | |
1752 max (read cur) | |
1753 opoint (point)) | |
1754 (skip-chars-forward " \t") | |
1755 (insert prefix) | |
1756 (goto-char opoint) | |
1757 (set (let ((obarray hashtb)) (read cur)) | |
1758 (cons min max))) | |
1759 (error (and group (symbolp group) (set group nil)))) | |
1760 (forward-line 1))) | |
1761 (let (min max group) | |
1762 (while (not (eobp)) | |
1763 (condition-case () | |
1764 (when (= (following-char) ?2) | |
1765 (read cur) (read cur) | |
1766 (setq min (read cur) | |
1767 max (read cur)) | |
1768 (set (setq group (let ((obarray hashtb)) (read cur))) | |
1769 (cons min max))) | |
1770 (error (and group (symbolp group) (set group nil)))) | |
1771 (forward-line 1)))))) | |
1772 | |
1773 (defun gnus-read-newsrc-file (&optional force) | |
1774 "Read startup file. | |
1775 If FORCE is non-nil, the .newsrc file is read." | |
1776 ;; Reset variables that might be defined in the .newsrc.eld file. | |
1777 (let ((variables gnus-variable-list)) | |
1778 (while variables | |
1779 (set (car variables) nil) | |
1780 (setq variables (cdr variables)))) | |
1781 (let* ((newsrc-file gnus-current-startup-file) | |
1782 (quick-file (concat newsrc-file ".el"))) | |
1783 (save-excursion | |
1784 ;; We always load the .newsrc.eld file. If always contains | |
1785 ;; much information that can not be gotten from the .newsrc | |
1786 ;; file (ticked articles, killed groups, foreign methods, etc.) | |
1787 (gnus-read-newsrc-el-file quick-file) | |
1788 | |
1789 (when (and (file-exists-p gnus-current-startup-file) | |
1790 (or force | |
1791 (and (file-newer-than-file-p newsrc-file quick-file) | |
1792 (file-newer-than-file-p newsrc-file | |
1793 (concat quick-file "d"))) | |
1794 (not gnus-newsrc-alist))) | |
1795 ;; We read the .newsrc file. Note that if there if a | |
1796 ;; .newsrc.eld file exists, it has already been read, and | |
1797 ;; the `gnus-newsrc-hashtb' has been created. While reading | |
1798 ;; the .newsrc file, Gnus will only use the information it | |
1799 ;; can find there for changing the data already read - | |
1800 ;; i. e., reading the .newsrc file will not trash the data | |
1801 ;; already read (except for read articles). | |
1802 (save-excursion | |
1803 (gnus-message 5 "Reading %s..." newsrc-file) | |
1804 (set-buffer (nnheader-find-file-noselect newsrc-file)) | |
1805 (buffer-disable-undo (current-buffer)) | |
1806 (gnus-newsrc-to-gnus-format) | |
1807 (kill-buffer (current-buffer)) | |
1808 (gnus-message 5 "Reading %s...done" newsrc-file))) | |
1809 | |
1810 ;; Convert old to new. | |
1811 (gnus-convert-old-newsrc)))) | |
1812 | |
1813 (defun gnus-convert-old-newsrc () | |
1814 "Convert old newsrc into the new format, if needed." | |
1815 (let ((fcv (and gnus-newsrc-file-version | |
1816 (gnus-continuum-version gnus-newsrc-file-version)))) | |
1817 (cond | |
1818 ;; No .newsrc.eld file was loaded. | |
1819 ((null fcv) nil) | |
1820 ;; Gnus 5 .newsrc.eld was loaded. | |
1821 ((< fcv (gnus-continuum-version "September Gnus v0.1")) | |
1822 (gnus-convert-old-ticks))))) | |
1823 | |
1824 (defun gnus-convert-old-ticks () | |
1825 (let ((newsrc (cdr gnus-newsrc-alist)) | |
1826 marks info dormant ticked) | |
1827 (while (setq info (pop newsrc)) | |
1828 (when (setq marks (gnus-info-marks info)) | |
1829 (setq dormant (cdr (assq 'dormant marks)) | |
1830 ticked (cdr (assq 'tick marks))) | |
1831 (when (or dormant ticked) | |
1832 (gnus-info-set-read | |
1833 info | |
1834 (gnus-add-to-range | |
1835 (gnus-info-read info) | |
1836 (nconc (gnus-uncompress-range dormant) | |
1837 (gnus-uncompress-range ticked))))))))) | |
1838 | |
1839 (defun gnus-read-newsrc-el-file (file) | |
1840 (let ((ding-file (concat file "d"))) | |
1841 ;; We always, always read the .eld file. | |
1842 (gnus-message 5 "Reading %s..." ding-file) | |
1843 (let (gnus-newsrc-assoc) | |
1844 (condition-case nil | |
1845 (load ding-file t t t) | |
1846 (error | |
1847 (ding) | |
1848 (unless (gnus-yes-or-no-p | |
1849 (format "Error in %s; continue? " ding-file)) | |
1850 (error "Error in %s" ding-file)))) | |
1851 (when gnus-newsrc-assoc | |
1852 (setq gnus-newsrc-alist gnus-newsrc-assoc))) | |
1853 (gnus-make-hashtable-from-newsrc-alist) | |
1854 (when (file-newer-than-file-p file ding-file) | |
1855 ;; Old format quick file | |
1856 (gnus-message 5 "Reading %s..." file) | |
1857 ;; The .el file is newer than the .eld file, so we read that one | |
1858 ;; as well. | |
1859 (gnus-read-old-newsrc-el-file file)))) | |
1860 | |
1861 ;; Parse the old-style quick startup file | |
1862 (defun gnus-read-old-newsrc-el-file (file) | |
1863 (let (newsrc killed marked group m info) | |
1864 (prog1 | |
1865 (let ((gnus-killed-assoc nil) | |
1866 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc) | |
1867 (prog1 | |
1868 (ignore-errors | |
1869 (load file t t t)) | |
1870 (setq newsrc gnus-newsrc-assoc | |
1871 killed gnus-killed-assoc | |
1872 marked gnus-marked-assoc))) | |
1873 (setq gnus-newsrc-alist nil) | |
1874 (while (setq group (pop newsrc)) | |
1875 (if (setq info (gnus-get-info (car group))) | |
1876 (progn | |
1877 (gnus-info-set-read info (cddr group)) | |
1878 (gnus-info-set-level | |
1879 info (if (nth 1 group) gnus-level-default-subscribed | |
1880 gnus-level-default-unsubscribed)) | |
1881 (push info gnus-newsrc-alist)) | |
1882 (push (setq info | |
1883 (list (car group) | |
1884 (if (nth 1 group) gnus-level-default-subscribed | |
1885 gnus-level-default-unsubscribed) | |
1886 (cddr group))) | |
1887 gnus-newsrc-alist)) | |
1888 ;; Copy marks into info. | |
1889 (when (setq m (assoc (car group) marked)) | |
1890 (unless (nthcdr 3 info) | |
1891 (nconc info (list nil))) | |
1892 (gnus-info-set-marks | |
1893 info (list (cons 'tick (gnus-compress-sequence | |
1894 (sort (cdr m) '<) t)))))) | |
1895 (setq newsrc killed) | |
1896 (while newsrc | |
1897 (setcar newsrc (caar newsrc)) | |
1898 (setq newsrc (cdr newsrc))) | |
1899 (setq gnus-killed-list killed)) | |
1900 ;; The .el file version of this variable does not begin with | |
1901 ;; "options", while the .eld version does, so we just add it if it | |
1902 ;; isn't there. | |
1903 (when | |
1904 gnus-newsrc-options | |
1905 (when (not (string-match "^ *options" gnus-newsrc-options)) | |
1906 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options))) | |
1907 (when (not (string-match "\n$" gnus-newsrc-options)) | |
1908 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n"))) | |
1909 ;; Finally, if we read some options lines, we parse them. | |
1910 (unless (string= gnus-newsrc-options "") | |
1911 (gnus-newsrc-parse-options gnus-newsrc-options))) | |
1912 | |
1913 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)) | |
1914 (gnus-make-hashtable-from-newsrc-alist))) | |
1915 | |
1916 (defun gnus-make-newsrc-file (file) | |
1917 "Make server dependent file name by catenating FILE and server host name." | |
1918 (let* ((file (expand-file-name file nil)) | |
1919 (real-file (concat file "-" (nth 1 gnus-select-method)))) | |
1920 (if (or (file-exists-p real-file) | |
1921 (file-exists-p (concat real-file ".el")) | |
1922 (file-exists-p (concat real-file ".eld"))) | |
1923 real-file file))) | |
1924 | |
1925 (defun gnus-newsrc-to-gnus-format () | |
1926 (setq gnus-newsrc-options "") | |
1927 (setq gnus-newsrc-options-n nil) | |
1928 | |
1929 (unless gnus-active-hashtb | |
1930 (setq gnus-active-hashtb (gnus-make-hashtable 4096))) | |
1931 (let ((buf (current-buffer)) | |
1932 (already-read (> (length gnus-newsrc-alist) 1)) | |
1933 group subscribed options-symbol newsrc Options-symbol | |
1934 symbol reads num1) | |
1935 (goto-char (point-min)) | |
1936 ;; We intern the symbol `options' in the active hashtb so that we | |
1937 ;; can `eq' against it later. | |
1938 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil) | |
1939 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil) | |
1940 | |
1941 (while (not (eobp)) | |
1942 ;; We first read the first word on the line by narrowing and | |
1943 ;; then reading into `gnus-active-hashtb'. Most groups will | |
1944 ;; already exist in that hashtb, so this will save some string | |
1945 ;; space. | |
1946 (narrow-to-region | |
1947 (point) | |
1948 (progn (skip-chars-forward "^ \t!:\n") (point))) | |
1949 (goto-char (point-min)) | |
1950 (setq symbol | |
1951 (and (/= (point-min) (point-max)) | |
1952 (let ((obarray gnus-active-hashtb)) (read buf)))) | |
1953 (widen) | |
1954 ;; Now, the symbol we have read is either `options' or a group | |
1955 ;; name. If it is an options line, we just add it to a string. | |
1956 (cond | |
1957 ((or (eq symbol options-symbol) | |
1958 (eq symbol Options-symbol)) | |
1959 (setq gnus-newsrc-options | |
1960 ;; This concating is quite inefficient, but since our | |
1961 ;; thorough studies show that approx 99.37% of all | |
1962 ;; .newsrc files only contain a single options line, we | |
1963 ;; don't give a damn, frankly, my dear. | |
1964 (concat gnus-newsrc-options | |
1965 (buffer-substring | |
1966 (gnus-point-at-bol) | |
1967 ;; Options may continue on the next line. | |
1968 (or (and (re-search-forward "^[^ \t]" nil 'move) | |
1969 (progn (beginning-of-line) (point))) | |
1970 (point))))) | |
1971 (forward-line -1)) | |
1972 (symbol | |
1973 ;; Group names can be just numbers. | |
1974 (when (numberp symbol) | |
1975 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb))) | |
1976 (unless (boundp symbol) | |
1977 (set symbol nil)) | |
1978 ;; It was a group name. | |
1979 (setq subscribed (= (following-char) ?:) | |
1980 group (symbol-name symbol) | |
1981 reads nil) | |
1982 (if (eolp) | |
1983 ;; If the line ends here, this is clearly a buggy line, so | |
1984 ;; we put point a the beginning of line and let the cond | |
1985 ;; below do the error handling. | |
1986 (beginning-of-line) | |
1987 ;; We skip to the beginning of the ranges. | |
1988 (skip-chars-forward "!: \t")) | |
1989 ;; We are now at the beginning of the list of read articles. | |
1990 ;; We read them range by range. | |
1991 (while | |
1992 (cond | |
1993 ((looking-at "[0-9]+") | |
1994 ;; We narrow and read a number instead of buffer-substring/ | |
1995 ;; string-to-int because it's faster. narrow/widen is | |
1996 ;; faster than save-restriction/narrow, and save-restriction | |
1997 ;; produces a garbage object. | |
1998 (setq num1 (progn | |
1999 (narrow-to-region (match-beginning 0) (match-end 0)) | |
2000 (read buf))) | |
2001 (widen) | |
2002 ;; If the next character is a dash, then this is a range. | |
2003 (if (= (following-char) ?-) | |
2004 (progn | |
2005 ;; We read the upper bound of the range. | |
2006 (forward-char 1) | |
2007 (if (not (looking-at "[0-9]+")) | |
2008 ;; This is a buggy line, by we pretend that | |
2009 ;; it's kinda OK. Perhaps the user should be | |
2010 ;; dinged? | |
2011 (push num1 reads) | |
2012 (push | |
2013 (cons num1 | |
2014 (progn | |
2015 (narrow-to-region (match-beginning 0) | |
2016 (match-end 0)) | |
2017 (read buf))) | |
2018 reads) | |
2019 (widen))) | |
2020 ;; It was just a simple number, so we add it to the | |
2021 ;; list of ranges. | |
2022 (push num1 reads)) | |
2023 ;; If the next char in ?\n, then we have reached the end | |
2024 ;; of the line and return nil. | |
2025 (/= (following-char) ?\n)) | |
2026 ((= (following-char) ?\n) | |
2027 ;; End of line, so we end. | |
2028 nil) | |
2029 (t | |
2030 ;; Not numbers and not eol, so this might be a buggy | |
2031 ;; line... | |
2032 (unless (eobp) | |
2033 ;; If it was eob instead of ?\n, we allow it. | |
2034 ;; The line was buggy. | |
2035 (setq group nil) | |
2036 (gnus-error 3.1 "Mangled line: %s" | |
2037 (buffer-substring (gnus-point-at-bol) | |
2038 (gnus-point-at-eol)))) | |
2039 nil)) | |
2040 ;; Skip past ", ". Spaces are illegal in these ranges, but | |
2041 ;; we allow them, because it's a common mistake to put a | |
2042 ;; space after the comma. | |
2043 (skip-chars-forward ", ")) | |
2044 | |
2045 ;; We have already read .newsrc.eld, so we gently update the | |
2046 ;; data in the hash table with the information we have just | |
2047 ;; read. | |
2048 (when group | |
2049 (let ((info (gnus-get-info group)) | |
2050 level) | |
2051 (if info | |
2052 ;; There is an entry for this file in the alist. | |
2053 (progn | |
2054 (gnus-info-set-read info (nreverse reads)) | |
2055 ;; We update the level very gently. In fact, we | |
2056 ;; only change it if there's been a status change | |
2057 ;; from subscribed to unsubscribed, or vice versa. | |
2058 (setq level (gnus-info-level info)) | |
2059 (cond ((and (<= level gnus-level-subscribed) | |
2060 (not subscribed)) | |
2061 (setq level (if reads | |
2062 gnus-level-default-unsubscribed | |
2063 (1+ gnus-level-default-unsubscribed)))) | |
2064 ((and (> level gnus-level-subscribed) subscribed) | |
2065 (setq level gnus-level-default-subscribed))) | |
2066 (gnus-info-set-level info level)) | |
2067 ;; This is a new group. | |
2068 (setq info (list group | |
2069 (if subscribed | |
2070 gnus-level-default-subscribed | |
2071 (if reads | |
2072 (1+ gnus-level-subscribed) | |
2073 gnus-level-default-unsubscribed)) | |
2074 (nreverse reads)))) | |
2075 (push info newsrc))))) | |
2076 (forward-line 1)) | |
2077 | |
2078 (setq newsrc (nreverse newsrc)) | |
2079 | |
2080 (if (not already-read) | |
2081 () | |
2082 ;; We now have two newsrc lists - `newsrc', which is what we | |
2083 ;; have read from .newsrc, and `gnus-newsrc-alist', which is | |
2084 ;; what we've read from .newsrc.eld. We have to merge these | |
2085 ;; lists. We do this by "attaching" any (foreign) groups in the | |
2086 ;; gnus-newsrc-alist to the (native) group that precedes them. | |
2087 (let ((rc (cdr gnus-newsrc-alist)) | |
2088 (prev gnus-newsrc-alist) | |
2089 entry mentry) | |
2090 (while rc | |
2091 (or (null (nth 4 (car rc))) ; It's a native group. | |
2092 (assoc (caar rc) newsrc) ; It's already in the alist. | |
2093 (if (setq entry (assoc (caar prev) newsrc)) | |
2094 (setcdr (setq mentry (memq entry newsrc)) | |
2095 (cons (car rc) (cdr mentry))) | |
2096 (push (car rc) newsrc))) | |
2097 (setq prev rc | |
2098 rc (cdr rc))))) | |
2099 | |
2100 (setq gnus-newsrc-alist newsrc) | |
2101 ;; We make the newsrc hashtb. | |
2102 (gnus-make-hashtable-from-newsrc-alist) | |
2103 | |
2104 ;; Finally, if we read some options lines, we parse them. | |
2105 (unless (string= gnus-newsrc-options "") | |
2106 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
2107 | |
2108 ;; Parse options lines to find "options -n !all rec.all" and stuff. | |
2109 ;; The return value will be a list on the form | |
2110 ;; ((regexp1 . ignore) | |
2111 ;; (regexp2 . subscribe)...) | |
2112 ;; When handling new newsgroups, groups that match a `ignore' regexp | |
2113 ;; will be ignored, and groups that match a `subscribe' regexp will be | |
2114 ;; subscribed. A line like | |
2115 ;; options -n !all rec.all | |
2116 ;; will lead to a list that looks like | |
2117 ;; (("^rec\\..+" . subscribe) | |
2118 ;; ("^.+" . ignore)) | |
2119 ;; So all "rec.*" groups will be subscribed, while all the other | |
2120 ;; groups will be ignored. Note that "options -n !all rec.all" is very | |
2121 ;; different from "options -n rec.all !all". | |
2122 (defun gnus-newsrc-parse-options (options) | |
2123 (let (out eol) | |
2124 (save-excursion | |
2125 (gnus-set-work-buffer) | |
2126 (insert (regexp-quote options)) | |
2127 ;; First we treat all continuation lines. | |
2128 (goto-char (point-min)) | |
2129 (while (re-search-forward "\n[ \t]+" nil t) | |
2130 (replace-match " " t t)) | |
2131 ;; Then we transform all "all"s into ".+"s. | |
2132 (goto-char (point-min)) | |
2133 (while (re-search-forward "\\ball\\b" nil t) | |
2134 (replace-match ".+" t t)) | |
2135 (goto-char (point-min)) | |
2136 ;; We remove all other options than the "-n" ones. | |
2137 (while (re-search-forward "[ \t]-[^n][^-]*" nil t) | |
2138 (replace-match " ") | |
2139 (forward-char -1)) | |
2140 (goto-char (point-min)) | |
2141 | |
2142 ;; We are only interested in "options -n" lines - we | |
2143 ;; ignore the other option lines. | |
2144 (while (re-search-forward "[ \t]-n" nil t) | |
2145 (setq eol | |
2146 (or (save-excursion | |
2147 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t) | |
2148 (- (point) 2))) | |
2149 (gnus-point-at-eol))) | |
2150 ;; Search for all "words"... | |
2151 (while (re-search-forward "[^ \t,\n]+" eol t) | |
2152 (if (= (char-after (match-beginning 0)) ?!) | |
2153 ;; If the word begins with a bang (!), this is a "not" | |
2154 ;; spec. We put this spec (minus the bang) and the | |
2155 ;; symbol `ignore' into the list. | |
2156 (push (cons (concat | |
2157 "^" (buffer-substring | |
2158 (1+ (match-beginning 0)) | |
2159 (match-end 0))) | |
2160 'ignore) | |
2161 out) | |
2162 ;; There was no bang, so this is a "yes" spec. | |
2163 (push (cons (concat "^" (match-string 0)) | |
2164 'subscribe) | |
2165 out)))) | |
2166 | |
2167 (setq gnus-newsrc-options-n out)))) | |
2168 | |
2169 (defun gnus-save-newsrc-file (&optional force) | |
2170 "Save .newsrc file." | |
2171 ;; Note: We cannot save .newsrc file if all newsgroups are removed | |
2172 ;; from the variable gnus-newsrc-alist. | |
2173 (when (and (or gnus-newsrc-alist gnus-killed-list) | |
2174 gnus-current-startup-file) | |
2175 (save-excursion | |
2176 (if (and (or gnus-use-dribble-file gnus-slave) | |
2177 (not force) | |
2178 (or (not gnus-dribble-buffer) | |
2179 (not (buffer-name gnus-dribble-buffer)) | |
2180 (zerop (save-excursion | |
2181 (set-buffer gnus-dribble-buffer) | |
2182 (buffer-size))))) | |
2183 (gnus-message 4 "(No changes need to be saved)") | |
2184 (run-hooks 'gnus-save-newsrc-hook) | |
2185 (if gnus-slave | |
2186 (gnus-slave-save-newsrc) | |
2187 ;; Save .newsrc. | |
2188 (when gnus-save-newsrc-file | |
2189 (gnus-message 8 "Saving %s..." gnus-current-startup-file) | |
2190 (gnus-gnus-to-newsrc-format) | |
2191 (gnus-message 8 "Saving %s...done" gnus-current-startup-file)) | |
2192 ;; Save .newsrc.eld. | |
2193 (set-buffer (get-buffer-create " *Gnus-newsrc*")) | |
2194 (make-local-variable 'version-control) | |
2195 (setq version-control 'never) | |
2196 (setq buffer-file-name | |
2197 (concat gnus-current-startup-file ".eld")) | |
2198 (setq default-directory (file-name-directory buffer-file-name)) | |
2199 (gnus-add-current-to-buffer-list) | |
2200 (buffer-disable-undo (current-buffer)) | |
2201 (erase-buffer) | |
2202 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) | |
2203 (gnus-gnus-to-quick-newsrc-format) | |
2204 (run-hooks 'gnus-save-quick-newsrc-hook) | |
2205 (save-buffer) | |
2206 (kill-buffer (current-buffer)) | |
2207 (gnus-message | |
2208 5 "Saving %s.eld...done" gnus-current-startup-file)) | |
2209 (gnus-dribble-delete-file) | |
2210 (gnus-group-set-mode-line))))) | |
2211 | |
2212 (defun gnus-gnus-to-quick-newsrc-format () | |
2213 "Insert Gnus variables such as gnus-newsrc-alist in lisp format." | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
2214 (let ((print-quoted t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19910
diff
changeset
|
2215 (print-escape-newlines t)) |
17493 | 2216 (insert ";; -*- emacs-lisp -*-\n") |
2217 (insert ";; Gnus startup file.\n") | |
2218 (insert | |
2219 ";; Never delete this file - touch .newsrc instead to force Gnus\n") | |
2220 (insert ";; to read .newsrc.\n") | |
2221 (insert "(setq gnus-newsrc-file-version " | |
2222 (prin1-to-string gnus-version) ")\n") | |
2223 (let* ((gnus-killed-list | |
2224 (if (and gnus-save-killed-list | |
2225 (stringp gnus-save-killed-list)) | |
2226 (gnus-strip-killed-list) | |
2227 gnus-killed-list)) | |
2228 (variables | |
2229 (if gnus-save-killed-list gnus-variable-list | |
2230 ;; Remove the `gnus-killed-list' from the list of variables | |
2231 ;; to be saved, if required. | |
2232 (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))) | |
2233 ;; Peel off the "dummy" group. | |
2234 (gnus-newsrc-alist (cdr gnus-newsrc-alist)) | |
2235 variable) | |
2236 ;; Insert the variables into the file. | |
2237 (while variables | |
2238 (when (and (boundp (setq variable (pop variables))) | |
2239 (symbol-value variable)) | |
2240 (insert "(setq " (symbol-name variable) " '") | |
2241 (gnus-prin1 (symbol-value variable)) | |
2242 (insert ")\n")))))) | |
2243 | |
2244 (defun gnus-strip-killed-list () | |
2245 "Return the killed list minus the groups that match `gnus-save-killed-list'." | |
2246 (let ((list gnus-killed-list) | |
2247 olist) | |
2248 (while list | |
2249 (when (string-match gnus-save-killed-list) | |
2250 (push (car list) olist)) | |
2251 (pop list)) | |
2252 (nreverse olist))) | |
2253 | |
2254 (defun gnus-gnus-to-newsrc-format () | |
2255 ;; Generate and save the .newsrc file. | |
2256 (save-excursion | |
2257 (set-buffer (create-file-buffer gnus-current-startup-file)) | |
2258 (let ((newsrc (cdr gnus-newsrc-alist)) | |
2259 (standard-output (current-buffer)) | |
2260 info ranges range method) | |
2261 (setq buffer-file-name gnus-current-startup-file) | |
2262 (setq default-directory (file-name-directory buffer-file-name)) | |
2263 (buffer-disable-undo (current-buffer)) | |
2264 (erase-buffer) | |
2265 ;; Write options. | |
2266 (when gnus-newsrc-options | |
2267 (insert gnus-newsrc-options)) | |
2268 ;; Write subscribed and unsubscribed. | |
2269 (while (setq info (pop newsrc)) | |
2270 ;; Don't write foreign groups to .newsrc. | |
2271 (when (or (null (setq method (gnus-info-method info))) | |
2272 (equal method "native") | |
2273 (inline (gnus-server-equal method gnus-select-method))) | |
2274 (insert (gnus-info-group info) | |
2275 (if (> (gnus-info-level info) gnus-level-subscribed) | |
2276 "!" ":")) | |
2277 (when (setq ranges (gnus-info-read info)) | |
2278 (insert " ") | |
2279 (if (not (listp (cdr ranges))) | |
2280 (if (= (car ranges) (cdr ranges)) | |
2281 (princ (car ranges)) | |
2282 (princ (car ranges)) | |
2283 (insert "-") | |
2284 (princ (cdr ranges))) | |
2285 (while (setq range (pop ranges)) | |
2286 (if (or (atom range) (= (car range) (cdr range))) | |
2287 (princ (or (and (atom range) range) (car range))) | |
2288 (princ (car range)) | |
2289 (insert "-") | |
2290 (princ (cdr range))) | |
2291 (when ranges | |
2292 (insert ","))))) | |
2293 (insert "\n"))) | |
2294 (make-local-variable 'version-control) | |
2295 (setq version-control 'never) | |
2296 ;; It has been reported that sometime the modtime on the .newsrc | |
2297 ;; file seems to be off. We really do want to overwrite it, so | |
2298 ;; we clear the modtime here before saving. It's a bit odd, | |
2299 ;; though... | |
2300 ;; sometimes the modtime clear isn't sufficient. most brute force: | |
2301 ;; delete the silly thing entirely first. but this fails to provide | |
2302 ;; such niceties as .newsrc~ creation. | |
2303 (if gnus-modtime-botch | |
2304 (delete-file gnus-startup-file) | |
2305 (clear-visited-file-modtime)) | |
2306 (run-hooks 'gnus-save-standard-newsrc-hook) | |
2307 (save-buffer) | |
2308 (kill-buffer (current-buffer))))) | |
2309 | |
2310 | |
2311 ;;; | |
2312 ;;; Slave functions. | |
2313 ;;; | |
2314 | |
2315 (defun gnus-slave-save-newsrc () | |
2316 (save-excursion | |
2317 (set-buffer gnus-dribble-buffer) | |
2318 (let ((slave-name | |
2319 (make-temp-name (concat gnus-current-startup-file "-slave-"))) | |
2320 (modes (ignore-errors | |
2321 (file-modes (concat gnus-current-startup-file ".eld"))))) | |
2322 (gnus-write-buffer slave-name) | |
2323 (when modes | |
2324 (set-file-modes slave-name modes))))) | |
2325 | |
2326 (defun gnus-master-read-slave-newsrc () | |
2327 (let ((slave-files | |
2328 (directory-files | |
2329 (file-name-directory gnus-current-startup-file) | |
2330 t (concat | |
2331 "^" (regexp-quote | |
2332 (concat | |
2333 (file-name-nondirectory gnus-current-startup-file) | |
2334 "-slave-"))) | |
2335 t)) | |
2336 file) | |
2337 (if (not slave-files) | |
2338 () ; There are no slave files to read. | |
2339 (gnus-message 7 "Reading slave newsrcs...") | |
2340 (save-excursion | |
2341 (set-buffer (get-buffer-create " *gnus slave*")) | |
2342 (buffer-disable-undo (current-buffer)) | |
2343 (setq slave-files | |
2344 (sort (mapcar (lambda (file) | |
2345 (list (nth 5 (file-attributes file)) file)) | |
2346 slave-files) | |
2347 (lambda (f1 f2) | |
2348 (or (< (caar f1) (caar f2)) | |
2349 (< (nth 1 (car f1)) (nth 1 (car f2))))))) | |
2350 (while slave-files | |
2351 (erase-buffer) | |
2352 (setq file (nth 1 (car slave-files))) | |
2353 (insert-file-contents file) | |
2354 (when (condition-case () | |
2355 (progn | |
2356 (eval-buffer (current-buffer)) | |
2357 t) | |
2358 (error | |
2359 (gnus-error 3.2 "Possible error in %s" file) | |
2360 nil)) | |
2361 (unless gnus-slave ; Slaves shouldn't delete these files. | |
2362 (ignore-errors | |
2363 (delete-file file)))) | |
2364 (setq slave-files (cdr slave-files)))) | |
2365 (gnus-dribble-touch) | |
2366 (gnus-message 7 "Reading slave newsrcs...done")))) | |
2367 | |
2368 | |
2369 ;;; | |
2370 ;;; Group description. | |
2371 ;;; | |
2372 | |
2373 (defun gnus-read-all-descriptions-files () | |
2374 (let ((methods (cons gnus-select-method | |
2375 (nconc | |
2376 (when (gnus-archive-server-wanted-p) | |
2377 (list "archive")) | |
2378 gnus-secondary-select-methods)))) | |
2379 (while methods | |
2380 (gnus-read-descriptions-file (car methods)) | |
2381 (setq methods (cdr methods))) | |
2382 t)) | |
2383 | |
2384 (defun gnus-read-descriptions-file (&optional method) | |
2385 (let ((method (or method gnus-select-method)) | |
2386 group) | |
2387 (when (stringp method) | |
2388 (setq method (gnus-server-to-method method))) | |
2389 ;; We create the hashtable whether we manage to read the desc file | |
2390 ;; to avoid trying to re-read after a failed read. | |
2391 (unless gnus-description-hashtb | |
2392 (setq gnus-description-hashtb | |
2393 (gnus-make-hashtable (length gnus-active-hashtb)))) | |
2394 ;; Mark this method's desc file as read. | |
2395 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read" | |
2396 gnus-description-hashtb) | |
2397 | |
2398 (gnus-message 5 "Reading descriptions file via %s..." (car method)) | |
2399 (cond | |
2400 ((not (gnus-check-server method)) | |
2401 (gnus-message 1 "Couldn't open server") | |
2402 nil) | |
2403 ((not (gnus-request-list-newsgroups method)) | |
2404 (gnus-message 1 "Couldn't read newsgroups descriptions") | |
2405 nil) | |
2406 (t | |
2407 (save-excursion | |
2408 (save-restriction | |
2409 (set-buffer nntp-server-buffer) | |
2410 (goto-char (point-min)) | |
2411 (when (or (search-forward "\n.\n" nil t) | |
2412 (goto-char (point-max))) | |
2413 (beginning-of-line) | |
2414 (narrow-to-region (point-min) (point))) | |
2415 ;; If these are groups from a foreign select method, we insert the | |
2416 ;; group prefix in front of the group names. | |
2417 (and method (not (inline | |
2418 (gnus-server-equal | |
2419 (gnus-server-get-method nil method) | |
2420 (gnus-server-get-method | |
2421 nil gnus-select-method)))) | |
2422 (let ((prefix (gnus-group-prefixed-name "" method))) | |
2423 (goto-char (point-min)) | |
2424 (while (and (not (eobp)) | |
2425 (progn (insert prefix) | |
2426 (zerop (forward-line 1))))))) | |
2427 (goto-char (point-min)) | |
2428 (while (not (eobp)) | |
2429 ;; If we get an error, we set group to 0, which is not a | |
2430 ;; symbol... | |
2431 (setq group | |
2432 (condition-case () | |
2433 (let ((obarray gnus-description-hashtb)) | |
2434 ;; Group is set to a symbol interned in this | |
2435 ;; hash table. | |
2436 (read nntp-server-buffer)) | |
2437 (error 0))) | |
2438 (skip-chars-forward " \t") | |
2439 ;; ... which leads to this line being effectively ignored. | |
2440 (when (symbolp group) | |
20235
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2441 (let ((str (buffer-substring |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2442 (point) (progn (end-of-line) (point)))) |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2443 (coding |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2444 (and enable-multibyte-characters |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2445 (gnus-mule-get-coding-system (symbol-name group))))) |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2446 (if coding |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2447 (setq str (decode-coding-string str (car coding)))) |
518f3a9e5812
(gnus-read-descriptions-file): Decode
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2448 (set group str))) |
17493 | 2449 (forward-line 1)))) |
2450 (gnus-message 5 "Reading descriptions file...done") | |
2451 t)))) | |
2452 | |
2453 (defun gnus-group-get-description (group) | |
2454 "Get the description of a group by sending XGTITLE to the server." | |
2455 (when (gnus-request-group-description group) | |
2456 (save-excursion | |
2457 (set-buffer nntp-server-buffer) | |
2458 (goto-char (point-min)) | |
2459 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)") | |
2460 (match-string 1))))) | |
2461 | |
2462 ;;;###autoload | |
2463 (defun gnus-declare-backend (name &rest abilities) | |
2464 "Declare backend NAME with ABILITIES as a Gnus backend." | |
2465 (setq gnus-valid-select-methods | |
2466 (nconc gnus-valid-select-methods | |
2467 (list (apply 'list name abilities))))) | |
2468 | |
2469 (defun gnus-set-default-directory () | |
2470 "Set the default directory in the current buffer to `gnus-default-directory'. | |
2471 If this variable is nil, don't do anything." | |
2472 (setq default-directory | |
2473 (if (and gnus-default-directory | |
2474 (file-exists-p gnus-default-directory)) | |
2475 (file-name-as-directory (expand-file-name gnus-default-directory)) | |
2476 default-directory))) | |
2477 | |
2478 (provide 'gnus-start) | |
2479 | |
2480 ;;; gnus-start.el ends here |