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