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