;;; gnus-start.el --- startup functions for Gnus
-;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000
+;; Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: news
;;;###autoload
(defun gnus-unload ()
- "Unload all Gnus features."
+ "Unload all Gnus features.
+\(For some value of `all' or `Gnus'.) Currently, features whose names
+have prefixes `gnus-', `nn', `mm-' or `rfc' are unloaded. Use
+cautiously -- unloading may cause trouble."
(interactive)
- (unless (boundp 'load-history)
- (error "Sorry, `gnus-unload' is not implemented in this Emacs version"))
- (let ((history load-history)
- feature)
- (while history
- (and (string-match "^\\(gnus\\|nn\\)" (caar history))
- (setq feature (cdr (assq 'provide (car history))))
- (unload-feature feature 'force))
- (setq history (cdr history)))))
+ (dolist (feature features)
+ (if (string-match "^\\(gnus-\\|nn\\|mm-\\|rfc\\)" (symbol-name feature))
+ (unload-feature feature 'force))))
\f
;;;
;; hack: `nnmail-get-new-mail' changes the mail-source depending
;; on the group, so we must perform a scan for every group
;; if the users has any directory mail sources.
- (if (and (null (assq 'directory
+ ;; hack: if `nnmail-scan-directory-mail-source-once' is non-nil,
+ ;; for it scan all spool files even when the groups are
+ ;; not required.
+ (if (and
+ (or nnmail-scan-directory-mail-source-once
+ (null (assq 'directory
(or mail-sources
(if (listp nnmail-spool-file)
nnmail-spool-file
- (list nnmail-spool-file)))))
- (member method scanned-methods))
+ (list nnmail-spool-file))))))
+ (member method scanned-methods))
(setq active (gnus-activate-group group))
(setq active (gnus-activate-group group 'scan))
(push method scanned-methods))
(gnus-group-prefixed-name "" method))))
;; Let the Gnus agent save the active file.
- (if (and gnus-agent real-active gnus-plugged (gnus-agent-method-p method))
+ (if (and gnus-agent
+ real-active
+ gnus-plugged
+ (gnus-agent-method-p method))
(progn
(gnus-agent-save-groups method)
(gnus-active-to-gnus-format method hashtb nil real-active))
(gnus-message 5 "Reading %s..." ding-file)
(let (gnus-newsrc-assoc)
(when (file-exists-p ding-file)
- (condition-case nil
- (with-temp-buffer
- (insert-file-contents-as-coding-system
- gnus-startup-file-coding-system ding-file)
- (eval-region (point-min) (point-max)))
- (error
- (ding)
- (unless (gnus-yes-or-no-p
- (format "Error in %s; continue? " ding-file))
- (error "Error in %s" ding-file))))
+ (with-temp-buffer
+ (condition-case nil
+ (progn
+ (insert-file-contents-as-coding-system
+ gnus-startup-file-coding-system ding-file)
+ (eval-region (point-min) (point-max)))
+ (error
+ (ding)
+ (or (not (or (zerop (buffer-size))
+ (eq 'binary gnus-startup-file-coding-system)
+ (gnus-re-read-newsrc-el-file ding-file)))
+ (gnus-yes-or-no-p
+ (format "Error in %s; continue? " ding-file))
+ (error "Error in %s" ding-file)))))
(when gnus-newsrc-assoc
(setq gnus-newsrc-alist gnus-newsrc-assoc))))
(gnus-make-hashtable-from-newsrc-alist)
(apply 'gnus-product-read-variable-file-1 (car list))
(setq list (cdr list))))))
+(defun gnus-re-read-newsrc-el-file (file)
+ "Attempt to re-read .newsrc.eld file. Returns `nil' if successful.
+The backup file \".newsrc.eld_\" will be created before re-reading."
+ (message "Error in %s; retrying..." file)
+ (if (and
+ (condition-case nil
+ (let ((backup (concat file "_")))
+ (copy-file file backup 'ok-if-already-exists 'keep-time)
+ (message " (The backup file %s has been created)" backup)
+ t)
+ (error nil))
+ (progn
+ (insert-file-contents-as-binary file nil nil nil 'replace)
+ (when (re-search-forward
+ "^[\t ]*([\t\n\r ]*setq[\t\n\r ]+gnus-format-specs" nil t)
+ (delete-region (goto-char (match-beginning 0)) (forward-list 1))
+ (decode-coding-region (point-min) (point-max)
+ gnus-startup-file-coding-system)
+ (condition-case nil
+ (progn
+ (eval-region (point-min) (point-max))
+ t)
+ (error nil)))))
+ (prog1
+ nil
+ (message "Error in %s; retrying...done" file))
+ (message "Error in %s; retrying...failed" file)
+ t))
+
(defun gnus-product-read-variable-file-1 (file checking-methods coding
&rest variables)
(let (gnus-product-file-version method file-ver)
(if (or (condition-case err
- (let ((coding-system-for-read coding))
+ (let ((coding-system-for-read coding)
+ (input-coding-system coding))
(load (expand-file-name file gnus-product-directory) t t t)
nil)
(error (message "%s" err)))
(gnus-prin1 (symbol-value variable))
(insert ")\n"))))))
-(defun gnus-product-variable-touch (variable)
- (put variable 'gnus-product-variable 'dirty))
+(defun gnus-product-variable-touch (&rest variables)
+ (while variables
+ (put (pop variables) 'gnus-product-variable 'dirty)))
(defun gnus-product-variables-dirty-p (variables)
(catch 'done