comparison lisp/gnus/gnus-start.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents bd315b9fa3f0
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; gnus-start.el --- startup functions for Gnus 1 ;;; gnus-start.el --- startup functions for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 2
3 ;; Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
4 5
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> 6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news 7 ;; Keywords: news
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
19 20
20 ;; You should have received a copy of the GNU General Public License 21 ;; 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 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02110-1301, USA.
24 25
25 ;;; Commentary: 26 ;;; Commentary:
26 27
27 ;;; Code: 28 ;;; Code:
28 29
30 (require 'gnus-win) 31 (require 'gnus-win)
31 (require 'gnus-int) 32 (require 'gnus-int)
32 (require 'gnus-spec) 33 (require 'gnus-spec)
33 (require 'gnus-range) 34 (require 'gnus-range)
34 (require 'gnus-util) 35 (require 'gnus-util)
35 (require 'message) 36 (autoload 'message-make-date "message")
36 (eval-when-compile (require 'cl)) 37 (autoload 'gnus-agent-read-servers-validate "gnus-agent")
38 (autoload 'gnus-agent-save-local "gnus-agent")
39 (autoload 'gnus-agent-possibly-alter-active "gnus-agent")
40
41 (eval-when-compile
42 (require 'cl)
43
44 (defvar gnus-agent-covered-methods nil)
45 (defvar gnus-agent-file-loading-local nil)
46 (defvar gnus-agent-file-loading-cache nil))
37 47
38 (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc") 48 (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc")
39 "Your `.newsrc' file. 49 "Your `.newsrc' file.
40 `.newsrc-SERVER' will be used instead if that exists." 50 `.newsrc-SERVER' will be used instead if that exists."
41 :group 'gnus-start 51 :group 'gnus-start
42 :type 'file) 52 :type 'file)
53
54 (defcustom gnus-backup-startup-file 'never
55 "Whether to create backup files.
56 This variable takes the same values as the `version-control'
57 variable."
58 :version "22.1"
59 :group 'gnus-start
60 :type '(choice (const :tag "Never" never)
61 (const :tag "If existing" nil)
62 (other :tag "Always" t)))
63
64 (defcustom gnus-save-startup-file-via-temp-buffer t
65 "Whether to write the startup file contents to a buffer then save
66 the buffer or write directly to the file. The buffer is faster
67 because all of the contents are written at once. The direct write
68 uses considerably less memory."
69 :version "22.1"
70 :group 'gnus-start
71 :type '(choice (const :tag "Write via buffer" t)
72 (const :tag "Write directly to file" nil)))
43 73
44 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus") 74 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus")
45 "Your Gnus Emacs-Lisp startup file name. 75 "Your Gnus Emacs-Lisp startup file name.
46 If a file with the `.el' or `.elc' suffixes exists, it will be read instead." 76 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
47 :group 'gnus-start 77 :group 'gnus-start
222 nil if you set this variable to nil. 252 nil if you set this variable to nil.
223 253
224 This variable can also be a regexp. In that case, all groups that do 254 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." 255 not match this regexp will be removed before saving the list."
226 :group 'gnus-newsrc 256 :group 'gnus-newsrc
227 :type 'boolean) 257 :type '(radio (sexp :format "Non-nil\n"
258 :match (lambda (widget value)
259 (and value (not (stringp value))))
260 :value t)
261 (const nil)
262 regexp))
228 263
229 (defcustom gnus-ignored-newsgroups 264 (defcustom gnus-ignored-newsgroups
230 (mapconcat 'identity 265 (mapconcat 'identity
231 '("^to\\." ; not "real" groups 266 '("^to\\." ; not "real" groups
232 "^[0-9. \t]+ " ; all digits in name 267 "^[0-9. \t]+\\( \\|$\\)" ; all digits in name
233 "^[\"][]\"[#'()]" ; bogus characters 268 "^[\"][]\"[#'()]" ; bogus characters
234 ) 269 )
235 "\\|") 270 "\\|")
236 "*A regexp to match uninteresting newsgroups in the active file. 271 "*A regexp to match uninteresting newsgroups in the active file.
237 Any lines in the active file matching this regular expression are 272 Any lines in the active file matching this regular expression are
239 thus making them effectively non-existent." 274 thus making them effectively non-existent."
240 :group 'gnus-group-new 275 :group 'gnus-group-new
241 :type 'regexp) 276 :type 'regexp)
242 277
243 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies 278 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
244 "*Function called with a group name when new group is detected. 279 "*Function(s) called with a group name when new group is detected.
245 A few pre-made functions are supplied: `gnus-subscribe-randomly' 280 A few pre-made functions are supplied: `gnus-subscribe-randomly'
246 inserts new groups at the beginning of the list of groups; 281 inserts new groups at the beginning of the list of groups;
247 `gnus-subscribe-alphabetically' inserts new groups in strict 282 `gnus-subscribe-alphabetically' inserts new groups in strict
248 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups 283 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
249 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks 284 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
257 (function-item gnus-subscribe-hierarchically) 292 (function-item gnus-subscribe-hierarchically)
258 (function-item gnus-subscribe-interactively) 293 (function-item gnus-subscribe-interactively)
259 (function-item gnus-subscribe-killed) 294 (function-item gnus-subscribe-killed)
260 (function-item gnus-subscribe-zombies) 295 (function-item gnus-subscribe-zombies)
261 (function-item gnus-subscribe-topics) 296 (function-item gnus-subscribe-topics)
262 function)) 297 function
298 (repeat function)))
299
300 (defcustom gnus-subscribe-newsgroup-hooks nil
301 "*Hooks run after you subscribe to a new group.
302 The hooks will be called with new group's name as argument."
303 :version "22.1"
304 :group 'gnus-group-new
305 :type 'hook)
263 306
264 (defcustom gnus-subscribe-options-newsgroup-method 307 (defcustom gnus-subscribe-options-newsgroup-method
265 'gnus-subscribe-alphabetically 308 'gnus-subscribe-alphabetically
266 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines. 309 "*Function(s) called to subscribe newsgroups mentioned on \"options -n\" lines.
267 If, for instance, you want to subscribe to all newsgroups in the 310 If, for instance, you want to subscribe to all newsgroups in the
268 \"no\" and \"alt\" hierarchies, you'd put the following in your 311 \"no\" and \"alt\" hierarchies, you'd put the following in your
269 .newsrc file: 312 .newsrc file:
270 313
271 options -n no.all alt.all 314 options -n no.all alt.all
277 (function-item gnus-subscribe-alphabetically) 320 (function-item gnus-subscribe-alphabetically)
278 (function-item gnus-subscribe-hierarchically) 321 (function-item gnus-subscribe-hierarchically)
279 (function-item gnus-subscribe-interactively) 322 (function-item gnus-subscribe-interactively)
280 (function-item gnus-subscribe-killed) 323 (function-item gnus-subscribe-killed)
281 (function-item gnus-subscribe-zombies) 324 (function-item gnus-subscribe-zombies)
282 function)) 325 (function-item gnus-subscribe-topics)
326 function
327 (repeat function)))
283 328
284 (defcustom gnus-subscribe-hierarchical-interactive nil 329 (defcustom gnus-subscribe-hierarchical-interactive nil
285 "*If non-nil, Gnus will offer to subscribe hierarchically. 330 "*If non-nil, Gnus will offer to subscribe hierarchically.
286 When a new hierarchy appears, Gnus will ask the user: 331 When a new hierarchy appears, Gnus will ask the user:
287 332
292 hierarchy in its entirety." 337 hierarchy in its entirety."
293 :group 'gnus-group-new 338 :group 'gnus-group-new
294 :type 'boolean) 339 :type 'boolean)
295 340
296 (defcustom gnus-auto-subscribed-groups 341 (defcustom gnus-auto-subscribed-groups
297 "nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl" 342 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl\\|^nnmaildir"
298 "*All new groups that match this regexp will be subscribed automatically. 343 "*All new groups that match this regexp will be subscribed automatically.
299 Note that this variable only deals with new groups. It has no effect 344 Note that this variable only deals with new groups. It has no effect
300 whatsoever on old groups. 345 whatsoever on old groups.
301 346
302 New groups that match this regexp will not be handled by 347 New groups that match this regexp will not be handled by
352 (defcustom gnus-started-hook nil 397 (defcustom gnus-started-hook nil
353 "A hook called as the last thing after startup." 398 "A hook called as the last thing after startup."
354 :group 'gnus-start 399 :group 'gnus-start
355 :type 'hook) 400 :type 'hook)
356 401
357 (defcustom gnus-setup-news-hook nil 402 (defcustom gnus-setup-news-hook
403 '(gnus-fixup-nnimap-unread-after-getting-new-news)
358 "A hook after reading the .newsrc file, but before generating the buffer." 404 "A hook after reading the .newsrc file, but before generating the buffer."
359 :group 'gnus-start 405 :group 'gnus-start
406 :type 'hook)
407
408 (defcustom gnus-get-top-new-news-hook nil
409 "A hook run just before Gnus checks for new news globally."
410 :version "22.1"
411 :group 'gnus-group-new
360 :type 'hook) 412 :type 'hook)
361 413
362 (defcustom gnus-get-new-news-hook nil 414 (defcustom gnus-get-new-news-hook nil
363 "A hook run just before Gnus checks for new news." 415 "A hook run just before Gnus checks for new news."
364 :group 'gnus-group-new 416 :group 'gnus-group-new
365 :type 'hook) 417 :type 'hook)
366 418
367 (defcustom gnus-after-getting-new-news-hook 419 (defcustom gnus-after-getting-new-news-hook
368 (when (gnus-boundp 'display-time-timer) 420 '(gnus-display-time-event-handler
369 '(display-time-event-handler)) 421 gnus-fixup-nnimap-unread-after-getting-new-news)
370 "*A hook run after Gnus checks for new news when Gnus is already running." 422 "*A hook run after Gnus checks for new news when Gnus is already running."
371 :group 'gnus-group-new 423 :group 'gnus-group-new
424 :type 'hook)
425
426 (defcustom gnus-read-newsrc-el-hook nil
427 "A hook called after reading the newsrc.eld? file."
428 :group 'gnus-newsrc
372 :type 'hook) 429 :type 'hook)
373 430
374 (defcustom gnus-save-newsrc-hook nil 431 (defcustom gnus-save-newsrc-hook nil
375 "A hook called before saving any of the newsrc files." 432 "A hook called before saving any of the newsrc files."
376 :group 'gnus-newsrc 433 :group 'gnus-newsrc
384 441
385 (defcustom gnus-save-standard-newsrc-hook nil 442 (defcustom gnus-save-standard-newsrc-hook nil
386 "A hook called just before saving the standard newsrc file. 443 "A hook called just before saving the standard newsrc file.
387 Can be used to turn version control on or off." 444 Can be used to turn version control on or off."
388 :group 'gnus-newsrc 445 :group 'gnus-newsrc
446 :type 'hook)
447
448 (defcustom gnus-group-mode-hook nil
449 "Hook for Gnus group mode."
450 :group 'gnus-group-various
451 :options '(gnus-topic-mode)
389 :type 'hook) 452 :type 'hook)
390 453
391 (defcustom gnus-always-read-dribble-file nil 454 (defcustom gnus-always-read-dribble-file nil
392 "Unconditionally read the dribble file." 455 "Unconditionally read the dribble file."
393 :group 'gnus-newsrc 456 :group 'gnus-newsrc
430 (if (or debug-on-error debug-on-quit) 493 (if (or debug-on-error debug-on-quit)
431 (load file nil t) 494 (load file nil t)
432 (condition-case var 495 (condition-case var
433 (load file nil t) 496 (load file nil t)
434 (error 497 (error
435 (error "Error in %s: %s" file var))))))))) 498 (error "Error in %s: %s" file (cadr var))))))))))
436 499
437 ;; For subscribing new newsgroup 500 ;; For subscribing new newsgroup
438 501
439 (defun gnus-subscribe-hierarchical-interactive (groups) 502 (defun gnus-subscribe-hierarchical-interactive (groups)
440 (let ((groups (sort groups 'string<)) 503 (let ((groups (sort groups 'string<))
506 (defun gnus-subscribe-randomly (newsgroup) 569 (defun gnus-subscribe-randomly (newsgroup)
507 "Subscribe new NEWSGROUP by making it the first newsgroup." 570 "Subscribe new NEWSGROUP by making it the first newsgroup."
508 (gnus-subscribe-newsgroup newsgroup)) 571 (gnus-subscribe-newsgroup newsgroup))
509 572
510 (defun gnus-subscribe-alphabetically (newgroup) 573 (defun gnus-subscribe-alphabetically (newgroup)
511 "Subscribe new NEWSGROUP and insert it in alphabetical order." 574 "Subscribe new NEWGROUP and insert it in alphabetical order."
512 (let ((groups (cdr gnus-newsrc-alist)) 575 (let ((groups (cdr gnus-newsrc-alist))
513 before) 576 before)
514 (while (and (not before) groups) 577 (while (and (not before) groups)
515 (if (string< newgroup (caar groups)) 578 (if (string< newgroup (caar groups))
516 (setq before (caar groups)) 579 (setq before (caar groups))
517 (setq groups (cdr groups)))) 580 (setq groups (cdr groups))))
518 (gnus-subscribe-newsgroup newgroup before))) 581 (gnus-subscribe-newsgroup newgroup before)))
519 582
520 (defun gnus-subscribe-hierarchically (newgroup) 583 (defun gnus-subscribe-hierarchically (newgroup)
521 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order." 584 "Subscribe new NEWGROUP and insert it in hierarchical newsgroup order."
522 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) 585 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
523 (save-excursion 586 (save-excursion
524 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file)) 587 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file))
525 (let ((groupkey newgroup) 588 (prog1
526 before) 589 (let ((groupkey newgroup) before)
527 (while (and (not before) groupkey) 590 (while (and (not before) groupkey)
528 (goto-char (point-min)) 591 (goto-char (point-min))
529 (let ((groupkey-re 592 (let ((groupkey-re
530 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) 593 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
531 (while (and (re-search-forward groupkey-re nil t) 594 (while (and (re-search-forward groupkey-re nil t)
532 (progn 595 (progn
533 (setq before (match-string 1)) 596 (setq before (match-string 1))
534 (string< before newgroup))))) 597 (string< before newgroup)))))
535 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) 598 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
536 (setq groupkey 599 (setq groupkey
537 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey) 600 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
538 (substring groupkey (match-beginning 1) (match-end 1))))) 601 (substring groupkey (match-beginning 1) (match-end 1)))))
539 (gnus-subscribe-newsgroup newgroup before)) 602 (gnus-subscribe-newsgroup newgroup before))
540 (kill-buffer (current-buffer)))) 603 (kill-buffer (current-buffer)))))
541 604
542 (defun gnus-subscribe-interactively (group) 605 (defun gnus-subscribe-interactively (group)
543 "Subscribe the new GROUP interactively. 606 "Subscribe the new GROUP interactively.
544 It is inserted in hierarchical newsgroup order if subscribed. If not, 607 It is inserted in hierarchical newsgroup order if subscribed. If not,
545 it is killed." 608 it is killed."
546 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group)) 609 (if (gnus-y-or-n-p (format "Subscribe new newsgroup %s? " group))
547 (gnus-subscribe-hierarchically group) 610 (gnus-subscribe-hierarchically group)
548 (push group gnus-killed-list))) 611 (push group gnus-killed-list)))
549 612
550 (defun gnus-subscribe-zombies (group) 613 (defun gnus-subscribe-zombies (group)
551 "Make the new GROUP into a zombie group." 614 "Make the new GROUP into a zombie group."
564 ;; We subscribe the group by changing its level to `subscribed'. 627 ;; We subscribe the group by changing its level to `subscribed'.
565 (gnus-group-change-level 628 (gnus-group-change-level
566 newsgroup gnus-level-default-subscribed 629 newsgroup gnus-level-default-subscribed
567 gnus-level-killed (gnus-gethash (or next "dummy.group") 630 gnus-level-killed (gnus-gethash (or next "dummy.group")
568 gnus-newsrc-hashtb)) 631 gnus-newsrc-hashtb))
569 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))) 632 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
633 (run-hook-with-args 'gnus-subscribe-newsgroup-hooks newsgroup)
634 t))
570 635
571 (defun gnus-read-active-file-p () 636 (defun gnus-read-active-file-p ()
572 "Say whether the active file has been read from `gnus-select-method'." 637 "Say whether the active file has been read from `gnus-select-method'."
573 (memq gnus-select-method gnus-have-read-active-file)) 638 (memq gnus-select-method gnus-have-read-active-file))
574 639
575 ;;; General various misc type functions. 640 ;;; General various misc type functions.
576 641
577 ;; Silence byte-compiler. 642 ;; Silence byte-compiler.
578 (defvar gnus-current-headers) 643 (eval-when-compile
579 (defvar gnus-thread-indent-array) 644 (defvar gnus-current-headers)
580 (defvar gnus-newsgroup-name) 645 (defvar gnus-thread-indent-array)
581 (defvar gnus-newsgroup-headers) 646 (defvar gnus-newsgroup-name)
582 (defvar gnus-group-list-mode) 647 (defvar gnus-newsgroup-headers)
583 (defvar gnus-group-mark-positions) 648 (defvar gnus-group-list-mode)
584 (defvar gnus-newsgroup-data) 649 (defvar gnus-group-mark-positions)
585 (defvar gnus-newsgroup-unreads) 650 (defvar gnus-newsgroup-data)
586 (defvar nnoo-state-alist) 651 (defvar gnus-newsgroup-unreads)
587 (defvar gnus-current-select-method) 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))
658
659 (defun gnus-close-all-servers ()
660 "Close all servers."
661 (interactive)
662 (dolist (server gnus-opened-servers)
663 (gnus-close-server (car server))))
588 664
589 (defun gnus-clear-system () 665 (defun gnus-clear-system ()
590 "Clear all variables and buffers." 666 "Clear all variables and buffers."
591 ;; Clear Gnus variables. 667 ;; Clear Gnus variables.
592 (let ((variables gnus-variable-list)) 668 (let ((variables (remove 'gnus-format-specs gnus-variable-list)))
593 (while variables 669 (while variables
594 (set (car variables) nil) 670 (set (car variables) nil)
595 (setq variables (cdr variables)))) 671 (setq variables (cdr variables))))
596 ;; Clear other internal variables. 672 ;; Clear other internal variables.
597 (setq gnus-list-of-killed-groups nil 673 (setq gnus-list-of-killed-groups nil
598 gnus-have-read-active-file 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
599 gnus-newsrc-alist nil 679 gnus-newsrc-alist nil
600 gnus-newsrc-hashtb nil 680 gnus-newsrc-hashtb nil
601 gnus-killed-list nil 681 gnus-killed-list nil
602 gnus-zombie-list nil 682 gnus-zombie-list nil
603 gnus-killed-hashtb nil 683 gnus-killed-hashtb nil
628 ;; Kill global KILL file buffer. 708 ;; Kill global KILL file buffer.
629 (when (get-file-buffer (gnus-newsgroup-kill-file nil)) 709 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
630 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil)))) 710 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
631 (gnus-kill-buffer nntp-server-buffer) 711 (gnus-kill-buffer nntp-server-buffer)
632 ;; Kill Gnus buffers. 712 ;; Kill Gnus buffers.
633 (let ((buffers (gnus-buffers))) 713 (dolist (buffer (gnus-buffers))
634 (when buffers 714 (gnus-kill-buffer buffer))
635 (mapcar 'kill-buffer buffers)))
636 ;; Remove Gnus frames. 715 ;; Remove Gnus frames.
637 (gnus-kill-gnus-frames)) 716 (gnus-kill-gnus-frames))
638 717
639 (defun gnus-no-server-1 (&optional arg slave) 718 (defun gnus-no-server-1 (&optional arg slave)
640 "Read network news. 719 "Read network news.
641 If ARG is a positive number, Gnus will use that as the 720 If ARG is a positive number, Gnus will use that as the startup
642 startup level. If ARG is nil, Gnus will be started at level 2. 721 level. If ARG is nil, Gnus will be started at level 2
643 If ARG is non-nil and not a positive number, Gnus will 722 \(`gnus-level-default-subscribed' minus one). If ARG is non-nil
644 prompt the user for the name of an NNTP server to use. 723 and not a positive number, Gnus will prompt the user for the name
645 As opposed to `gnus', this command will not connect to the local server." 724 of an NNTP server to use. As opposed to \\[gnus], this command
725 will not connect to the local server."
646 (interactive "P") 726 (interactive "P")
647 (let ((val (or arg (1- gnus-level-default-subscribed)))) 727 (let ((val (or arg (1- gnus-level-default-subscribed))))
648 (gnus val t slave) 728 (gnus val t slave)
649 (make-local-variable 'gnus-group-use-permanent-levels) 729 (make-local-variable 'gnus-group-use-permanent-levels)
650 (setq gnus-group-use-permanent-levels val))) 730 (setq gnus-group-use-permanent-levels val)))
668 (gnus-splash) 748 (gnus-splash)
669 (gnus-run-hooks 'gnus-before-startup-hook) 749 (gnus-run-hooks 'gnus-before-startup-hook)
670 (nnheader-init-server-buffer) 750 (nnheader-init-server-buffer)
671 (setq gnus-slave slave) 751 (setq gnus-slave slave)
672 (gnus-read-init-file) 752 (gnus-read-init-file)
753 (if gnus-agent
754 (gnus-agentize))
673 755
674 (when gnus-simple-splash 756 (when gnus-simple-splash
675 (setq gnus-simple-splash nil) 757 (setq gnus-simple-splash nil)
676 (cond 758 (cond
677 ((featurep 'xemacs) 759 ((featurep 'xemacs)
705 (when gnus-use-grouplens 787 (when gnus-use-grouplens
706 (bbb-login) 788 (bbb-login)
707 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode)) 789 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
708 790
709 ;; Do the actual startup. 791 ;; Do the actual startup.
792 (if gnus-agent
793 (gnus-request-create-group "queue" '(nndraft "")))
794 (gnus-request-create-group "drafts" '(nndraft ""))
710 (gnus-setup-news nil level dont-connect) 795 (gnus-setup-news nil level dont-connect)
711 (gnus-run-hooks 'gnus-setup-news-hook) 796 (gnus-run-hooks 'gnus-setup-news-hook)
712 (gnus-start-draft-setup) 797 (gnus-start-draft-setup)
713 ;; Generate the group buffer. 798 ;; Generate the group buffer.
714 (gnus-group-list-groups level) 799 (gnus-group-list-groups level)
719 804
720 (defun gnus-start-draft-setup () 805 (defun gnus-start-draft-setup ()
721 "Make sure the draft group exists." 806 "Make sure the draft group exists."
722 (gnus-request-create-group "drafts" '(nndraft "")) 807 (gnus-request-create-group "drafts" '(nndraft ""))
723 (unless (gnus-gethash "nndraft:drafts" gnus-newsrc-hashtb) 808 (unless (gnus-gethash "nndraft:drafts" gnus-newsrc-hashtb)
809 (gnus-message 3 "Subscribing drafts group")
724 (let ((gnus-level-default-subscribed 1)) 810 (let ((gnus-level-default-subscribed 1))
725 (gnus-subscribe-group "nndraft:drafts" nil '(nndraft ""))) 811 (gnus-subscribe-group "nndraft:drafts" nil '(nndraft ""))))
812 (unless (equal (gnus-group-get-parameter "nndraft:drafts" 'gnus-dummy t)
813 '((gnus-draft-mode)))
814 (gnus-message 3 "Setting up drafts group")
726 (gnus-group-set-parameter 815 (gnus-group-set-parameter
727 "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode))))) 816 "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode)))))
728
729 ;;;###autoload
730 (defun gnus-unload ()
731 "Unload all Gnus features.
732 \(For some value of `all' or `Gnus'.) Currently, features whose names
733 have prefixes `gnus-', `nn', `mm-' or `rfc' are unloaded. Use
734 cautiously -- unloading may cause trouble."
735 (interactive)
736 (dolist (feature features)
737 (if (string-match "^\\(gnus-\\|nn\\|mm-\\|rfc\\)" (symbol-name feature))
738 (unload-feature feature 'force))))
739 817
740 818
741 ;;; 819 ;;;
742 ;;; Dribble file 820 ;;; Dribble file
743 ;;; 821 ;;;
761 (buffer-name gnus-dribble-buffer)) 839 (buffer-name gnus-dribble-buffer))
762 (let ((obuf (current-buffer))) 840 (let ((obuf (current-buffer)))
763 (set-buffer gnus-dribble-buffer) 841 (set-buffer gnus-dribble-buffer)
764 (goto-char (point-max)) 842 (goto-char (point-max))
765 (insert string "\n") 843 (insert string "\n")
766 (set-window-point (get-buffer-window (current-buffer)) (point-max)) 844 ;; This has been commented by Josh Huber <huber@alum.wpi.edu>
845 ;; It causes problems with both XEmacs and Emacs 21, and doesn't
846 ;; seem to be of much value. (FIXME: remove this after we make sure
847 ;; it's not needed).
848 ;; (set-window-point (get-buffer-window (current-buffer)) (point-max))
767 (bury-buffer gnus-dribble-buffer) 849 (bury-buffer gnus-dribble-buffer)
768 (save-excursion 850 (save-excursion
769 (set-buffer gnus-group-buffer) 851 (set-buffer gnus-group-buffer)
770 (gnus-group-set-mode-line)) 852 (gnus-group-set-mode-line))
771 (set-buffer obuf)))) 853 (set-buffer obuf))))
779 (let ((dribble-file (gnus-dribble-file-name))) 861 (let ((dribble-file (gnus-dribble-file-name)))
780 (save-excursion 862 (save-excursion
781 (set-buffer (setq gnus-dribble-buffer 863 (set-buffer (setq gnus-dribble-buffer
782 (gnus-get-buffer-create 864 (gnus-get-buffer-create
783 (file-name-nondirectory dribble-file)))) 865 (file-name-nondirectory dribble-file))))
866 (set (make-local-variable 'file-precious-flag) t)
784 (erase-buffer) 867 (erase-buffer)
785 (setq buffer-file-name dribble-file) 868 (setq buffer-file-name dribble-file)
786 (auto-save-mode t) 869 (auto-save-mode t)
787 (buffer-disable-undo) 870 (buffer-disable-undo)
788 (bury-buffer (current-buffer)) 871 (bury-buffer (current-buffer))
789 (set-buffer-modified-p nil) 872 (set-buffer-modified-p nil)
790 (let ((auto (make-auto-save-file-name)) 873 (let ((auto (make-auto-save-file-name))
791 (gnus-dribble-ignore t) 874 (gnus-dribble-ignore t)
875 (purpose nil)
792 modes) 876 modes)
793 (when (or (file-exists-p auto) (file-exists-p dribble-file)) 877 (when (or (file-exists-p auto) (file-exists-p dribble-file))
794 ;; Load whichever file is newest -- the auto save file 878 ;; Load whichever file is newest -- the auto save file
795 ;; or the "real" file. 879 ;; or the "real" file.
796 (if (file-newer-than-file-p auto dribble-file) 880 (if (file-newer-than-file-p auto dribble-file)
802 (save-buffer) 886 (save-buffer)
803 (when (and (file-exists-p gnus-current-startup-file) 887 (when (and (file-exists-p gnus-current-startup-file)
804 (file-exists-p dribble-file) 888 (file-exists-p dribble-file)
805 (setq modes (file-modes gnus-current-startup-file))) 889 (setq modes (file-modes gnus-current-startup-file)))
806 (set-file-modes dribble-file modes)) 890 (set-file-modes dribble-file modes))
891 (goto-char (point-min))
892 (when (search-forward "Gnus was exited on purpose" nil t)
893 (setq purpose t))
807 ;; Possibly eval the file later. 894 ;; Possibly eval the file later.
808 (when (or gnus-always-read-dribble-file 895 (when (or gnus-always-read-dribble-file
809 (gnus-y-or-n-p 896 (gnus-y-or-n-p
810 "Gnus auto-save file exists. Do you want to read it? ")) 897 (if purpose
898 "Gnus exited on purpose without saving; read auto-save file anyway? "
899 "Gnus auto-save file exists. Do you want to read it? ")))
811 (setq gnus-dribble-eval-file t))))))) 900 (setq gnus-dribble-eval-file t)))))))
812 901
813 (defun gnus-dribble-eval-file () 902 (defun gnus-dribble-eval-file ()
814 (when gnus-dribble-eval-file 903 (when gnus-dribble-eval-file
815 (setq gnus-dribble-eval-file nil) 904 (setq gnus-dribble-eval-file nil)
867 ;; Read the newsrc file and create `gnus-newsrc-hashtb'. 956 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
868 (gnus-read-newsrc-file rawfile)) 957 (gnus-read-newsrc-file rawfile))
869 958
870 ;; Make sure the archive server is available to all and sundry. 959 ;; Make sure the archive server is available to all and sundry.
871 (when gnus-message-archive-method 960 (when gnus-message-archive-method
872 (setq gnus-server-alist (delq (assoc "archive" gnus-server-alist) 961 (unless (assoc "archive" gnus-server-alist)
873 gnus-server-alist)) 962 (let ((method (or (and (stringp gnus-message-archive-method)
874 (push (cons "archive" gnus-message-archive-method) 963 (gnus-server-to-method
875 gnus-server-alist)) 964 gnus-message-archive-method))
965 gnus-message-archive-method)))
966 ;; Check whether the archive method is writable.
967 (unless (or (stringp method)
968 (memq 'respool (assoc (format "%s" (car method))
969 gnus-valid-select-methods)))
970 (setq method "archive")) ;; The default.
971 (push (if (stringp method)
972 `("archive"
973 nnfolder
974 ,method
975 (nnfolder-directory
976 ,(nnheader-concat message-directory method))
977 (nnfolder-active-file
978 ,(nnheader-concat message-directory
979 (concat method "/active")))
980 (nnfolder-get-new-mail nil)
981 (nnfolder-inhibit-expiry t))
982 (cons "archive" method))
983 gnus-server-alist))))
876 984
877 ;; If we don't read the complete active file, we fill in the 985 ;; If we don't read the complete active file, we fill in the
878 ;; hashtb here. 986 ;; hashtb here.
879 (when (or (null gnus-read-active-file) 987 (when (or (null gnus-read-active-file)
880 (eq gnus-read-active-file 'some)) 988 (eq gnus-read-active-file 'some))
881 (gnus-update-active-hashtb-from-killed)) 989 (gnus-update-active-hashtb-from-killed))
990
991 ;; Validate agent covered methods now that gnus-server-alist has
992 ;; been initialized.
993 ;; NOTE: This is here for one purpose only. By validating the
994 ;; agentized server's, it converts the old 5.10.3, and earlier,
995 ;; format to the current format. That enables the agent code
996 ;; within gnus-read-active-file to function correctly.
997 (if gnus-agent
998 (gnus-agent-read-servers-validate))
882 999
883 ;; Read the active file and create `gnus-active-hashtb'. 1000 ;; Read the active file and create `gnus-active-hashtb'.
884 ;; If `gnus-read-active-file' is nil, then we just create an empty 1001 ;; If `gnus-read-active-file' is nil, then we just create an empty
885 ;; hash table. The partial filling out of the hash table will be 1002 ;; hash table. The partial filling out of the hash table will be
886 ;; done in `gnus-get-unread-articles'. 1003 ;; done in `gnus-get-unread-articles'.
906 1023
907 (gnus-update-format-specifications) 1024 (gnus-update-format-specifications)
908 1025
909 ;; See whether we need to read the description file. 1026 ;; See whether we need to read the description file.
910 (when (and (boundp 'gnus-group-line-format) 1027 (when (and (boundp 'gnus-group-line-format)
1028 (stringp gnus-group-line-format)
911 (let ((case-fold-search nil)) 1029 (let ((case-fold-search nil))
912 (string-match "%[-,0-9]*D" gnus-group-line-format)) 1030 (string-match "%[-,0-9]*D" gnus-group-line-format))
913 (not gnus-description-hashtb) 1031 (not gnus-description-hashtb)
914 (not dont-connect) 1032 (not dont-connect)
915 gnus-read-active-file) 1033 gnus-read-active-file)
920 (gnus-check-server gnus-select-method) 1038 (gnus-check-server gnus-select-method)
921 (not gnus-slave) 1039 (not gnus-slave)
922 gnus-plugged) 1040 gnus-plugged)
923 (gnus-find-new-newsgroups)) 1041 (gnus-find-new-newsgroups))
924 1042
1043 ;; Check and remove bogus newsgroups.
1044 (when (and init gnus-check-bogus-newsgroups
1045 gnus-read-active-file (not level)
1046 (gnus-server-opened gnus-select-method))
1047 (gnus-check-bogus-newsgroups))
1048
925 ;; We might read in new NoCeM messages here. 1049 ;; We might read in new NoCeM messages here.
926 (when (and gnus-use-nocem 1050 (when (and gnus-use-nocem
927 (not level) 1051 (not level)
928 (not dont-connect)) 1052 (not dont-connect))
929 (gnus-nocem-scan-groups)) 1053 (gnus-nocem-scan-groups))
931 ;; Read any slave files. 1055 ;; Read any slave files.
932 (gnus-master-read-slave-newsrc) 1056 (gnus-master-read-slave-newsrc)
933 1057
934 ;; Find the number of unread articles in each non-dead group. 1058 ;; Find the number of unread articles in each non-dead group.
935 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) 1059 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
936 (gnus-get-unread-articles level)) 1060 (gnus-get-unread-articles level))))
937 1061
938 (when (and init gnus-check-bogus-newsgroups 1062 (defun gnus-call-subscribe-functions (method group)
939 gnus-read-active-file (not level) 1063 "Call METHOD to subscribe GROUP.
940 (gnus-server-opened gnus-select-method)) 1064 If no function returns `non-nil', call `gnus-subscribe-zombies'."
941 (gnus-check-bogus-newsgroups)))) 1065 (unless (cond
1066 ((functionp method)
1067 (funcall method group))
1068 ((listp method)
1069 (catch 'found
1070 (dolist (func method)
1071 (if (funcall func group)
1072 (throw 'found t)))
1073 nil))
1074 (t nil))
1075 (gnus-subscribe-zombies group)))
942 1076
943 (defun gnus-find-new-newsgroups (&optional arg) 1077 (defun gnus-find-new-newsgroups (&optional arg)
944 "Search for new newsgroups and add them. 1078 "Search for new newsgroups and add them.
945 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method'. 1079 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method'.
946 The `-n' option line from .newsrc is respected. 1080 The `-n' option line from .newsrc is respected.
990 (let ((do-sub (gnus-matches-options-n group))) 1124 (let ((do-sub (gnus-matches-options-n group)))
991 (cond 1125 (cond
992 ((eq do-sub 'subscribe) 1126 ((eq do-sub 'subscribe)
993 (setq groups (1+ groups)) 1127 (setq groups (1+ groups))
994 (gnus-sethash group group gnus-killed-hashtb) 1128 (gnus-sethash group group gnus-killed-hashtb)
995 (funcall gnus-subscribe-options-newsgroup-method group)) 1129 (gnus-call-subscribe-functions
1130 gnus-subscribe-options-newsgroup-method group))
996 ((eq do-sub 'ignore) 1131 ((eq do-sub 'ignore)
997 nil) 1132 nil)
998 (t 1133 (t
999 (setq groups (1+ groups)) 1134 (setq groups (1+ groups))
1000 (gnus-sethash group group gnus-killed-hashtb) 1135 (gnus-sethash group group gnus-killed-hashtb)
1001 (if gnus-subscribe-hierarchical-interactive 1136 (if gnus-subscribe-hierarchical-interactive
1002 (push group new-newsgroups) 1137 (push group new-newsgroups)
1003 (funcall gnus-subscribe-newsgroup-method group))))))) 1138 (gnus-call-subscribe-functions
1139 gnus-subscribe-newsgroup-method group)))))))
1004 gnus-active-hashtb) 1140 gnus-active-hashtb)
1005 (when new-newsgroups 1141 (when new-newsgroups
1006 (gnus-subscribe-hierarchical-interactive new-newsgroups)) 1142 (gnus-subscribe-hierarchical-interactive new-newsgroups))
1007 (if (> groups 0) 1143 (if (> groups 0)
1008 (gnus-message 5 "%d new newsgroup%s arrived." 1144 (gnus-message 5 "%d new newsgroup%s arrived."
1083 (let ((do-sub (gnus-matches-options-n group))) 1219 (let ((do-sub (gnus-matches-options-n group)))
1084 (cond 1220 (cond
1085 ((eq do-sub 'subscribe) 1221 ((eq do-sub 'subscribe)
1086 (incf groups) 1222 (incf groups)
1087 (gnus-sethash group group gnus-killed-hashtb) 1223 (gnus-sethash group group gnus-killed-hashtb)
1088 (funcall gnus-subscribe-options-newsgroup-method group)) 1224 (gnus-call-subscribe-functions
1225 gnus-subscribe-options-newsgroup-method group))
1089 ((eq do-sub 'ignore) 1226 ((eq do-sub 'ignore)
1090 nil) 1227 nil)
1091 (t 1228 (t
1092 (incf groups) 1229 (incf groups)
1093 (gnus-sethash group group gnus-killed-hashtb) 1230 (gnus-sethash group group gnus-killed-hashtb)
1094 (if gnus-subscribe-hierarchical-interactive 1231 (if gnus-subscribe-hierarchical-interactive
1095 (push group new-newsgroups) 1232 (push group new-newsgroups)
1096 (funcall gnus-subscribe-newsgroup-method group))))))) 1233 (gnus-call-subscribe-functions
1234 gnus-subscribe-newsgroup-method group)))))))
1097 hashtb)) 1235 hashtb))
1098 (when new-newsgroups 1236 (when new-newsgroups
1099 (gnus-subscribe-hierarchical-interactive new-newsgroups))) 1237 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
1100 (if (> groups 0) 1238 (if (> groups 0)
1101 (gnus-message 5 "%d new newsgroup%s arrived" 1239 (gnus-message 5 "%d new newsgroup%s arrived"
1107 1245
1108 (defun gnus-check-first-time-used () 1246 (defun gnus-check-first-time-used ()
1109 (catch 'ended 1247 (catch 'ended
1110 ;; First check if any of the following files exist. If they do, 1248 ;; First check if any of the following files exist. If they do,
1111 ;; it's not the first time the user has used Gnus. 1249 ;; it's not the first time the user has used Gnus.
1112 (dolist (file (list gnus-current-startup-file 1250 (dolist (file (list (concat gnus-current-startup-file ".el")
1113 (concat gnus-current-startup-file ".el")
1114 (concat gnus-current-startup-file ".eld") 1251 (concat gnus-current-startup-file ".eld")
1115 gnus-startup-file
1116 (concat gnus-startup-file ".el") 1252 (concat gnus-startup-file ".el")
1117 (concat gnus-startup-file ".eld"))) 1253 (concat gnus-startup-file ".eld")))
1118 (when (file-exists-p file) 1254 (when (file-exists-p file)
1119 (throw 'ended nil))) 1255 (throw 'ended nil)))
1120 (gnus-message 6 "First time user; subscribing you to default groups") 1256 (gnus-message 6 "First time user; subscribing you to default groups")
1124 (setq gnus-newsrc-last-checked-date (message-make-date)) 1260 (setq gnus-newsrc-last-checked-date (message-make-date))
1125 ;; Subscribe to the default newsgroups. 1261 ;; Subscribe to the default newsgroups.
1126 (let ((groups (or gnus-default-subscribed-newsgroups 1262 (let ((groups (or gnus-default-subscribed-newsgroups
1127 gnus-backup-default-subscribed-newsgroups)) 1263 gnus-backup-default-subscribed-newsgroups))
1128 group) 1264 group)
1129 (when (eq groups t) 1265 (if (eq groups t)
1130 ;; If t, we subscribe (or not) all groups as if they were new. 1266 ;; If t, we subscribe (or not) all groups as if they were new.
1131 (mapatoms 1267 (mapatoms
1132 (lambda (sym) 1268 (lambda (sym)
1133 (when (setq group (symbol-name sym)) 1269 (when (setq group (symbol-name sym))
1134 (let ((do-sub (gnus-matches-options-n group))) 1270 (let ((do-sub (gnus-matches-options-n group)))
1135 (cond 1271 (cond
1136 ((eq do-sub 'subscribe) 1272 ((eq do-sub 'subscribe)
1137 (gnus-sethash group group gnus-killed-hashtb) 1273 (gnus-sethash group group gnus-killed-hashtb)
1138 (funcall gnus-subscribe-options-newsgroup-method group)) 1274 (gnus-call-subscribe-functions
1139 ((eq do-sub 'ignore) 1275 gnus-subscribe-options-newsgroup-method group))
1140 nil) 1276 ((eq do-sub 'ignore)
1141 (t 1277 nil)
1142 (push group gnus-killed-list)))))) 1278 (t
1143 gnus-active-hashtb) 1279 (push group gnus-killed-list))))))
1280 gnus-active-hashtb)
1144 (dolist (group groups) 1281 (dolist (group groups)
1145 ;; Only subscribe the default groups that are activated. 1282 ;; Only subscribe the default groups that are activated.
1146 (when (gnus-active group) 1283 (when (gnus-active group)
1147 (gnus-group-change-level 1284 (gnus-group-change-level
1148 group gnus-level-default-subscribed gnus-level-killed))) 1285 group gnus-level-default-subscribed gnus-level-killed)))
1149 (save-excursion 1286 (save-excursion
1150 (set-buffer gnus-group-buffer) 1287 (set-buffer gnus-group-buffer)
1151 (gnus-group-make-help-group)) 1288 ;; Don't error if the group already exists. This happens when a
1289 ;; first-time user types 'F'. -- didier
1290 (gnus-group-make-help-group t))
1152 (when gnus-novice-user 1291 (when gnus-novice-user
1153 (gnus-message 7 "`A k' to list killed groups")))))) 1292 (gnus-message 7 "`A k' to list killed groups"))))))
1154 1293
1155 (defun gnus-subscribe-group (group &optional previous method) 1294 (defun gnus-subscribe-group (group &optional previous method)
1156 "Subcribe GROUP and put it after PREVIOUS." 1295 "Subscribe GROUP and put it after PREVIOUS."
1157 (gnus-group-change-level 1296 (gnus-group-change-level
1158 (if method 1297 (if method
1159 (list t group gnus-level-default-subscribed nil nil method) 1298 (list t group gnus-level-default-subscribed nil nil method)
1160 group) 1299 group)
1161 gnus-level-default-subscribed gnus-level-killed previous t) 1300 gnus-level-default-subscribed gnus-level-killed previous t)
1211 ;; If the group was killed, we remove it from the killed or zombie 1350 ;; If the group was killed, we remove it from the killed or zombie
1212 ;; list. If not, and it is in fact going to be killed, we remove 1351 ;; list. If not, and it is in fact going to be killed, we remove
1213 ;; it from the newsrc hash table and assoc. 1352 ;; it from the newsrc hash table and assoc.
1214 (cond 1353 (cond
1215 ((>= oldlevel gnus-level-zombie) 1354 ((>= oldlevel gnus-level-zombie)
1216 (if (= oldlevel gnus-level-zombie) 1355 ;; oldlevel could be wrong.
1217 (setq gnus-zombie-list (delete group gnus-zombie-list)) 1356 (setq gnus-zombie-list (delete group gnus-zombie-list))
1218 (setq gnus-killed-list (delete group gnus-killed-list)))) 1357 (setq gnus-killed-list (delete group gnus-killed-list)))
1219 (t 1358 (t
1220 (when (and (>= level gnus-level-zombie) 1359 (when (and (>= level gnus-level-zombie)
1221 entry) 1360 entry)
1222 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb) 1361 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
1223 (when (nth 3 entry) 1362 (when (nth 3 entry)
1236 ;; We do not enter foreign groups into the list of dead 1375 ;; We do not enter foreign groups into the list of dead
1237 ;; groups. 1376 ;; groups.
1238 (unless (gnus-group-foreign-p group) 1377 (unless (gnus-group-foreign-p group)
1239 (if (= level gnus-level-zombie) 1378 (if (= level gnus-level-zombie)
1240 (push group gnus-zombie-list) 1379 (push group gnus-zombie-list)
1241 (push group gnus-killed-list)))) 1380 (if (= oldlevel gnus-level-killed)
1381 ;; Remove from active hashtb.
1382 (unintern group gnus-active-hashtb)
1383 ;; Don't add it into killed-list if it was killed.
1384 (push group gnus-killed-list)))))
1242 (t 1385 (t
1243 ;; If the list is to be entered into the newsrc assoc, and 1386 ;; If the list is to be entered into the newsrc assoc, and
1244 ;; it was killed, we have to create an entry in the newsrc 1387 ;; it was killed, we have to create an entry in the newsrc
1245 ;; hashtb format and fix the pointers in the newsrc assoc. 1388 ;; hashtb format and fix the pointers in the newsrc assoc.
1246 (if (< oldlevel gnus-level-zombie) 1389 (if (< oldlevel gnus-level-zombie)
1304 ;; Find all bogus newsgroup that are subscribed. 1447 ;; Find all bogus newsgroup that are subscribed.
1305 (while newsrc 1448 (while newsrc
1306 (setq info (pop newsrc) 1449 (setq info (pop newsrc)
1307 group (gnus-info-group info)) 1450 group (gnus-info-group info))
1308 (unless (or (gnus-active group) ; Active 1451 (unless (or (gnus-active group) ; Active
1309 (gnus-info-method info)) ; Foreign 1452 (and (gnus-info-method info)
1453 (not (gnus-secondary-method-p
1454 (gnus-info-method info))))) ; Foreign
1310 ;; Found a bogus newsgroup. 1455 ;; Found a bogus newsgroup.
1311 (push group bogus))) 1456 (push group bogus)))
1312 (if confirm 1457 (if confirm
1313 (map-y-or-n-p 1458 (map-y-or-n-p
1314 "Remove bogus group %s? " 1459 "Remove bogus group %s? "
1362 (setcar active (car cache-active))) 1507 (setcar active (car cache-active)))
1363 (when (> (cdr cache-active) (cdr active)) 1508 (when (> (cdr cache-active) (cdr active))
1364 (setcdr active (cdr cache-active)))))))) 1509 (setcdr active (cdr cache-active))))))))
1365 1510
1366 (defun gnus-activate-group (group &optional scan dont-check method) 1511 (defun gnus-activate-group (group &optional scan dont-check method)
1367 ;; Check whether a group has been activated or not. 1512 "Check whether a group has been activated or not.
1368 ;; If SCAN, request a scan of that group as well. 1513 If SCAN, request a scan of that group as well."
1369 (let ((method (or method (inline (gnus-find-method-for-group group)))) 1514 (let ((method (or method (inline (gnus-find-method-for-group group))))
1370 active) 1515 active)
1371 (and (inline (gnus-check-server method)) 1516 (and (inline (gnus-check-server method))
1372 ;; We escape all bugs and quit here to make it possible to 1517 ;; We escape all bugs and quit here to make it possible to
1373 ;; continue if a group is so out-there that it reports bugs 1518 ;; continue if a group is so out-there that it reports bugs
1375 (progn 1520 (progn
1376 (and scan 1521 (and scan
1377 (gnus-check-backend-function 'request-scan (car method)) 1522 (gnus-check-backend-function 'request-scan (car method))
1378 (gnus-request-scan group method)) 1523 (gnus-request-scan group method))
1379 t) 1524 t)
1380 (condition-case () 1525 (if (or debug-on-error debug-on-quit)
1381 (inline (gnus-request-group group dont-check method)) 1526 (inline (gnus-request-group group dont-check method))
1382 ;;(error nil) 1527 (condition-case nil
1383 (quit 1528 (inline (gnus-request-group group dont-check method))
1384 (message "Quit activating %s" group) 1529 ;;(error nil)
1385 nil)) 1530 (quit
1386 (setq active (gnus-parse-active)) 1531 (message "Quit activating %s" group)
1387 ;; If there are no articles in the group, the GROUP 1532 nil)))
1388 ;; command may have responded with the `(0 . 0)'. We 1533 (unless dont-check
1389 ;; ignore this if we already have an active entry 1534 (setq active (gnus-parse-active))
1390 ;; for the group. 1535 ;; If there are no articles in the group, the GROUP
1391 (if (and (zerop (car active)) 1536 ;; command may have responded with the `(0 . 0)'. We
1392 (zerop (cdr active)) 1537 ;; ignore this if we already have an active entry
1393 (gnus-active group)) 1538 ;; for the group.
1394 (gnus-active group) 1539 (if (and (zerop (car active))
1395 (gnus-set-active group active) 1540 (zerop (cdr active))
1396 ;; Return the new active info. 1541 (gnus-active group))
1397 active)))) 1542 (gnus-active group)
1543
1544 ;; If a cache is present, we may have to alter the active info.
1545 (when gnus-use-cache
1546 (inline (gnus-cache-possibly-alter-active
1547 group active)))
1548
1549 ;; If the agent is enabled, we may have to alter the active info.
1550 (when gnus-agent
1551 (gnus-agent-possibly-alter-active group active))
1552
1553 (gnus-set-active group active)
1554 ;; Return the new active info.
1555 active)))))
1398 1556
1399 (defun gnus-get-unread-articles-in-group (info active &optional update) 1557 (defun gnus-get-unread-articles-in-group (info active &optional update)
1400 (when active 1558 (when (and info active)
1401 ;; Allow the backend to update the info in the group. 1559 ;; Allow the backend to update the info in the group.
1402 (when (and update 1560 (when (and update
1403 (gnus-request-update-info 1561 (gnus-request-update-info
1404 info (inline (gnus-find-method-for-group 1562 info (inline (gnus-find-method-for-group
1405 (gnus-info-group info))))) 1563 (gnus-info-group info)))))
1406 (gnus-activate-group (gnus-info-group info) nil t)) 1564 (gnus-activate-group (gnus-info-group info) nil t))
1407 1565
1408 (let* ((range (gnus-info-read info)) 1566 (let* ((range (gnus-info-read info))
1409 (num 0)) 1567 (num 0))
1568
1569 ;; These checks are present in gnus-activate-group but skipped
1570 ;; due to setting dont-check in the preceeding call.
1571
1410 ;; If a cache is present, we may have to alter the active info. 1572 ;; If a cache is present, we may have to alter the active info.
1411 (when (and gnus-use-cache info) 1573 (when (and gnus-use-cache info)
1412 (inline (gnus-cache-possibly-alter-active 1574 (inline (gnus-cache-possibly-alter-active
1413 (gnus-info-group info) active))) 1575 (gnus-info-group info) active)))
1576
1577 ;; If the agent is enabled, we may have to alter the active info.
1578 (when (and gnus-agent info)
1579 (gnus-agent-possibly-alter-active (gnus-info-group info) active info))
1580
1414 ;; Modify the list of read articles according to what articles 1581 ;; Modify the list of read articles according to what articles
1415 ;; are available; then tally the unread articles and add the 1582 ;; are available; then tally the unread articles and add the
1416 ;; number to the group hash table entry. 1583 ;; number to the group hash table entry.
1417 (cond 1584 (cond
1418 ((zerop (cdr active)) 1585 ((zerop (cdr active))
1475 (or (and (atom (car range)) (car range)) 1642 (or (and (atom (car range)) (car range))
1476 (caar range))))) 1643 (caar range)))))
1477 (setq range (cdr range))) 1644 (setq range (cdr range)))
1478 (setq num (max 0 (- (cdr active) num))))) 1645 (setq num (max 0 (- (cdr active) num)))))
1479 ;; Set the number of unread articles. 1646 ;; Set the number of unread articles.
1480 (when info 1647 (when (and info
1648 (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb))
1481 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)) 1649 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
1482 num))) 1650 num)))
1483 1651
1484 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' 1652 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
1485 ;; and compute how many unread articles there are in each group. 1653 ;; and compute how many unread articles there are in each group.
1486 (defun gnus-get-unread-articles (&optional level) 1654 (defun gnus-get-unread-articles (&optional level)
1655 (setq gnus-server-method-cache nil)
1487 (let* ((newsrc (cdr gnus-newsrc-alist)) 1656 (let* ((newsrc (cdr gnus-newsrc-alist))
1488 (level (or level gnus-activate-level (1+ gnus-level-subscribed))) 1657 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
1489 (foreign-level 1658 (foreign-level
1490 (min 1659 (min
1491 (cond ((and gnus-activate-foreign-newsgroups 1660 (cond ((and gnus-activate-foreign-newsgroups
1493 (1+ gnus-level-subscribed)) 1662 (1+ gnus-level-subscribed))
1494 ((numberp gnus-activate-foreign-newsgroups) 1663 ((numberp gnus-activate-foreign-newsgroups)
1495 gnus-activate-foreign-newsgroups) 1664 gnus-activate-foreign-newsgroups)
1496 (t 0)) 1665 (t 0))
1497 level)) 1666 level))
1498 scanned-methods info group active method retrievegroups) 1667 (methods-cache nil)
1499 (gnus-message 5 "Checking new news...") 1668 (type-cache nil)
1669 scanned-methods info group active method retrieve-groups cmethod
1670 method-type)
1671 (gnus-message 6 "Checking new news...")
1500 1672
1501 (while newsrc 1673 (while newsrc
1502 (setq active (gnus-active (setq group (gnus-info-group 1674 (setq active (gnus-active (setq group (gnus-info-group
1503 (setq info (pop newsrc)))))) 1675 (setq info (pop newsrc))))))
1504 1676
1505 ;; Check newsgroups. If the user doesn't want to check them, or 1677 ;; Check newsgroups. If the user doesn't want to check them, or
1506 ;; they can't be checked (for instance, if the news server can't 1678 ;; they can't be checked (for instance, if the news server can't
1507 ;; be reached) we just set the number of unread articles in this 1679 ;; be reached) we just set the number of unread articles in this
1508 ;; newsgroup to t. This means that Gnus thinks that there are 1680 ;; newsgroup to t. This means that Gnus thinks that there are
1512 ;; >0 for an active group with messages 1684 ;; >0 for an active group with messages
1513 ;; 0 for an active group with no unread messages 1685 ;; 0 for an active group with no unread messages
1514 ;; nil for non-foreign groups that the user has requested not be checked 1686 ;; nil for non-foreign groups that the user has requested not be checked
1515 ;; t for unchecked foreign groups or bogus groups, or groups that can't 1687 ;; t for unchecked foreign groups or bogus groups, or groups that can't
1516 ;; be checked, for one reason or other. 1688 ;; be checked, for one reason or other.
1517 (if (and (setq method (gnus-info-method info)) 1689 (when (setq method (gnus-info-method info))
1518 (not (inline 1690 (if (setq cmethod (assoc method methods-cache))
1519 (gnus-server-equal 1691 (setq method (cdr cmethod))
1520 gnus-select-method 1692 (setq cmethod (inline (gnus-server-get-method nil method)))
1521 (setq method (gnus-server-get-method nil method))))) 1693 (push (cons method cmethod) methods-cache)
1522 (not (gnus-secondary-method-p method))) 1694 (setq method cmethod)))
1523 ;; These groups are foreign. Check the level. 1695 (when (and method
1524 (when (and (<= (gnus-info-level info) foreign-level) 1696 (not (setq method-type (cdr (assoc method type-cache)))))
1525 (setq active (gnus-activate-group group 'scan))) 1697 (setq method-type
1526 ;; Let the Gnus agent save the active file. 1698 (cond
1527 (when (and gnus-agent gnus-plugged active) 1699 ((gnus-secondary-method-p method)
1528 (gnus-agent-save-group-info 1700 'secondary)
1529 method (gnus-group-real-name group) active)) 1701 ((inline (gnus-server-equal gnus-select-method method))
1530 (unless (inline (gnus-virtual-group-p group)) 1702 'primary)
1531 (inline (gnus-close-group group))) 1703 (t
1532 (when (fboundp (intern (concat (symbol-name (car method)) 1704 'foreign)))
1533 "-request-update-info"))) 1705 (push (cons method method-type) type-cache))
1534 (inline (gnus-request-update-info info method)))) 1706
1535 ;; These groups are native or secondary. 1707 (cond ((and method (eq method-type 'foreign))
1536 (cond 1708 ;; These groups are foreign. Check the level.
1537 ;; We don't want these groups. 1709 (when (and (<= (gnus-info-level info) foreign-level)
1538 ((> (gnus-info-level info) level) 1710 (setq active (gnus-activate-group group 'scan)))
1539 (setq active 'ignore)) 1711 ;; Let the Gnus agent save the active file.
1540 ;; Activate groups. 1712 (when (and gnus-agent active (gnus-online method))
1541 ((not gnus-read-active-file) 1713 (gnus-agent-save-group-info
1542 (if (gnus-check-backend-function 'retrieve-groups group) 1714 method (gnus-group-real-name group) active))
1543 ;; if server support gnus-retrieve-groups we push 1715 (unless (inline (gnus-virtual-group-p group))
1544 ;; the group onto retrievegroups for later checking 1716 (inline (gnus-close-group group)))
1545 (if (assoc method retrievegroups) 1717 (when (fboundp (intern (concat (symbol-name (car method))
1546 (setcdr (assoc method retrievegroups) 1718 "-request-update-info")))
1547 (cons group (cdr (assoc method retrievegroups)))) 1719 (inline (gnus-request-update-info info method)))))
1548 (push (list method group) retrievegroups)) 1720 ;; These groups are native or secondary.
1549 ;; hack: `nnmail-get-new-mail' changes the mail-source depending 1721 ((> (gnus-info-level info) level)
1550 ;; on the group, so we must perform a scan for every group 1722 ;; We don't want these groups.
1551 ;; if the users has any directory mail sources. 1723 (setq active 'ignore))
1552 ;; hack: if `nnmail-scan-directory-mail-source-once' is non-nil, 1724 ;; Activate groups.
1553 ;; for it scan all spool files even when the groups are 1725 ((not gnus-read-active-file)
1554 ;; not required. 1726 (if (gnus-check-backend-function 'retrieve-groups group)
1555 (if (and 1727 ;; if server support gnus-retrieve-groups we push
1556 (or nnmail-scan-directory-mail-source-once 1728 ;; the group onto retrievegroups for later checking
1557 (null (assq 'directory 1729 (if (assoc method retrieve-groups)
1558 (or mail-sources 1730 (setcdr (assoc method retrieve-groups)
1559 (if (listp nnmail-spool-file) 1731 (cons group (cdr (assoc method retrieve-groups))))
1560 nnmail-spool-file 1732 (push (list method group) retrieve-groups))
1561 (list nnmail-spool-file)))))) 1733 ;; hack: `nnmail-get-new-mail' changes the mail-source depending
1562 (member method scanned-methods)) 1734 ;; on the group, so we must perform a scan for every group
1563 (setq active (gnus-activate-group group)) 1735 ;; if the users has any directory mail sources.
1564 (setq active (gnus-activate-group group 'scan)) 1736 ;; hack: if `nnmail-scan-directory-mail-source-once' is non-nil,
1565 (push method scanned-methods)) 1737 ;; for it scan all spool files even when the groups are
1566 (when active 1738 ;; not required.
1567 (gnus-close-group group)))))) 1739 (if (and
1740 (or nnmail-scan-directory-mail-source-once
1741 (null (assq 'directory
1742 (or mail-sources
1743 (if (listp nnmail-spool-file)
1744 nnmail-spool-file
1745 (list nnmail-spool-file))))))
1746 (member method scanned-methods))
1747 (setq active (gnus-activate-group group))
1748 (setq active (gnus-activate-group group 'scan))
1749 (push method scanned-methods))
1750 (when active
1751 (gnus-close-group group)))))
1568 1752
1569 ;; Get the number of unread articles in the group. 1753 ;; Get the number of unread articles in the group.
1570 (cond 1754 (cond
1571 ((eq active 'ignore) 1755 ((eq active 'ignore)
1572 ;; Don't do anything. 1756 ;; Don't do anything.
1576 (t 1760 (t
1577 ;; The group couldn't be reached, so we nix out the number of 1761 ;; The group couldn't be reached, so we nix out the number of
1578 ;; unread articles and stuff. 1762 ;; unread articles and stuff.
1579 (gnus-set-active group nil) 1763 (gnus-set-active group nil)
1580 (let ((tmp (gnus-gethash group gnus-newsrc-hashtb))) 1764 (let ((tmp (gnus-gethash group gnus-newsrc-hashtb)))
1581 (if tmp (setcar tmp t)))))) 1765 (when tmp
1766 (setcar tmp t))))))
1582 1767
1583 ;; iterate through groups on methods which support gnus-retrieve-groups 1768 ;; iterate through groups on methods which support gnus-retrieve-groups
1584 ;; and fetch a partial active file and use it to find new news. 1769 ;; and fetch a partial active file and use it to find new news.
1585 (while retrievegroups 1770 (dolist (rg retrieve-groups)
1586 (let* ((mg (pop retrievegroups)) 1771 (let ((method (or (car rg) gnus-select-method))
1587 (method (or (car mg) gnus-select-method)) 1772 (groups (cdr rg)))
1588 (groups (cdr mg)))
1589 (when (gnus-check-server method) 1773 (when (gnus-check-server method)
1590 ;; Request that the backend scan its incoming messages. 1774 ;; Request that the backend scan its incoming messages.
1591 (when (gnus-check-backend-function 'request-scan (car method)) 1775 (when (gnus-check-backend-function 'request-scan (car method))
1592 (gnus-request-scan nil method)) 1776 (gnus-request-scan nil method))
1593 (gnus-read-active-file-2 (mapcar (lambda (group) 1777 (gnus-read-active-file-2
1594 (gnus-group-real-name group)) 1778 (mapcar (lambda (group) (gnus-group-real-name group)) groups)
1595 groups) method) 1779 method)
1596 (dolist (group groups) 1780 (dolist (group groups)
1597 (cond 1781 (cond
1598 ((setq active (gnus-active (gnus-info-group 1782 ((setq active (gnus-active (gnus-info-group
1599 (setq info (gnus-get-info group))))) 1783 (setq info (gnus-get-info group)))))
1600 (inline (gnus-get-unread-articles-in-group info active t))) 1784 (inline (gnus-get-unread-articles-in-group info active t)))
1601 (t 1785 (t
1602 ;; The group couldn't be reached, so we nix out the number of 1786 ;; The group couldn't be reached, so we nix out the number of
1603 ;; unread articles and stuff. 1787 ;; unread articles and stuff.
1604 (gnus-set-active group nil) 1788 (gnus-set-active group nil)
1605 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))))))) 1789 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))))))
1606 1790
1607 (gnus-message 5 "Checking new news...done"))) 1791 (gnus-message 6 "Checking new news...done")))
1608 1792
1609 ;; Create a hash table out of the newsrc alist. The `car's of the 1793 ;; Create a hash table out of the newsrc alist. The `car's of the
1610 ;; alist elements are used as keys. 1794 ;; alist elements are used as keys.
1611 (defun gnus-make-hashtable-from-newsrc-alist () 1795 (defun gnus-make-hashtable-from-newsrc-alist ()
1612 (let ((alist gnus-newsrc-alist) 1796 (let ((alist gnus-newsrc-alist)
1662 (while articles 1846 (while articles
1663 (when (gnus-member-of-range 1847 (when (gnus-member-of-range
1664 (setq article (pop articles)) ranges) 1848 (setq article (pop articles)) ranges)
1665 (push article news))) 1849 (push article news)))
1666 (when news 1850 (when news
1851 ;; Enter this list into the group info.
1667 (gnus-info-set-read 1852 (gnus-info-set-read
1668 info (gnus-remove-from-range (gnus-info-read info) (nreverse news))) 1853 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
1854
1855 ;; Set the number of unread articles in gnus-newsrc-hashtb.
1856 (gnus-get-unread-articles-in-group info (gnus-active group))
1857
1858 ;; Insert the change into the group buffer and the dribble file.
1859 (gnus-group-update-group group t))))
1860
1861 (defun gnus-make-ascending-articles-unread (group articles)
1862 "Mark ascending ARTICLES in GROUP as unread."
1863 (let* ((entry (or (gnus-gethash group gnus-newsrc-hashtb)
1864 (gnus-gethash (gnus-group-real-name group)
1865 gnus-newsrc-hashtb)))
1866 (info (nth 2 entry))
1867 (ranges (gnus-info-read info))
1868 (r ranges)
1869 modified)
1870
1871 (while articles
1872 (let ((article (pop articles))) ; get the next article to remove from ranges
1873 (while (let ((range (car ranges))) ; note the current range
1874 (if (atom range) ; single value range
1875 (cond ((not range)
1876 ;; the articles extend past the end of the ranges
1877 ;; OK - I'm done
1878 (setq articles nil))
1879 ((< range article)
1880 ;; this range preceeds the article. Leave the range unmodified.
1881 (pop ranges)
1882 ranges)
1883 ((= range article)
1884 ;; this range exactly matches the article; REMOVE THE RANGE.
1885 ;; NOTE: When the range being removed is the last range, the list is corrupted by inserting null at its end.
1886 (setcar ranges (cadr ranges))
1887 (setcdr ranges (cddr ranges))
1888 (setq modified (if (car ranges) t 'remove-null))
1889 nil))
1890 (let ((min (car range))
1891 (max (cdr range)))
1892 ;; I have a min/max range to consider
1893 (cond ((> min max) ; invalid range introduced by splitter
1894 (setcar ranges (cadr ranges))
1895 (setcdr ranges (cddr ranges))
1896 (setq modified (if (car ranges) t 'remove-null))
1897 ranges)
1898 ((= min max)
1899 ;; replace min/max range with a single-value range
1900 (setcar ranges min)
1901 ranges)
1902 ((< max article)
1903 ;; this range preceeds the article. Leave the range unmodified.
1904 (pop ranges)
1905 ranges)
1906 ((< article min)
1907 ;; this article preceeds the range. Return null to move to the
1908 ;; next article
1909 nil)
1910 (t
1911 ;; this article splits the range into two parts
1912 (setcdr ranges (cons (cons (1+ article) max) (cdr ranges)))
1913 (setcdr range (1- article))
1914 (setq modified t)
1915 ranges))))))))
1916
1917 (when modified
1918 (when (eq modified 'remove-null)
1919 (setq r (delq nil r)))
1920 ;; Enter this list into the group info.
1921 (gnus-info-set-read info r)
1922
1923 ;; Set the number of unread articles in gnus-newsrc-hashtb.
1924 (gnus-get-unread-articles-in-group info (gnus-active group))
1925
1926 ;; Insert the change into the group buffer and the dribble file.
1669 (gnus-group-update-group group t)))) 1927 (gnus-group-update-group group t))))
1670 1928
1671 ;; Enter all dead groups into the hashtb. 1929 ;; Enter all dead groups into the hashtb.
1672 (defun gnus-update-active-hashtb-from-killed () 1930 (defun gnus-update-active-hashtb-from-killed ()
1673 (let ((hashtb (setq gnus-active-hashtb (gnus-make-hashtable 4096))) 1931 (let ((hashtb (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
1729 (set-buffer nntp-server-buffer) 1987 (set-buffer nntp-server-buffer)
1730 (while (setq method (pop methods)) 1988 (while (setq method (pop methods))
1731 ;; Only do each method once, in case the methods appear more 1989 ;; Only do each method once, in case the methods appear more
1732 ;; than once in this list. 1990 ;; than once in this list.
1733 (unless (member method methods) 1991 (unless (member method methods)
1734 (condition-case () 1992 (if (or debug-on-error debug-on-quit)
1735 (gnus-read-active-file-1 method force) 1993 (gnus-read-active-file-1 method force)
1736 ;; We catch C-g so that we can continue past servers 1994 (condition-case ()
1737 ;; that do not respond. 1995 (gnus-read-active-file-1 method force)
1738 (quit 1996 ;; We catch C-g so that we can continue past servers
1739 (message "Quit reading the active file") 1997 ;; that do not respond.
1740 nil))))))) 1998 (quit
1999 (message "Quit reading the active file")
2000 nil))))))))
1741 2001
1742 (defun gnus-read-active-file-1 (method force) 2002 (defun gnus-read-active-file-1 (method force)
1743 (let (where mesg) 2003 (let (where mesg)
1744 (setq where (nth 1 method) 2004 (setq where (nth 1 method)
1745 mesg (format "Reading active file%s via %s..." 2005 mesg (format "Reading active file%s via %s..."
1759 (gmethod (gnus-server-get-method nil method)) 2019 (gmethod (gnus-server-get-method nil method))
1760 groups info) 2020 groups info)
1761 (while (setq info (pop newsrc)) 2021 (while (setq info (pop newsrc))
1762 (when (inline 2022 (when (inline
1763 (gnus-server-equal 2023 (gnus-server-equal
1764 (inline 2024 (inline
1765 (gnus-find-method-for-group 2025 (gnus-find-method-for-group
1766 (gnus-info-group info) info)) 2026 (gnus-info-group info) info))
1767 gmethod)) 2027 gmethod))
1768 (push (gnus-group-real-name (gnus-info-group info)) 2028 (push (gnus-group-real-name (gnus-info-group info))
1769 groups))) 2029 groups)))
1770 (gnus-read-active-file-2 groups method))) 2030 (gnus-read-active-file-2 groups method)))
1771 ((null method) 2031 ((null method)
1772 t) 2032 t)
1780 ;; We mark this active file as read. 2040 ;; We mark this active file as read.
1781 (push method gnus-have-read-active-file) 2041 (push method gnus-have-read-active-file)
1782 (gnus-message 5 "%sdone" mesg))))))) 2042 (gnus-message 5 "%sdone" mesg)))))))
1783 2043
1784 (defun gnus-read-active-file-2 (groups method) 2044 (defun gnus-read-active-file-2 (groups method)
1785 "Read an active file for GROUPS in METHOD using gnus-retrieve-groups." 2045 "Read an active file for GROUPS in METHOD using `gnus-retrieve-groups'."
1786 (when groups 2046 (when groups
1787 (save-excursion 2047 (save-excursion
1788 (set-buffer nntp-server-buffer) 2048 (set-buffer nntp-server-buffer)
1789 (gnus-check-server method) 2049 (gnus-check-server method)
1790 (let ((list-type (gnus-retrieve-groups groups method))) 2050 (let ((list-type (gnus-retrieve-groups groups method)))
1827 (goto-char (point-max)) 2087 (goto-char (point-max))
1828 (while (re-search-backward "[][';?()#]" nil t) 2088 (while (re-search-backward "[][';?()#]" nil t)
1829 (insert ?\\))) 2089 (insert ?\\)))
1830 2090
1831 ;; Let the Gnus agent save the active file. 2091 ;; Let the Gnus agent save the active file.
1832 (when (and gnus-agent real-active gnus-plugged) 2092 (when (and gnus-agent real-active (gnus-online method))
1833 (gnus-agent-save-active method)) 2093 (gnus-agent-save-active method))
1834 2094
1835 ;; If these are groups from a foreign select method, we insert the 2095 ;; If these are groups from a foreign select method, we insert the
1836 ;; group prefix in front of the group names. 2096 ;; group prefix in front of the group names.
1837 (when (not (gnus-server-equal 2097 (when (not (gnus-server-equal
1847 (zerop (forward-line 1))))))) 2107 (zerop (forward-line 1)))))))
1848 ;; Store the active file in a hash table. 2108 ;; Store the active file in a hash table.
1849 (goto-char (point-min)) 2109 (goto-char (point-min))
1850 (let (group max min) 2110 (let (group max min)
1851 (while (not (eobp)) 2111 (while (not (eobp))
1852 (condition-case err 2112 (condition-case ()
1853 (progn 2113 (progn
1854 (narrow-to-region (point) (gnus-point-at-eol)) 2114 (narrow-to-region (point) (gnus-point-at-eol))
1855 ;; group gets set to a symbol interned in the hash table 2115 ;; group gets set to a symbol interned in the hash table
1856 ;; (what a hack!!) - jwz 2116 ;; (what a hack!!) - jwz
1857 (setq group (let ((obarray hashtb)) (read cur))) 2117 (setq group (let ((obarray hashtb)) (read cur)))
1903 (gnus-group-prefixed-name "" method)))) 2163 (gnus-group-prefixed-name "" method))))
1904 2164
1905 ;; Let the Gnus agent save the active file. 2165 ;; Let the Gnus agent save the active file.
1906 (if (and gnus-agent 2166 (if (and gnus-agent
1907 real-active 2167 real-active
1908 gnus-plugged 2168 (gnus-online method)
1909 (gnus-agent-method-p method)) 2169 (gnus-agent-method-p method))
1910 (progn 2170 (progn
1911 (gnus-agent-save-groups method) 2171 (gnus-agent-save-active method)
1912 (gnus-active-to-gnus-format method hashtb nil real-active)) 2172 (gnus-active-to-gnus-format method hashtb nil real-active))
1913 2173
1914 (goto-char (point-min)) 2174 (goto-char (point-min))
1915 ;; We split this into to separate loops, one with the prefix 2175 ;; We split this into to separate loops, one with the prefix
1916 ;; and one without to speed the reading up somewhat. 2176 ;; and one without to speed the reading up somewhat.
1944 2204
1945 (defun gnus-read-newsrc-file (&optional force) 2205 (defun gnus-read-newsrc-file (&optional force)
1946 "Read startup file. 2206 "Read startup file.
1947 If FORCE is non-nil, the .newsrc file is read." 2207 If FORCE is non-nil, the .newsrc file is read."
1948 ;; Reset variables that might be defined in the .newsrc.eld file. 2208 ;; Reset variables that might be defined in the .newsrc.eld file.
1949 (let ((variables gnus-variable-list)) 2209 (let ((variables (remove 'gnus-format-specs gnus-variable-list)))
1950 (while variables 2210 (while variables
1951 (set (car variables) nil) 2211 (set (car variables) nil)
1952 (setq variables (cdr variables)))) 2212 (setq variables (cdr variables))))
1953 (let* ((newsrc-file gnus-current-startup-file) 2213 (let* ((newsrc-file gnus-current-startup-file)
1954 (quick-file (concat newsrc-file ".el"))) 2214 (quick-file (concat newsrc-file ".el")))
1982 2242
1983 ;; Convert old to new. 2243 ;; Convert old to new.
1984 (gnus-convert-old-newsrc)))) 2244 (gnus-convert-old-newsrc))))
1985 2245
1986 (defun gnus-convert-old-newsrc () 2246 (defun gnus-convert-old-newsrc ()
1987 "Convert old newsrc into the new format, if needed." 2247 "Convert old newsrc formats into the current format, if needed."
1988 (let ((fcv (and gnus-newsrc-file-version 2248 (let ((fcv (and gnus-newsrc-file-version
1989 (gnus-continuum-version gnus-newsrc-file-version)))) 2249 (gnus-continuum-version gnus-newsrc-file-version)))
1990 (cond 2250 (gcv (gnus-continuum-version)))
1991 ;; No .newsrc.eld file was loaded. 2251 (when fcv
1992 ((null fcv) nil) 2252 ;; A newsrc file was loaded.
1993 ;; Gnus 5 .newsrc.eld was loaded. 2253 (let (prompt-displayed
1994 ((< fcv (gnus-continuum-version "September Gnus v0.1")) 2254 (converters
1995 (gnus-convert-old-ticks))))) 2255 (sort
1996 2256 (mapcar (lambda (date-func)
1997 (defun gnus-convert-old-ticks () 2257 (cons (gnus-continuum-version (car date-func))
2258 date-func))
2259 ;; This is a list of converters that must be run
2260 ;; to bring the newsrc file up to the current
2261 ;; version. If you create an incompatibility
2262 ;; with older versions, you should create an
2263 ;; entry here. The entry should consist of the
2264 ;; current gnus version (hardcoded so that it
2265 ;; doesn't change with each release) and the
2266 ;; function that must be applied to convert the
2267 ;; previous version into the current version.
2268 '(("September Gnus v0.1" nil
2269 gnus-convert-old-ticks)
2270 ("Oort Gnus v0.08" "legacy-gnus-agent"
2271 gnus-agent-convert-to-compressed-agentview)
2272 ("Gnus v5.10.7" "legacy-gnus-agent"
2273 gnus-agent-unlist-expire-days)
2274 ("Gnus v5.10.7" "legacy-gnus-agent"
2275 gnus-agent-unhook-expire-days)))
2276 #'car-less-than-car)))
2277 ;; Skip converters older than the file version
2278 (while (and converters (>= fcv (caar converters)))
2279 (pop converters))
2280
2281 ;; Perform converters to bring older version up to date.
2282 (when (and converters (< fcv (caar converters)))
2283 (while (and converters (< fcv (caar converters))
2284 (<= (caar converters) gcv))
2285 (let* ((converter-spec (pop converters))
2286 (convert-to (nth 1 converter-spec))
2287 (load-from (nth 2 converter-spec))
2288 (func (nth 3 converter-spec)))
2289 (when (and load-from
2290 (not (fboundp func)))
2291 (load load-from t))
2292 (or prompt-displayed
2293 (not (gnus-convert-converter-needs-prompt func))
2294 (while (let (c
2295 (cursor-in-echo-area t)
2296 (echo-keystrokes 0))
2297 (message "Convert gnus from version '%s' to '%s'? (n/y/?)"
2298 gnus-newsrc-file-version gnus-version)
2299 (setq c (read-char-exclusive))
2300
2301 (cond ((or (eq c ?n) (eq c ?N))
2302 (error "Can not start gnus without converting"))
2303 ((or (eq c ?y) (eq c ?Y))
2304 (setq prompt-displayed t)
2305 nil)
2306 ((eq c ?\?)
2307 (message "This conversion is irreversible. \
2308 To be safe, you should backup your files before proceeding.")
2309 (sit-for 5)
2310 t)
2311 (t
2312 (gnus-message 3 "Ignoring unexpected input")
2313 (sit-for 3)
2314 t)))))
2315
2316 (funcall func convert-to)))
2317 (gnus-dribble-enter
2318 (format ";Converted gnus from version '%s' to '%s'."
2319 gnus-newsrc-file-version gnus-version)))))))
2320
2321 (defun gnus-convert-mark-converter-prompt (converter no-prompt)
2322 "Indicate whether CONVERTER requires gnus-convert-old-newsrc to
2323 display the conversion prompt. NO-PROMPT may be nil (prompt),
2324 t (no prompt), or any form that can be called as a function.
2325 The form should return either t or nil."
2326 (put converter 'gnus-convert-no-prompt no-prompt))
2327
2328 (defun gnus-convert-converter-needs-prompt (converter)
2329 (let ((no-prompt (get converter 'gnus-convert-no-prompt)))
2330 (not (if (memq no-prompt '(t nil))
2331 no-prompt
2332 (funcall no-prompt)))))
2333
2334 (defun gnus-convert-old-ticks (converting-to)
1998 (let ((newsrc (cdr gnus-newsrc-alist)) 2335 (let ((newsrc (cdr gnus-newsrc-alist))
1999 marks info dormant ticked) 2336 marks info dormant ticked)
2000 (while (setq info (pop newsrc)) 2337 (while (setq info (pop newsrc))
2001 (when (setq marks (gnus-info-marks info)) 2338 (when (setq marks (gnus-info-marks info))
2002 (setq dormant (cdr (assq 'dormant marks)) 2339 (setq dormant (cdr (assq 'dormant marks))
2007 (gnus-add-to-range 2344 (gnus-add-to-range
2008 (gnus-info-read info) 2345 (gnus-info-read info)
2009 (nconc (gnus-uncompress-range dormant) 2346 (nconc (gnus-uncompress-range dormant)
2010 (gnus-uncompress-range ticked))))))))) 2347 (gnus-uncompress-range ticked)))))))))
2011 2348
2349 (defun gnus-load (file)
2350 "Load FILE, but in such a way that read errors can be reported."
2351 (with-temp-buffer
2352 (insert-file-contents file)
2353 (while (not (eobp))
2354 (condition-case type
2355 (let ((form (read (current-buffer))))
2356 (eval form))
2357 (error
2358 (unless (eq (car type) 'end-of-file)
2359 (let ((error (format "Error in %s line %d" file
2360 (count-lines (point-min) (point)))))
2361 (ding)
2362 (unless (gnus-yes-or-no-p (concat error "; continue? "))
2363 (error "%s" error)))))))))
2364
2012 (defun gnus-read-newsrc-el-file (file) 2365 (defun gnus-read-newsrc-el-file (file)
2013 (let ((ding-file (concat file "d"))) 2366 (let ((ding-file (concat file "d")))
2014 ;; We always, always read the .eld file. 2367 (when (file-exists-p ding-file)
2015 (gnus-message 5 "Reading %s..." ding-file) 2368 ;; We always, always read the .eld file.
2016 (let (gnus-newsrc-assoc) 2369 (gnus-message 5 "Reading %s..." ding-file)
2017 (condition-case nil 2370 (let (gnus-newsrc-assoc)
2018 (let ((coding-system-for-read gnus-ding-file-coding-system)) 2371 (let ((coding-system-for-read gnus-ding-file-coding-system))
2019 (load ding-file t t t)) 2372 (gnus-load ding-file))
2020 (error 2373 ;; Older versions of `gnus-format-specs' are no longer valid
2021 (ding) 2374 ;; in Oort Gnus 0.01.
2022 (unless (gnus-yes-or-no-p 2375 (let ((version
2023 (format "Error in %s; continue? " ding-file)) 2376 (and gnus-newsrc-file-version
2024 (error "Error in %s" ding-file)))) 2377 (gnus-continuum-version gnus-newsrc-file-version))))
2025 (when gnus-newsrc-assoc 2378 (when (or (not version)
2026 (setq gnus-newsrc-alist gnus-newsrc-assoc))) 2379 (< version 5.090009))
2380 (setq gnus-format-specs gnus-default-format-specs)))
2381 (when gnus-newsrc-assoc
2382 (setq gnus-newsrc-alist gnus-newsrc-assoc))))
2027 (gnus-make-hashtable-from-newsrc-alist) 2383 (gnus-make-hashtable-from-newsrc-alist)
2028 (when (file-newer-than-file-p file ding-file) 2384 (when (file-newer-than-file-p file ding-file)
2029 ;; Old format quick file 2385 ;; Old format quick file
2030 (gnus-message 5 "Reading %s..." file) 2386 (gnus-message 5 "Reading %s..." file)
2031 ;; The .el file is newer than the .eld file, so we read that one 2387 ;; The .el file is newer than the .eld file, so we read that one
2032 ;; as well. 2388 ;; as well.
2033 (gnus-read-old-newsrc-el-file file)))) 2389 (gnus-read-old-newsrc-el-file file)))
2390 (gnus-run-hooks 'gnus-read-newsrc-el-hook))
2034 2391
2035 ;; Parse the old-style quick startup file 2392 ;; Parse the old-style quick startup file
2036 (defun gnus-read-old-newsrc-el-file (file) 2393 (defun gnus-read-old-newsrc-el-file (file)
2037 (let (newsrc killed marked group m info) 2394 (let (newsrc killed marked group m info)
2038 (prog1 2395 (prog1
2154 (setq subscribed (eq (char-after) ?:) 2511 (setq subscribed (eq (char-after) ?:)
2155 group (symbol-name symbol) 2512 group (symbol-name symbol)
2156 reads nil) 2513 reads nil)
2157 (if (eolp) 2514 (if (eolp)
2158 ;; If the line ends here, this is clearly a buggy line, so 2515 ;; If the line ends here, this is clearly a buggy line, so
2159 ;; we put point at the beginning of line and let the cond 2516 ;; we put point a the beginning of line and let the cond
2160 ;; below do the error handling. 2517 ;; below do the error handling.
2161 (beginning-of-line) 2518 (beginning-of-line)
2162 ;; We skip to the beginning of the ranges. 2519 ;; We skip to the beginning of the ranges.
2163 (skip-chars-forward "!: \t")) 2520 (skip-chars-forward "!: \t"))
2164 ;; We are now at the beginning of the list of read articles. 2521 ;; We are now at the beginning of the list of read articles.
2165 ;; We read them range by range. 2522 ;; We read them range by range.
2166 (while 2523 (while
2167 (cond 2524 (cond
2168 ((looking-at "[0-9]+") 2525 ((looking-at "[0-9]+")
2169 ;; We narrow and read a number instead of buffer-substring/ 2526 ;; We narrow and read a number instead of buffer-substring/
2170 ;; string-to-int because it's faster. narrow/widen is 2527 ;; string-to-number because it's faster. narrow/widen is
2171 ;; faster than save-restriction/narrow, and save-restriction 2528 ;; faster than save-restriction/narrow, and save-restriction
2172 ;; produces a garbage object. 2529 ;; produces a garbage object.
2173 (setq num1 (progn 2530 (setq num1 (progn
2174 (narrow-to-region (match-beginning 0) (match-end 0)) 2531 (narrow-to-region (match-beginning 0) (match-end 0))
2175 (read buf))) 2532 (read buf)))
2340 'subscribe) 2697 'subscribe)
2341 out)))) 2698 out))))
2342 2699
2343 (setq gnus-newsrc-options-n out)))) 2700 (setq gnus-newsrc-options-n out))))
2344 2701
2702 (eval-and-compile
2703 (defalias 'gnus-long-file-names
2704 (if (fboundp 'msdos-long-file-names)
2705 'msdos-long-file-names
2706 (lambda () t))))
2707
2345 (defun gnus-save-newsrc-file (&optional force) 2708 (defun gnus-save-newsrc-file (&optional force)
2346 "Save .newsrc file." 2709 "Save .newsrc file."
2347 ;; Note: We cannot save .newsrc file if all newsgroups are removed 2710 ;; Note: We cannot save .newsrc file if all newsgroups are removed
2348 ;; from the variable gnus-newsrc-alist. 2711 ;; from the variable gnus-newsrc-alist.
2349 (when (and (or gnus-newsrc-alist gnus-killed-list) 2712 (when (and (or gnus-newsrc-alist gnus-killed-list)
2350 gnus-current-startup-file) 2713 gnus-current-startup-file)
2714 ;; Save agent range limits for the currently active method.
2715 (when gnus-agent
2716 (gnus-agent-save-local force))
2717
2351 (save-excursion 2718 (save-excursion
2352 (if (and (or gnus-use-dribble-file gnus-slave) 2719 (if (and (or gnus-use-dribble-file gnus-slave)
2353 (not force) 2720 (not force)
2354 (or (not gnus-dribble-buffer) 2721 (or (not gnus-dribble-buffer)
2355 (not (buffer-name gnus-dribble-buffer)) 2722 (not (buffer-name gnus-dribble-buffer))
2363 ;; Save .newsrc. 2730 ;; Save .newsrc.
2364 (when gnus-save-newsrc-file 2731 (when gnus-save-newsrc-file
2365 (gnus-message 8 "Saving %s..." gnus-current-startup-file) 2732 (gnus-message 8 "Saving %s..." gnus-current-startup-file)
2366 (gnus-gnus-to-newsrc-format) 2733 (gnus-gnus-to-newsrc-format)
2367 (gnus-message 8 "Saving %s...done" gnus-current-startup-file)) 2734 (gnus-message 8 "Saving %s...done" gnus-current-startup-file))
2735
2368 ;; Save .newsrc.eld. 2736 ;; Save .newsrc.eld.
2369 (set-buffer (gnus-get-buffer-create " *Gnus-newsrc*")) 2737 (set-buffer (gnus-get-buffer-create " *Gnus-newsrc*"))
2370 (make-local-variable 'version-control) 2738 (make-local-variable 'version-control)
2371 (setq version-control 'never) 2739 (setq version-control gnus-backup-startup-file)
2372 (setq buffer-file-name 2740 (setq buffer-file-name
2373 (concat gnus-current-startup-file ".eld")) 2741 (concat gnus-current-startup-file ".eld"))
2374 (setq default-directory (file-name-directory buffer-file-name)) 2742 (setq default-directory (file-name-directory buffer-file-name))
2375 (buffer-disable-undo) 2743 (buffer-disable-undo)
2376 (erase-buffer) 2744 (erase-buffer)
2377 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) 2745 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
2378 (gnus-gnus-to-quick-newsrc-format) 2746
2379 (gnus-run-hooks 'gnus-save-quick-newsrc-hook) 2747 (if gnus-save-startup-file-via-temp-buffer
2380 (let ((coding-system-for-write gnus-ding-file-coding-system)) 2748 (let ((coding-system-for-write gnus-ding-file-coding-system)
2381 (save-buffer)) 2749 (standard-output (current-buffer)))
2382 (kill-buffer (current-buffer)) 2750 (gnus-gnus-to-quick-newsrc-format)
2751 (gnus-run-hooks 'gnus-save-quick-newsrc-hook)
2752 (save-buffer))
2753 (let ((coding-system-for-write gnus-ding-file-coding-system)
2754 (version-control gnus-backup-startup-file)
2755 (startup-file (concat gnus-current-startup-file ".eld"))
2756 (working-dir (file-name-directory gnus-current-startup-file))
2757 working-file
2758 (i -1))
2759 ;; Generate the name of a non-existent file.
2760 (while (progn (setq working-file
2761 (format
2762 (if (and (eq system-type 'ms-dos)
2763 (not (gnus-long-file-names)))
2764 "%s#%d.tm#" ; MSDOS limits files to 8+3
2765 (if (memq system-type '(vax-vms axp-vms))
2766 "%s$tmp$%d"
2767 "%s#tmp#%d"))
2768 working-dir (setq i (1+ i))))
2769 (file-exists-p working-file)))
2770
2771 (unwind-protect
2772 (progn
2773 (gnus-with-output-to-file working-file
2774 (gnus-gnus-to-quick-newsrc-format)
2775 (gnus-run-hooks 'gnus-save-quick-newsrc-hook))
2776
2777 ;; These bindings will mislead the current buffer
2778 ;; into thinking that it is visiting the startup
2779 ;; file.
2780 (let ((buffer-backed-up nil)
2781 (buffer-file-name startup-file)
2782 (file-precious-flag t)
2783 (setmodes (file-modes startup-file)))
2784 ;; Backup the current version of the startup file.
2785 (backup-buffer)
2786
2787 ;; Replace the existing startup file with the temp file.
2788 (rename-file working-file startup-file t)
2789 (set-file-modes startup-file setmodes)))
2790 (condition-case nil
2791 (delete-file working-file)
2792 (file-error nil)))))
2793
2794 (gnus-kill-buffer (current-buffer))
2383 (gnus-message 2795 (gnus-message
2384 5 "Saving %s.eld...done" gnus-current-startup-file)) 2796 5 "Saving %s.eld...done" gnus-current-startup-file))
2385 (gnus-dribble-delete-file) 2797 (gnus-dribble-delete-file)
2386 (gnus-group-set-mode-line))))) 2798 (gnus-group-set-mode-line)))))
2387 2799
2388 (defun gnus-gnus-to-quick-newsrc-format () 2800 (defun gnus-gnus-to-quick-newsrc-format (&optional minimal name &rest specific-variables)
2389 "Insert Gnus variables such as gnus-newsrc-alist in lisp format." 2801 "Print Gnus variables such as `gnus-newsrc-alist' in Lisp format."
2390 (let ((print-quoted t) 2802 (princ ";; -*- emacs-lisp -*-\n")
2391 (print-escape-newlines t)) 2803 (if name
2392 2804 (princ (format ";; %s\n" name))
2393 (insert ";; -*- emacs-lisp -*-\n") 2805 (princ ";; Gnus startup file.\n"))
2394 (insert ";; Gnus startup file.\n") 2806
2395 (insert "\ 2807 (unless minimal
2808 (princ "\
2396 ;; Never delete this file -- if you want to force Gnus to read the 2809 ;; Never delete this file -- if you want to force Gnus to read the
2397 ;; .newsrc file (if you have one), touch .newsrc instead.\n") 2810 ;; .newsrc file (if you have one), touch .newsrc instead.\n")
2398 (insert "(setq gnus-newsrc-file-version " 2811 (princ "(setq gnus-newsrc-file-version ")
2399 (prin1-to-string gnus-version) ")\n") 2812 (princ (gnus-prin1-to-string gnus-version))
2400 (let* ((gnus-killed-list 2813 (princ ")\n"))
2814
2815 (let* ((print-quoted t)
2816 (print-readably t)
2817 (print-escape-multibyte nil)
2818 (print-escape-nonascii t)
2819 (print-length nil)
2820 (print-level nil)
2821 (print-circle nil)
2822 (print-escape-newlines t)
2823 (gnus-killed-list
2401 (if (and gnus-save-killed-list 2824 (if (and gnus-save-killed-list
2402 (stringp gnus-save-killed-list)) 2825 (stringp gnus-save-killed-list))
2403 (gnus-strip-killed-list) 2826 (gnus-strip-killed-list)
2404 gnus-killed-list)) 2827 gnus-killed-list))
2405 (variables 2828 (variables
2406 (if gnus-save-killed-list gnus-variable-list 2829 (or specific-variables
2407 ;; Remove the `gnus-killed-list' from the list of variables 2830 (if gnus-save-killed-list gnus-variable-list
2408 ;; to be saved, if required. 2831 ;; Remove the `gnus-killed-list' from the list of variables
2409 (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))) 2832 ;; to be saved, if required.
2833 (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))))
2410 ;; Peel off the "dummy" group. 2834 ;; Peel off the "dummy" group.
2411 (gnus-newsrc-alist (cdr gnus-newsrc-alist)) 2835 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
2412 variable) 2836 variable)
2413 ;; Insert the variables into the file. 2837 ;; Insert the variables into the file.
2414 (while variables 2838 (while variables
2415 (when (and (boundp (setq variable (pop variables))) 2839 (when (and (boundp (setq variable (pop variables)))
2416 (symbol-value variable)) 2840 (symbol-value variable))
2417 (insert "(setq " (symbol-name variable) " '") 2841 (princ "(setq ")
2418 (gnus-prin1 (symbol-value variable)) 2842 (princ (symbol-name variable))
2419 (insert ")\n")))))) 2843 (princ " '")
2844 (prin1 (symbol-value variable))
2845 (princ ")\n")))))
2420 2846
2421 (defun gnus-strip-killed-list () 2847 (defun gnus-strip-killed-list ()
2422 "Return the killed list minus the groups that match `gnus-save-killed-list'." 2848 "Return the killed list minus the groups that match `gnus-save-killed-list'."
2423 (let ((list gnus-killed-list) 2849 (let ((list gnus-killed-list)
2424 olist) 2850 olist)
2622 (read nntp-server-buffer)) 3048 (read nntp-server-buffer))
2623 (error 0))) 3049 (error 0)))
2624 (skip-chars-forward " \t") 3050 (skip-chars-forward " \t")
2625 ;; ... which leads to this line being effectively ignored. 3051 ;; ... which leads to this line being effectively ignored.
2626 (when (symbolp group) 3052 (when (symbolp group)
2627 (let ((str (buffer-substring 3053 (let* ((str (buffer-substring
2628 (point) (progn (end-of-line) (point)))) 3054 (point) (progn (end-of-line) (point))))
2629 (coding 3055 (name (symbol-name group))
2630 (and (or (featurep 'xemacs) 3056 (charset
2631 (and (boundp 'enable-multibyte-characters) 3057 (or (gnus-group-name-charset method name)
2632 enable-multibyte-characters)) 3058 (gnus-parameter-charset name)
2633 (fboundp 'gnus-mule-get-coding-system) 3059 gnus-default-charset)))
2634 (gnus-mule-get-coding-system (symbol-name group))))) 3060 ;; Fixme: Don't decode in unibyte mode.
2635 (when coding 3061 (when (and str charset (featurep 'mule))
2636 (setq str (mm-decode-coding-string str (car coding)))) 3062 (setq str (mm-decode-coding-string str charset)))
2637 (set group str))) 3063 (set group str)))
2638 (forward-line 1)))) 3064 (forward-line 1))))
2639 (gnus-message 5 "Reading descriptions file...done") 3065 (gnus-message 5 "Reading descriptions file...done")
2640 t)))) 3066 t))))
2641 3067
2648 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)") 3074 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
2649 (match-string 1))))) 3075 (match-string 1)))))
2650 3076
2651 ;;;###autoload 3077 ;;;###autoload
2652 (defun gnus-declare-backend (name &rest abilities) 3078 (defun gnus-declare-backend (name &rest abilities)
2653 "Declare backend NAME with ABILITIES as a Gnus backend." 3079 "Declare back end NAME with ABILITIES as a Gnus back end."
2654 (setq gnus-valid-select-methods 3080 (setq gnus-valid-select-methods
2655 (nconc gnus-valid-select-methods 3081 (nconc gnus-valid-select-methods
2656 (list (apply 'list name abilities)))) 3082 (list (apply 'list name abilities))))
2657 (gnus-redefine-select-method-widget)) 3083 (gnus-redefine-select-method-widget))
2658 3084
2663 (if (and gnus-default-directory 3089 (if (and gnus-default-directory
2664 (file-exists-p gnus-default-directory)) 3090 (file-exists-p gnus-default-directory))
2665 (file-name-as-directory (expand-file-name gnus-default-directory)) 3091 (file-name-as-directory (expand-file-name gnus-default-directory))
2666 default-directory))) 3092 default-directory)))
2667 3093
3094 (defun gnus-display-time-event-handler ()
3095 (if (and (fboundp 'display-time-event-handler)
3096 (gnus-boundp 'display-time-timer))
3097 (display-time-event-handler)))
3098
3099 ;;;###autoload
3100 (defun gnus-fixup-nnimap-unread-after-getting-new-news ()
3101 (let (server group info)
3102 (mapatoms
3103 (lambda (sym)
3104 (when (and (setq group (symbol-name sym))
3105 (gnus-group-entry group)
3106 (setq info (symbol-value sym)))
3107 (gnus-sethash group (cons (nth 2 info) (cdr (gnus-group-entry group)))
3108 gnus-newsrc-hashtb)))
3109 (if (boundp 'nnimap-mailbox-info)
3110 (symbol-value 'nnimap-mailbox-info)
3111 (make-vector 1 0)))))
3112
3113
2668 (provide 'gnus-start) 3114 (provide 'gnus-start)
2669 3115
3116 ;; arch-tag: f4584a22-b7b7-4853-abfc-a637329af5d2
2670 ;;; gnus-start.el ends here 3117 ;;; gnus-start.el ends here
3118
3119