*** empty log message ***
[gnus] / lisp / gnus-group.el
index fb40853..ae849e0 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-group.el --- group mode commands for Gnus
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996,97 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
 ;; Keywords: news
 (require 'gnus-win)
 (require 'gnus-undo)
 
-(defgroup gnus-group nil
-  "Group buffers."
-  :group 'gnus)
-
 (defcustom gnus-group-archive-directory
   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
   "*The address of the (ding) archives."
-  :group 'gnus-group
+  :group 'gnus-group-foreign
   :type 'directory)
 
 (defcustom gnus-group-recent-archive-directory
   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
   "*The address of the most recent (ding) articles."
-  :group 'gnus-group
+  :group 'gnus-group-foreign
   :type 'directory)
 
-;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
-(defcustom gnus-no-groups-message "No news is horrible news"
+(defcustom gnus-no-groups-message "No news is no news"
   "*Message displayed by Gnus when no groups are available."
-  :group 'gnus-group
+  :group 'gnus-start
   :type 'string)
 
 (defcustom gnus-keep-same-level nil
@@ -68,43 +63,46 @@ available, the next newsgroup with the lowest possible level higher
 than the current level.
 If this variable is `best', Gnus will make the next newsgroup the one
 with the best level."
-  :group 'gnus-group
+  :group 'gnus-group-levels
   :type '(choice (const nil)
                 (const best)
                 (sexp :tag "other" t)))
 
 (defcustom gnus-group-goto-unread t
   "*If non-nil, movement commands will go to the next unread and subscribed group."
-  :group 'gnus-group
+  :link '(custom-manual "(gnus)Group Maneuvering")
+  :group 'gnus-group-various
   :type 'boolean)
 
 (defcustom gnus-goto-next-group-when-activating t
   "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
-  :group 'gnus-group
+  :link '(custom-manual "(gnus)Scanning New Messages")
+  :group 'gnus-group-various
   :type 'boolean)
 
 (defcustom gnus-permanently-visible-groups nil
   "*Regexp to match groups that should always be listed in the group buffer.
 This means that they will still be listed when there are no unread
 articles in the groups."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type 'regexp)
 
 (defcustom gnus-list-groups-with-ticked-articles t
   "*If non-nil, list groups that have only ticked articles.
 If nil, only list groups that have unread articles."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type 'boolean)
 
 (defcustom gnus-group-default-list-level gnus-level-subscribed
   "*Default listing level.
 Ignored if `gnus-group-use-permanent-levels' is non-nil."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type 'integer)
 
 (defcustom gnus-group-list-inactive-groups t
   "*If non-nil, inactive groups will be listed."
-  :group 'gnus-group
+  :group 'gnus-group-listing
+  :group 'gnus-group-levels
   :type 'boolean)
 
 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
@@ -119,7 +117,8 @@ for the groups to be sorted.  Pre-made functions include
 This variable can also be a list of sorting functions. In that case,
 the most significant sort function should be the last function in the
 list."
-  :group 'gnus-group
+  :group 'gnus-group-listing
+  :link '(custom-manual "(gnus)Sorting Groups")
   :type '(radio (function-item gnus-group-sort-by-alphabet)
                (function-item gnus-group-sort-by-real-name)
                (function-item gnus-group-sort-by-unread)
@@ -156,7 +155,7 @@ with some simple extensions.
 %l    Whether there are GroupLens predictions for this group (string)
 %n    Select from where (string)
 %z    A string that look like `<%s:%n>' if a foreign select method is used
-?d    The date the group was last entered.
+%d    The date the group was last entered.
 %u    User defined specifier.  The next character in the format string should
       be a letter.  Gnus will call the function gnus-user-format-function-X,
       where X is the letter following %u.  The function will be passed the
@@ -178,7 +177,7 @@ a bit of extra memory will be used.  %D will also worsen performance.
 Also note that if you change the format specification to include any
 of these specs, you must probably re-start Gnus to see them go into
 effect."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type 'string)
 
 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
@@ -189,28 +188,29 @@ with some simple extensions:
 %S   The native news server.
 %M   The native select method.
 %:   \":\" if %S isn't \"\"."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type 'string)
 
 (defcustom gnus-group-mode-hook nil
   "Hook for Gnus group mode."
-  :group 'gnus-group
+  :group 'gnus-group-various
   :options '(gnus-topic-mode)
   :type 'hook)
 
 (defcustom gnus-group-menu-hook nil
   "Hook run after the creation of the group mode menu."
-  :group 'gnus-group
+  :group 'gnus-group-various
   :type 'hook)
 
 (defcustom gnus-group-catchup-group-hook nil
   "Hook run when catching up a group from the group buffer."
-  :group 'gnus-group
+  :group 'gnus-group-various
+  :link '(custom-manual "(gnus)Group Data")
   :type 'hook)
 
 (defcustom gnus-group-update-group-hook nil
   "Hook called when updating group lines."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type 'hook)
 
 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
@@ -222,28 +222,28 @@ the third is non-nil, it is a number.  No groups with a level lower
 than this number should be displayed.
 
 The only current function implemented is `gnus-group-prepare-flat'."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type 'function)
 
 (defcustom gnus-group-prepare-hook nil
   "Hook called after the group buffer has been generated.
 If you want to modify the group buffer, you can use this hook."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type 'hook)
 
 (defcustom gnus-suspend-gnus-hook nil
   "Hook called when suspending (not exiting) Gnus."
-  :group 'gnus-group
+  :group 'gnus-exit
   :type 'hook)
 
 (defcustom gnus-exit-gnus-hook nil
   "Hook called when exiting Gnus."
-  :group 'gnus-group
+  :group 'gnus-exit
   :type 'hook)
 
 (defcustom gnus-after-exiting-gnus-hook nil
   "Hook called after exiting Gnus."
-  :group 'gnus-group
+  :group 'gnus-exit
   :type 'hook)
 
 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
@@ -253,7 +253,7 @@ The hook will not be called if `gnus-visual' is nil.
 The default function `gnus-group-highlight-line' will
 highlight the line according to the `gnus-group-highlight'
 variable."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type 'hook)
 
 (defcustom gnus-useful-groups
@@ -265,194 +265,18 @@ variable."
      "gnus-help"
      (nndoc "gnus-help"
            (nndoc-article-type mbox)
-           (eval `(nndoc-address 
+           (eval `(nndoc-address
                    ,(let ((file (nnheader-find-etc-directory
                                  "gnus-tut.txt" t)))
                       (unless file
                         (error "Couldn't find doc group"))
                       file))))))
   "Alist of useful group-server pairs."
-  :group 'gnus-group
+  :group 'gnus-group-listing
   :type '(repeat (list (string :tag "Description")
                       (string :tag "Name")
                       (sexp :tag "Method"))))
 
-(defface gnus-group-news-1-face 
-  '((((class color)
-      (background dark))
-     (:foreground "PaleTurquoise" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "ForestGreen" :bold t))
-    (t
-     ()))
-  "Level 1 newsgroup face.")
-
-(defface gnus-group-news-1-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "PaleTurquoise"))
-    (((class color)
-      (background light))
-     (:foreground "ForestGreen"))
-    (t
-     ()))
-  "Level 1 empty newsgroup face.")
-
-(defface gnus-group-news-2-face 
-  '((((class color)
-      (background dark))
-     (:foreground "turquoise" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "CadetBlue4" :bold t))
-    (t
-     ()))
-  "Level 2 newsgroup face.")
-
-(defface gnus-group-news-2-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "turquoise"))
-    (((class color)
-      (background light))
-     (:foreground "CadetBlue4"))
-    (t
-     ()))
-  "Level 2 empty newsgroup face.")
-
-(defface gnus-group-news-3-face 
-  '((((class color)
-      (background dark))
-     (:bold t))
-    (((class color)
-      (background light))
-     (:bold t))
-    (t
-     ()))
-  "Level 3 newsgroup face.")
-
-(defface gnus-group-news-3-empty-face
-  '((((class color)
-      (background dark))
-     ())
-    (((class color)
-      (background light))
-     ())
-    (t
-     ()))
-  "Level 3 empty newsgroup face.")
-
-(defface gnus-group-news-low-face 
-  '((((class color)
-      (background dark))
-     (:foreground "DarkTurquoise" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "DarkGreen" :bold t))
-    (t
-     ()))
-  "Low level newsgroup face.")
-
-(defface gnus-group-news-low-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "DarkTurquoise"))
-    (((class color)
-      (background light))
-     (:foreground "DarkGreen"))
-    (t
-     ()))
-  "Low level empty newsgroup face.")
-
-(defface gnus-group-mail-1-face 
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine1" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "DeepPink3" :bold t))
-    (t
-     (:bold t)))
-  "Level 1 mailgroup face.")
-
-(defface gnus-group-mail-1-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine1"))
-    (((class color)
-      (background light))
-     (:foreground "DeepPink3"))
-    (t
-     (:italic t :bold t)))
-  "Level 1 empty mailgroup face.")
-
-(defface gnus-group-mail-2-face 
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine2" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "HotPink3" :bold t))
-    (t
-     (:bold t)))
-  "Level 2 mailgroup face.")
-
-(defface gnus-group-mail-2-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine2"))
-    (((class color)
-      (background light))
-     (:foreground "HotPink3"))
-    (t
-     (:bold t)))
-  "Level 2 empty mailgroup face.")
-
-(defface gnus-group-mail-3-face 
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine3" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "magenta4" :bold t))
-    (t
-     (:bold t)))
-  "Level 3 mailgroup face.")
-
-(defface gnus-group-mail-3-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine3"))
-    (((class color)
-      (background light))
-     (:foreground "magenta4"))
-    (t
-     ()))
-  "Level 3 empty mailgroup face.")
-
-(defface gnus-group-mail-low-face 
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine4" :bold t))
-    (((class color)
-      (background light))
-     (:foreground "DeepPink4" :bold t))
-    (t
-     (:bold t)))
-  "Low level mailgroup face.")
-
-(defface gnus-group-mail-low-empty-face
-  '((((class color)
-      (background dark))
-     (:foreground "aquamarine4"))
-    (((class color)
-      (background light))
-     (:foreground "DeepPink4"))
-    (t
-     (:bold t)))
-  "Low level empty mailgroup face.")
-
 (defcustom gnus-group-highlight
   '(;; News.
     ((and (= unread 0) (not mailp) (eq level 1)) .
@@ -488,13 +312,13 @@ variable."
      gnus-group-mail-low-empty-face)
     (t .
      gnus-group-mail-low-face))
-  "Controls the highlighting of group buffer lines. 
+  "Controls the highlighting of group buffer lines.
 
 Below is a list of `Form'/`Face' pairs.  When deciding how a a
 particular group line should be displayed, each form is
 evaluated.  The content of the face field after the first true form is
 used.  You can change how those group lines are displayed by
-editing the face field.  
+editing the face field.
 
 It is also possible to change and add form fields, but currently that
 requires an understanding of Lisp expressions.  Hopefully this will
@@ -508,12 +332,12 @@ mailp: Whether it's a mail group or not.
 level: The level of the group.
 score: The score of the group.
 ticked: The number of ticked articles."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type '(repeat (cons (sexp :tag "Form") face)))
 
 (defcustom gnus-new-mail-mark ?%
   "Mark used for groups with new mail."
-  :group 'gnus-group
+  :group 'gnus-group-visual
   :type 'character)
 
 ;;; Internal variables
@@ -594,6 +418,7 @@ ticked: The number of ticked articles."
     "=" gnus-group-select-group
     "\r" gnus-group-select-group
     "\M-\r" gnus-group-quick-select-group
+    [(meta control return)] gnus-group-select-group-ephemerally
     "j" gnus-group-jump-to-group
     "n" gnus-group-next-unread-group
     "p" gnus-group-prev-unread-group
@@ -758,8 +583,6 @@ ticked: The number of ticked articles."
        ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
        ["Describe" gnus-group-describe-group (gnus-group-group-name)]
        ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
-       ["Edit kill file" gnus-group-edit-local-kill
-       (gnus-group-group-name)]
        ;; Actually one should check, if any of the marked groups gives t for
        ;; (gnus-check-backend-function 'request-expire-articles ...)
        ["Expire articles" gnus-group-expire-articles
@@ -770,8 +593,17 @@ ticked: The number of ticked articles."
        ["Set group level" gnus-group-set-current-level
        (gnus-group-group-name)]
        ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
+       ["Customize" gnus-group-customize (gnus-group-group-name)]
+       ("Edit"
+       ["Parameters" gnus-group-edit-group-parameters
+        (gnus-group-group-name)]
+       ["Select method" gnus-group-edit-group-method
+        (gnus-group-group-name)]
+       ["Info" gnus-group-edit-group (gnus-group-group-name)]
+       ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
+       ["Global kill file" gnus-group-edit-global-kill t])
        ))
-  
+
     (easy-menu-define
      gnus-group-group-menu gnus-group-mode-map ""
      '("Groups"
@@ -845,14 +677,6 @@ ticked: The number of ticked articles."
        ["Delete group" gnus-group-delete-group
         (gnus-check-backend-function
          'request-delete-group (gnus-group-group-name))])
-       ("Editing groups"
-       ["Parameters" gnus-group-edit-group-parameters
-        (gnus-group-group-name)]
-       ["Select method" gnus-group-edit-group-method
-        (gnus-group-group-name)]
-       ["Info" gnus-group-edit-group (gnus-group-group-name)])
-       ("Score file"
-       ["Flush cache" gnus-score-flush-cache t])
        ("Move"
        ["Next" gnus-group-next-group t]
        ["Previous" gnus-group-prev-group t]
@@ -864,6 +688,8 @@ ticked: The number of ticked articles."
        ["Jump to group" gnus-group-jump-to-group t]
        ["First unread group" gnus-group-first-unread-group t]
        ["Best unread group" gnus-group-best-unread-group t])
+       ["Delete bogus groups" gnus-group-check-bogus-groups t]
+       ["Find new newsgroups" gnus-find-new-newsgroups t]
        ["Transpose" gnus-group-transpose-groups
        (gnus-group-group-name)]
        ["Read a directory as a group..." gnus-group-enter-directory t]
@@ -872,14 +698,18 @@ ticked: The number of ticked articles."
     (easy-menu-define
      gnus-group-misc-menu gnus-group-mode-map ""
      '("Misc"
+       ("SOUP"
+       ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
+       ["Send replies" gnus-soup-send-replies
+        (fboundp 'gnus-soup-pack-packet)]
+       ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
+       ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
+       ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
        ["Send a bug report" gnus-bug t]
-       ["Customize" gnus-group-customize t]
        ["Send a mail" gnus-group-mail t]
        ["Post an article..." gnus-group-post-news t]
-       ["Check for new news" gnus-group-get-new-news t]     
+       ["Check for new news" gnus-group-get-new-news t]
        ["Activate all groups" gnus-activate-all-groups t]
-       ["Delete bogus groups" gnus-group-check-bogus-groups t]
-       ["Find new newsgroups" gnus-find-new-newsgroups t]
        ["Restart Gnus" gnus-group-restart t]
        ["Read init file" gnus-group-read-init-file t]
        ["Browse foreign server" gnus-group-browse-foreign-server t]
@@ -890,22 +720,14 @@ ticked: The number of ticked articles."
        ["Save .newsrc files" gnus-group-save-newsrc t]
        ["Suspend Gnus" gnus-group-suspend t]
        ["Clear dribble buffer" gnus-group-clear-dribble t]
-       ["Edit global kill file" gnus-group-edit-global-kill t]
        ["Read manual" gnus-info-find-node t]
+       ["Flush score cache" gnus-score-flush-cache t]
        ["Toggle topics" gnus-topic-mode t]
-       ("SOUP"
-       ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
-       ["Send replies" gnus-soup-send-replies
-        (fboundp 'gnus-soup-pack-packet)]
-       ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
-       ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
-       ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
        ["Exit from Gnus" gnus-group-exit t]
        ["Exit without saving" gnus-group-quit t]
        ))
 
-    (run-hooks 'gnus-group-menu-hook)
-    ))
+    (run-hooks 'gnus-group-menu-hook)))
 
 (defun gnus-group-mode ()
   "Major mode for reading news.
@@ -925,8 +747,7 @@ The following commands are available:
 
 \\{gnus-group-mode-map}"
   (interactive)
-  (when (and menu-bar-mode
-            (gnus-visual-p 'group-menu 'menu))
+  (when (gnus-visual-p 'group-menu 'menu)
     (gnus-group-make-menu-bar))
   (kill-all-local-variables)
   (gnus-simplify-mode-line)
@@ -941,7 +762,7 @@ The following commands are available:
   (gnus-set-default-directory)
   (gnus-update-format-specifications nil 'group 'group-mode)
   (gnus-update-group-mark-positions)
-  (gnus-make-local-hook 'post-command-hook)
+  (make-local-hook 'post-command-hook)
   (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
   (when gnus-use-undo
     (gnus-undo-mode 1))
@@ -1012,44 +833,54 @@ listed."
     (setq level (car gnus-group-list-mode)
          unread (cdr gnus-group-list-mode)))
   (setq level (gnus-group-default-level level))
-  (gnus-group-setup-buffer)            ;May call from out of group buffer
+  (gnus-group-setup-buffer)
   (gnus-update-format-specifications nil 'group 'group-mode)
   (let ((case-fold-search nil)
        (props (text-properties-at (gnus-point-at-bol)))
-       (group (gnus-group-group-name)))
+       (empty (= (point-min) (point-max)))
+       (group (gnus-group-group-name))
+       number)
     (set-buffer gnus-group-buffer)
-    (funcall gnus-group-prepare-function level unread lowest)
-    (if (zerop (buffer-size))
-       (gnus-message 5 gnus-no-groups-message)
-      (goto-char (point-max))
-      (when (or (not gnus-group-goto-next-group-function)
-               (not (funcall gnus-group-goto-next-group-function 
-                             group props)))
-       (if (not group)
-           ;; Go to the first group with unread articles.
-           (gnus-group-search-forward t)
-         ;; Find the right group to put point on.  If the current group
-         ;; has disappeared in the new listing, try to find the next
-         ;; one.        If no next one can be found, just leave point at the
-         ;; first newsgroup in the buffer.
-         (when (not (gnus-goto-char
-                     (text-property-any
-                      (point-min) (point-max)
-                      'gnus-group (gnus-intern-safe
-                                   group gnus-active-hashtb))))
-           (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
-             (while (and newsrc
-                         (not (gnus-goto-char
-                               (text-property-any
-                                (point-min) (point-max) 'gnus-group
-                                (gnus-intern-safe
-                                 (caar newsrc) gnus-active-hashtb)))))
-               (setq newsrc (cdr newsrc)))
-             (unless newsrc
-               (goto-char (point-max))
-               (forward-line -1))))))
-      ;; Adjust cursor point.
-      (gnus-group-position-point))))
+    (setq number (funcall gnus-group-prepare-function level unread lowest))
+    (when (or (and (numberp number)
+                  (zerop number))
+             (zerop (buffer-size)))
+      ;; No groups in the buffer.
+      (gnus-message 5 gnus-no-groups-message))
+    ;; We have some groups displayed.
+    (goto-char (point-max))
+    (when (or (not gnus-group-goto-next-group-function)
+             (not (funcall gnus-group-goto-next-group-function
+                           group props)))
+      (cond
+       (empty
+       (goto-char (point-min)))
+       ((not group)
+       ;; Go to the first group with unread articles.
+       (gnus-group-search-forward t))
+       (t
+       ;; Find the right group to put point on.  If the current group
+       ;; has disappeared in the new listing, try to find the next
+       ;; one.  If no next one can be found, just leave point at the
+       ;; first newsgroup in the buffer.
+       (when (not (gnus-goto-char
+                   (text-property-any
+                    (point-min) (point-max)
+                    'gnus-group (gnus-intern-safe
+                                 group gnus-active-hashtb))))
+         (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
+           (while (and newsrc
+                       (not (gnus-goto-char
+                             (text-property-any
+                              (point-min) (point-max) 'gnus-group
+                              (gnus-intern-safe
+                               (caar newsrc) gnus-active-hashtb)))))
+             (setq newsrc (cdr newsrc)))
+           (unless newsrc
+             (goto-char (point-max))
+             (forward-line -1)))))))
+    ;; Adjust cursor point.
+    (gnus-group-position-point)))
 
 (defun gnus-group-list-level (level &optional all)
   "List groups on LEVEL.
@@ -1083,7 +914,7 @@ If REGEXP, only list groups matching REGEXP."
             (>= clevel lowest)
             (or all                    ; We list all groups?
                 (if (eq unread t)      ; Unactivated?
-                    gnus-group-list-inactive-groups ; We list unactivated 
+                    gnus-group-list-inactive-groups ; We list unactivated
                   (> unread 0))        ; We list groups with unread articles
                 (and gnus-list-groups-with-ticked-articles
                      (cdr (assq 'tick (gnus-info-marks info))))
@@ -1111,7 +942,8 @@ If REGEXP, only list groups matching REGEXP."
 
     (gnus-group-set-mode-line)
     (setq gnus-group-list-mode (cons level all))
-    (run-hooks 'gnus-group-prepare-hook)))
+    (run-hooks 'gnus-group-prepare-hook)
+    t))
 
 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
   ;; List zombies and killed lists somewhat faster, which was
@@ -1180,10 +1012,10 @@ If REGEXP, only list groups matching REGEXP."
           (if (zerop (cdr active))
               0
             (- (1+ (cdr active)) (car active)))
-        0)
+        nil)
        nil))))
 
-(defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level 
+(defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
                                                    gnus-tmp-marked number
                                                    gnus-tmp-method)
   "Insert a group line in the group buffer."
@@ -1286,8 +1118,8 @@ If REGEXP, only list groups matching REGEXP."
       (setq list (cdr list)))
     (let ((face (cdar list)))
       (unless (eq face (get-text-property beg 'face))
-       (gnus-put-text-property 
-        beg end 'face 
+       (gnus-put-text-property
+        beg end 'face
         (setq face (if (boundp face) (symbol-value face) face)))
        (gnus-extent-start-open beg)))
     (goto-char p)))
@@ -1296,8 +1128,11 @@ If REGEXP, only list groups matching REGEXP."
   "Update all lines where GROUP appear.
 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
 already."
-  (save-excursion
+  ;; Can't use `save-excursion' here, so we do it manually.
+  (let ((buf (current-buffer))
+       mark)
     (set-buffer gnus-group-buffer)
+    (setq mark (point-marker))
     ;; The buffer may be narrowed.
     (save-restriction
       (widen)
@@ -1308,7 +1143,7 @@ already."
        (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
          (when (and entry (not (gnus-ephemeral-group-p group)))
            (gnus-dribble-enter
-            (concat "(gnus-group-set-info '" 
+            (concat "(gnus-group-set-info '"
                     (gnus-prin1-to-string (nth 2 entry))
                     ")"))))
        ;; Find all group instances.  If topics are in use, each group
@@ -1347,7 +1182,10 @@ already."
              (run-hooks 'gnus-group-update-group-hook))))
        (when gnus-group-update-group-function
          (funcall gnus-group-update-group-function group))
-       (gnus-group-set-mode-line)))))
+       (gnus-group-set-mode-line)))
+    (goto-char mark)
+    (set-marker mark nil)
+    (set-buffer buf)))
 
 (defun gnus-group-set-mode-line ()
   "Update the mode line in the group buffer."
@@ -1366,7 +1204,7 @@ already."
             (max-len 60)
             gnus-tmp-header            ;Dummy binding for user-defined formats
             ;; Get the resulting string.
-            (modified 
+            (modified
              (and gnus-dribble-buffer
                   (buffer-name gnus-dribble-buffer)
                   (buffer-modified-p gnus-dribble-buffer)
@@ -1376,12 +1214,12 @@ already."
             (mode-string (eval gformat)))
        ;; Say whether the dribble buffer has been modified.
        (setq mode-line-modified
-             (if modified "---*- " "----- "))
+             (if modified "--**- " "----- "))
        ;; If the line is too long, we chop it off.
        (when (> (length mode-string) max-len)
          (setq mode-string (substring mode-string 0 (- max-len 4))))
        (prog1
-           (setq mode-line-buffer-identification 
+           (setq mode-line-buffer-identification
                  (gnus-mode-line-buffer-identification
                   (list mode-string)))
          (set-buffer-modified-p modified))))))
@@ -1411,6 +1249,12 @@ already."
       gnus-new-mail-mark
     ? ))
 
+(defun gnus-group-level (group)
+  "Return the estimated level of GROUP."
+  (or (gnus-info-level (gnus-get-info group))
+      (and (member group gnus-zombie-list) 8)
+      9))
+
 (defun gnus-group-search-forward (&optional backward all level first-too)
   "Find the next newsgroup with unread articles.
 If BACKWARD is non-nil, find the previous newsgroup instead.
@@ -1575,10 +1419,7 @@ Take into consideration N (the prefix) and the list of marked groups."
          (setq n (1- n))
          (gnus-group-next-group way)))
       (nreverse groups)))
-   ((and (boundp 'transient-mark-mode)
-        transient-mark-mode
-        (boundp 'mark-active)
-        mark-active)
+   ((gnus-region-active-p)
     ;; Work on the region between point and mark.
     (let ((max (max (point) (mark)))
          groups)
@@ -1640,7 +1481,7 @@ group."
                 (- (1+ (cdr active)) (car active)))))
     (gnus-summary-read-group
      group (or all (and (numberp number)
-                       (zerop (+ number (gnus-range-length 
+                       (zerop (+ number (gnus-range-length
                                          (cdr (assq 'tick marked)))
                                  (gnus-range-length
                                   (cdr (assq 'dormant marked)))))))
@@ -1663,6 +1504,7 @@ buffer."
   (require 'gnus-score)
   (let (gnus-visual
        gnus-score-find-score-files-function
+       gnus-home-score-file
        gnus-apply-kill-hook
        gnus-summary-expunge-below)
     (gnus-group-read-group all t)))
@@ -1673,6 +1515,26 @@ buffer."
   (let ((gnus-inhibit-limiting t))
     (gnus-group-read-group all t)))
 
+(defun gnus-group-select-group-ephemerally ()
+  "Select the current group without doing any processing whatsoever.
+You will actually be entered into a group that's a copy of
+the current group; no changes you make while in this group will
+be permanent."
+  (interactive)
+  (require 'gnus-score)
+  (let* (gnus-visual
+        gnus-score-find-score-files-function gnus-apply-kill-hook
+        gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
+        gnus-summary-mode-hook gnus-select-group-hook
+        (group (gnus-group-group-name))
+        (method (gnus-find-method-for-group group)))
+    (setq method
+         `(,(car method) ,(concat (cadr method) "-ephemeral")
+           (,(intern (format "%s-address" (car method))) ,(cadr method))
+           ,@(cddr method)))
+    (gnus-group-read-ephemeral-group
+     (gnus-group-prefixed-name group method) method)))
+
 ;;;###autoload
 (defun gnus-fetch-group (group)
   "Start Gnus if necessary and enter GROUP.
@@ -1682,9 +1544,11 @@ Returns whether the fetching was successful or not."
     (gnus))
   (gnus-group-read-group nil nil group))
 
+(defvar gnus-ephemeral-group-server 0)
+
 ;; Enter a group that is not in the group buffer.  Non-nil is returned
 ;; if selection was successful.
-(defun gnus-group-read-ephemeral-group (group method &optional activate 
+(defun gnus-group-read-ephemeral-group (group method &optional activate
                                              quit-config request-only)
   "Read GROUP from METHOD as an ephemeral group.
 If ACTIVATE, request the group first.
@@ -1693,11 +1557,18 @@ ephemeral group.
 If REQUEST-ONLY, don't actually read the group; just request it.
 
 Return the name of the group is selection was successful."
+  ;; Transform the select method into a unique server.
+  (let ((saddr (intern (format "%s-address" (car method)))))
+    (setq method (gnus-copy-sequence method))
+    (unless (assq saddr method)
+      (nconc method `((,saddr ,(cadr method)))))
+    (setf (cadr method) (format "%s-%d" (cadr method)
+                               (incf gnus-ephemeral-group-server))))
   (let ((group (if (gnus-group-foreign-p group) group
                 (gnus-group-prefixed-name group method))))
     (gnus-sethash
      group
-     `(-1 nil (,group 
+     `(-1 nil (,group
               ,gnus-level-default-subscribed nil nil ,method
               ((quit-config .
                             ,(if quit-config quit-config
@@ -1710,7 +1581,7 @@ Return the name of the group is selection was successful."
     (when activate
       (gnus-activate-group group 'scan)
       (unless (gnus-request-group group)
-       (error "Couldn't request group: %s" 
+       (error "Couldn't request group: %s"
               (nnheader-get-report (car method)))))
     (if request-only
        group
@@ -1747,7 +1618,7 @@ If FAR, it is likely that the group is not on the current line."
   (when group
     (if far
        (gnus-goto-char
-        (text-property-any 
+        (text-property-any
          (point-min) (point-max)
          'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
       (beginning-of-line)
@@ -1773,7 +1644,7 @@ If FAR, it is likely that the group is not on the current line."
        (t
        ;; Search through the entire buffer.
        (gnus-goto-char
-        (text-property-any 
+        (text-property-any
          (point-min) (point-max)
          'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
 
@@ -1910,7 +1781,7 @@ ADDRESS."
     (gnus-set-active nname (cons 1 0))
     (unless (gnus-ephemeral-group-p name)
       (gnus-dribble-enter
-       (concat "(gnus-group-set-info '" 
+       (concat "(gnus-group-set-info '"
               (gnus-prin1-to-string (cdr info)) ")")))
     ;; Insert the line.
     (gnus-group-insert-group-line-info nname)
@@ -1968,20 +1839,19 @@ and NEW-NAME will be prompted for."
       (unless (gnus-check-backend-function
               'request-rename-group (gnus-group-group-name))
        (error "This backend does not support renaming groups"))
-      (read-string "New group name: " (gnus-group-group-name)))))
+      (gnus-read-group "Rename group to: "
+                      (gnus-group-real-name (gnus-group-group-name))))))
 
   (unless (gnus-check-backend-function 'request-rename-group group)
     (error "This backend does not support renaming groups"))
-  (unless group 
+  (unless group
     (error "No group to rename"))
-  (when (string-match "^[ \t]*$" new-name)
-    (error "Not a valid group name"))
-  (when (equal group new-name)
+  (when (equal (gnus-group-real-name group) new-name)
     (error "Can't rename to the same name"))
 
   ;; We find the proper prefixed name.
   (setq new-name
-       (if (equal (gnus-group-real-name new-name) new-name)
+       (if (gnus-group-native-p group)
            ;; Native group.
            new-name
          ;; Foreign group.
@@ -2014,6 +1884,8 @@ and NEW-NAME will be prompted for."
       (error "No group on current line"))
     (unless (setq info (gnus-get-info group))
       (error "Killed group; can't be edited"))
+    (ignore-errors
+      (gnus-close-group group))
     (gnus-edit-form
      ;; Find the proper form to edit.
      (cond ((eq part 'method)
@@ -2023,11 +1895,12 @@ and NEW-NAME will be prompted for."
           (t info))
      ;; The proper documentation.
      (format
-      "Editing the %s."
+      "Editing the %s for `%s'."
       (cond
        ((eq part 'method) "select method")
        ((eq part 'params) "group parameters")
-       (t "group info")))
+       (t "group info"))
+      group)
      `(lambda (form)
        (gnus-group-edit-group-done ',part ,group form)))))
 
@@ -2157,8 +2030,8 @@ If SOLID (the prefix), create a solid group."
                       0)
           'gnus-group-web-type-history))
         (search
-         (read-string 
-          "Search string: " 
+         (read-string
+          "Search string: "
           (cons (or (car gnus-group-web-search-history) "") 0)
           'gnus-group-web-search-history))
         (method
@@ -2248,6 +2121,7 @@ score file entries for articles to include in the group."
                          "nnvirtual:")))
   (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
     (error "%s is not an nnvirtual group" vgroup))
+  (gnus-close-group vgroup)
   (let* ((groups (gnus-group-process-prefix n))
         (method (gnus-info-method (gnus-get-info vgroup))))
     (setcar (cdr method)
@@ -2294,7 +2168,9 @@ score file entries for articles to include in the group."
 
 (defun gnus-group-sort-groups (func &optional reverse)
   "Sort the group buffer according to FUNC.
-If REVERSE, reverse the sorting order."
+When used interactively, the sorting function used will be
+determined by the `gnus-group-sort-function' variable.
+If REVERSE (the prefix), reverse the sorting order."
   (interactive (list gnus-group-sort-function current-prefix-arg))
   (funcall gnus-group-sort-alist-function
           (gnus-make-sort-function func) reverse)
@@ -2483,7 +2359,7 @@ If REVERSE, sort in reverse order."
          (gnus-info-clear-data info)))
       (gnus-get-unread-articles)
       (gnus-dribble-enter "")
-      (when (gnus-y-or-n-p 
+      (when (gnus-y-or-n-p
             "Move the cache away to avoid problems in the future? ")
        (call-interactively 'gnus-cache-move-cache)))))
 
@@ -2492,7 +2368,7 @@ If REVERSE, sort in reverse order."
   (let ((group (gnus-info-group info)))
     (gnus-undo-register
       `(progn
-        (gnus-info-set-marks ',info ',(gnus-info-marks info))
+        (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
         (gnus-info-set-read ',info ',(gnus-info-read info))
         (when (gnus-group-goto-group ,group)
           (gnus-group-update-group-line))))
@@ -2512,15 +2388,20 @@ caught up is returned."
   (interactive "P")
   (unless (gnus-group-group-name)
     (error "No group on the current line"))
-  (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
-              gnus-expert-user
-              (gnus-y-or-n-p
-               (if all
-                   "Do you really want to mark all articles as read? "
-                 "Mark all unread articles as read? "))))
-      n
-    (let ((groups (gnus-group-process-prefix n))
-         (ret 0))
+  (let ((groups (gnus-group-process-prefix n))
+       (ret 0))
+    (if (not
+        (or (not gnus-interactive-catchup) ;Without confirmation?
+            gnus-expert-user
+            (gnus-y-or-n-p
+             (format
+              (if all
+                  "Do you really want to mark all articles in %s as read? "
+                "Mark all unread articles in %s as read? ")
+              (if (= (length groups) 1)
+                  (car groups)
+                (format "these %d groups" (length groups)))))))
+       n
       (while groups
        ;; Virtual groups have to be given special treatment.
        (let ((method (gnus-find-method-for-group (car groups))))
@@ -2597,7 +2478,7 @@ or nil if no action could be taken."
             (gnus-compress-sequence
              (if expiry-wait
                  ;; We set the expiry variables to the group
-                 ;; parameter. 
+                 ;; parameter.
                  (let ((nnmail-expiry-wait-function nil)
                        (nnmail-expiry-wait expiry-wait))
                    (gnus-request-expire-articles
@@ -2669,7 +2550,7 @@ If given numerical prefix, toggle the N next groups."
            groups (cdr groups))
       (gnus-group-remove-mark group)
       (gnus-group-unsubscribe-group
-       group 
+       group
        (cond
        ((eq do-sub 'unsubscribe)
         gnus-level-default-unsubscribed)
@@ -2691,7 +2572,7 @@ group line."
    (list (completing-read
          "Group: " gnus-active-hashtb nil
          (gnus-read-active-file-p)
-         nil 
+         nil
          'gnus-group-history)))
   (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
     (cond
@@ -2700,7 +2581,7 @@ group line."
      (newsrc
       ;; Toggle subscription flag.
       (gnus-group-change-level
-       newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
+       newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
                                      gnus-level-subscribed)
                                  (1+ gnus-level-subscribed)
                                gnus-level-default-subscribed)))
@@ -2930,10 +2811,17 @@ entail asking the server for the groups."
             gnus-active-hashtb)
            list)
          'string<))
-       (buffer-read-only nil))
+       (buffer-read-only nil)
+       group)
     (erase-buffer)
     (while groups
-      (gnus-group-insert-group-line-info (pop groups)))
+      (gnus-add-text-properties
+       (point) (prog1 (1+ (point))
+                (insert "       *: "
+                        (setq group (pop groups)) "\n"))
+       (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
+            'gnus-unread t
+            'gnus-level (inline (gnus-group-level group)))))
     (goto-char (point-min))))
 
 (defun gnus-activate-all-groups (level)
@@ -2956,14 +2844,18 @@ re-scanning.  If ARG is non-nil and not a number, this will force
     (gnus-master-read-slave-newsrc))
 
   ;; We might read in new NoCeM messages here.
-  (when (and gnus-use-nocem 
+  (when (and gnus-use-nocem
             (null arg))
     (gnus-nocem-scan-groups))
   ;; If ARG is not a number, then we read the active file.
   (when (and arg (not (numberp arg)))
     (let ((gnus-read-active-file t))
       (gnus-read-active-file))
-    (setq arg nil))
+    (setq arg nil)
+
+    ;; If the user wants it, we scan for new groups.
+    (when (eq gnus-check-new-newsgroups 'always)
+      (gnus-find-new-newsgroups)))
 
   (setq arg (gnus-group-default-level arg t))
   (if (and gnus-read-active-file (not arg))
@@ -2973,7 +2865,8 @@ re-scanning.  If ARG is non-nil and not a number, this will force
     (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
       (gnus-get-unread-articles arg)))
   (run-hooks 'gnus-after-getting-new-news-hook)
-  (gnus-group-list-groups))
+  (gnus-group-list-groups (and (numberp arg)
+                              (max (car gnus-group-list-mode) arg))))
 
 (defun gnus-group-get-new-news-this-group (&optional n)
   "Check for newly arrived news in the current group (and the N-1 next groups).
@@ -3031,8 +2924,9 @@ to use."
                         (gnus-group-real-name group)))
       (if (not (file-exists-p file))
          (gnus-message 1 "No such file: %s" file)
-       (find-file file)
-       (setq found t)))))
+       (let ((enable-local-variables nil))
+         (find-file file)
+         (setq found t))))))
 
 (defun gnus-group-describe-group (force &optional group)
   "Display a description of the current newsgroup."
@@ -3144,7 +3038,7 @@ This command may read the active file."
   (when (and level
             (> (prefix-numeric-value level) gnus-level-killed))
     (gnus-get-killed-groups))
-  (gnus-group-prepare-flat 
+  (gnus-group-prepare-flat
    (or level gnus-level-subscribed) all (or lowest 1) regexp)
   (goto-char (point-min))
   (gnus-group-position-point))
@@ -3155,6 +3049,8 @@ If the prefix LEVEL is non-nil, it should be a number that says which
 level to cut off listing groups.
 If LOWEST, don't list groups with level lower than LOWEST."
   (interactive "P\nsList newsgroups matching: ")
+  (when level
+    (setq level (prefix-numeric-value level)))
   (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
 
 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
@@ -3171,8 +3067,7 @@ If FORCE, force saving whether it is necessary or not."
         (format "Are you sure you want to restart Gnus? "))
     (gnus-save-newsrc-file)
     (gnus-clear-system)
-    (gnus-setup-news 'force)
-    (gnus-group-list-groups arg)))
+    (gnus)))
 
 (defun gnus-group-read-init-file ()
   "Read the Gnus elisp init file."
@@ -3239,7 +3134,7 @@ The hook gnus-suspend-gnus-hook is called before actually suspending."
   "Quit reading news after updating .newsrc.eld and .newsrc.
 The hook `gnus-exit-gnus-hook' is called before actually exiting."
   (interactive)
-  (when 
+  (when
       (or noninteractive               ;For gnus-batch-kill
          (not gnus-interactive-exit)   ;Without confirmation
          gnus-expert-user