1 ;;; gnus-start.el --- startup functions for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
35 (autoload 'message-make-date "message")
36 (autoload 'gnus-agent-read-servers-validate "gnus-agent")
37 (autoload 'gnus-agent-save-local "gnus-agent")
38 (autoload 'gnus-agent-possibly-alter-active "gnus-agent")
43 (defvar gnus-agent-covered-methods nil)
44 (defvar gnus-agent-file-loading-local nil)
45 (defvar gnus-agent-file-loading-cache nil))
47 (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc")
49 `.newsrc-SERVER' will be used instead if that exists."
53 (defcustom gnus-backup-startup-file 'never
54 "Whether to create backup files.
55 This variable takes the same values as the `version-control'
58 :type '(choice (const :tag "Never" never)
59 (const :tag "If existing" nil)
60 (other :tag "Always" t)))
62 (defcustom gnus-save-startup-file-via-temp-buffer t
63 "Whether to write the startup file contents to a buffer then save
64 the buffer or write directly to the file. The buffer is faster
65 because all of the contents are written at once. The direct write
66 uses considerably less memory."
68 :type '(choice (const :tag "Write via buffer" t)
69 (const :tag "Write directly to file" nil)))
71 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus")
72 "Your Gnus Emacs-Lisp startup file name.
73 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
77 (defcustom gnus-site-init-file
79 (concat (file-name-directory
80 (directory-file-name installation-directory))
81 "site-lisp/gnus-init")
83 "The site-wide Gnus Emacs-Lisp startup file name, or nil if none.
84 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
86 :type '(choice file (const nil)))
88 (defcustom gnus-default-subscribed-newsgroups nil
89 "List of newsgroups to subscribe, when a user runs Gnus the first time.
90 The value should be a list of strings.
91 If it is t, Gnus will not do anything special the first time it is
92 started; it'll just use the normal newsgroups subscription methods."
94 :type '(choice (repeat string) (const :tag "Nothing special" t)))
96 (defcustom gnus-use-dribble-file t
97 "*Non-nil means that Gnus will use a dribble file to store user updates.
98 If Emacs should crash without saving the .newsrc files, complete
99 information can be restored from the dribble file."
100 :group 'gnus-dribble-file
103 (defcustom gnus-dribble-directory nil
104 "*The directory where dribble files will be saved.
105 If this variable is nil, the directory where the .newsrc files are
107 :group 'gnus-dribble-file
108 :type '(choice directory (const nil)))
110 (defcustom gnus-check-new-newsgroups 'ask-server
111 "*Non-nil means that Gnus will run `gnus-find-new-newsgroups' at startup.
112 This normally finds new newsgroups by comparing the active groups the
113 servers have already reported with those Gnus already knows, either alive
116 When any of the following are true, `gnus-find-new-newsgroups' will instead
117 ask the servers (primary, secondary, and archive servers) to list new
118 groups since the last time it checked:
119 1. This variable is `ask-server'.
120 2. This variable is a list of select methods (see below).
121 3. `gnus-read-active-file' is nil or `some'.
122 4. A prefix argument is given to `gnus-find-new-newsgroups' interactively.
124 Thus, if this variable is `ask-server' or a list of select methods or
125 `gnus-read-active-file' is nil or `some', then the killed list is no
126 longer necessary, so you could safely set `gnus-save-killed-list' to nil.
128 This variable can be a list of select methods which Gnus will query with
129 the `ask-server' method in addition to the primary, secondary, and archive
133 (setq gnus-check-new-newsgroups
134 '((nntp \"some.server\") (nntp \"other.server\")))
136 If this variable is nil, then you have to tell Gnus explicitly to
137 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups]."
139 :type '(choice (const :tag "no" nil)
140 (const :tag "by brute force" t)
141 (const :tag "ask servers" ask-server)
142 (repeat :menu-tag "ask additional servers"
143 :tag "ask additional servers"
145 (sexp :format "%v"))))
147 (defcustom gnus-check-bogus-newsgroups nil
148 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
149 If this variable is nil, then you have to tell Gnus explicitly to
150 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups]."
151 :group 'gnus-start-server
154 (defcustom gnus-read-active-file 'some
155 "*Non-nil means that Gnus will read the entire active file at startup.
156 If this variable is nil, Gnus will only know about the groups in your
159 If this variable is `some', Gnus will try to only read the relevant
160 parts of the active file from the server. Not all servers support
161 this, and it might be quite slow with other servers, but this should
162 generally be faster than both the t and nil value.
164 If you set this variable to nil or `some', you probably still want to
165 be told about new newsgroups that arrive. To do that, set
166 `gnus-check-new-newsgroups' to `ask-server'. This may not work
167 properly with all servers."
168 :group 'gnus-start-server
169 :type '(choice (const nil)
173 (defconst gnus-level-subscribed 5
174 "Groups with levels less than or equal to this variable are subscribed.")
176 (defconst gnus-level-unsubscribed 7
177 "Groups with levels less than or equal to this variable are unsubscribed.
178 Groups with levels less than `gnus-level-subscribed', which should be
179 less than this variable, are subscribed.")
181 (defconst gnus-level-zombie 8
182 "Groups with this level are zombie groups.")
184 (defconst gnus-level-killed 9
185 "Groups with this level are killed.")
187 (defcustom gnus-level-default-subscribed 3
188 "*New subscribed groups will be subscribed at this level."
189 :group 'gnus-group-levels
192 (defcustom gnus-level-default-unsubscribed 6
193 "*New unsubscribed groups will be unsubscribed at this level."
194 :group 'gnus-group-levels
197 (defcustom gnus-activate-level (1+ gnus-level-subscribed)
198 "*Groups higher than this level won't be activated on startup.
199 Setting this variable to something low might save lots of time when
200 you have many groups that you aren't interested in."
201 :group 'gnus-group-levels
204 (defcustom gnus-activate-foreign-newsgroups 4
205 "*If nil, Gnus will not check foreign newsgroups at startup.
206 If it is non-nil, it should be a number between one and nine. Foreign
207 newsgroups that have a level lower or equal to this number will be
208 activated on startup. For instance, if you want to active all
209 subscribed newsgroups, but not the rest, you'd set this variable to
210 `gnus-level-subscribed'.
212 If you subscribe to lots of newsgroups from different servers, startup
213 might take a while. By setting this variable to nil, you'll save time,
214 but you won't be told how many unread articles there are in the
216 :group 'gnus-group-levels
217 :type '(choice integer
218 (const :tag "none" nil)))
220 (defcustom gnus-read-newsrc-file t
221 "*Non-nil means that Gnus will read the `.newsrc' file.
222 Gnus always reads its own startup file, which is called
223 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
224 be readily understood by other newsreaders. If you don't plan on
225 using other newsreaders, set this variable to nil to save some time on
231 (defcustom gnus-save-newsrc-file t
232 "*Non-nil means that Gnus will save the `.newsrc' file.
233 Gnus always saves its own startup file, which is called
234 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
235 be readily understood by other newsreaders. If you don't plan on
236 using other newsreaders, set this variable to nil to save some time on
241 (defcustom gnus-save-killed-list t
242 "*If non-nil, save the list of killed groups to the startup file.
243 If you set this variable to nil, you'll save both time (when starting
244 and quitting) and space (both memory and disk), but it will also mean
245 that Gnus has no record of which groups are new and which are old, so
246 the automatic new newsgroups subscription methods become meaningless.
248 You should always set `gnus-check-new-newsgroups' to `ask-server' or
249 nil if you set this variable to nil.
251 This variable can also be a regexp. In that case, all groups that do
252 not match this regexp will be removed before saving the list."
254 :type '(radio (sexp :format "Non-nil\n"
255 :match (lambda (widget value)
256 (and value (not (stringp value))))
259 (regexp :format "%t: %v\n" :size 0)))
261 (defcustom gnus-ignored-newsgroups
263 '("^to\\." ; not "real" groups
264 "^[0-9. \t]+\\( \\|$\\)" ; all digits in name
265 "^[\"][]\"[#'()]" ; bogus characters
268 "*A regexp to match uninteresting newsgroups in the active file.
269 Any lines in the active file matching this regular expression are
270 removed from the newsgroup list before anything else is done to it,
271 thus making them effectively non-existent."
272 :group 'gnus-group-new
275 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
276 "*Function(s) called with a group name when new group is detected.
277 A few pre-made functions are supplied: `gnus-subscribe-randomly'
278 inserts new groups at the beginning of the list of groups;
279 `gnus-subscribe-alphabetically' inserts new groups in strict
280 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
281 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
282 for your decision; `gnus-subscribe-killed' kills all new groups;
283 `gnus-subscribe-zombies' will make all new groups into zombies;
284 `gnus-subscribe-topics' will enter groups into the topics that
286 :group 'gnus-group-new
287 :type '(radio (function-item gnus-subscribe-randomly)
288 (function-item gnus-subscribe-alphabetically)
289 (function-item gnus-subscribe-hierarchically)
290 (function-item gnus-subscribe-interactively)
291 (function-item gnus-subscribe-killed)
292 (function-item gnus-subscribe-zombies)
293 (function-item gnus-subscribe-topics)
297 (defcustom gnus-subscribe-newsgroup-hooks nil
298 "*Hooks run after you subscribe to a new group.
299 The hooks will be called with new group's name as argument."
300 :group 'gnus-group-new
303 (defcustom gnus-subscribe-options-newsgroup-method
304 'gnus-subscribe-alphabetically
305 "*Function(s) called to subscribe newsgroups mentioned on \"options -n\" lines.
306 If, for instance, you want to subscribe to all newsgroups in the
307 \"no\" and \"alt\" hierarchies, you'd put the following in your
310 options -n no.all alt.all
312 Gnus will the subscribe all new newsgroups in these hierarchies with
313 the subscription method in this variable."
314 :group 'gnus-group-new
315 :type '(radio (function-item gnus-subscribe-randomly)
316 (function-item gnus-subscribe-alphabetically)
317 (function-item gnus-subscribe-hierarchically)
318 (function-item gnus-subscribe-interactively)
319 (function-item gnus-subscribe-killed)
320 (function-item gnus-subscribe-zombies)
321 (function-item gnus-subscribe-topics)
325 (defcustom gnus-subscribe-hierarchical-interactive nil
326 "*If non-nil, Gnus will offer to subscribe hierarchically.
327 When a new hierarchy appears, Gnus will ask the user:
329 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
331 If the user pressed `d', Gnus will descend the hierarchy, `y' will
332 subscribe to all newsgroups in the hierarchy and `s' will skip this
333 hierarchy in its entirety."
334 :group 'gnus-group-new
337 (defcustom gnus-auto-subscribed-groups
338 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl\\|^nnmaildir"
339 "*All new groups that match this regexp will be subscribed automatically.
340 Note that this variable only deals with new groups. It has no effect
341 whatsoever on old groups.
343 New groups that match this regexp will not be handled by
344 `gnus-subscribe-newsgroup-method'. Instead, they will
345 be subscribed using `gnus-subscribe-options-newsgroup-method'."
346 :group 'gnus-group-new
349 (defcustom gnus-options-subscribe nil
350 "*All new groups matching this regexp will be subscribed unconditionally.
351 Note that this variable deals only with new newsgroups. This variable
352 does not affect old newsgroups.
354 New groups that match this regexp will not be handled by
355 `gnus-subscribe-newsgroup-method'. Instead, they will
356 be subscribed using `gnus-subscribe-options-newsgroup-method'."
357 :group 'gnus-group-new
358 :type '(choice regexp
359 (const :tag "none" nil)))
361 (defcustom gnus-options-not-subscribe nil
362 "*All new groups matching this regexp will be ignored.
363 Note that this variable deals only with new newsgroups. This variable
364 does not affect old (already subscribed) newsgroups."
365 :group 'gnus-group-new
366 :type '(choice regexp
367 (const :tag "none" nil)))
369 (defcustom gnus-modtime-botch nil
370 "*Non-nil means .newsrc should be deleted prior to save.
371 Its use is due to the bogus appearance that .newsrc was modified on
376 (defcustom gnus-check-bogus-groups-hook nil
377 "A hook run after removing bogus groups."
378 :group 'gnus-start-server
381 (defcustom gnus-startup-hook nil
382 "A hook called at startup.
383 This hook is called after Gnus is connected to the NNTP server."
387 (defcustom gnus-before-startup-hook nil
388 "A hook called at before startup.
389 This hook is called as the first thing when Gnus is started."
393 (defcustom gnus-started-hook nil
394 "A hook called as the last thing after startup."
398 (defcustom gnus-setup-news-hook
399 '(gnus-fixup-nnimap-unread-after-getting-new-news)
400 "A hook after reading the .newsrc file, but before generating the buffer."
404 (defcustom gnus-get-top-new-news-hook nil
405 "A hook run just before Gnus checks for new news globally."
406 :group 'gnus-group-new
409 (defcustom gnus-get-new-news-hook nil
410 "A hook run just before Gnus checks for new news."
411 :group 'gnus-group-new
414 (defcustom gnus-after-getting-new-news-hook
415 '(gnus-display-time-event-handler
416 gnus-fixup-nnimap-unread-after-getting-new-news)
417 "*A hook run after Gnus checks for new news when Gnus is already running."
418 :group 'gnus-group-new
421 (defcustom gnus-read-newsrc-el-hook nil
422 "A hook called after reading the newsrc.eld? file."
426 (defcustom gnus-save-newsrc-hook nil
427 "A hook called before saving any of the newsrc files."
431 (defcustom gnus-save-quick-newsrc-hook nil
432 "A hook called just before saving the quick newsrc file.
433 Can be used to turn version control on or off."
437 (defcustom gnus-save-standard-newsrc-hook nil
438 "A hook called just before saving the standard newsrc file.
439 Can be used to turn version control on or off."
443 (defcustom gnus-group-mode-hook nil
444 "Hook for Gnus group mode."
445 :group 'gnus-group-various
446 :options '(gnus-topic-mode)
449 (defcustom gnus-always-read-dribble-file nil
450 "Unconditionally read the dribble file."
454 ;;; Internal variables
456 (defvar gnus-ding-file-coding-system mm-universal-coding-system
457 "Coding system for ding file.")
459 (defvar gnus-newsrc-file-version nil)
460 (defvar gnus-override-subscribe-method nil)
461 (defvar gnus-dribble-buffer nil)
462 (defvar gnus-newsrc-options nil
463 "Options line in the .newsrc file.")
465 (defvar gnus-newsrc-options-n nil
466 "List of regexps representing groups to be subscribed/ignored unconditionally.")
468 (defvar gnus-newsrc-last-checked-date nil
469 "Date Gnus last asked server for new newsgroups.")
471 (defvar gnus-current-startup-file nil
472 "Startup file for the current host.")
474 ;; Byte-compiler warning.
475 (defvar gnus-group-line-format)
477 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
478 (defvar gnus-init-inhibit nil)
479 (defun gnus-read-init-file (&optional inhibit-next)
480 ;; Don't load .gnus if the -q option was used.
482 (if gnus-init-inhibit
483 (setq gnus-init-inhibit nil)
484 (setq gnus-init-inhibit inhibit-next)
485 (dolist (file (list gnus-site-init-file gnus-init-file))
487 (locate-library file))
488 (if (or debug-on-error debug-on-quit)
493 (error "Error in %s: %s" file (cadr var))))))))))
495 ;; For subscribing new newsgroup
497 (defun gnus-subscribe-hierarchical-interactive (groups)
498 (let ((groups (sort groups 'string<))
499 prefixes prefix start ans group starts real-group)
501 (setq prefixes (list "^"))
502 (while (and groups prefixes)
503 (while (not (string-match (car prefixes)
504 (gnus-group-real-name (car groups))))
505 (setq prefixes (cdr prefixes)))
506 (setq prefix (car prefixes))
507 (setq start (1- (length prefix)))
508 (if (and (string-match "[^\\.]\\." (gnus-group-real-name (car groups))
512 (concat "^" (substring
513 (gnus-group-real-name (car groups))
515 (string-match prefix (gnus-group-real-name (cadr groups))))
517 (push prefix prefixes)
518 (message "Descend hierarchy %s? ([y]nsq): "
519 (substring prefix 1 (1- (length prefix))))
520 (while (not (memq (setq ans (read-char-exclusive))
521 '(?y ?\n ?\r ?n ?s ?q)))
523 (message "Descend hierarchy %s? ([y]nsq): "
524 (substring prefix 1 (1- (length prefix)))))
527 (setq group (car groups)
528 real-group (gnus-group-real-name group))
529 (string-match prefix real-group))
530 (push group gnus-killed-list)
531 (gnus-sethash group group gnus-killed-hashtb)
532 (setq groups (cdr groups)))
533 (setq starts (cdr starts)))
536 (setq group (car groups)
537 real-group (gnus-group-real-name group))
538 (string-match prefix real-group))
539 (gnus-sethash group group gnus-killed-hashtb)
540 (gnus-subscribe-alphabetically (car groups))
541 (setq groups (cdr groups)))
542 (setq starts (cdr starts)))
545 (setq group (car groups))
546 (push group gnus-killed-list)
547 (gnus-sethash group group gnus-killed-hashtb)
548 (setq groups (cdr groups))))
550 (message "Subscribe %s? ([n]yq)" (car groups))
551 (while (not (memq (setq ans (read-char-exclusive))
552 '(?y ?\n ?\r ?q ?n)))
554 (message "Subscribe %s? ([n]yq)" (car groups)))
555 (setq group (car groups))
557 (gnus-subscribe-alphabetically (car groups))
558 (gnus-sethash group group gnus-killed-hashtb))
561 (setq group (car groups))
562 (push group gnus-killed-list)
563 (gnus-sethash group group gnus-killed-hashtb)
564 (setq groups (cdr groups))))
566 (push group gnus-killed-list)
567 (gnus-sethash group group gnus-killed-hashtb)))
568 (setq groups (cdr groups)))))))
570 (defun gnus-subscribe-randomly (newsgroup)
571 "Subscribe new NEWSGROUP by making it the first newsgroup."
572 (gnus-subscribe-newsgroup newsgroup))
574 (defun gnus-subscribe-alphabetically (newgroup)
575 "Subscribe new NEWGROUP and insert it in alphabetical order."
576 (let ((groups (cdr gnus-newsrc-alist))
578 (while (and (not before) groups)
579 (if (string< newgroup (caar groups))
580 (setq before (caar groups))
581 (setq groups (cdr groups))))
582 (gnus-subscribe-newsgroup newgroup before)))
584 (defun gnus-subscribe-hierarchically (newgroup)
585 "Subscribe new NEWGROUP and insert it in hierarchical newsgroup order."
586 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
588 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file))
590 (let ((groupkey newgroup) before)
591 (while (and (not before) groupkey)
592 (goto-char (point-min))
594 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
595 (while (and (re-search-forward groupkey-re nil t)
597 (setq before (match-string 1))
598 (string< before newgroup)))))
599 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
601 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
602 (substring groupkey (match-beginning 1) (match-end 1)))))
603 (gnus-subscribe-newsgroup newgroup before))
604 (kill-buffer (current-buffer)))))
606 (defun gnus-subscribe-interactively (group)
607 "Subscribe the new GROUP interactively.
608 It is inserted in hierarchical newsgroup order if subscribed. If not,
610 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
611 (gnus-subscribe-hierarchically group)
612 (push group gnus-killed-list)))
614 (defun gnus-subscribe-zombies (group)
615 "Make the new GROUP into a zombie group."
616 (push group gnus-zombie-list))
618 (defun gnus-subscribe-killed (group)
619 "Make the new GROUP a killed group."
620 (push group gnus-killed-list))
622 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
623 "Subscribe new NEWSGROUP.
624 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
625 the first newsgroup."
627 (goto-char (point-min))
628 ;; We subscribe the group by changing its level to `subscribed'.
629 (gnus-group-change-level
630 newsgroup gnus-level-default-subscribed
631 gnus-level-killed (gnus-group-entry (or next "dummy.group")))
632 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
633 (run-hook-with-args 'gnus-subscribe-newsgroup-hooks newsgroup)
636 (defun gnus-read-active-file-p ()
637 "Say whether the active file has been read from `gnus-select-method'."
638 (memq gnus-select-method gnus-have-read-active-file))
640 ;;; General various misc type functions.
642 ;; Silence byte-compiler.
644 (defvar gnus-current-headers)
645 (defvar gnus-thread-indent-array)
646 (defvar gnus-newsgroup-name)
647 (defvar gnus-newsgroup-headers)
648 (defvar gnus-group-list-mode)
649 (defvar gnus-group-mark-positions)
650 (defvar gnus-newsgroup-data)
651 (defvar gnus-newsgroup-unreads)
652 (defvar nnoo-state-alist)
653 (defvar gnus-current-select-method)
654 (defvar mail-sources)
655 (defvar nnmail-scan-directory-mail-source-once)
656 (defvar nnmail-split-history)
657 (defvar nnmail-spool-file))
659 (defun gnus-close-all-servers ()
662 (dolist (server gnus-opened-servers)
663 (gnus-close-server (car server))))
665 (defun gnus-clear-system ()
666 "Clear all variables and buffers."
667 ;; Clear Gnus variables.
668 (let ((variables (remove 'gnus-format-specs gnus-variable-list)))
670 (set (car variables) nil)
671 (setq variables (cdr variables))))
672 ;; Clear other internal variables.
673 (setq gnus-list-of-killed-groups nil
674 gnus-have-read-active-file nil
675 gnus-agent-covered-methods nil
676 gnus-agent-file-loading-local nil
677 gnus-agent-file-loading-cache nil
678 gnus-server-method-cache nil
679 gnus-newsrc-alist nil
680 gnus-newsrc-hashtb nil
683 gnus-killed-hashtb nil
684 gnus-active-hashtb nil
685 gnus-moderated-hashtb nil
686 gnus-description-hashtb nil
687 gnus-current-headers nil
688 gnus-thread-indent-array nil
689 gnus-newsgroup-headers nil
690 gnus-newsgroup-name nil
691 gnus-server-alist nil
692 gnus-group-list-mode nil
693 gnus-opened-servers nil
694 gnus-group-mark-positions nil
695 gnus-newsgroup-data nil
696 gnus-newsgroup-unreads nil
698 gnus-current-select-method nil
699 nnmail-split-history nil
700 gnus-ephemeral-servers nil)
701 (gnus-shutdown 'gnus)
702 ;; Kill the startup file.
703 (and gnus-current-startup-file
704 (get-file-buffer gnus-current-startup-file)
705 (kill-buffer (get-file-buffer gnus-current-startup-file)))
706 ;; Clear the dribble buffer.
708 ;; Kill global KILL file buffer.
709 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
710 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
711 (gnus-kill-buffer nntp-server-buffer)
712 ;; Kill Gnus buffers.
713 (dolist (buffer (gnus-buffers))
714 (gnus-kill-buffer buffer))
715 ;; Remove Gnus frames.
716 (gnus-kill-gnus-frames))
718 (defun gnus-no-server-1 (&optional arg slave)
720 If ARG is a positive number, Gnus will use that as the
721 startup level. If ARG is nil, Gnus will be started at level 2.
722 If ARG is non-nil and not a positive number, Gnus will
723 prompt the user for the name of an NNTP server to use.
724 As opposed to `gnus', this command will not connect to the local server."
726 (let ((val (or arg (1- gnus-level-default-subscribed))))
728 (make-local-variable 'gnus-group-use-permanent-levels)
729 (setq gnus-group-use-permanent-levels val)))
731 (defun gnus-1 (&optional arg dont-connect slave)
733 If ARG is non-nil and a positive number, Gnus will use that as the
734 startup level. If ARG is non-nil and not a positive number, Gnus will
735 prompt the user for the name of an NNTP server to use."
740 (switch-to-buffer gnus-group-buffer)
741 (gnus-group-get-new-news
744 (max (car gnus-group-list-mode) arg))))
748 (gnus-run-hooks 'gnus-before-startup-hook)
749 (nnheader-init-server-buffer)
750 (setq gnus-slave slave)
751 (gnus-read-init-file)
755 (when gnus-simple-splash
756 (setq gnus-simple-splash nil)
761 (= (frame-height) (1+ (window-height))))
764 (let ((level (and (numberp arg) (> arg 0) arg))
770 (gnus-start-news-server (and arg (not level))))))
771 (if (and (not dont-connect)
774 (gnus-run-hooks 'gnus-startup-hook)
775 ;; NNTP server is successfully open.
777 ;; Find the current startup file name.
778 (setq gnus-current-startup-file
779 (gnus-make-newsrc-file gnus-startup-file))
781 ;; Read the dribble file.
782 (when (or gnus-slave gnus-use-dribble-file)
783 (gnus-dribble-read-file))
785 ;; Do the actual startup.
787 (gnus-request-create-group "queue" '(nndraft "")))
788 (gnus-request-create-group "drafts" '(nndraft ""))
789 (gnus-setup-news nil level dont-connect)
790 (gnus-run-hooks 'gnus-setup-news-hook)
791 (gnus-start-draft-setup)
792 ;; Generate the group buffer.
793 (gnus-group-list-groups level)
794 (gnus-group-first-unread-group)
795 (gnus-configure-windows 'group)
796 (gnus-group-set-mode-line)
797 (gnus-run-hooks 'gnus-started-hook))))))
799 (defun gnus-start-draft-setup ()
800 "Make sure the draft group exists."
801 (gnus-request-create-group "drafts" '(nndraft ""))
802 (unless (gnus-group-entry "nndraft:drafts")
803 (let ((gnus-level-default-subscribed 1))
804 (gnus-subscribe-group "nndraft:drafts" nil '(nndraft "")))
805 (gnus-group-set-parameter
806 "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode)))))
813 (defvar gnus-dribble-ignore nil)
814 (defvar gnus-dribble-eval-file nil)
816 (defun gnus-dribble-file-name ()
817 "Return the dribble file for the current .newsrc."
819 (if gnus-dribble-directory
820 (concat (file-name-as-directory gnus-dribble-directory)
821 (file-name-nondirectory gnus-current-startup-file))
822 gnus-current-startup-file)
825 (defun gnus-dribble-enter (string)
826 "Enter STRING into the dribble buffer."
827 (when (and (not gnus-dribble-ignore)
829 (buffer-name gnus-dribble-buffer))
830 (let ((obuf (current-buffer)))
831 (set-buffer gnus-dribble-buffer)
832 (goto-char (point-max))
834 ;; This has been commented by Josh Huber <huber@alum.wpi.edu>
835 ;; It causes problems with both XEmacs and Emacs 21, and doesn't
836 ;; seem to be of much value. (FIXME: remove this after we make sure
838 ;; (set-window-point (get-buffer-window (current-buffer)) (point-max))
839 (bury-buffer gnus-dribble-buffer)
841 (set-buffer gnus-group-buffer)
842 (gnus-group-set-mode-line))
845 (defun gnus-dribble-touch ()
846 "Touch the dribble buffer."
847 (gnus-dribble-enter ""))
849 (defun gnus-dribble-read-file ()
850 "Read the dribble file from disk."
851 (let ((dribble-file (gnus-dribble-file-name)))
853 (set-buffer (setq gnus-dribble-buffer
854 (gnus-get-buffer-create
855 (file-name-nondirectory dribble-file))))
857 (setq buffer-file-name dribble-file)
859 (buffer-disable-undo)
860 (bury-buffer (current-buffer))
861 (set-buffer-modified-p nil)
862 (let ((auto (make-auto-save-file-name))
863 (gnus-dribble-ignore t)
866 (when (or (file-exists-p auto) (file-exists-p dribble-file))
867 ;; Load whichever file is newest -- the auto save file
868 ;; or the "real" file.
869 (if (file-newer-than-file-p auto dribble-file)
870 (nnheader-insert-file-contents auto)
871 (nnheader-insert-file-contents dribble-file))
872 (unless (zerop (buffer-size))
873 (set-buffer-modified-p t))
874 ;; Set the file modes to reflect the .newsrc file modes.
876 (when (and (file-exists-p gnus-current-startup-file)
877 (file-exists-p dribble-file)
878 (setq modes (file-modes gnus-current-startup-file)))
879 (gnus-set-file-modes dribble-file modes))
880 (goto-char (point-min))
881 (when (search-forward "Gnus was exited on purpose" nil t)
883 ;; Possibly eval the file later.
884 (when (or gnus-always-read-dribble-file
887 "Gnus exited on purpose without saving; read auto-save file anyway? "
888 "Gnus auto-save file exists. Do you want to read it? ")))
889 (setq gnus-dribble-eval-file t)))))))
891 (defun gnus-dribble-eval-file ()
892 (when gnus-dribble-eval-file
893 (setq gnus-dribble-eval-file nil)
895 (let ((gnus-dribble-ignore t))
896 (set-buffer gnus-dribble-buffer)
897 (eval-buffer (current-buffer))))))
899 (defun gnus-dribble-delete-file ()
900 (when (file-exists-p (gnus-dribble-file-name))
901 (delete-file (gnus-dribble-file-name)))
902 (when gnus-dribble-buffer
904 (set-buffer gnus-dribble-buffer)
905 (let ((auto (make-auto-save-file-name)))
906 (when (file-exists-p auto)
909 (set-buffer-modified-p nil)))))
911 (defun gnus-dribble-save ()
912 (when (and gnus-dribble-buffer
913 (buffer-name gnus-dribble-buffer))
915 (set-buffer gnus-dribble-buffer)
918 (defun gnus-dribble-clear ()
919 (when (gnus-buffer-exists-p gnus-dribble-buffer)
921 (set-buffer gnus-dribble-buffer)
923 (set-buffer-modified-p nil)
924 (setq buffer-saved-size (buffer-size)))))
928 ;;; Active & Newsrc File Handling
931 (defun gnus-setup-news (&optional rawfile level dont-connect)
932 "Setup news information.
933 If RAWFILE is non-nil, the .newsrc file will also be read.
934 If LEVEL is non-nil, the news will be set up at level LEVEL."
936 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))
937 ;; Binding this variable will inhibit multiple fetchings
938 ;; of the same mail source.
939 (nnmail-fetched-sources (list t)))
942 ;; Clear some variables to re-initialize news information.
943 (setq gnus-newsrc-alist nil
944 gnus-active-hashtb nil)
945 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
946 (gnus-read-newsrc-file rawfile))
948 ;; Make sure the archive server is available to all and sundry.
949 (when gnus-message-archive-method
950 (unless (assoc "archive" gnus-server-alist)
955 ,(nnheader-concat message-directory "archive"))
956 (nnfolder-active-file
957 ,(nnheader-concat message-directory "archive/active"))
958 (nnfolder-get-new-mail nil)
959 (nnfolder-inhibit-expiry t))
962 ;; If we don't read the complete active file, we fill in the
964 (when (or (null gnus-read-active-file)
965 (eq gnus-read-active-file 'some))
966 (gnus-update-active-hashtb-from-killed))
968 ;; Validate agent covered methods now that gnus-server-alist has
970 ;; NOTE: This is here for one purpose only. By validating the
971 ;; agentized server's, it converts the old 5.10.3, and earlier,
972 ;; format to the current format. That enables the agent code
973 ;; within gnus-read-active-file to function correctly.
975 (gnus-agent-read-servers-validate))
977 ;; Read the active file and create `gnus-active-hashtb'.
978 ;; If `gnus-read-active-file' is nil, then we just create an empty
979 ;; hash table. The partial filling out of the hash table will be
980 ;; done in `gnus-get-unread-articles'.
981 (and gnus-read-active-file
983 (gnus-read-active-file nil dont-connect))
985 (unless gnus-active-hashtb
986 (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
988 ;; Initialize the cache.
992 ;; Possibly eval the dribble file.
994 (or gnus-use-dribble-file gnus-slave)
995 (gnus-dribble-eval-file))
997 ;; Slave Gnusii should then clear the dribble buffer.
998 (when (and init gnus-slave)
999 (gnus-dribble-clear))
1001 (gnus-update-format-specifications)
1003 ;; See whether we need to read the description file.
1004 (when (and (boundp 'gnus-group-line-format)
1005 (stringp gnus-group-line-format)
1006 (let ((case-fold-search nil))
1007 (string-match "%[-,0-9]*D" gnus-group-line-format))
1008 (not gnus-description-hashtb)
1010 gnus-read-active-file)
1011 (gnus-read-all-descriptions-files))
1013 ;; Find new newsgroups and treat them.
1014 (when (and init gnus-check-new-newsgroups (not level)
1015 (gnus-check-server gnus-select-method)
1018 (gnus-find-new-newsgroups))
1020 ;; Check and remove bogus newsgroups.
1021 (when (and init gnus-check-bogus-newsgroups
1022 gnus-read-active-file (not level)
1023 (gnus-server-opened gnus-select-method))
1024 (gnus-check-bogus-newsgroups))
1026 ;; We might read in new NoCeM messages here.
1027 (when (and gnus-use-nocem
1030 (gnus-nocem-scan-groups))
1032 ;; Read any slave files.
1033 (gnus-master-read-slave-newsrc)
1035 ;; Find the number of unread articles in each non-dead group.
1036 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
1037 (gnus-get-unread-articles level))))
1039 (defun gnus-call-subscribe-functions (method group)
1040 "Call METHOD to subscribe GROUP.
1041 If no function returns `non-nil', call `gnus-subscribe-zombies'."
1044 (funcall method group))
1047 (dolist (func method)
1048 (if (funcall func group)
1052 (gnus-subscribe-zombies group)))
1054 (defun gnus-find-new-newsgroups (&optional arg)
1055 "Search for new newsgroups and add them.
1056 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method'.
1057 The `-n' option line from .newsrc is respected.
1059 With 1 C-u, use the `ask-server' method to query the server for new
1061 With 2 C-u's, use most complete method possible to query the server
1062 for new groups, and subscribe the new groups as zombies."
1064 (let* ((gnus-subscribe-newsgroup-method
1065 gnus-subscribe-newsgroup-method)
1067 ((or (and (= (or arg 1) 4)
1068 (not (listp gnus-check-new-newsgroups)))
1069 (null gnus-read-active-file)
1070 (eq gnus-read-active-file 'some))
1073 (setq gnus-subscribe-newsgroup-method
1074 'gnus-subscribe-zombies)
1076 (t gnus-check-new-newsgroups))))
1077 (unless (gnus-check-first-time-used)
1078 (if (or (consp check)
1079 (eq check 'ask-server))
1080 ;; Ask the server for new groups.
1081 (gnus-ask-server-for-new-groups)
1082 ;; Go through the active hashtb and look for new groups.
1084 group new-newsgroups)
1085 (gnus-message 5 "Looking for new newsgroups...")
1086 (unless gnus-have-read-active-file
1087 (gnus-read-active-file))
1088 (setq gnus-newsrc-last-checked-date (message-make-date))
1089 (unless gnus-killed-hashtb
1090 (gnus-make-hashtable-from-killed))
1091 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
1092 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
1095 (if (or (null (setq group (symbol-name sym)))
1097 (null (symbol-value sym))
1098 (gnus-gethash group gnus-killed-hashtb)
1099 (gnus-gethash group gnus-newsrc-hashtb))
1101 (let ((do-sub (gnus-matches-options-n group)))
1103 ((eq do-sub 'subscribe)
1104 (setq groups (1+ groups))
1105 (gnus-sethash group group gnus-killed-hashtb)
1106 (gnus-call-subscribe-functions
1107 gnus-subscribe-options-newsgroup-method group))
1108 ((eq do-sub 'ignore)
1111 (setq groups (1+ groups))
1112 (gnus-sethash group group gnus-killed-hashtb)
1113 (if gnus-subscribe-hierarchical-interactive
1114 (push group new-newsgroups)
1115 (gnus-call-subscribe-functions
1116 gnus-subscribe-newsgroup-method group)))))))
1118 (when new-newsgroups
1119 (gnus-subscribe-hierarchical-interactive new-newsgroups))
1121 (gnus-message 5 "%d new newsgroup%s arrived."
1122 groups (if (> groups 1) "s have" " has"))
1123 (gnus-message 5 "No new newsgroups.")))))))
1125 (defun gnus-matches-options-n (group)
1126 ;; Returns `subscribe' if the group is to be unconditionally
1127 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
1128 ;; no match for the group.
1130 ;; First we check the two user variables.
1132 ((and gnus-options-subscribe
1133 (string-match gnus-options-subscribe group))
1135 ((and gnus-auto-subscribed-groups
1136 (string-match gnus-auto-subscribed-groups group))
1138 ((and gnus-options-not-subscribe
1139 (string-match gnus-options-not-subscribe group))
1141 ;; Then we go through the list that was retrieved from the .newsrc
1142 ;; file. This list has elements on the form
1143 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
1144 ;; is in the reverse order of the options line) is returned.
1146 (let ((regs gnus-newsrc-options-n))
1148 (not (string-match (caar regs) group)))
1149 (setq regs (cdr regs)))
1150 (and regs (cdar regs))))))
1152 (defun gnus-ask-server-for-new-groups ()
1153 (let* ((new-date (message-make-date))
1154 (date (or gnus-newsrc-last-checked-date new-date))
1155 (methods (cons gnus-select-method
1157 (when (gnus-archive-server-wanted-p)
1160 (and (consp gnus-check-new-newsgroups)
1161 gnus-check-new-newsgroups)
1162 gnus-secondary-select-methods))))
1164 group new-newsgroups got-new method hashtb
1165 gnus-override-subscribe-method)
1166 (unless gnus-killed-hashtb
1167 (gnus-make-hashtable-from-killed))
1168 ;; Go through both primary and secondary select methods and
1169 ;; request new newsgroups.
1170 (while (setq method (gnus-server-get-method nil (pop methods)))
1171 (setq new-newsgroups nil
1172 gnus-override-subscribe-method method)
1173 (when (and (gnus-check-server method)
1174 (gnus-request-newgroups date method))
1177 hashtb (gnus-make-hashtable 100))
1178 (set-buffer nntp-server-buffer)
1179 ;; Enter all the new groups into a hashtable.
1180 (gnus-active-to-gnus-format method hashtb 'ignore))
1181 ;; Now all new groups from `method' are in `hashtb'.
1184 (if (or (null (setq group (symbol-name group-sym)))
1185 (not (boundp group-sym))
1186 (null (symbol-value group-sym))
1187 (gnus-gethash group gnus-newsrc-hashtb)
1188 (member group gnus-zombie-list)
1189 (member group gnus-killed-list))
1190 ;; The group is already known.
1192 ;; Make this group active.
1193 (when (symbol-value group-sym)
1194 (gnus-set-active group (symbol-value group-sym)))
1195 ;; Check whether we want it or not.
1196 (let ((do-sub (gnus-matches-options-n group)))
1198 ((eq do-sub 'subscribe)
1200 (gnus-sethash group group gnus-killed-hashtb)
1201 (gnus-call-subscribe-functions
1202 gnus-subscribe-options-newsgroup-method group))
1203 ((eq do-sub 'ignore)
1207 (gnus-sethash group group gnus-killed-hashtb)
1208 (if gnus-subscribe-hierarchical-interactive
1209 (push group new-newsgroups)
1210 (gnus-call-subscribe-functions
1211 gnus-subscribe-newsgroup-method group)))))))
1213 (when new-newsgroups
1214 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
1216 (gnus-message 5 "%d new newsgroup%s arrived"
1217 groups (if (> groups 1) "s have" " has"))
1218 (gnus-message 5 "No new newsgroups"))
1220 (setq gnus-newsrc-last-checked-date new-date))
1223 (defun gnus-check-first-time-used ()
1225 ;; First check if any of the following files exist. If they do,
1226 ;; it's not the first time the user has used Gnus.
1227 (dolist (file (list (concat gnus-current-startup-file ".el")
1228 (concat gnus-current-startup-file ".eld")
1229 (concat gnus-startup-file ".el")
1230 (concat gnus-startup-file ".eld")))
1231 (when (file-exists-p file)
1232 (throw 'ended nil)))
1233 (gnus-message 6 "First time user; subscribing you to default groups")
1234 (unless (gnus-read-active-file-p)
1235 (let ((gnus-read-active-file t))
1236 (gnus-read-active-file)))
1237 (setq gnus-newsrc-last-checked-date (message-make-date))
1238 ;; Subscribe to the default newsgroups.
1239 (let ((groups (or gnus-default-subscribed-newsgroups
1240 gnus-backup-default-subscribed-newsgroups))
1243 ;; If t, we subscribe (or not) all groups as if they were new.
1246 (when (setq group (symbol-name sym))
1247 (let ((do-sub (gnus-matches-options-n group)))
1249 ((eq do-sub 'subscribe)
1250 (gnus-sethash group group gnus-killed-hashtb)
1251 (gnus-call-subscribe-functions
1252 gnus-subscribe-options-newsgroup-method group))
1253 ((eq do-sub 'ignore)
1256 (push group gnus-killed-list))))))
1258 (dolist (group groups)
1259 ;; Only subscribe the default groups that are activated.
1260 (when (gnus-active group)
1261 (gnus-group-change-level
1262 group gnus-level-default-subscribed gnus-level-killed)))
1264 (set-buffer gnus-group-buffer)
1265 ;; Don't error if the group already exists. This happens when a
1266 ;; first-time user types 'F'. -- didier
1267 (gnus-group-make-help-group t))
1268 (when gnus-novice-user
1269 (gnus-message 7 "`A k' to list killed groups"))))))
1271 (defun gnus-subscribe-group (group &optional previous method)
1272 "Subscribe GROUP and put it after PREVIOUS."
1273 (gnus-group-change-level
1275 (list t group gnus-level-default-subscribed nil nil method)
1277 gnus-level-default-subscribed gnus-level-killed previous t)
1280 ;; `gnus-group-change-level' is the fundamental function for changing
1281 ;; subscription levels of newsgroups. This might mean just changing
1282 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
1283 ;; again, which subscribes/unsubscribes a group, which is equally
1284 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
1285 ;; from 8-9 to 1-7 means that you remove the group from the list of
1286 ;; killed (or zombie) groups and add them to the (kinda) subscribed
1287 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
1288 ;; which is trivial.
1289 ;; ENTRY can either be a string (newsgroup name) or a list (if
1290 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
1291 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
1293 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
1294 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
1296 (defun gnus-group-change-level (entry level &optional oldlevel
1297 previous fromkilled)
1298 (let (group info active num)
1299 ;; Glean what info we can from the arguments
1301 (if fromkilled (setq group (nth 1 entry))
1302 (setq group (car (nth 2 entry))))
1304 (when (and (stringp entry)
1306 (< oldlevel gnus-level-zombie))
1307 (setq entry (gnus-group-entry entry)))
1308 (if (and (not oldlevel)
1310 (setq oldlevel (gnus-info-level (nth 2 entry)))
1311 (setq oldlevel (or oldlevel gnus-level-killed)))
1312 (when (stringp previous)
1313 (setq previous (gnus-group-entry previous)))
1315 (if (and (>= oldlevel gnus-level-zombie)
1316 (gnus-group-entry group))
1317 ;; We are trying to subscribe a group that is already
1321 (unless (gnus-ephemeral-group-p group)
1323 (format "(gnus-group-change-level %S %S %S %S %S)"
1324 group level oldlevel (car (nth 2 previous)) fromkilled)))
1326 ;; Then we remove the newgroup from any old structures, if needed.
1327 ;; If the group was killed, we remove it from the killed or zombie
1328 ;; list. If not, and it is in fact going to be killed, we remove
1329 ;; it from the newsrc hash table and assoc.
1331 ((>= oldlevel gnus-level-zombie)
1332 ;; oldlevel could be wrong.
1333 (setq gnus-zombie-list (delete group gnus-zombie-list))
1334 (setq gnus-killed-list (delete group gnus-killed-list)))
1336 (when (and (>= level gnus-level-zombie)
1338 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
1340 (setcdr (gnus-group-entry (car (nth 3 entry)))
1342 (setcdr (cdr entry) (cdddr entry)))))
1344 ;; Finally we enter (if needed) the list where it is supposed to
1345 ;; go, and change the subscription level. If it is to be killed,
1346 ;; we enter it into the killed or zombie list.
1348 ((>= level gnus-level-zombie)
1349 ;; Remove from the hash table.
1350 (gnus-sethash group nil gnus-newsrc-hashtb)
1351 ;; We do not enter foreign groups into the list of dead
1353 (unless (gnus-group-foreign-p group)
1354 (if (= level gnus-level-zombie)
1355 (push group gnus-zombie-list)
1356 (if (= oldlevel gnus-level-killed)
1357 ;; Remove from active hashtb.
1358 (unintern group gnus-active-hashtb)
1359 ;; Don't add it into killed-list if it was killed.
1360 (push group gnus-killed-list)))))
1362 ;; If the list is to be entered into the newsrc assoc, and
1363 ;; it was killed, we have to create an entry in the newsrc
1364 ;; hashtb format and fix the pointers in the newsrc assoc.
1365 (if (< oldlevel gnus-level-zombie)
1366 ;; It was alive, and it is going to stay alive, so we
1367 ;; just change the level and don't change any pointers or
1368 ;; hash table entries.
1369 (setcar (cdaddr entry) level)
1371 (setq info (cdr entry)
1373 (setq active (gnus-active group))
1375 (if active (- (1+ (cdr active)) (car active)) t))
1376 ;; Shorten the select method if possible, if we need to
1377 ;; store it at all (native groups).
1378 (let ((method (gnus-method-simplify
1379 (or gnus-override-subscribe-method
1380 (gnus-group-method group)))))
1382 (setq info (list group level nil nil method))
1383 (setq info (list group level nil)))))
1386 (let ((p gnus-newsrc-alist))
1390 (setq entry (cons info (cddr previous)))
1393 (setcdr (cdr previous) entry)
1394 (gnus-sethash group (cons num (cdr previous))
1395 gnus-newsrc-hashtb))
1396 (setcdr previous entry)
1397 (gnus-sethash group (cons num previous)
1398 gnus-newsrc-hashtb))
1400 (setcdr (gnus-group-entry (caadr entry)) entry))
1403 "(gnus-group-set-info '%S)" info)))))
1404 (when gnus-group-change-level-function
1405 (funcall gnus-group-change-level-function
1406 group level oldlevel previous)))))
1408 (defun gnus-kill-newsgroup (newsgroup)
1409 "Obsolete function. Kills a newsgroup."
1410 (gnus-group-change-level
1411 (gnus-group-entry newsgroup) gnus-level-killed))
1413 (defun gnus-check-bogus-newsgroups (&optional confirm)
1414 "Remove bogus newsgroups.
1415 If CONFIRM is non-nil, the user has to confirm the deletion of every
1417 (let ((newsrc (cdr gnus-newsrc-alist))
1418 bogus group entry info)
1419 (gnus-message 5 "Checking bogus newsgroups...")
1420 (unless (gnus-read-active-file-p)
1421 (gnus-read-active-file t))
1422 (when (gnus-read-active-file-p)
1423 ;; Find all bogus newsgroup that are subscribed.
1425 (setq info (pop newsrc)
1426 group (gnus-info-group info))
1427 (unless (or (gnus-active group) ; Active
1428 (and (gnus-info-method info)
1429 (not (gnus-secondary-method-p
1430 (gnus-info-method info))))) ; Foreign
1431 ;; Found a bogus newsgroup.
1432 (push group bogus)))
1435 "Remove bogus group %s? "
1437 ;; Remove all bogus subscribed groups by first killing them, and
1438 ;; then removing them from the list of killed groups.
1439 (when (setq entry (gnus-group-entry group))
1440 (gnus-group-change-level entry gnus-level-killed)
1441 (setq gnus-killed-list (delete group gnus-killed-list))))
1442 bogus '("group" "groups" "remove"))
1443 (while (setq group (pop bogus))
1444 ;; Remove all bogus subscribed groups by first killing them, and
1445 ;; then removing them from the list of killed groups.
1446 (when (setq entry (gnus-group-entry group))
1447 (gnus-group-change-level entry gnus-level-killed)
1448 (setq gnus-killed-list (delete group gnus-killed-list)))))
1449 ;; Then we remove all bogus groups from the list of killed and
1450 ;; zombie groups. They are removed without confirmation.
1451 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
1454 (setq killed (symbol-value (car dead-lists)))
1456 (unless (gnus-active (setq group (pop killed)))
1457 ;; The group is bogus.
1459 (set (car dead-lists)
1460 (delete group (symbol-value (car dead-lists))))))
1461 (setq dead-lists (cdr dead-lists))))
1462 (gnus-run-hooks 'gnus-check-bogus-groups-hook)
1463 (gnus-message 5 "Checking bogus newsgroups...done"))))
1465 (defun gnus-check-duplicate-killed-groups ()
1466 "Remove duplicates from the list of killed groups."
1468 (let ((killed gnus-killed-list))
1470 (gnus-message 9 "%d" (length killed))
1471 (setcdr killed (delete (car killed) (cdr killed)))
1472 (setq killed (cdr killed)))))
1474 ;; We want to inline a function from gnus-cache, so we cheat here:
1476 (defvar gnus-cache-active-hashtb)
1477 (defun gnus-cache-possibly-alter-active (group active)
1478 "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
1479 (when gnus-cache-active-hashtb
1480 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))