*** empty log message ***
[gnus] / lisp / gnus-start.el
index 3abb42c..0061d01 100644 (file)
 If a file with the .el or .elc suffixes exist, it will be read
 instead.")
 
+(defvar gnus-site-init-file
+  (condition-case ()
+      (concat (file-name-directory 
+              (directory-file-name installation-directory))
+             "site-lisp/gnus-init")
+    (error nil))
+  "*The site-wide Gnus elisp startup file.
+If a file with the .el or .elc suffixes exist, it will be read
+instead.")
+
 (defvar gnus-default-subscribed-newsgroups nil
   "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
 It should be a list of strings.
@@ -129,7 +139,7 @@ less than this variable, are subscribed.")
 
 (defvar gnus-activate-level (1+ gnus-level-subscribed)
   "*Groups higher than this level won't be activated on startup.
-Setting this variable to something log might save lots of time when
+Setting this variable to something low might save lots of time when
 you have many groups that you aren't interested in.")
 
 (defvar gnus-activate-foreign-newsgroups 4
@@ -161,7 +171,10 @@ that Gnus has no record of which groups are new and which are old, so
 the automatic new newsgroups subscription methods become meaningless.
 
 You should always set `gnus-check-new-newsgroups' to `ask-server' or
-nil if you set this variable to nil.")
+nil if you set this variable to nil.
+
+This variable can also be a regexp.  In that case, all groups that do
+not match this regexp will be removed before saving the list.")
 
 (defvar gnus-ignored-newsgroups
   (purecopy (mapconcat 'identity
@@ -288,16 +301,19 @@ Can be used to turn version control on or off.")
   (if gnus-init-inhibit
       (setq gnus-init-inhibit nil)
     (setq gnus-init-inhibit inhibit-next)
-    (and gnus-init-file
-        (or (and (file-exists-p gnus-init-file)
-                 ;; Don't try to load a directory.
-                 (not (file-directory-p gnus-init-file)))
-            (file-exists-p (concat gnus-init-file ".el"))
-            (file-exists-p (concat gnus-init-file ".elc")))
-        (condition-case var
-            (load gnus-init-file nil t)
-          (error
-           (error "Error in %s: %s" gnus-init-file var))))))
+    (let ((files (list gnus-site-init-file gnus-init-file))
+         file)
+      (while files
+       (and (setq file (pop files))
+            (or (and (file-exists-p file)
+                     ;; Don't try to load a directory.
+                     (not (file-directory-p file)))
+                (file-exists-p (concat file ".el"))
+                (file-exists-p (concat file ".elc")))
+            (condition-case var
+                (load file nil t)
+              (error
+               (error "Error in %s: %s" file var))))))))
 
 ;; For subscribing new newsgroup
 
@@ -705,9 +721,9 @@ If LEVEL is non-nil, the news will be set up at level LEVEL."
 
     ;; If we don't read the complete active file, we fill in the
     ;; hashtb here.
-    (if (or (null gnus-read-active-file)
-           (eq gnus-read-active-file 'some))
-       (gnus-update-active-hashtb-from-killed))
+    (when (or (null gnus-read-active-file)
+             (eq gnus-read-active-file 'some))
+      (gnus-update-active-hashtb-from-killed))
 
     ;; Read the active file and create `gnus-active-hashtb'.
     ;; If `gnus-read-active-file' is nil, then we just create an empty
@@ -717,8 +733,8 @@ If LEVEL is non-nil, the news will be set up at level LEVEL."
         (not level)
         (gnus-read-active-file))
 
-    (or gnus-active-hashtb
-       (setq gnus-active-hashtb (make-vector 4095 0)))
+    (unless gnus-active-hashtb
+      (setq gnus-active-hashtb (make-vector 4095 0)))
 
     ;; Initialize the cache.
     (when gnus-use-cache
@@ -734,16 +750,16 @@ If LEVEL is non-nil, the news will be set up at level LEVEL."
     (gnus-update-format-specifications)
 
     ;; See whether we need to read the description file.
-    (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
-            (not gnus-description-hashtb)
-            (not dont-connect)
-            gnus-read-active-file)
-       (gnus-read-all-descriptions-files))
+    (when (and (string-match "%[-,0-9]*D" gnus-group-line-format)
+              (not gnus-description-hashtb)
+              (not dont-connect)
+              gnus-read-active-file)
+      (gnus-read-all-descriptions-files))
 
     ;; Find new newsgroups and treat them.
-    (if (and init gnus-check-new-newsgroups (not level)
-            (gnus-check-server gnus-select-method))
-       (gnus-find-new-newsgroups))
+    (when (and init gnus-check-new-newsgroups (not level)
+              (gnus-check-server gnus-select-method))
+      (gnus-find-new-newsgroups))
 
     ;; We might read in new NoCeM messages here.
     (when (and gnus-use-nocem 
@@ -755,10 +771,10 @@ If LEVEL is non-nil, the news will be set up at level LEVEL."
     (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
       (gnus-get-unread-articles level))
 
-    (if (and init gnus-check-bogus-newsgroups
-            gnus-read-active-file (not level)
-            (gnus-server-opened gnus-select-method))
-       (gnus-check-bogus-newsgroups))))
+    (when (and init gnus-check-bogus-newsgroups
+              gnus-read-active-file (not level)
+              (gnus-server-opened gnus-select-method))
+      (gnus-check-bogus-newsgroups))))
 
 (defun gnus-find-new-newsgroups (&optional arg)
   "Search for new newsgroups and add them.
@@ -2071,26 +2087,43 @@ If FORCE is non-nil, the .newsrc file is read."
 
 (defun gnus-gnus-to-quick-newsrc-format ()
   "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
-  (insert ";; Gnus startup file.\n")
-  (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
-  (insert ";; to read .newsrc.\n")
-  (insert "(setq gnus-newsrc-file-version "
-         (prin1-to-string gnus-version) ")\n")
-  (let ((variables
-        (if gnus-save-killed-list gnus-variable-list
-          ;; Remove the `gnus-killed-list' from the list of variables
-          ;; to be saved, if required.
-          (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
-       ;; Peel off the "dummy" group.
-       (gnus-newsrc-alist (cdr gnus-newsrc-alist))
-       variable)
-    ;; Insert the variables into the file.
-    (while variables
-      (when (and (boundp (setq variable (pop variables)))
-                (symbol-value variable))
-       (insert "(setq " (symbol-name variable) " '")
-       (prin1 (symbol-value variable) (current-buffer))
-       (insert ")\n")))))
+  (let ((print-quoted t))
+    (insert ";; Gnus startup file.\n")
+    (insert
+     ";; Never delete this file - touch .newsrc instead to force Gnus\n")
+    (insert ";; to read .newsrc.\n")
+    (insert "(setq gnus-newsrc-file-version "
+           (prin1-to-string gnus-version) ")\n")
+    (let* ((gnus-killed-list
+           (if (and gnus-save-killed-list
+                    (stringp gnus-save-killed-list))
+               (gnus-strip-killed-list)
+             gnus-killed-list))
+          (variables
+           (if gnus-save-killed-list gnus-variable-list
+             ;; Remove the `gnus-killed-list' from the list of variables
+             ;; to be saved, if required.
+             (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
+          ;; Peel off the "dummy" group.
+          (gnus-newsrc-alist (cdr gnus-newsrc-alist))
+          variable)
+      ;; Insert the variables into the file.
+      (while variables
+       (when (and (boundp (setq variable (pop variables)))
+                  (symbol-value variable))
+         (insert "(setq " (symbol-name variable) " '")
+         (prin1 (symbol-value variable) (current-buffer))
+         (insert ")\n"))))))
+
+(defun gnus-strip-killed-list ()
+  "Return the killed list minus the groups that match `gnus-save-killed-list'."
+  (let ((list gnus-killed-list)
+       olist)
+    (while list
+      (when (string-match gnus-save-killed-list)
+       (push (car list) olist))
+      (pop list))
+    (nreverse olist)))
 
 (defun gnus-gnus-to-newsrc-format ()
   ;; Generate and save the .newsrc file.
@@ -2293,6 +2326,11 @@ If FORCE is non-nil, the .newsrc file is read."
        (nconc gnus-valid-select-methods
               (list (apply 'list name abilities)))))
 
+(defun gnus-set-default-directory ()
+  "Set the default directory in the current buffer to `gnus-default-directory'.
+If this variable is nil, don't do anything."
+  (setq default-directory (or gnus-default-directory default-directory)))
+
 (provide 'gnus-start)
 
 ;;; gnus-start.el ends here