X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-start.el;h=57a9dde6899ad9472bccfd0c56dd404ce0baaf27;hb=d0498ec691ac9cc3f6bdd9f4ba3ac26457cc3d8a;hp=c90304ecec31c0f493b16171ac8119009799e0cb;hpb=4b41275525751899e167289322e192b3c0db35b9;p=gnus diff --git a/lisp/gnus-start.el b/lisp/gnus-start.el index c90304ece..57a9dde68 100644 --- a/lisp/gnus-start.el +++ b/lisp/gnus-start.el @@ -42,6 +42,16 @@ 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. @@ -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 @@ -530,7 +546,7 @@ prompt the user for the name of an NNTP server to use." (gnus-read-init-file) (setq gnus-slave slave) - (when (string-match "xemacs" (emacs-version)) + (when (string-match "XEmacs" (emacs-version)) (gnus-splash)) (let ((level (and (numberp arg) (> arg 0) arg)) @@ -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 @@ -751,14 +767,18 @@ If LEVEL is non-nil, the news will be set up at level LEVEL." (not dont-connect)) (gnus-nocem-scan-groups)) + ;; Read any slave files. + (unless gnus-slave + (gnus-master-read-slave-newsrc)) + ;; Find the number of unread articles in each non-dead group. (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. @@ -1337,7 +1357,7 @@ newsgroup." t) (condition-case () (gnus-request-group group dont-check method) - ; (error nil) + (error nil) (quit nil)) (gnus-set-active group (setq active (gnus-parse-active))) ;; Return the new active info. @@ -1405,7 +1425,8 @@ newsgroup." (setq gnus-killed-list (cons group gnus-killed-list)) (gnus-sethash group group gnus-killed-hashtb)))))) - gnus-active-hashtb)) + gnus-active-hashtb) + (gnus-dribble-enter "")) ;; Get the active file(s) from the backend(s). (defun gnus-read-active-file () @@ -1655,7 +1676,7 @@ If FORCE is non-nil, the .newsrc file is read." ;; the `gnus-newsrc-hashtb' has been created. While reading ;; the .newsrc file, Gnus will only use the information it ;; can find there for changing the data already read - - ;; ie. reading the .newsrc file will not trash the data + ;; i. e., reading the .newsrc file will not trash the data ;; already read (except for read articles). (save-excursion (gnus-message 5 "Reading %s..." newsrc-file) @@ -1664,10 +1685,6 @@ If FORCE is non-nil, the .newsrc file is read." (gnus-newsrc-to-gnus-format) (kill-buffer (current-buffer)) (gnus-message 5 "Reading %s...done" newsrc-file))) - - ;; Read any slave files. - (unless gnus-slave - (gnus-master-read-slave-newsrc)) ;; Convert old to new. (gnus-convert-old-newsrc)))) @@ -1951,7 +1968,7 @@ If FORCE is non-nil, the .newsrc file is read." entry mentry) (while rc (or (null (nth 4 (car rc))) ; It's a native group. - (assoc (caar rc) newsrc) ; It's already in the alist. + (assoc (caar rc) newsrc) ; It's already in the alist. (if (setq entry (assoc (caar prev) newsrc)) (setcdr (setq mentry (memq entry newsrc)) (cons (car rc) (cdr mentry))) @@ -2071,26 +2088,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. @@ -2193,7 +2227,7 @@ If FORCE is non-nil, the .newsrc file is read." (error (gnus-error 3.2 "Possible error in %s" file) nil)) - (or gnus-slave ; Slaves shouldn't delete these files. + (or gnus-slave ; Slaves shouldn't delete these files. (condition-case () (delete-file file) (error nil)))) @@ -2293,6 +2327,15 @@ 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 + (if (and gnus-default-directory + (file-exists-p gnus-default-directory)) + (file-name-as-directory (expand-file-name gnus-default-directory)) + default-directory))) + (provide 'gnus-start) ;;; gnus-start.el ends here