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