1 ;;; gnus-start.el --- startup functions for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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.
36 (eval-when-compile (require 'cl))
38 (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc")
40 `.newsrc-SERVER' will be used instead if that exists."
44 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus")
45 "Your Gnus Emacs-Lisp startup file name.
46 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
50 (defcustom gnus-site-init-file
52 (concat (file-name-directory
53 (directory-file-name installation-directory))
54 "site-lisp/gnus-init")
56 "The site-wide Gnus Emacs-Lisp startup file name, or nil if none.
57 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
59 :type '(choice file (const nil)))
61 (defcustom gnus-default-subscribed-newsgroups nil
62 "List of newsgroups to subscribe, when a user runs Gnus the first time.
63 The value should be a list of strings.
64 If it is t, Gnus will not do anything special the first time it is
65 started; it'll just use the normal newsgroups subscription methods."
67 :type '(choice (repeat string) (const :tag "Nothing special" t)))
69 (defcustom gnus-use-dribble-file t
70 "*Non-nil means that Gnus will use a dribble file to store user updates.
71 If Emacs should crash without saving the .newsrc files, complete
72 information can be restored from the dribble file."
73 :group 'gnus-dribble-file
76 (defcustom gnus-dribble-directory nil
77 "*The directory where dribble files will be saved.
78 If this variable is nil, the directory where the .newsrc files are
80 :group 'gnus-dribble-file
81 :type '(choice directory (const nil)))
83 (defcustom gnus-check-new-newsgroups 'ask-server
84 "*Non-nil means that Gnus will run `gnus-find-new-newsgroups' at startup.
85 This normally finds new newsgroups by comparing the active groups the
86 servers have already reported with those Gnus already knows, either alive
89 When any of the following are true, `gnus-find-new-newsgroups' will instead
90 ask the servers (primary, secondary, and archive servers) to list new
91 groups since the last time it checked:
92 1. This variable is `ask-server'.
93 2. This variable is a list of select methods (see below).
94 3. `gnus-read-active-file' is nil or `some'.
95 4. A prefix argument is given to `gnus-find-new-newsgroups' interactively.
97 Thus, if this variable is `ask-server' or a list of select methods or
98 `gnus-read-active-file' is nil or `some', then the killed list is no
99 longer necessary, so you could safely set `gnus-save-killed-list' to nil.
101 This variable can be a list of select methods which Gnus will query with
102 the `ask-server' method in addition to the primary, secondary, and archive
106 (setq gnus-check-new-newsgroups
107 '((nntp \"some.server\") (nntp \"other.server\")))
109 If this variable is nil, then you have to tell Gnus explicitly to
110 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups]."
112 :type '(choice (const :tag "no" nil)
113 (const :tag "by brute force" t)
114 (const :tag "ask servers" ask-server)
115 (repeat :menu-tag "ask additional servers"
116 :tag "ask additional servers"
118 (sexp :format "%v"))))
120 (defcustom gnus-check-bogus-newsgroups nil
121 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
122 If this variable is nil, then you have to tell Gnus explicitly to
123 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups]."
124 :group 'gnus-start-server
127 (defcustom gnus-read-active-file 'some
128 "*Non-nil means that Gnus will read the entire active file at startup.
129 If this variable is nil, Gnus will only know about the groups in your
132 If this variable is `some', Gnus will try to only read the relevant
133 parts of the active file from the server. Not all servers support
134 this, and it might be quite slow with other servers, but this should
135 generally be faster than both the t and nil value.
137 If you set this variable to nil or `some', you probably still want to
138 be told about new newsgroups that arrive. To do that, set
139 `gnus-check-new-newsgroups' to `ask-server'. This may not work
140 properly with all servers."
141 :group 'gnus-start-server
142 :type '(choice (const nil)
146 (defconst gnus-level-subscribed 5
147 "Groups with levels less than or equal to this variable are subscribed.")
149 (defconst gnus-level-unsubscribed 7
150 "Groups with levels less than or equal to this variable are unsubscribed.
151 Groups with levels less than `gnus-level-subscribed', which should be
152 less than this variable, are subscribed.")
154 (defconst gnus-level-zombie 8
155 "Groups with this level are zombie groups.")
157 (defconst gnus-level-killed 9
158 "Groups with this level are killed.")
160 (defcustom gnus-level-default-subscribed 3
161 "*New subscribed groups will be subscribed at this level."
162 :group 'gnus-group-levels
165 (defcustom gnus-level-default-unsubscribed 6
166 "*New unsubscribed groups will be unsubscribed at this level."
167 :group 'gnus-group-levels
170 (defcustom gnus-activate-level (1+ gnus-level-subscribed)
171 "*Groups higher than this level won't be activated on startup.
172 Setting this variable to something low might save lots of time when
173 you have many groups that you aren't interested in."
174 :group 'gnus-group-levels
177 (defcustom gnus-activate-foreign-newsgroups 4
178 "*If nil, Gnus will not check foreign newsgroups at startup.
179 If it is non-nil, it should be a number between one and nine. Foreign
180 newsgroups that have a level lower or equal to this number will be
181 activated on startup. For instance, if you want to active all
182 subscribed newsgroups, but not the rest, you'd set this variable to
183 `gnus-level-subscribed'.
185 If you subscribe to lots of newsgroups from different servers, startup
186 might take a while. By setting this variable to nil, you'll save time,
187 but you won't be told how many unread articles there are in the
189 :group 'gnus-group-levels
190 :type '(choice integer
191 (const :tag "none" nil)))
193 (defcustom gnus-read-newsrc-file t
194 "*Non-nil means that Gnus will read the `.newsrc' file.
195 Gnus always reads its own startup file, which is called
196 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
197 be readily understood by other newsreaders. If you don't plan on
198 using other newsreaders, set this variable to nil to save some time on
204 (defcustom gnus-save-newsrc-file t
205 "*Non-nil means that Gnus will save the `.newsrc' file.
206 Gnus always saves its own startup file, which is called
207 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
208 be readily understood by other newsreaders. If you don't plan on
209 using other newsreaders, set this variable to nil to save some time on
214 (defcustom gnus-save-killed-list t
215 "*If non-nil, save the list of killed groups to the startup file.
216 If you set this variable to nil, you'll save both time (when starting
217 and quitting) and space (both memory and disk), but it will also mean
218 that Gnus has no record of which groups are new and which are old, so
219 the automatic new newsgroups subscription methods become meaningless.
221 You should always set `gnus-check-new-newsgroups' to `ask-server' or
222 nil if you set this variable to nil.
224 This variable can also be a regexp. In that case, all groups that do
225 not match this regexp will be removed before saving the list."
229 (defcustom gnus-ignored-newsgroups
231 '("^to\\." ; not "real" groups
232 "^[0-9. \t]+\\( \\|$\\)" ; all digits in name
233 "^[\"][]\"[#'()]" ; bogus characters
236 "*A regexp to match uninteresting newsgroups in the active file.
237 Any lines in the active file matching this regular expression are
238 removed from the newsgroup list before anything else is done to it,
239 thus making them effectively non-existent."
240 :group 'gnus-group-new
243 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
244 "*Function(s) called with a group name when new group is detected.
245 A few pre-made functions are supplied: `gnus-subscribe-randomly'
246 inserts new groups at the beginning of the list of groups;
247 `gnus-subscribe-alphabetically' inserts new groups in strict
248 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
249 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
250 for your decision; `gnus-subscribe-killed' kills all new groups;
251 `gnus-subscribe-zombies' will make all new groups into zombies;
252 `gnus-subscribe-topics' will enter groups into the topics that
254 :group 'gnus-group-new
255 :type '(radio (function-item gnus-subscribe-randomly)
256 (function-item gnus-subscribe-alphabetically)
257 (function-item gnus-subscribe-hierarchically)
258 (function-item gnus-subscribe-interactively)
259 (function-item gnus-subscribe-killed)
260 (function-item gnus-subscribe-zombies)
261 (function-item gnus-subscribe-topics)
265 (defcustom gnus-subscribe-newsgroup-hooks nil
266 "*Hooks run after you subscribe to a new group. The hooks will be called
267 with new group's name as argument."
268 :group 'gnus-group-new
271 (defcustom gnus-subscribe-options-newsgroup-method
272 'gnus-subscribe-alphabetically
273 "*Function(s) called to subscribe newsgroups mentioned on \"options -n\" lines.
274 If, for instance, you want to subscribe to all newsgroups in the
275 \"no\" and \"alt\" hierarchies, you'd put the following in your
278 options -n no.all alt.all
280 Gnus will the subscribe all new newsgroups in these hierarchies with
281 the subscription method in this variable."
282 :group 'gnus-group-new
283 :type '(radio (function-item gnus-subscribe-randomly)
284 (function-item gnus-subscribe-alphabetically)
285 (function-item gnus-subscribe-hierarchically)
286 (function-item gnus-subscribe-interactively)
287 (function-item gnus-subscribe-killed)
288 (function-item gnus-subscribe-zombies)
289 (function-item gnus-subscribe-topics)
293 (defcustom gnus-subscribe-hierarchical-interactive nil
294 "*If non-nil, Gnus will offer to subscribe hierarchically.
295 When a new hierarchy appears, Gnus will ask the user:
297 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
299 If the user pressed `d', Gnus will descend the hierarchy, `y' will
300 subscribe to all newsgroups in the hierarchy and `s' will skip this
301 hierarchy in its entirety."
302 :group 'gnus-group-new
305 (defcustom gnus-auto-subscribed-groups
306 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl\\|^nnmaildir"
307 "*All new groups that match this regexp will be subscribed automatically.
308 Note that this variable only deals with new groups. It has no effect
309 whatsoever on old groups.
311 New groups that match this regexp will not be handled by
312 `gnus-subscribe-newsgroup-method'. Instead, they will
313 be subscribed using `gnus-subscribe-options-newsgroup-method'."
314 :group 'gnus-group-new
317 (defcustom gnus-options-subscribe nil
318 "*All new groups matching this regexp will be subscribed unconditionally.
319 Note that this variable deals only with new newsgroups. This variable
320 does not affect old newsgroups.
322 New groups that match this regexp will not be handled by
323 `gnus-subscribe-newsgroup-method'. Instead, they will
324 be subscribed using `gnus-subscribe-options-newsgroup-method'."
325 :group 'gnus-group-new
326 :type '(choice regexp
327 (const :tag "none" nil)))
329 (defcustom gnus-options-not-subscribe nil
330 "*All new groups matching this regexp will be ignored.
331 Note that this variable deals only with new newsgroups. This variable
332 does not affect old (already subscribed) newsgroups."
333 :group 'gnus-group-new
334 :type '(choice regexp
335 (const :tag "none" nil)))
337 (defcustom gnus-modtime-botch nil
338 "*Non-nil means .newsrc should be deleted prior to save.
339 Its use is due to the bogus appearance that .newsrc was modified on
344 (defcustom gnus-check-bogus-groups-hook nil
345 "A hook run after removing bogus groups."
346 :group 'gnus-start-server
349 (defcustom gnus-startup-hook nil
350 "A hook called at startup.
351 This hook is called after Gnus is connected to the NNTP server."
355 (defcustom gnus-before-startup-hook nil
356 "A hook called at before startup.
357 This hook is called as the first thing when Gnus is started."
361 (defcustom gnus-started-hook nil
362 "A hook called as the last thing after startup."
366 (defcustom gnus-setup-news-hook
367 '(gnus-fixup-nnimap-unread-after-getting-new-news)
368 "A hook after reading the .newsrc file, but before generating the buffer."
372 (defcustom gnus-get-new-news-hook nil
373 "A hook run just before Gnus checks for new news."
374 :group 'gnus-group-new
377 (defcustom gnus-after-getting-new-news-hook
378 '(gnus-display-time-event-handler
379 gnus-fixup-nnimap-unread-after-getting-new-news)
380 "*A hook run after Gnus checks for new news when Gnus is already running."
381 :group 'gnus-group-new
384 (defcustom gnus-save-newsrc-hook nil
385 "A hook called before saving any of the newsrc files."
389 (defcustom gnus-save-quick-newsrc-hook nil
390 "A hook called just before saving the quick newsrc file.
391 Can be used to turn version control on or off."
395 (defcustom gnus-save-standard-newsrc-hook nil
396 "A hook called just before saving the standard newsrc file.
397 Can be used to turn version control on or off."
401 (defcustom gnus-group-mode-hook nil
402 "Hook for Gnus group mode."
403 :group 'gnus-group-various
404 :options '(gnus-topic-mode)
407 (defcustom gnus-always-read-dribble-file nil
408 "Unconditionally read the dribble file."
412 ;;; Internal variables
414 (defvar gnus-ding-file-coding-system mm-universal-coding-system
415 "Coding system for ding file.")
417 (defvar gnus-newsrc-file-version nil)
418 (defvar gnus-override-subscribe-method nil)
419 (defvar gnus-dribble-buffer nil)
420 (defvar gnus-newsrc-options nil
421 "Options line in the .newsrc file.")
423 (defvar gnus-newsrc-options-n nil
424 "List of regexps representing groups to be subscribed/ignored unconditionally.")
426 (defvar gnus-newsrc-last-checked-date nil
427 "Date Gnus last asked server for new newsgroups.")
429 (defvar gnus-current-startup-file nil
430 "Startup file for the current host.")
432 ;; Byte-compiler warning.
433 (defvar gnus-group-line-format)
435 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
436 (defvar gnus-init-inhibit nil)
437 (defun gnus-read-init-file (&optional inhibit-next)
438 ;; Don't load .gnus if the -q option was used.
440 (if gnus-init-inhibit
441 (setq gnus-init-inhibit nil)
442 (setq gnus-init-inhibit inhibit-next)
443 (dolist (file (list gnus-site-init-file gnus-init-file))
445 (locate-library file))
446 (if (or debug-on-error debug-on-quit)
451 (error "Error in %s: %s" file (cadr var))))))))))
453 ;; For subscribing new newsgroup
455 (defun gnus-subscribe-hierarchical-interactive (groups)
456 (let ((groups (sort groups 'string<))
457 prefixes prefix start ans group starts)
459 (setq prefixes (list "^"))
460 (while (and groups prefixes)
461 (while (not (string-match (car prefixes) (car groups)))
462 (setq prefixes (cdr prefixes)))
463 (setq prefix (car prefixes))
464 (setq start (1- (length prefix)))
465 (if (and (string-match "[^\\.]\\." (car groups) start)
468 (concat "^" (substring (car groups) 0 (match-end 0))))
469 (string-match prefix (cadr groups)))
471 (push prefix prefixes)
472 (message "Descend hierarchy %s? ([y]nsq): "
473 (substring prefix 1 (1- (length prefix))))
474 (while (not (memq (setq ans (read-char-exclusive))
475 '(?y ?\n ?\r ?n ?s ?q)))
477 (message "Descend hierarchy %s? ([y]nsq): "
478 (substring prefix 1 (1- (length prefix)))))
482 (setq group (car groups))))
483 (push group gnus-killed-list)
484 (gnus-sethash group group gnus-killed-hashtb)
485 (setq groups (cdr groups)))
486 (setq starts (cdr starts)))
490 (setq group (car groups))))
491 (gnus-sethash group group gnus-killed-hashtb)
492 (gnus-subscribe-alphabetically (car groups))
493 (setq groups (cdr groups)))
494 (setq starts (cdr starts)))
497 (setq group (car groups))
498 (push group gnus-killed-list)
499 (gnus-sethash group group gnus-killed-hashtb)
500 (setq groups (cdr groups))))
502 (message "Subscribe %s? ([n]yq)" (car groups))
503 (while (not (memq (setq ans (read-char-exclusive))
504 '(?y ?\n ?\r ?q ?n)))
506 (message "Subscribe %s? ([n]yq)" (car groups)))
507 (setq group (car groups))
509 (gnus-subscribe-alphabetically (car groups))
510 (gnus-sethash group group gnus-killed-hashtb))
513 (setq group (car groups))
514 (push group gnus-killed-list)
515 (gnus-sethash group group gnus-killed-hashtb)
516 (setq groups (cdr groups))))
518 (push group gnus-killed-list)
519 (gnus-sethash group group gnus-killed-hashtb)))
520 (setq groups (cdr groups)))))))
522 (defun gnus-subscribe-randomly (newsgroup)
523 "Subscribe new NEWSGROUP by making it the first newsgroup."
524 (gnus-subscribe-newsgroup newsgroup))
526 (defun gnus-subscribe-alphabetically (newgroup)
527 "Subscribe new NEWSGROUP and insert it in alphabetical order."
528 (let ((groups (cdr gnus-newsrc-alist))
530 (while (and (not before) groups)
531 (if (string< newgroup (caar groups))
532 (setq before (caar groups))
533 (setq groups (cdr groups))))
534 (gnus-subscribe-newsgroup newgroup before)))
536 (defun gnus-subscribe-hierarchically (newgroup)
537 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
538 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
540 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file))
542 (let ((groupkey newgroup) before)
543 (while (and (not before) groupkey)
544 (goto-char (point-min))
546 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
547 (while (and (re-search-forward groupkey-re nil t)
549 (setq before (match-string 1))
550 (string< before newgroup)))))
551 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
553 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
554 (substring groupkey (match-beginning 1) (match-end 1)))))
555 (gnus-subscribe-newsgroup newgroup before))
556 (kill-buffer (current-buffer)))))
558 (defun gnus-subscribe-interactively (group)
559 "Subscribe the new GROUP interactively.
560 It is inserted in hierarchical newsgroup order if subscribed. If not,
562 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
563 (gnus-subscribe-hierarchically group)
564 (push group gnus-killed-list)))
566 (defun gnus-subscribe-zombies (group)
567 "Make the new GROUP into a zombie group."
568 (push group gnus-zombie-list))
570 (defun gnus-subscribe-killed (group)
571 "Make the new GROUP a killed group."
572 (push group gnus-killed-list))
574 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
575 "Subscribe new NEWSGROUP.
576 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
577 the first newsgroup."
579 (goto-char (point-min))
580 ;; We subscribe the group by changing its level to `subscribed'.
581 (gnus-group-change-level
582 newsgroup gnus-level-default-subscribed
583 gnus-level-killed (gnus-gethash (or next "dummy.group")
585 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
586 (run-hook-with-args 'gnus-subscribe-newsgroup-hooks newsgroup)
589 (defun gnus-read-active-file-p ()
590 "Say whether the active file has been read from `gnus-select-method'."
591 (memq gnus-select-method gnus-have-read-active-file))
593 ;;; General various misc type functions.
595 ;; Silence byte-compiler.
596 (defvar gnus-current-headers)
597 (defvar gnus-thread-indent-array)
598 (defvar gnus-newsgroup-name)
599 (defvar gnus-newsgroup-headers)
600 (defvar gnus-group-list-mode)
601 (defvar gnus-group-mark-positions)
602 (defvar gnus-newsgroup-data)
603 (defvar gnus-newsgroup-unreads)
604 (defvar nnoo-state-alist)
605 (defvar gnus-current-select-method)
607 (defun gnus-close-all-servers ()
610 (dolist (server gnus-opened-servers)
611 (gnus-close-server (car server))))
613 (defun gnus-clear-system ()
614 "Clear all variables and buffers."
615 ;; Clear Gnus variables.
616 (let ((variables (remove 'gnus-format-specs gnus-variable-list)))
618 (set (car variables) nil)
619 (setq variables (cdr variables))))
620 ;; Clear other internal variables.
621 (setq gnus-list-of-killed-groups nil
622 gnus-have-read-active-file nil
623 gnus-newsrc-alist nil
624 gnus-newsrc-hashtb nil
627 gnus-killed-hashtb nil
628 gnus-active-hashtb nil
629 gnus-moderated-hashtb nil
630 gnus-description-hashtb nil
631 gnus-current-headers nil
632 gnus-thread-indent-array nil
633 gnus-newsgroup-headers nil
634 gnus-newsgroup-name nil
635 gnus-server-alist nil
636 gnus-group-list-mode nil
637 gnus-opened-servers nil
638 gnus-group-mark-positions nil
639 gnus-newsgroup-data nil
640 gnus-newsgroup-unreads nil
642 gnus-current-select-method nil
643 nnmail-split-history nil
644 gnus-ephemeral-servers nil)
645 (gnus-shutdown 'gnus)
646 ;; Kill the startup file.
647 (and gnus-current-startup-file
648 (get-file-buffer gnus-current-startup-file)
649 (kill-buffer (get-file-buffer gnus-current-startup-file)))
650 ;; Clear the dribble buffer.
652 ;; Kill global KILL file buffer.
653 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
654 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
655 (gnus-kill-buffer nntp-server-buffer)
656 ;; Kill Gnus buffers.
657 (let ((buffers (gnus-buffers)))
659 (mapcar 'kill-buffer buffers)))
660 ;; Remove Gnus frames.
661 (gnus-kill-gnus-frames))
663 (defun gnus-no-server-1 (&optional arg slave)
665 If ARG is a positive number, Gnus will use that as the
666 startup level. If ARG is nil, Gnus will be started at level 2.
667 If ARG is non-nil and not a positive number, Gnus will
668 prompt the user for the name of an NNTP server to use.
669 As opposed to `gnus', this command will not connect to the local server."
671 (let ((val (or arg (1- gnus-level-default-subscribed))))
673 (make-local-variable 'gnus-group-use-permanent-levels)
674 (setq gnus-group-use-permanent-levels val)))
676 (defun gnus-1 (&optional arg dont-connect slave)
678 If ARG is non-nil and a positive number, Gnus will use that as the
679 startup level. If ARG is non-nil and not a positive number, Gnus will
680 prompt the user for the name of an NNTP server to use."
685 (switch-to-buffer gnus-group-buffer)
686 (gnus-group-get-new-news
689 (max (car gnus-group-list-mode) arg))))
693 (gnus-run-hooks 'gnus-before-startup-hook)
694 (nnheader-init-server-buffer)
695 (setq gnus-slave slave)
696 (gnus-read-init-file)
700 (when gnus-simple-splash
701 (setq gnus-simple-splash nil)
706 (= (frame-height) (1+ (window-height))))
709 (let ((level (and (numberp arg) (> arg 0) arg))
715 (gnus-start-news-server (and arg (not level))))))
716 (if (and (not dont-connect)
719 (gnus-run-hooks 'gnus-startup-hook)
720 ;; NNTP server is successfully open.
722 ;; Find the current startup file name.
723 (setq gnus-current-startup-file
724 (gnus-make-newsrc-file gnus-startup-file))
726 ;; Read the dribble file.
727 (when (or gnus-slave gnus-use-dribble-file)
728 (gnus-dribble-read-file))
730 ;; Allow using GroupLens predictions.
731 (when gnus-use-grouplens
733 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
735 ;; Do the actual startup.
737 (gnus-request-create-group "queue" '(nndraft "")))
738 (gnus-request-create-group "drafts" '(nndraft ""))
739 (gnus-setup-news nil level dont-connect)
740 (gnus-run-hooks 'gnus-setup-news-hook)
741 (gnus-start-draft-setup)
742 ;; Generate the group buffer.
743 (gnus-group-list-groups level)
744 (gnus-group-first-unread-group)
745 (gnus-configure-windows 'group)
746 (gnus-group-set-mode-line)
747 (gnus-run-hooks 'gnus-started-hook))))))
749 (defun gnus-start-draft-setup ()
750 "Make sure the draft group exists."
751 (gnus-request-create-group "drafts" '(nndraft ""))
752 (unless (gnus-gethash "nndraft:drafts" gnus-newsrc-hashtb)
753 (let ((gnus-level-default-subscribed 1))
754 (gnus-subscribe-group "nndraft:drafts" nil '(nndraft "")))
755 (gnus-group-set-parameter
756 "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode)))))
759 (defun gnus-unload ()
760 "Unload all Gnus features.
761 \(For some value of `all' or `Gnus'.) Currently, features whose names
762 have prefixes `gnus-', `nn', `mm-' or `rfc' are unloaded. Use
763 cautiously -- unloading may cause trouble."
765 (dolist (feature features)
766 (if (string-match "^\\(gnus-\\|nn\\|mm-\\|rfc\\)" (symbol-name feature))
767 (unload-feature feature 'force))))
774 (defvar gnus-dribble-ignore nil)
775 (defvar gnus-dribble-eval-file nil)
777 (defun gnus-dribble-file-name ()
778 "Return the dribble file for the current .newsrc."
780 (if gnus-dribble-directory
781 (concat (file-name-as-directory gnus-dribble-directory)
782 (file-name-nondirectory gnus-current-startup-file))
783 gnus-current-startup-file)
786 (defun gnus-dribble-enter (string)
787 "Enter STRING into the dribble buffer."
788 (when (and (not gnus-dribble-ignore)
790 (buffer-name gnus-dribble-buffer))
791 (let ((obuf (current-buffer)))
792 (set-buffer gnus-dribble-buffer)
793 (goto-char (point-max))
795 ;; This has been commented by Josh Huber <huber@alum.wpi.edu>
796 ;; It causes problems with both XEmacs and Emacs 21, and doesn't
797 ;; seem to be of much value. (FIXME: remove this after we make sure
799 ;; (set-window-point (get-buffer-window (current-buffer)) (point-max))
800 (bury-buffer gnus-dribble-buffer)
802 (set-buffer gnus-group-buffer)
803 (gnus-group-set-mode-line))
806 (defun gnus-dribble-touch ()
807 "Touch the dribble buffer."
808 (gnus-dribble-enter ""))
810 (defun gnus-dribble-read-file ()
811 "Read the dribble file from disk."
812 (let ((dribble-file (gnus-dribble-file-name)))
814 (set-buffer (setq gnus-dribble-buffer
815 (gnus-get-buffer-create
816 (file-name-nondirectory dribble-file))))
818 (setq buffer-file-name dribble-file)
820 (buffer-disable-undo)
821 (bury-buffer (current-buffer))
822 (set-buffer-modified-p nil)
823 (let ((auto (make-auto-save-file-name))
824 (gnus-dribble-ignore t)
827 (when (or (file-exists-p auto) (file-exists-p dribble-file))
828 ;; Load whichever file is newest -- the auto save file
829 ;; or the "real" file.
830 (if (file-newer-than-file-p auto dribble-file)
831 (nnheader-insert-file-contents auto)
832 (nnheader-insert-file-contents dribble-file))
833 (unless (zerop (buffer-size))
834 (set-buffer-modified-p t))
835 ;; Set the file modes to reflect the .newsrc file modes.
837 (when (and (file-exists-p gnus-current-startup-file)
838 (file-exists-p dribble-file)
839 (setq modes (file-modes gnus-current-startup-file)))
840 (set-file-modes dribble-file modes))
841 (goto-char (point-min))
842 (when (search-forward "Gnus was exited on purpose" nil t)
844 ;; Possibly eval the file later.
845 (when (or gnus-always-read-dribble-file
848 "Gnus exited on purpose without saving; read auto-save file anyway? "
849 "Gnus auto-save file exists. Do you want to read it? ")))
850 (setq gnus-dribble-eval-file t)))))))
852 (defun gnus-dribble-eval-file ()
853 (when gnus-dribble-eval-file
854 (setq gnus-dribble-eval-file nil)
856 (let ((gnus-dribble-ignore t))
857 (set-buffer gnus-dribble-buffer)
858 (eval-buffer (current-buffer))))))
860 (defun gnus-dribble-delete-file ()
861 (when (file-exists-p (gnus-dribble-file-name))
862 (delete-file (gnus-dribble-file-name)))
863 (when gnus-dribble-buffer
865 (set-buffer gnus-dribble-buffer)
866 (let ((auto (make-auto-save-file-name)))
867 (when (file-exists-p auto)
870 (set-buffer-modified-p nil)))))
872 (defun gnus-dribble-save ()
873 (when (and gnus-dribble-buffer
874 (buffer-name gnus-dribble-buffer))
876 (set-buffer gnus-dribble-buffer)
879 (defun gnus-dribble-clear ()
880 (when (gnus-buffer-exists-p gnus-dribble-buffer)
882 (set-buffer gnus-dribble-buffer)
884 (set-buffer-modified-p nil)
885 (setq buffer-saved-size (buffer-size)))))
889 ;;; Active & Newsrc File Handling
892 (defun gnus-setup-news (&optional rawfile level dont-connect)
893 "Setup news information.
894 If RAWFILE is non-nil, the .newsrc file will also be read.
895 If LEVEL is non-nil, the news will be set up at level LEVEL."
897 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))
898 ;; Binding this variable will inhibit multiple fetchings
899 ;; of the same mail source.
900 (nnmail-fetched-sources (list t)))
903 ;; Clear some variables to re-initialize news information.
904 (setq gnus-newsrc-alist nil
905 gnus-active-hashtb nil)
906 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
907 (gnus-read-newsrc-file rawfile))
909 ;; Make sure the archive server is available to all and sundry.
910 (when gnus-message-archive-method
911 (unless (assoc "archive" gnus-server-alist)
916 ,(nnheader-concat message-directory "archive"))
917 (nnfolder-active-file
918 ,(nnheader-concat message-directory "archive/active"))
919 (nnfolder-get-new-mail nil)
920 (nnfolder-inhibit-expiry t))
923 ;; If we don't read the complete active file, we fill in the
925 (when (or (null gnus-read-active-file)
926 (eq gnus-read-active-file 'some))
927 (gnus-update-active-hashtb-from-killed))
929 ;; Read the active file and create `gnus-active-hashtb'.
930 ;; If `gnus-read-active-file' is nil, then we just create an empty
931 ;; hash table. The partial filling out of the hash table will be
932 ;; done in `gnus-get-unread-articles'.
933 (and gnus-read-active-file
935 (gnus-read-active-file nil dont-connect))
937 (unless gnus-active-hashtb
938 (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
940 ;; Initialize the cache.
944 ;; Possibly eval the dribble file.
946 (or gnus-use-dribble-file gnus-slave)
947 (gnus-dribble-eval-file))
949 ;; Slave Gnusii should then clear the dribble buffer.
950 (when (and init gnus-slave)
951 (gnus-dribble-clear))
953 (gnus-update-format-specifications)
955 ;; See whether we need to read the description file.
956 (when (and (boundp 'gnus-group-line-format)
957 (stringp gnus-group-line-format)
958 (let ((case-fold-search nil))
959 (string-match "%[-,0-9]*D" gnus-group-line-format))
960 (not gnus-description-hashtb)
962 gnus-read-active-file)
963 (gnus-read-all-descriptions-files))
965 ;; Find new newsgroups and treat them.
966 (when (and init gnus-check-new-newsgroups (not level)
967 (gnus-check-server gnus-select-method)
970 (gnus-find-new-newsgroups))
972 ;; Check and remove bogus newsgroups.
973 (when (and init gnus-check-bogus-newsgroups
974 gnus-read-active-file (not level)
975 (gnus-server-opened gnus-select-method))
976 (gnus-check-bogus-newsgroups))
978 ;; We might read in new NoCeM messages here.
979 (when (and gnus-use-nocem
982 (gnus-nocem-scan-groups))
984 ;; Read any slave files.
985 (gnus-master-read-slave-newsrc)
987 ;; Find the number of unread articles in each non-dead group.
988 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
989 (gnus-get-unread-articles level))))
991 (defun gnus-call-subscribe-functions (method group)
992 "Call METHOD to subscribe GROUP.
993 If no function returns `non-nil', call `gnus-subscribe-zombies'."
995 ((gnus-functionp method)
996 (funcall method group))
999 (dolist (func method)
1000 (if (funcall func group)
1004 (gnus-subscribe-zombies group)))
1006 (defun gnus-find-new-newsgroups (&optional arg)
1007 "Search for new newsgroups and add them.
1008 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method'.
1009 The `-n' option line from .newsrc is respected.
1011 With 1 C-u, use the `ask-server' method to query the server for new
1013 With 2 C-u's, use most complete method possible to query the server
1014 for new groups, and subscribe the new groups as zombies."
1016 (let* ((gnus-subscribe-newsgroup-method
1017 gnus-subscribe-newsgroup-method)
1019 ((or (and (= (or arg 1) 4)
1020 (not (listp gnus-check-new-newsgroups)))
1021 (null gnus-read-active-file)
1022 (eq gnus-read-active-file 'some))
1025 (setq gnus-subscribe-newsgroup-method
1026 'gnus-subscribe-zombies)
1028 (t gnus-check-new-newsgroups))))
1029 (unless (gnus-check-first-time-used)
1030 (if (or (consp check)
1031 (eq check 'ask-server))
1032 ;; Ask the server for new groups.
1033 (gnus-ask-server-for-new-groups)
1034 ;; Go through the active hashtb and look for new groups.
1036 group new-newsgroups)
1037 (gnus-message 5 "Looking for new newsgroups...")
1038 (unless gnus-have-read-active-file
1039 (gnus-read-active-file))
1040 (setq gnus-newsrc-last-checked-date (message-make-date))
1041 (unless gnus-killed-hashtb
1042 (gnus-make-hashtable-from-killed))
1043 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
1044 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
1047 (if (or (null (setq group (symbol-name sym)))
1049 (null (symbol-value sym))
1050 (gnus-gethash group gnus-killed-hashtb)
1051 (gnus-gethash group gnus-newsrc-hashtb))
1053 (let ((do-sub (gnus-matches-options-n group)))
1055 ((eq do-sub 'subscribe)
1056 (setq groups (1+ groups))
1057 (gnus-sethash group group gnus-killed-hashtb)
1058 (gnus-call-subscribe-functions
1059 gnus-subscribe-options-newsgroup-method group))
1060 ((eq do-sub 'ignore)
1063 (setq groups (1+ groups))
1064 (gnus-sethash group group gnus-killed-hashtb)
1065 (if gnus-subscribe-hierarchical-interactive
1066 (push group new-newsgroups)
1067 (gnus-call-subscribe-functions
1068 gnus-subscribe-newsgroup-method group)))))))
1070 (when new-newsgroups
1071 (gnus-subscribe-hierarchical-interactive new-newsgroups))
1073 (gnus-message 5 "%d new newsgroup%s arrived."
1074 groups (if (> groups 1) "s have" " has"))
1075 (gnus-message 5 "No new newsgroups.")))))))
1077 (defun gnus-matches-options-n (group)
1078 ;; Returns `subscribe' if the group is to be unconditionally
1079 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
1080 ;; no match for the group.
1082 ;; First we check the two user variables.
1084 ((and gnus-options-subscribe
1085 (string-match gnus-options-subscribe group))
1087 ((and gnus-auto-subscribed-groups
1088 (string-match gnus-auto-subscribed-groups group))
1090 ((and gnus-options-not-subscribe
1091 (string-match gnus-options-not-subscribe group))
1093 ;; Then we go through the list that was retrieved from the .newsrc
1094 ;; file. This list has elements on the form
1095 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
1096 ;; is in the reverse order of the options line) is returned.
1098 (let ((regs gnus-newsrc-options-n))
1100 (not (string-match (caar regs) group)))
1101 (setq regs (cdr regs)))
1102 (and regs (cdar regs))))))
1104 (defun gnus-ask-server-for-new-groups ()
1105 (let* ((new-date (message-make-date))
1106 (date (or gnus-newsrc-last-checked-date new-date))
1107 (methods (cons gnus-select-method
1109 (when (gnus-archive-server-wanted-p)
1112 (and (consp gnus-check-new-newsgroups)
1113 gnus-check-new-newsgroups)
1114 gnus-secondary-select-methods))))
1116 group new-newsgroups got-new method hashtb
1117 gnus-override-subscribe-method)
1118 (unless gnus-killed-hashtb
1119 (gnus-make-hashtable-from-killed))
1120 ;; Go through both primary and secondary select methods and
1121 ;; request new newsgroups.
1122 (while (setq method (gnus-server-get-method nil (pop methods)))
1123 (setq new-newsgroups nil
1124 gnus-override-subscribe-method method)
1125 (when (and (gnus-check-server method)
1126 (gnus-request-newgroups date method))
1129 hashtb (gnus-make-hashtable 100))
1130 (set-buffer nntp-server-buffer)
1131 ;; Enter all the new groups into a hashtable.
1132 (gnus-active-to-gnus-format method hashtb 'ignore))
1133 ;; Now all new groups from `method' are in `hashtb'.
1136 (if (or (null (setq group (symbol-name group-sym)))
1137 (not (boundp group-sym))
1138 (null (symbol-value group-sym))
1139 (gnus-gethash group gnus-newsrc-hashtb)
1140 (member group gnus-zombie-list)
1141 (member group gnus-killed-list))
1142 ;; The group is already known.
1144 ;; Make this group active.
1145 (when (symbol-value group-sym)
1146 (gnus-set-active group (symbol-value group-sym)))
1147 ;; Check whether we want it or not.
1148 (let ((do-sub (gnus-matches-options-n group)))
1150 ((eq do-sub 'subscribe)
1152 (gnus-sethash group group gnus-killed-hashtb)
1153 (gnus-call-subscribe-functions
1154 gnus-subscribe-options-newsgroup-method group))
1155 ((eq do-sub 'ignore)
1159 (gnus-sethash group group gnus-killed-hashtb)
1160 (if gnus-subscribe-hierarchical-interactive
1161 (push group new-newsgroups)
1162 (gnus-call-subscribe-functions
1163 gnus-subscribe-newsgroup-method group)))))))
1165 (when new-newsgroups
1166 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
1168 (gnus-message 5 "%d new newsgroup%s arrived"
1169 groups (if (> groups 1) "s have" " has"))
1170 (gnus-message 5 "No new newsgroups"))
1172 (setq gnus-newsrc-last-checked-date new-date))
1175 (defun gnus-check-first-time-used ()
1177 ;; First check if any of the following files exist. If they do,
1178 ;; it's not the first time the user has used Gnus.
1179 (dolist (file (list (concat gnus-current-startup-file ".el")
1180 (concat gnus-current-startup-file ".eld")
1181 (concat gnus-startup-file ".el")
1182 (concat gnus-startup-file ".eld")))
1183 (when (file-exists-p file)
1184 (throw 'ended nil)))
1185 (gnus-message 6 "First time user; subscribing you to default groups")
1186 (unless (gnus-read-active-file-p)
1187 (let ((gnus-read-active-file t))
1188 (gnus-read-active-file)))
1189 (setq gnus-newsrc-last-checked-date (message-make-date))
1190 ;; Subscribe to the default newsgroups.
1191 (let ((groups (or gnus-default-subscribed-newsgroups
1192 gnus-backup-default-subscribed-newsgroups))
1195 ;; If t, we subscribe (or not) all groups as if they were new.
1198 (when (setq group (symbol-name sym))
1199 (let ((do-sub (gnus-matches-options-n group)))
1201 ((eq do-sub 'subscribe)
1202 (gnus-sethash group group gnus-killed-hashtb)
1203 (gnus-call-subscribe-functions
1204 gnus-subscribe-options-newsgroup-method group))
1205 ((eq do-sub 'ignore)
1208 (push group gnus-killed-list))))))
1210 (dolist (group groups)
1211 ;; Only subscribe the default groups that are activated.
1212 (when (gnus-active group)
1213 (gnus-group-change-level
1214 group gnus-level-default-subscribed gnus-level-killed)))
1216 (set-buffer gnus-group-buffer)
1217 ;; Don't error if the group already exists. This happens when a
1218 ;; first-time user types 'F'. -- didier
1219 (gnus-group-make-help-group t))
1220 (when gnus-novice-user
1221 (gnus-message 7 "`A k' to list killed groups"))))))
1223 (defun gnus-subscribe-group (group &optional previous method)
1224 "Subcribe GROUP and put it after PREVIOUS."
1225 (gnus-group-change-level
1227 (list t group gnus-level-default-subscribed nil nil method)
1229 gnus-level-default-subscribed gnus-level-killed previous t)
1232 ;; `gnus-group-change-level' is the fundamental function for changing
1233 ;; subscription levels of newsgroups. This might mean just changing
1234 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
1235 ;; again, which subscribes/unsubscribes a group, which is equally
1236 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
1237 ;; from 8-9 to 1-7 means that you remove the group from the list of
1238 ;; killed (or zombie) groups and add them to the (kinda) subscribed
1239 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
1240 ;; which is trivial.
1241 ;; ENTRY can either be a string (newsgroup name) or a list (if
1242 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
1243 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
1245 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
1246 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
1248 (defun gnus-group-change-level (entry level &optional oldlevel
1249 previous fromkilled)
1250 (let (group info active num)
1251 ;; Glean what info we can from the arguments
1253 (if fromkilled (setq group (nth 1 entry))
1254 (setq group (car (nth 2 entry))))
1256 (when (and (stringp entry)
1258 (< oldlevel gnus-level-zombie))
1259 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
1260 (if (and (not oldlevel)
1262 (setq oldlevel (gnus-info-level (nth 2 entry)))
1263 (setq oldlevel (or oldlevel gnus-level-killed)))
1264 (when (stringp previous)
1265 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
1267 (if (and (>= oldlevel gnus-level-zombie)
1268 (gnus-gethash group gnus-newsrc-hashtb))
1269 ;; We are trying to subscribe a group that is already
1273 (unless (gnus-ephemeral-group-p group)
1275 (format "(gnus-group-change-level %S %S %S %S %S)"
1276 group level oldlevel (car (nth 2 previous)) fromkilled)))
1278 ;; Then we remove the newgroup from any old structures, if needed.
1279 ;; If the group was killed, we remove it from the killed or zombie
1280 ;; list. If not, and it is in fact going to be killed, we remove
1281 ;; it from the newsrc hash table and assoc.
1283 ((>= oldlevel gnus-level-zombie)
1284 ;; oldlevel could be wrong.
1285 (setq gnus-zombie-list (delete group gnus-zombie-list))
1286 (setq gnus-killed-list (delete group gnus-killed-list)))
1288 (when (and (>= level gnus-level-zombie)
1290 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
1292 (setcdr (gnus-gethash (car (nth 3 entry))
1295 (setcdr (cdr entry) (cdddr entry)))))
1297 ;; Finally we enter (if needed) the list where it is supposed to
1298 ;; go, and change the subscription level. If it is to be killed,
1299 ;; we enter it into the killed or zombie list.
1301 ((>= level gnus-level-zombie)
1302 ;; Remove from the hash table.
1303 (gnus-sethash group nil gnus-newsrc-hashtb)
1304 ;; We do not enter foreign groups into the list of dead
1306 (unless (gnus-group-foreign-p group)
1307 (if (= level gnus-level-zombie)
1308 (push group gnus-zombie-list)
1309 (if (= oldlevel gnus-level-killed)
1310 ;; Remove from active hashtb.
1311 (unintern group gnus-active-hashtb)
1312 ;; Don't add it into killed-list if it was killed.
1313 (push group gnus-killed-list)))))
1315 ;; If the list is to be entered into the newsrc assoc, and
1316 ;; it was killed, we have to create an entry in the newsrc
1317 ;; hashtb format and fix the pointers in the newsrc assoc.
1318 (if (< oldlevel gnus-level-zombie)
1319 ;; It was alive, and it is going to stay alive, so we
1320 ;; just change the level and don't change any pointers or
1321 ;; hash table entries.
1322 (setcar (cdaddr entry) level)
1324 (setq info (cdr entry)
1326 (setq active (gnus-active group))
1328 (if active (- (1+ (cdr active)) (car active)) t))
1329 ;; Shorten the select method if possible, if we need to
1330 ;; store it at all (native groups).
1331 (let ((method (gnus-method-simplify
1332 (or gnus-override-subscribe-method
1333 (gnus-group-method group)))))
1335 (setq info (list group level nil nil method))
1336 (setq info (list group level nil)))))
1339 (let ((p gnus-newsrc-alist))
1343 (setq entry (cons info (cddr previous)))
1346 (setcdr (cdr previous) entry)
1347 (gnus-sethash group (cons num (cdr previous))
1348 gnus-newsrc-hashtb))
1349 (setcdr previous entry)
1350 (gnus-sethash group (cons num previous)
1351 gnus-newsrc-hashtb))
1353 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry))
1356 "(gnus-group-set-info '%S)" info)))))
1357 (when gnus-group-change-level-function
1358 (funcall gnus-group-change-level-function
1359 group level oldlevel previous)))))
1361 (defun gnus-kill-newsgroup (newsgroup)
1362 "Obsolete function. Kills a newsgroup."
1363 (gnus-group-change-level
1364 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
1366 (defun gnus-check-bogus-newsgroups (&optional confirm)
1367 "Remove bogus newsgroups.
1368 If CONFIRM is non-nil, the user has to confirm the deletion of every
1370 (let ((newsrc (cdr gnus-newsrc-alist))
1371 bogus group entry info)
1372 (gnus-message 5 "Checking bogus newsgroups...")
1373 (unless (gnus-read-active-file-p)
1374 (gnus-read-active-file t))
1375 (when (gnus-read-active-file-p)
1376 ;; Find all bogus newsgroup that are subscribed.
1378 (setq info (pop newsrc)
1379 group (gnus-info-group info))
1380 (unless (or (gnus-active group) ; Active
1381 (and (gnus-info-method info)
1382 (not (gnus-secondary-method-p
1383 (gnus-info-method info))))) ; Foreign
1384 ;; Found a bogus newsgroup.
1385 (push group bogus)))
1388 "Remove bogus group %s? "
1390 ;; Remove all bogus subscribed groups by first killing them, and
1391 ;; then removing them from the list of killed groups.
1392 (when (setq entry (gnus-gethash group gnus-newsrc-hashtb))
1393 (gnus-group-change-level entry gnus-level-killed)
1394 (setq gnus-killed-list (delete group gnus-killed-list))))
1395 bogus '("group" "groups" "remove"))
1396 (while (setq group (pop bogus))
1397 ;; Remove all bogus subscribed groups by first killing them, and
1398 ;; then removing them from the list of killed groups.
1399 (when (setq entry (gnus-gethash group gnus-newsrc-hashtb))
1400 (gnus-group-change-level entry gnus-level-killed)
1401 (setq gnus-killed-list (delete group gnus-killed-list)))))
1402 ;; Then we remove all bogus groups from the list of killed and
1403 ;; zombie groups. They are removed without confirmation.
1404 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
1407 (setq killed (symbol-value (car dead-lists)))
1409 (unless (gnus-active (setq group (pop killed)))
1410 ;; The group is bogus.
1412 (set (car dead-lists)
1413 (delete group (symbol-value (car dead-lists))))))
1414 (setq dead-lists (cdr dead-lists))))
1415 (gnus-run-hooks 'gnus-check-bogus-groups-hook)
1416 (gnus-message 5 "Checking bogus newsgroups...done"))))
1418 (defun gnus-check-duplicate-killed-groups ()
1419 "Remove duplicates from the list of killed groups."
1421 (let ((killed gnus-killed-list))
1423 (gnus-message 9 "%d" (length killed))
1424 (setcdr killed (delete (car killed) (cdr killed)))
1425 (setq killed (cdr killed)))))
1427 ;; We want to inline a function from gnus-cache, so we cheat here:
1429 (defvar gnus-cache-active-hashtb)
1430 (defun gnus-cache-possibly-alter-active (group active)
1431 "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
1432 (when gnus-cache-active-hashtb
1433 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
1435 (when (< (car cache-active) (car active))
1436 (setcar active (car cache-active)))
1437 (when (> (cdr cache-active) (cdr active))
1438 (setcdr active (cdr cache-active))))))))
1440 (defun gnus-activate-group (group &optional scan dont-check method)
1441 ;; Check whether a group has been activated or not.
1442 ;; If SCAN, request a scan of that group as well.
1443 (let ((method (or method (inline (gnus-find-method-for-group group))))
1445 (and (inline (gnus-check-server method))
1446 ;; We escape all bugs and quit here to make it possible to
1447 ;; continue if a group is so out-there that it reports bugs
1451 (gnus-check-backend-function 'request-scan (car method))
1452 (gnus-request-scan group method))
1454 (if (or debug-on-error debug-on-quit)
1455 (inline (gnus-request-group group dont-check method))
1457 (inline (gnus-request-group group dont-check method))
1460 (message "Quit activating %s" group)
1463 (setq active (gnus-parse-active))
1464 ;; If there are no articles in the group, the GROUP
1465 ;; command may have responded with the `(0 . 0)'. We
1466 ;; ignore this if we already have an active entry
1468 (if (and (zerop (car active))
1469 (zerop (cdr active))
1470 (gnus-active group))
1472 (gnus-set-active group active)
1473 ;; Return the new active info.
1476 (defun gnus-get-unread-articles-in-group (info active &optional update)
1478 ;; Allow the backend to update the info in the group.
1480 (gnus-request-update-info
1481 info (inline (gnus-find-method-for-group
1482 (gnus-info-group info)))))
1483 (gnus-activate-group (gnus-info-group info) nil t))
1485 (let* ((range (gnus-info-read info))
1487 ;; If a cache is present, we may have to alter the active info.
1488 (when (and gnus-use-cache info)
1489 (inline (gnus-cache-possibly-alter-active
1490 (gnus-info-group info) active)))
1491 ;; Modify the list of read articles according to what articles
1492 ;; are available; then tally the unread articles and add the
1493 ;; number to the group hash table entry.
1495 ((zerop (cdr active))
1498 (setq num (- (1+ (cdr active)) (car active))))
1499 ((not (listp (cdr range)))
1500 ;; Fix a single (num . num) range according to the
1501 ;; active hash table.
1502 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
1503 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
1504 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
1505 ;; Compute number of unread articles.
1506 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
1508 ;; The read list is a list of ranges. Fix them according to
1509 ;; the active hash table.
1510 ;; First peel off any elements that are below the lower
1512 (while (and (cdr range)
1514 (or (and (atom (cadr range)) (cadr range))
1516 (if (numberp (car range))
1519 (or (and (numberp (cadr range))
1523 (or (and (numberp (nth 1 range)) (nth 1 range))
1525 (setcdr range (cddr range)))
1526 ;; Adjust the first element to be the same as the lower limit.
1527 (when (and (not (atom (car range)))
1528 (< (cdar range) (car active)))
1529 (setcdr (car range) (1- (car active))))
1530 ;; Then we want to peel off any elements that are higher
1531 ;; than the upper active limit.
1532 (let ((srange range))
1533 ;; Go past all valid elements.
1534 (while (and (cdr srange)
1535 (<= (or (and (atom (cadr srange))
1539 (setq srange (cdr srange)))
1541 ;; Nuke all remaining invalid elements.
1542 (setcdr srange nil))
1544 ;; Adjust the final element.
1545 (when (and (not (atom (car srange)))
1546 (> (cdar srange) (cdr active)))
1547 (setcdr (car srange) (cdr active))))
1548 ;; Compute the number of unread articles.
1550 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
1552 (or (and (atom (car range)) (car range))
1554 (setq range (cdr range)))
1555 (setq num (max 0 (- (cdr active) num)))))
1556 ;; Set the number of unread articles.
1558 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
1561 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
1562 ;; and compute how many unread articles there are in each group.
1563 (defun gnus-get-unread-articles (&optional level)
1564 (setq gnus-server-method-cache nil)
1565 (let* ((newsrc (cdr gnus-newsrc-alist))
1566 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
1569 (cond ((and gnus-activate-foreign-newsgroups
1570 (not (numberp gnus-activate-foreign-newsgroups)))
1571 (1+ gnus-level-subscribed))
1572 ((numberp gnus-activate-foreign-newsgroups)
1573 gnus-activate-foreign-newsgroups)
1576 scanned-methods info group active method retrieve-groups)
1577 (gnus-message 6 "Checking new news...")
1580 (setq active (gnus-active (setq group (gnus-info-group
1581 (setq info (pop newsrc))))))
1583 ;; Check newsgroups. If the user doesn't want to check them, or
1584 ;; they can't be checked (for instance, if the news server can't
1585 ;; be reached) we just set the number of unread articles in this
1586 ;; newsgroup to t. This means that Gnus thinks that there are
1587 ;; unread articles, but it has no idea how many.
1589 ;; To be more explicit:
1590 ;; >0 for an active group with messages
1591 ;; 0 for an active group with no unread messages
1592 ;; nil for non-foreign groups that the user has requested not be checked
1593 ;; t for unchecked foreign groups or bogus groups, or groups that can't
1594 ;; be checked, for one reason or other.
1595 (if (and (setq method (gnus-info-method info))
1599 (setq method (gnus-server-get-method nil method)))))
1600 (not (gnus-secondary-method-p method)))
1601 ;; These groups are foreign. Check the level.
1602 (when (and (<= (gnus-info-level info) foreign-level)
1603 (setq active (gnus-activate-group group 'scan)))
1604 ;; Let the Gnus agent save the active file.
1605 (when (and gnus-agent active (gnus-online method))
1606 (gnus-agent-save-group-info
1607 method (gnus-group-real-name group) active))
1608 (unless (inline (gnus-virtual-group-p group))
1609 (inline (gnus-close-group group)))
1610 (when (fboundp (intern (concat (symbol-name (car method))
1611 "-request-update-info")))
1612 (inline (gnus-request-update-info info method))))
1613 ;; These groups are native or secondary.
1615 ;; We don't want these groups.
1616 ((> (gnus-info-level info) level)
1617 (setq active 'ignore))
1619 ((not gnus-read-active-file)
1620 (if (gnus-check-backend-function 'retrieve-groups group)
1621 ;; if server support gnus-retrieve-groups we push
1622 ;; the group onto retrievegroups for later checking
1623 (if (assoc method retrieve-groups)
1624 (setcdr (assoc method retrieve-groups)
1625 (cons group (cdr (assoc method retrieve-groups))))
1626 (push (list method group) retrieve-groups))
1627 ;; hack: `nnmail-get-new-mail' changes the mail-source depending
1628 ;; on the group, so we must perform a scan for every group
1629 ;; if the users has any directory mail sources.
1630 ;; hack: if `nnmail-scan-directory-mail-source-once' is non-nil,
1631 ;; for it scan all spool files even when the groups are
1634 (or nnmail-scan-directory-mail-source-once
1635 (null (assq 'directory
1637 (if (listp nnmail-spool-file)
1639 (list nnmail-spool-file))))))
1640 (member method scanned-methods))
1641 (setq active (gnus-activate-group group))
1642 (setq active (gnus-activate-group group 'scan))
1643 (push method scanned-methods))
1645 (gnus-close-group group))))))
1647 ;; Get the number of unread articles in the group.
1649 ((eq active 'ignore)
1650 ;; Don't do anything.
1653 (inline (gnus-get-unread-articles-in-group info active t)))
1655 ;; The group couldn't be reached, so we nix out the number of
1656 ;; unread articles and stuff.
1657 (gnus-set-active group nil)
1658 (let ((tmp (gnus-gethash group gnus-newsrc-hashtb)))
1662 ;; iterate through groups on methods which support gnus-retrieve-groups
1663 ;; and fetch a partial active file and use it to find new news.
1664 (dolist (rg retrieve-groups)
1665 (let ((method (or (car rg) gnus-select-method))
1667 (when (gnus-check-server method)
1668 ;; Request that the backend scan its incoming messages.
1669 (when (gnus-check-backend-function 'request-scan (car method))
1670 (gnus-request-scan nil method))
1671 (gnus-read-active-file-2
1672 (mapcar (lambda (group) (gnus-group-real-name group)) groups)
1674 (dolist (group groups)
1676 ((setq active (gnus-active (gnus-info-group
1677 (setq info (gnus-get-info group)))))
1678 (inline (gnus-get-unread-articles-in-group info active t)))
1680 ;; The group couldn't be reached, so we nix out the number of
1681 ;; unread articles and stuff.
1682 (gnus-set-active group nil)
1683 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))))))
1685 (gnus-message 6 "Checking new news...done")))
1687 ;; Create a hash table out of the newsrc alist. The `car's of the
1688 ;; alist elements are used as keys.
1689 (defun gnus-make-hashtable-from-newsrc-alist ()
1690 (let ((alist gnus-newsrc-alist)
1691 (ohashtb gnus-newsrc-hashtb)
1693 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
1695 (setq prev (setq gnus-newsrc-alist
1696 (if (equal (caar gnus-newsrc-alist)
1699 (cons (list "dummy.group" 0 nil) alist)))))
1703 ;; Preserve number of unread articles in groups.
1704 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
1708 alist (cdr alist)))))
1710 (defun gnus-make-hashtable-from-killed ()
1711 "Create a hash table from the killed and zombie lists."
1712 (let ((lists '(gnus-killed-list gnus-zombie-list))
1714 (setq gnus-killed-hashtb
1715 (gnus-make-hashtable
1716 (+ (length gnus-killed-list) (length gnus-zombie-list))))
1718 (setq list (symbol-value (pop lists)))
1720 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
1722 (defun gnus-parse-active ()
1723 "Parse active info in the nntp server buffer."
1725 (set-buffer nntp-server-buffer)
1726 (goto-char (point-min))
1727 ;; Parse the result we got from `gnus-request-group'.
1728 (when (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
1729 (goto-char (match-beginning 1))
1730 (cons (read (current-buffer))
1731 (read (current-buffer))))))
1733 (defun gnus-make-articles-unread (group articles)
1734 "Mark ARTICLES in GROUP as unread."
1735 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
1736 (gnus-gethash (gnus-group-real-name group)
1737 gnus-newsrc-hashtb))))
1738 (ranges (gnus-info-read info))
1741 (when (gnus-member-of-range
1742 (setq article (pop articles)) ranges)
1743 (push article news)))
1745 ;; Enter this list into the group info.
1747 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
1749 ;; Set the number of unread articles in gnus-newsrc-hashtb.
1750 (gnus-get-unread-articles-in-group info (gnus-active group))
1752 ;; Insert the change into the group buffer and the dribble file.
1753 (gnus-group-update-group group t))))
1755 (defun gnus-make-ascending-articles-unread (group articles)
1756 "Mark ascending ARTICLES in GROUP as unread."
1757 (let* ((entry (or (gnus-gethash group gnus-newsrc-hashtb)
1758 (gnus-gethash (gnus-group-real-name group)
1759 gnus-newsrc-hashtb)))
1760 (info (nth 2 entry))
1761 (ranges (gnus-info-read info))
1766 (let ((article (pop articles))) ; get the next article to remove from ranges
1767 (while (let ((range (car ranges))) ; note the current range
1768 (if (atom range) ; single value range
1770 ;; the articles extend past the end of the ranges
1772 (setq articles nil))
1774 ;; this range preceeds the article. Leave the range unmodified.
1778 ;; this range exactly matches the article; REMOVE THE RANGE.
1779 ;; NOTE: When the range being removed is the last range, the list is corrupted by inserting null at its end.
1780 (setcar ranges (cadr ranges))
1781 (setcdr ranges (cddr ranges))
1782 (setq modified (if (car ranges) t 'remove-null))
1784 (let ((min (car range))
1786 ;; I have a min/max range to consider
1787 (cond ((> min max) ; invalid range introduced by splitter
1788 (setcar ranges (cadr ranges))
1789 (setcdr ranges (cddr ranges))
1790 (setq modified (if (car ranges) t 'remove-null))
1793 ;; replace min/max range with a single-value range
1797 ;; this range preceeds the article. Leave the range unmodified.
1801 ;; this article preceeds the range. Return null to move to the
1805 ;; this article splits the range into two parts
1806 (setcdr ranges (cons (cons (1+ article) max) (cdr ranges)))
1807 (setcdr range (1- article))
1812 (when (eq modified 'remove-null)
1813 (setq r (delq nil r)))
1814 ;; Enter this list into the group info.
1815 (gnus-info-set-read info r)
1817 ;; Set the number of unread articles in gnus-newsrc-hashtb.
1818 (gnus-get-unread-articles-in-group info (gnus-active group))
1820 ;; Insert the change into the group buffer and the dribble file.
1821 (gnus-group-update-group group t))))
1823 ;; Enter all dead groups into the hashtb.
1824 (defun gnus-update-active-hashtb-from-killed ()
1825 (let ((hashtb (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
1826 (lists (list gnus-killed-list gnus-zombie-list))
1829 (setq killed (car lists))
1831 (gnus-sethash (car killed) nil hashtb)
1832 (setq killed (cdr killed)))
1833 (setq lists (cdr lists)))))
1835 (defun gnus-get-killed-groups ()
1836 "Go through the active hashtb and mark all unknown groups as killed."
1837 ;; First make sure active file has been read.
1838 (unless (gnus-read-active-file-p)
1839 (let ((gnus-read-active-file t))
1840 (gnus-read-active-file)))
1841 (unless gnus-killed-hashtb
1842 (gnus-make-hashtable-from-killed))
1843 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
1847 (group (symbol-name sym)))
1848 (if (or (null group)
1849 (gnus-gethash group gnus-killed-hashtb)
1850 (gnus-gethash group gnus-newsrc-hashtb))
1852 (let ((do-sub (gnus-matches-options-n group)))
1853 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
1855 (setq groups (1+ groups))
1856 (push group gnus-killed-list)
1857 (gnus-sethash group group gnus-killed-hashtb))))))
1859 (gnus-dribble-touch))
1861 ;; Get the active file(s) from the backend(s).
1862 (defun gnus-read-active-file (&optional force not-native)
1863 (gnus-group-set-mode-line)
1866 (lambda (m) (if (stringp m) (gnus-server-get-method nil m) m))
1868 (if (and (not not-native)
1869 (gnus-check-server gnus-select-method))
1870 ;; The native server is available.
1871 (cons gnus-select-method gnus-secondary-select-methods)
1872 ;; The native server is down, so we just do the
1874 gnus-secondary-select-methods)
1875 ;; Also read from the archive server.
1876 (when (gnus-archive-server-wanted-p)
1877 (list "archive")))))
1879 (setq gnus-have-read-active-file nil)
1881 (set-buffer nntp-server-buffer)
1882 (while (setq method (pop methods))
1883 ;; Only do each method once, in case the methods appear more
1884 ;; than once in this list.
1885 (unless (member method methods)
1886 (if (or debug-on-error debug-on-quit)
1887 (gnus-read-active-file-1 method force)
1889 (gnus-read-active-file-1 method force)
1890 ;; We catch C-g so that we can continue past servers
1891 ;; that do not respond.
1893 (message "Quit reading the active file")
1896 (defun gnus-read-active-file-1 (method force)
1898 (setq where (nth 1 method)
1899 mesg (format "Reading active file%s via %s..."
1900 (if (and where (not (zerop (length where))))
1901 (concat " from " where) "")
1903 (gnus-message 5 mesg)
1904 (when (gnus-check-server method)
1905 ;; Request that the backend scan its incoming messages.
1906 (when (gnus-check-backend-function 'request-scan (car method))
1907 (gnus-request-scan nil method))
1909 ((and (eq gnus-read-active-file 'some)
1910 (gnus-check-backend-function 'retrieve-groups (car method))
1912 (let ((newsrc (cdr gnus-newsrc-alist))
1913 (gmethod (gnus-server-get-method nil method))
1915 (while (setq info (pop newsrc))
1919 (gnus-find-method-for-group
1920 (gnus-info-group info) info))
1922 (push (gnus-group-real-name (gnus-info-group info))
1924 (gnus-read-active-file-2 groups method)))
1928 (if (not (gnus-request-list method))
1929 (unless (equal method gnus-message-archive-method)
1930 (gnus-error 1 "Cannot read active file from %s server"
1932 (gnus-message 5 mesg)
1933 (gnus-active-to-gnus-format method gnus-active-hashtb nil t)
1934 ;; We mark this active file as read.
1935 (push method gnus-have-read-active-file)
1936 (gnus-message 5 "%sdone" mesg)))))))
1938 (defun gnus-read-active-file-2 (groups method)
1939 "Read an active file for GROUPS in METHOD using gnus-retrieve-groups."
1942 (set-buffer nntp-server-buffer)
1943 (gnus-check-server method)
1944 (let ((list-type (gnus-retrieve-groups groups method)))
1945 (cond ((not list-type)
1947 1.2 "Cannot read partial active file from %s server."
1949 ((eq list-type 'active)
1950 (gnus-active-to-gnus-format method gnus-active-hashtb nil t))
1952 (gnus-groups-to-gnus-format method gnus-active-hashtb t)))))))
1954 ;; Read an active file and place the results in `gnus-active-hashtb'.
1955 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors
1958 (setq method gnus-select-method))
1959 (let ((cur (current-buffer))
1961 (if (and gnus-active-hashtb
1962 (not (equal method gnus-select-method)))
1964 (setq gnus-active-hashtb
1965 (if (equal method gnus-select-method)
1966 (gnus-make-hashtable
1967 (count-lines (point-min) (point-max)))
1968 (gnus-make-hashtable 4096)))))))
1969 ;; Delete unnecessary lines.
1970 (goto-char (point-min))
1972 ((string= gnus-ignored-newsgroups "")
1973 (delete-matching-lines "^to\\."))
1975 (delete-matching-lines (concat "^to\\.\\|" gnus-ignored-newsgroups))))
1977 (goto-char (point-min))
1978 (unless (re-search-forward "[\\\"]" nil t)
1979 ;; Make the group names readable as a lisp expression even if they
1980 ;; contain special characters.
1981 (goto-char (point-max))
1982 (while (re-search-backward "[][';?()#]" nil t)
1985 ;; Let the Gnus agent save the active file.
1986 (when (and gnus-agent real-active (gnus-online method))
1987 (gnus-agent-save-active method))
1989 ;; If these are groups from a foreign select method, we insert the
1990 ;; group prefix in front of the group names.
1991 (when (not (gnus-server-equal
1992 (gnus-server-get-method nil method)
1993 (gnus-server-get-method nil gnus-select-method)))
1994 (let ((prefix (gnus-group-prefixed-name "" method)))
1995 (goto-char (point-min))
1996 (while (and (not (eobp))
1998 (when (= (following-char) ?\")
2001 (zerop (forward-line 1)))))))
2002 ;; Store the active file in a hash table.
2003 (goto-char (point-min))
2004 (let (group max min)
2008 (narrow-to-region (point) (gnus-point-at-eol))
2009 ;; group gets set to a symbol interned in the hash table
2010 ;; (what a hack!!) - jwz
2011 (setq group (let ((obarray hashtb)) (read cur)))
2012 ;; ### The extended group name scheme makes
2013 ;; the previous optimization strategy sort of pointless...
2014 (when (stringp group)
2015 (setq group (intern group hashtb)))
2016 (if (and (numberp (setq max (read cur)))
2017 (numberp (setq min (read cur)))
2019 (skip-chars-forward " \t")
2021 (or (eq (char-after) ?=)
2022 (eq (char-after) ?x)
2023 (eq (char-after) ?j)))))
2025 (set group (cons min max))
2026 ;; if group is moderated, stick in moderation table
2027 (when (eq (char-after) ?m)
2028 (unless gnus-moderated-hashtb
2029 (setq gnus-moderated-hashtb (gnus-make-hashtable)))
2030 (gnus-sethash (symbol-name group) t
2031 gnus-moderated-hashtb)))
2037 (unless ignore-errors
2038 (gnus-message 3 "Warning - invalid active: %s"
2040 (gnus-point-at-bol) (gnus-point-at-eol))))))
2042 (forward-line 1)))))
2044 (defun gnus-groups-to-gnus-format (method &optional hashtb real-active)
2045 ;; Parse a "groups" active file.
2046 (let ((cur (current-buffer))
2048 (if (and method gnus-active-hashtb)
2050 (setq gnus-active-hashtb
2051 (gnus-make-hashtable
2052 (count-lines (point-min) (point-max)))))))
2054 (not (gnus-server-equal
2055 (gnus-server-get-method nil method)
2056 (gnus-server-get-method nil gnus-select-method)))
2057 (gnus-group-prefixed-name "" method))))
2059 ;; Let the Gnus agent save the active file.
2062 (gnus-online method)
2063 (gnus-agent-method-p method))
2065 (gnus-agent-save-groups method)
2066 (gnus-active-to-gnus-format method hashtb nil real-active))
2068 (goto-char (point-min))
2069 ;; We split this into to separate loops, one with the prefix
2070 ;; and one without to speed the reading up somewhat.
2072 (let (min max opoint group)
2076 (read cur) (read cur)
2077 (setq min (read cur)
2080 (skip-chars-forward " \t")
2083 (set (let ((obarray hashtb)) (read cur))
2085 (error (and group (symbolp group) (set group nil))))
2087 (let (min max group)
2090 (when (eq (char-after) ?2)
2091 (read cur) (read cur)
2092 (setq min (read cur)
2094 (set (setq group (let ((obarray hashtb)) (read cur)))
2096 (error (and group (symbolp group) (set group nil))))
2097 (forward-line 1)))))))
2099 (defun gnus-read-newsrc-file (&optional force)
2101 If FORCE is non-nil, the .newsrc file is read."
2102 ;; Reset variables that might be defined in the .newsrc.eld file.
2103 (let ((variables (remove 'gnus-format-specs gnus-variable-list)))
2105 (set (car variables) nil)
2106 (setq variables (cdr variables))))
2107 (let* ((newsrc-file gnus-current-startup-file)
2108 (quick-file (concat newsrc-file ".el")))
2110 ;; We always load the .newsrc.eld file. If always contains
2111 ;; much information that can not be gotten from the .newsrc
2112 ;; file (ticked articles, killed groups, foreign methods, etc.)
2113 (gnus-read-newsrc-el-file quick-file)
2115 (when (and gnus-read-newsrc-file
2116 (file-exists-p gnus-current-startup-file)
2118 (and (file-newer-than-file-p newsrc-file quick-file)
2119 (file-newer-than-file-p newsrc-file
2120 (concat quick-file "d")))
2121 (not gnus-newsrc-alist)))
2122 ;; We read the .newsrc file. Note that if there if a
2123 ;; .newsrc.eld file exists, it has already been read, and
2124 ;; the `gnus-newsrc-hashtb' has been created. While reading
2125 ;; the .newsrc file, Gnus will only use the information it
2126 ;; can find there for changing the data already read -
2127 ;; i. e., reading the .newsrc file will not trash the data
2128 ;; already read (except for read articles).
2130 (gnus-message 5 "Reading %s..." newsrc-file)
2131 (set-buffer (nnheader-find-file-noselect newsrc-file))
2132 (buffer-disable-undo)
2133 (gnus-newsrc-to-gnus-format)
2134 (kill-buffer (current-buffer))
2135 (gnus-message 5 "Reading %s...done" newsrc-file)))
2137 ;; Convert old to new.
2138 (gnus-convert-old-newsrc))))
2140 (defun gnus-convert-old-newsrc ()
2141 "Convert old newsrc into the new format, if needed."
2142 (let ((fcv (and gnus-newsrc-file-version
2143 (gnus-continuum-version gnus-newsrc-file-version))))
2145 ;; No .newsrc.eld file was loaded.
2147 ;; Gnus 5 .newsrc.eld was loaded.
2148 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
2149 (gnus-convert-old-ticks)))))
2151 (defun gnus-convert-old-ticks ()
2152 (let ((newsrc (cdr gnus-newsrc-alist))
2153 marks info dormant ticked)
2154 (while (setq info (pop newsrc))
2155 (when (setq marks (gnus-info-marks info))
2156 (setq dormant (cdr (assq 'dormant marks))
2157 ticked (cdr (assq 'tick marks)))
2158 (when (or dormant ticked)
2162 (gnus-info-read info)
2163 (nconc (gnus-uncompress-range dormant)
2164 (gnus-uncompress-range ticked)))))))))
2166 (defun gnus-load (file)
2167 "Load FILE, but in such a way that read errors can be reported."
2169 (insert-file-contents file)
2171 (condition-case type
2172 (let ((form (read (current-buffer))))
2175 (unless (eq (car type) 'end-of-file)
2176 (let ((error (format "Error in %s line %d" file
2177 (count-lines (point-min) (point)))))
2179 (unless (gnus-yes-or-no-p (concat error "; continue? "))
2180 (error "%s" error)))))))))
2182 (defun gnus-read-newsrc-el-file (file)
2183 (let ((ding-file (concat file "d")))
2184 (when (file-exists-p ding-file)
2185 ;; We always, always read the .eld file.
2186 (gnus-message 5 "Reading %s..." ding-file)
2187 (let (gnus-newsrc-assoc)
2188 (let ((coding-system-for-read gnus-ding-file-coding-system))
2189 (gnus-load ding-file))
2190 ;; Older versions of `gnus-format-specs' are no longer valid
2191 ;; in Oort Gnus 0.01.
2193 (and gnus-newsrc-file-version
2194 (gnus-continuum-version gnus-newsrc-file-version))))
2195 (when (or (not version)
2196 (< version 5.090009))
2197 (setq gnus-format-specs gnus-default-format-specs)))
2198 (when gnus-newsrc-assoc
2199 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
2200 (gnus-make-hashtable-from-newsrc-alist)
2201 (when (file-newer-than-file-p file ding-file)
2202 ;; Old format quick file
2203 (gnus-message 5 "Reading %s..." file)
2204 ;; The .el file is newer than the .eld file, so we read that one
2206 (gnus-read-old-newsrc-el-file file)))))
2208 ;; Parse the old-style quick startup file
2209 (defun gnus-read-old-newsrc-el-file (file)
2210 (let (newsrc killed marked group m info)
2212 (let ((gnus-killed-assoc nil)
2213 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
2217 (setq newsrc gnus-newsrc-assoc
2218 killed gnus-killed-assoc
2219 marked gnus-marked-assoc)))
2220 (setq gnus-newsrc-alist nil)
2221 (while (setq group (pop newsrc))
2222 (if (setq info (gnus-get-info (car group)))
2224 (gnus-info-set-read info (cddr group))
2225 (gnus-info-set-level
2226 info (if (nth 1 group) gnus-level-default-subscribed
2227 gnus-level-default-unsubscribed))
2228 (push info gnus-newsrc-alist))
2231 (if (nth 1 group) gnus-level-default-subscribed
2232 gnus-level-default-unsubscribed)
2235 ;; Copy marks into info.
2236 (when (setq m (assoc (car group) marked))
2237 (unless (nthcdr 3 info)
2238 (nconc info (list nil)))
2239 (gnus-info-set-marks
2240 info (list (cons 'tick (gnus-compress-sequence
2241 (sort (cdr m) '<) t))))))
2242 (setq newsrc killed)
2244 (setcar newsrc (caar newsrc))
2245 (setq newsrc (cdr newsrc)))
2246 (setq gnus-killed-list killed))
2247 ;; The .el file version of this variable does not begin with
2248 ;; "options", while the .eld version does, so we just add it if it
2252 (when (not (string-match "^ *options" gnus-newsrc-options))
2253 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
2254 (when (not (string-match "\n$" gnus-newsrc-options))
2255 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
2256 ;; Finally, if we read some options lines, we parse them.
2257 (unless (string= gnus-newsrc-options "")
2258 (gnus-newsrc-parse-options gnus-newsrc-options)))
2260 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
2261 (gnus-make-hashtable-from-newsrc-alist)))
2263 (defun gnus-make-newsrc-file (file)
2264 "Make server dependent file name by catenating FILE and server host name."
2265 (let* ((file (expand-file-name file nil))
2266 (real-file (concat file "-" (nth 1 gnus-select-method))))
2267 (if (or (file-exists-p real-file)
2268 (file-exists-p (concat real-file ".el"))
2269 (file-exists-p (concat real-file ".eld")))
2273 (defun gnus-newsrc-to-gnus-format ()
2274 (setq gnus-newsrc-options "")
2275 (setq gnus-newsrc-options-n nil)
2277 (unless gnus-active-hashtb
2278 (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
2279 (let ((buf (current-buffer))
2280 (already-read (> (length gnus-newsrc-alist) 1))
2281 group subscribed options-symbol newsrc Options-symbol
2283 (goto-char (point-min))
2284 ;; We intern the symbol `options' in the active hashtb so that we
2285 ;; can `eq' against it later.
2286 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
2287 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
2290 ;; We first read the first word on the line by narrowing and
2291 ;; then reading into `gnus-active-hashtb'. Most groups will
2292 ;; already exist in that hashtb, so this will save some string
2296 (progn (skip-chars-forward "^ \t!:\n") (point)))
2297 (goto-char (point-min))
2299 (and (/= (point-min) (point-max))
2300 (let ((obarray gnus-active-hashtb)) (read buf))))
2302 ;; Now, the symbol we have read is either `options' or a group
2303 ;; name. If it is an options line, we just add it to a string.
2305 ((or (eq symbol options-symbol)
2306 (eq symbol Options-symbol))
2307 (setq gnus-newsrc-options
2308 ;; This concating is quite inefficient, but since our
2309 ;; thorough studies show that approx 99.37% of all
2310 ;; .newsrc files only contain a single options line, we
2311 ;; don't give a damn, frankly, my dear.
2312 (concat gnus-newsrc-options
2315 ;; Options may continue on the next line.
2316 (or (and (re-search-forward "^[^ \t]" nil 'move)
2317 (progn (beginning-of-line) (point)))
2321 ;; Group names can be just numbers.
2322 (when (numberp symbol)
2323 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
2324 (unless (boundp symbol)
2326 ;; It was a group name.
2327 (setq subscribed (eq (char-after) ?:)
2328 group (symbol-name symbol)
2331 ;; If the line ends here, this is clearly a buggy line, so
2332 ;; we put point a the beginning of line and let the cond
2333 ;; below do the error handling.
2335 ;; We skip to the beginning of the ranges.
2336 (skip-chars-forward "!: \t"))
2337 ;; We are now at the beginning of the list of read articles.
2338 ;; We read them range by range.
2341 ((looking-at "[0-9]+")
2342 ;; We narrow and read a number instead of buffer-substring/
2343 ;; string-to-int because it's faster. narrow/widen is
2344 ;; faster than save-restriction/narrow, and save-restriction
2345 ;; produces a garbage object.
2347 (narrow-to-region (match-beginning 0) (match-end 0))
2350 ;; If the next character is a dash, then this is a range.
2351 (if (eq (char-after) ?-)
2353 ;; We read the upper bound of the range.
2355 (if (not (looking-at "[0-9]+"))
2356 ;; This is a buggy line, by we pretend that
2357 ;; it's kinda OK. Perhaps the user should be
2363 (narrow-to-region (match-beginning 0)
2368 ;; It was just a simple number, so we add it to the
2371 ;; If the next char in ?\n, then we have reached the end
2372 ;; of the line and return nil.
2373 (not (eq (char-after) ?\n)))
2374 ((eq (char-after) ?\n)
2375 ;; End of line, so we end.
2378 ;; Not numbers and not eol, so this might be a buggy
2381 ;; If it was eob instead of ?\n, we allow it.
2382 ;; The line was buggy.
2384 (gnus-error 3.1 "Mangled line: %s"
2385 (buffer-substring (gnus-point-at-bol)
2386 (gnus-point-at-eol))))
2388 ;; Skip past ", ". Spaces are invalid in these ranges, but
2389 ;; we allow them, because it's a common mistake to put a
2390 ;; space after the comma.
2391 (skip-chars-forward ", "))
2393 ;; We have already read .newsrc.eld, so we gently update the
2394 ;; data in the hash table with the information we have just
2397 (let ((info (gnus-get-info group))
2400 ;; There is an entry for this file in the alist.
2402 (gnus-info-set-read info (nreverse reads))
2403 ;; We update the level very gently. In fact, we
2404 ;; only change it if there's been a status change
2405 ;; from subscribed to unsubscribed, or vice versa.
2406 (setq level (gnus-info-level info))
2407 (cond ((and (<= level gnus-level-subscribed)
2409 (setq level (if reads
2410 gnus-level-default-unsubscribed
2411 (1+ gnus-level-default-unsubscribed))))
2412 ((and (> level gnus-level-subscribed) subscribed)
2413 (setq level gnus-level-default-subscribed)))
2414 (gnus-info-set-level info level))
2415 ;; This is a new group.
2416 (setq info (list group
2418 gnus-level-default-subscribed
2420 (1+ gnus-level-subscribed)
2421 gnus-level-default-unsubscribed))
2423 (push info newsrc)))))
2426 (setq newsrc (nreverse newsrc))
2428 (if (not already-read)
2430 ;; We now have two newsrc lists - `newsrc', which is what we
2431 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
2432 ;; what we've read from .newsrc.eld. We have to merge these
2433 ;; lists. We do this by "attaching" any (foreign) groups in the
2434 ;; gnus-newsrc-alist to the (native) group that precedes them.
2435 (let ((rc (cdr gnus-newsrc-alist))
2436 (prev gnus-newsrc-alist)
2439 (or (null (nth 4 (car rc))) ; It's a native group.
2440 (assoc (caar rc) newsrc) ; It's already in the alist.
2441 (if (setq entry (assoc (caar prev) newsrc))
2442 (setcdr (setq mentry (memq entry newsrc))
2443 (cons (car rc) (cdr mentry)))
2444 (push (car rc) newsrc)))
2448 (setq gnus-newsrc-alist newsrc)
2449 ;; We make the newsrc hashtb.
2450 (gnus-make-hashtable-from-newsrc-alist)
2452 ;; Finally, if we read some options lines, we parse them.
2453 (unless (string= gnus-newsrc-options "")
2454 (gnus-newsrc-parse-options gnus-newsrc-options))))
2456 ;; Parse options lines to find "options -n !all rec.all" and stuff.
2457 ;; The return value will be a list on the form
2458 ;; ((regexp1 . ignore)
2459 ;; (regexp2 . subscribe)...)
2460 ;; When handling new newsgroups, groups that match a `ignore' regexp
2461 ;; will be ignored, and groups that match a `subscribe' regexp will be
2462 ;; subscribed. A line like
2463 ;; options -n !all rec.all
2464 ;; will lead to a list that looks like
2465 ;; (("^rec\\..+" . subscribe)
2466 ;; ("^.+" . ignore))
2467 ;; So all "rec.*" groups will be subscribed, while all the other
2468 ;; groups will be ignored. Note that "options -n !all rec.all" is very
2469 ;; different from "options -n rec.all !all".
2470 (defun gnus-newsrc-parse-options (options)
2473 (gnus-set-work-buffer)
2474 (insert (regexp-quote options))
2475 ;; First we treat all continuation lines.
2476 (goto-char (point-min))
2477 (while (re-search-forward "\n[ \t]+" nil t)
2478 (replace-match " " t t))
2479 ;; Then we transform all "all"s into ".+"s.
2480 (goto-char (point-min))
2481 (while (re-search-forward "\\ball\\b" nil t)
2482 (replace-match ".+" t t))
2483 (goto-char (point-min))
2484 ;; We remove all other options than the "-n" ones.
2485 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
2488 (goto-char (point-min))
2490 ;; We are only interested in "options -n" lines - we
2491 ;; ignore the other option lines.
2492 (while (re-search-forward "[ \t]-n" nil t)
2495 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
2497 (gnus-point-at-eol)))
2498 ;; Search for all "words"...
2499 (while (re-search-forward "[^ \t,\n]+" eol t)
2500 (if (eq (char-after (match-beginning 0)) ?!)
2501 ;; If the word begins with a bang (!), this is a "not"
2502 ;; spec. We put this spec (minus the bang) and the
2503 ;; symbol `ignore' into the list.
2505 "^" (buffer-substring
2506 (1+ (match-beginning 0))
2511 ;; There was no bang, so this is a "yes" spec.
2512 (push (cons (concat "^" (match-string 0) "\\($\\|\\.\\)")
2516 (setq gnus-newsrc-options-n out))))
2518 (defun gnus-save-newsrc-file (&optional force)
2519 "Save .newsrc file."
2520 ;; Note: We cannot save .newsrc file if all newsgroups are removed
2521 ;; from the variable gnus-newsrc-alist.
2522 (when (and (or gnus-newsrc-alist gnus-killed-list)
2523 gnus-current-startup-file)
2525 (if (and (or gnus-use-dribble-file gnus-slave)
2527 (or (not gnus-dribble-buffer)
2528 (not (buffer-name gnus-dribble-buffer))
2529 (zerop (save-excursion
2530 (set-buffer gnus-dribble-buffer)
2532 (gnus-message 4 "(No changes need to be saved)")
2533 (gnus-run-hooks 'gnus-save-newsrc-hook)
2535 (gnus-slave-save-newsrc)
2537 (when gnus-save-newsrc-file
2538 (gnus-message 8 "Saving %s..." gnus-current-startup-file)
2539 (gnus-gnus-to-newsrc-format)
2540 (gnus-message 8 "Saving %s...done" gnus-current-startup-file))
2541 ;; Save .newsrc.eld.
2542 (set-buffer (gnus-get-buffer-create " *Gnus-newsrc*"))
2543 (make-local-variable 'version-control)
2544 (setq version-control 'never)
2545 (setq buffer-file-name
2546 (concat gnus-current-startup-file ".eld"))
2547 (setq default-directory (file-name-directory buffer-file-name))
2548 (buffer-disable-undo)
2550 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
2551 (gnus-gnus-to-quick-newsrc-format)
2552 (gnus-run-hooks 'gnus-save-quick-newsrc-hook)
2553 (let ((coding-system-for-write gnus-ding-file-coding-system))
2555 (kill-buffer (current-buffer))
2557 5 "Saving %s.eld...done" gnus-current-startup-file))
2558 (gnus-dribble-delete-file)
2559 (gnus-group-set-mode-line)))))
2561 (defun gnus-gnus-to-quick-newsrc-format ()
2562 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
2563 (let ((print-quoted t)
2564 (print-escape-newlines t))
2566 (insert ";; -*- emacs-lisp -*-\n")
2567 (insert ";; Gnus startup file.\n")
2569 ;; Never delete this file -- if you want to force Gnus to read the
2570 ;; .newsrc file (if you have one), touch .newsrc instead.\n")
2571 (insert "(setq gnus-newsrc-file-version "
2572 (prin1-to-string gnus-version) ")\n")
2573 (let* ((gnus-killed-list
2574 (if (and gnus-save-killed-list
2575 (stringp gnus-save-killed-list))
2576 (gnus-strip-killed-list)
2579 (if gnus-save-killed-list gnus-variable-list
2580 ;; Remove the `gnus-killed-list' from the list of variables
2581 ;; to be saved, if required.
2582 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
2583 ;; Peel off the "dummy" group.
2584 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
2586 ;; Insert the variables into the file.
2588 (when (and (boundp (setq variable (pop variables)))
2589 (symbol-value variable))
2590 (insert "(setq " (symbol-name variable) " '")
2591 (gnus-prin1 (symbol-value variable))
2594 (defun gnus-strip-killed-list ()
2595 "Return the killed list minus the groups that match `gnus-save-killed-list'."
2596 (let ((list gnus-killed-list)
2599 (when (string-match gnus-save-killed-list (car list))
2600 (push (car list) olist))
2604 (defun gnus-gnus-to-newsrc-format ()
2605 ;; Generate and save the .newsrc file.
2607 (set-buffer (create-file-buffer gnus-current-startup-file))
2608 (let ((newsrc (cdr gnus-newsrc-alist))
2609 (standard-output (current-buffer))
2610 info ranges range method)
2611 (setq buffer-file-name gnus-current-startup-file)
2612 (setq default-directory (file-name-directory buffer-file-name))
2613 (buffer-disable-undo)
2616 (when gnus-newsrc-options
2617 (insert gnus-newsrc-options))
2618 ;; Write subscribed and unsubscribed.
2619 (while (setq info (pop newsrc))
2620 ;; Don't write foreign groups to .newsrc.
2621 (when (or (null (setq method (gnus-info-method info)))
2622 (equal method "native")
2623 (inline (gnus-server-equal method gnus-select-method)))
2624 (insert (gnus-info-group info)
2625 (if (> (gnus-info-level info) gnus-level-subscribed)
2627 (when (setq ranges (gnus-info-read info))
2629 (if (not (listp (cdr ranges)))
2630 (if (= (car ranges) (cdr ranges))
2631 (princ (car ranges))
2632 (princ (car ranges))
2634 (princ (cdr ranges)))
2635 (while (setq range (pop ranges))
2636 (if (or (atom range) (= (car range) (cdr range)))
2637 (princ (or (and (atom range) range) (car range)))
2640 (princ (cdr range)))
2644 (make-local-variable 'version-control)
2645 (setq version-control 'never)
2646 ;; It has been reported that sometime the modtime on the .newsrc
2647 ;; file seems to be off. We really do want to overwrite it, so
2648 ;; we clear the modtime here before saving. It's a bit odd,
2650 ;; sometimes the modtime clear isn't sufficient. most brute force:
2651 ;; delete the silly thing entirely first. but this fails to provide
2652 ;; such niceties as .newsrc~ creation.
2653 (if gnus-modtime-botch
2654 (delete-file gnus-startup-file)
2655 (clear-visited-file-modtime))
2656 (gnus-run-hooks 'gnus-save-standard-newsrc-hook)
2658 (kill-buffer (current-buffer)))))
2662 ;;; Slave functions.
2665 (defvar gnus-slave-mode nil)
2667 (defun gnus-slave-mode ()
2668 "Minor mode for slave Gnusae."
2669 (gnus-add-minor-mode 'gnus-slave-mode " Slave" (make-sparse-keymap))
2670 (gnus-run-hooks 'gnus-slave-mode-hook))
2672 (defun gnus-slave-save-newsrc ()
2674 (set-buffer gnus-dribble-buffer)
2676 (mm-make-temp-file (concat gnus-current-startup-file "-slave-")))
2677 (modes (ignore-errors
2678 (file-modes (concat gnus-current-startup-file ".eld")))))
2679 (let ((coding-system-for-write gnus-ding-file-coding-system))
2680 (gnus-write-buffer slave-name))
2682 (set-file-modes slave-name modes)))))
2684 (defun gnus-master-read-slave-newsrc ()
2687 (file-name-directory gnus-current-startup-file)
2691 (file-name-nondirectory gnus-current-startup-file)
2695 (if (not slave-files)
2696 () ; There are no slave files to read.
2697 (gnus-message 7 "Reading slave newsrcs...")
2699 (set-buffer (gnus-get-buffer-create " *gnus slave*"))
2701 (sort (mapcar (lambda (file)
2702 (list (nth 5 (file-attributes file)) file))
2705 (or (< (caar f1) (caar f2))
2706 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
2709 (setq file (nth 1 (car slave-files)))
2710 (nnheader-insert-file-contents file)
2711 (when (condition-case ()
2713 (eval-buffer (current-buffer))
2716 (gnus-error 3.2 "Possible error in %s" file)
2718 (unless gnus-slave ; Slaves shouldn't delete these files.
2720 (delete-file file))))
2721 (setq slave-files (cdr slave-files))))
2722 (gnus-dribble-touch)
2723 (gnus-message 7 "Reading slave newsrcs...done"))))
2727 ;;; Group description.
2730 (defun gnus-read-all-descriptions-files ()
2731 (let ((methods (cons gnus-select-method
2733 (when (gnus-archive-server-wanted-p)
2735 gnus-secondary-select-methods))))
2737 (gnus-read-descriptions-file (car methods))
2738 (setq methods (cdr methods)))
2741 (defun gnus-read-descriptions-file (&optional method)
2742 (let ((method (or method gnus-select-method))
2744 (when (stringp method)
2745 (setq method (gnus-server-to-method method)))
2746 ;; We create the hashtable whether we manage to read the desc file
2747 ;; to avoid trying to re-read after a failed read.
2748 (unless gnus-description-hashtb
2749 (setq gnus-description-hashtb
2750 (gnus-make-hashtable (length gnus-active-hashtb))))
2751 ;; Mark this method's desc file as read.
2752 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
2753 gnus-description-hashtb)
2755 (gnus-message 5 "Reading descriptions file via %s..." (car method))
2757 ((null (gnus-get-function method 'request-list-newsgroups t))
2759 ((not (gnus-check-server method))
2760 (gnus-message 1 "Couldn't open server")
2762 ((not (gnus-request-list-newsgroups method))
2763 (gnus-message 1 "Couldn't read newsgroups descriptions")
2768 (set-buffer nntp-server-buffer)
2769 (goto-char (point-min))
2770 (when (or (search-forward "\n.\n" nil t)
2771 (goto-char (point-max)))
2773 (narrow-to-region (point-min) (point)))
2774 ;; If these are groups from a foreign select method, we insert the
2775 ;; group prefix in front of the group names.
2776 (and method (not (inline
2778 (gnus-server-get-method nil method)
2779 (gnus-server-get-method
2780 nil gnus-select-method))))
2781 (let ((prefix (gnus-group-prefixed-name "" method)))
2782 (goto-char (point-min))
2783 (while (and (not (eobp))
2784 (progn (insert prefix)
2785 (zerop (forward-line 1)))))))
2786 (goto-char (point-min))
2788 ;; If we get an error, we set group to 0, which is not a
2792 (let ((obarray gnus-description-hashtb))
2793 ;; Group is set to a symbol interned in this
2795 (read nntp-server-buffer))
2797 (skip-chars-forward " \t")
2798 ;; ... which leads to this line being effectively ignored.
2799 (when (symbolp group)
2800 (let* ((str (buffer-substring
2801 (point) (progn (end-of-line) (point))))
2802 (name (symbol-name group))
2804 (or (gnus-group-name-charset method name)
2805 (gnus-parameter-charset name)
2806 gnus-default-charset)))
2807 (when (and str charset (featurep 'mule))
2808 (setq str (mm-decode-coding-string str charset)))
2811 (gnus-message 5 "Reading descriptions file...done")
2814 (defun gnus-group-get-description (group)
2815 "Get the description of a group by sending XGTITLE to the server."
2816 (when (gnus-request-group-description group)
2818 (set-buffer nntp-server-buffer)
2819 (goto-char (point-min))
2820 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
2821 (match-string 1)))))
2824 (defun gnus-declare-backend (name &rest abilities)
2825 "Declare backend NAME with ABILITIES as a Gnus backend."
2826 (setq gnus-valid-select-methods
2827 (nconc gnus-valid-select-methods
2828 (list (apply 'list name abilities))))
2829 (gnus-redefine-select-method-widget))
2831 (defun gnus-set-default-directory ()
2832 "Set the default directory in the current buffer to `gnus-default-directory'.
2833 If this variable is nil, don't do anything."
2834 (setq default-directory
2835 (if (and gnus-default-directory
2836 (file-exists-p gnus-default-directory))
2837 (file-name-as-directory (expand-file-name gnus-default-directory))
2838 default-directory)))
2840 (defun gnus-display-time-event-handler ()
2841 "Like `display-time-event-handler', but test `display-time-timer'."
2842 (when (gnus-boundp 'display-time-timer)
2843 (display-time-event-handler)))
2846 (defun gnus-fixup-nnimap-unread-after-getting-new-news ()
2847 (let (server group info)
2850 (when (and (setq group (symbol-name sym))
2851 (gnus-group-entry group)
2852 (setq info (symbol-value sym)))
2853 (gnus-sethash group (cons (nth 2 info) (cdr (gnus-group-entry group)))
2854 gnus-newsrc-hashtb)))
2855 (if (boundp 'nnimap-mailbox-info)
2856 (symbol-value 'nnimap-mailbox-info)
2857 (make-vector 1 0)))))
2860 (provide 'gnus-start)
2862 ;;; gnus-start.el ends here