Importing Pterodactyl Gnus v0.96.
[elisp/gnus.git-] / lisp / gnus-start.el
index d049d02..ef27428 100644 (file)
@@ -47,11 +47,10 @@ If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
   :type 'file)
 
 (defcustom gnus-site-init-file
-  (condition-case nil
-      (concat (file-name-directory
-              (directory-file-name installation-directory))
-             "site-lisp/gnus-init")
-    (error nil))
+  (ignore-errors
+    (concat (file-name-directory
+            (directory-file-name installation-directory))
+           "site-lisp/gnus-init"))
   "*The site-wide Gnus Emacs-Lisp startup file name, or nil if none.
 If a file with the `.el' or `.elc' suffixes exists, it will be read instead."
   :group 'gnus-start
@@ -197,6 +196,16 @@ groups."
   :type '(choice integer
                 (const :tag "none" nil)))
 
+(defcustom gnus-read-newsrc-file t
+  "*Non-nil means that Gnus will read the `.newsrc' file.
+Gnus always reads its own startup file, which is called
+\".newsrc.eld\".  The file called \".newsrc\" is in a format that can
+be readily understood by other newsreaders.  If you don't plan on
+using other newsreaders, set this variable to nil to save some time on
+entry."
+  :group 'gnus-newsrc
+  :type 'boolean)
+
 (defcustom gnus-save-newsrc-file t
   "*Non-nil means that Gnus will save the `.newsrc' file.
 Gnus always saves its own startup file, which is called
@@ -223,12 +232,12 @@ not match this regexp will be removed before saving the list."
   :type 'boolean)
 
 (defcustom gnus-ignored-newsgroups
-  (purecopy (mapconcat 'identity
-                      '("^to\\."       ; not "real" groups
-                        "^[0-9. \t]+ " ; all digits in name
-                        "[][\"#'()]"   ; bogus characters
-                        )
-                      "\\|"))
+ (mapconcat 'identity
+           '("^to\\."                  ; not "real" groups
+             "^[0-9. \t]+ "            ; all digits in name
+             "[][\"#'()]"              ; bogus characters
+             )
+           "\\|")
   "*A regexp to match uninteresting newsgroups in the active file.
 Any lines in the active file matching this regular expression are
 removed from the newsgroup list before anything else is done to it,
@@ -360,7 +369,7 @@ This hook is called as the first thing when Gnus is started."
 (defcustom gnus-after-getting-new-news-hook
   (when (gnus-boundp 'display-time-timer)
     '(display-time-event-handler))
-  "*A hook run after Gnus checks for new news."
+  "*A hook run after Gnus checks for new news when Gnus is already running."
   :group 'gnus-group-new
   :type 'hook)
 
@@ -382,7 +391,7 @@ Can be used to turn version control on or off."
   :type 'hook)
 
 (defcustom gnus-always-read-dribble-file nil
-  "Uncoditionally read the dribble file."
+  "Unconditionally read the dribble file."
   :group 'gnus-newsrc
   :type 'boolean)
 
@@ -721,7 +730,6 @@ prompt the user for the name of an NNTP server to use."
   (unless (gnus-gethash "nndraft:drafts" gnus-newsrc-hashtb)
     (let ((gnus-level-default-subscribed 1))
       (gnus-subscribe-group "nndraft:drafts" nil '(nndraft "")))
-    (gnus-group-set-parameter "nndraft:drafts" 'charset nil)
     (gnus-group-set-parameter
      "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode)))))
 
@@ -856,7 +864,11 @@ prompt the user for the name of an NNTP server to use."
   "Setup news information.
 If RAWFILE is non-nil, the .newsrc file will also be read.
 If LEVEL is non-nil, the news will be set up at level LEVEL."
-  (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
+  (require 'nnmail)
+  (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))
+       ;; Binding this variable will inhibit multiple fetchings
+       ;; of the same mail source.
+       (nnmail-fetched-sources (list t)))
 
     (when init
       ;; Clear some variables to re-initialize news information.
@@ -940,7 +952,7 @@ If LEVEL is non-nil, the news will be set up at level LEVEL."
 
 (defun gnus-find-new-newsgroups (&optional arg)
   "Search for new newsgroups and add them.
-Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
+Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method'.
 The `-n' option line from .newsrc is respected.
 
 With 1 C-u, use the `ask-server' method to query the server for new
@@ -1446,7 +1458,7 @@ newsgroup."
        ;; Then we want to peel off any elements that are higher
        ;; than the upper active limit.
        (let ((srange range))
-         ;; Go past all legal elements.
+         ;; Go past all valid elements.
          (while (and (cdr srange)
                      (<= (or (and (atom (cadr srange))
                                   (cadr srange))
@@ -1454,7 +1466,7 @@ newsgroup."
                          (cdr active)))
            (setq srange (cdr srange)))
          (when (cdr srange)
-           ;; Nuke all remaining illegal elements.
+           ;; Nuke all remaining invalid elements.
            (setcdr srange nil))
 
          ;; Adjust the final element.
@@ -1519,18 +1531,27 @@ newsgroup."
                                           "-request-update-info")))
              (inline (gnus-request-update-info info method))))
        ;; These groups are native or secondary.
-       (when (and (<= (gnus-info-level info) level)
-                  (not gnus-read-active-file))
+       (cond
+        ;; We don't want these groups.
+        ((> (gnus-info-level info) level)
+         (setq active 'ignore))
+        ;; Activate groups.
+        ((not gnus-read-active-file)
          (setq active (gnus-activate-group group 'scan))
-         (inline (gnus-close-group group))))
+         (inline (gnus-close-group group)))))
 
       ;; Get the number of unread articles in the group.
-      (if active
-         (inline (gnus-get-unread-articles-in-group info active t))
+      (cond
+       ((eq active 'ignore)
+       ;; Don't do anything.
+       )
+       (active
+       (inline (gnus-get-unread-articles-in-group info active t)))
+       (t
        ;; The group couldn't be reached, so we nix out the number of
        ;; unread articles and stuff.
        (gnus-set-active group nil)
-       (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
+       (setcar (gnus-gethash group gnus-newsrc-hashtb) t))))
 
     (gnus-message 5 "Checking new news...done")))
 
@@ -1638,30 +1659,30 @@ newsgroup."
 (defun gnus-read-active-file (&optional force not-native)
   (gnus-group-set-mode-line)
   (let ((methods
-        (append
-         (if (and (not not-native)
-                  (gnus-check-server gnus-select-method))
-             ;; The native server is available.
-             (cons gnus-select-method gnus-secondary-select-methods)
-           ;; The native server is down, so we just do the
-           ;; secondary ones.
-           gnus-secondary-select-methods)
-         ;; Also read from the archive server.
-         (when (gnus-archive-server-wanted-p)
-           (list "archive"))))
-       list-type)
+        (mapcar
+         (lambda (m) (if (stringp m) (gnus-server-get-method nil m) m))
+         (append
+          (if (and (not not-native)
+                   (gnus-check-server gnus-select-method))
+              ;; The native server is available.
+              (cons gnus-select-method gnus-secondary-select-methods)
+            ;; The native server is down, so we just do the
+            ;; secondary ones.
+            gnus-secondary-select-methods)
+          ;; Also read from the archive server.
+          (when (gnus-archive-server-wanted-p)
+            (list "archive")))))
+       method where mesg list-type)
     (setq gnus-have-read-active-file nil)
     (save-excursion
       (set-buffer nntp-server-buffer)
-      (while methods
-       (let* ((method (if (stringp (car methods))
-                          (gnus-server-get-method nil (car methods))
-                        (car methods)))
-              (where (nth 1 method))
-              (mesg (format "Reading active file%s via %s..."
+      (while (setq method (pop methods))
+       (unless (member method methods)
+         (setq where (nth 1 method)
+               mesg (format "Reading active file%s via %s..."
                             (if (and where (not (zerop (length where))))
                                 (concat " from " where) "")
-                            (car method))))
+                            (car method)))
          (gnus-message 5 mesg)
          (when (gnus-check-server method)
            ;; Request that the backend scan its incoming messages.
@@ -1708,8 +1729,7 @@ newsgroup."
                (gnus-active-to-gnus-format method gnus-active-hashtb nil t)
                ;; We mark this active file as read.
                (push method gnus-have-read-active-file)
-               (gnus-message 5 "%sdone" mesg))))))
-       (setq methods (cdr methods))))))
+               (gnus-message 5 "%sdone" mesg))))))))))
 
 ;; Read an active file and place the results in `gnus-active-hashtb'.
 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors
@@ -1741,7 +1761,7 @@ newsgroup."
       (insert ?\\))
 
     ;; Let the Gnus agent save the active file.
-    (when (and gnus-agent real-active)
+    (when (and gnus-agent real-active gnus-plugged)
       (gnus-agent-save-active method))
 
     ;; If these are groups from a foreign select method, we insert the
@@ -1786,7 +1806,7 @@ newsgroup."
                (symbolp group)
                (set group nil))
           (unless ignore-errors
-            (gnus-message 3 "Warning - illegal active: %s"
+            (gnus-message 3 "Warning - invalid active: %s"
                           (buffer-substring
                            (gnus-point-at-bol) (gnus-point-at-eol))))))
        (widen)
@@ -1808,39 +1828,41 @@ newsgroup."
                     (gnus-group-prefixed-name "" method))))
 
     ;; Let the Gnus agent save the active file.
-    (when (and gnus-agent real-active)
-      (gnus-agent-save-groups 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))
 
-    (goto-char (point-min))
-    ;; We split this into to separate loops, one with the prefix
-    ;; and one without to speed the reading up somewhat.
-    (if prefix
-       (let (min max opoint group)
+      (goto-char (point-min))
+      ;; We split this into to separate loops, one with the prefix
+      ;; and one without to speed the reading up somewhat.
+      (if prefix
+         (let (min max opoint group)
+           (while (not (eobp))
+             (condition-case ()
+                 (progn
+                   (read cur) (read cur)
+                   (setq min (read cur)
+                         max (read cur)
+                         opoint (point))
+                   (skip-chars-forward " \t")
+                   (insert prefix)
+                   (goto-char opoint)
+                   (set (let ((obarray hashtb)) (read cur))
+                        (cons min max)))
+               (error (and group (symbolp group) (set group nil))))
+             (forward-line 1)))
+       (let (min max group)
          (while (not (eobp))
            (condition-case ()
-               (progn
+               (when (eq (char-after) ?2)
                  (read cur) (read cur)
                  (setq min (read cur)
-                       max (read cur)
-                       opoint (point))
-                 (skip-chars-forward " \t")
-                 (insert prefix)
-                 (goto-char opoint)
-                 (set (let ((obarray hashtb)) (read cur))
+                       max (read cur))
+                 (set (setq group (let ((obarray hashtb)) (read cur)))
                       (cons min max)))
              (error (and group (symbolp group) (set group nil))))
-           (forward-line 1)))
-      (let (min max group)
-       (while (not (eobp))
-         (condition-case ()
-             (when (eq (char-after) ?2)
-               (read cur) (read cur)
-               (setq min (read cur)
-                     max (read cur))
-               (set (setq group (let ((obarray hashtb)) (read cur)))
-                    (cons min max)))
-           (error (and group (symbolp group) (set group nil))))
-         (forward-line 1))))))
+           (forward-line 1)))))))
 
 (defun gnus-read-newsrc-file (&optional force)
   "Read startup file.
@@ -1858,7 +1880,8 @@ If FORCE is non-nil, the .newsrc file is read."
       ;; file (ticked articles, killed groups, foreign methods, etc.)
       (gnus-read-newsrc-el-file quick-file)
 
-      (when (and (file-exists-p gnus-current-startup-file)
+      (when (and gnus-read-newsrc-file
+                (file-exists-p gnus-current-startup-file)
                 (or force
                     (and (file-newer-than-file-p newsrc-file quick-file)
                          (file-newer-than-file-p newsrc-file
@@ -2111,7 +2134,7 @@ If FORCE is non-nil, the .newsrc file is read."
                            (buffer-substring (gnus-point-at-bol)
                                              (gnus-point-at-eol))))
              nil))
-         ;; Skip past ", ".  Spaces are illegal in these ranges, but
+         ;; Skip past ", ".  Spaces are invalid in these ranges, but
          ;; we allow them, because it's a common mistake to put a
          ;; space after the comma.
          (skip-chars-forward ", "))
@@ -2478,6 +2501,8 @@ If FORCE is non-nil, the .newsrc file is read."
 
     (gnus-message 5 "Reading descriptions file via %s..." (car method))
     (cond
+     ((null (gnus-get-function method 'request-list-newsgroups t))
+      t)
      ((not (gnus-check-server method))
       (gnus-message 1 "Couldn't open server")
       nil)