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