Add arch taglines
[gnus] / lisp / gnus-sum.el
index 46f3839..725d936 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-sum.el --- summary mode commands for Gnus
-;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -26,7 +26,9 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl)
+  (defvar tool-bar-map))
 
 (require 'gnus)
 (require 'gnus-group)
@@ -42,6 +44,7 @@
 (autoload 'gnus-cache-write-active "gnus-cache")
 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
+(autoload 'gnus-pick-line-number "gnus-salt" nil t)
 (autoload 'mm-uu-dissect "mm-uu")
 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
   "Deuglify broken Outlook (Express) articles and redisplay."
@@ -251,7 +254,12 @@ If threads are hidden, you have to run the command
 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
 to expose hidden threads."
   :group 'gnus-thread
-  :type 'boolean)
+  :type '(radio (sexp :format "Non-nil\n"
+                     :match (lambda (widget value)
+                              (not (or (consp value) (functionp value))))
+                     :value t)
+               (const nil)
+               (sexp :tag "Predicate specifier" :size 0)))
 
 (defcustom gnus-thread-hide-killed t
   "*If non-nil, hide killed threads automatically."
@@ -321,13 +329,13 @@ place point on some subject line."
 (defcustom gnus-auto-select-next t
   "*If non-nil, offer to go to the next group from the end of the previous.
 If the value is t and the next newsgroup is empty, Gnus will exit
-summary mode and go back to group mode.         If the value is neither nil
-nor t, Gnus will select the following unread newsgroup.         In
+summary mode and go back to group mode.  If the value is neither nil
+nor t, Gnus will select the following unread newsgroup.  In
 particular, if the value is the symbol `quietly', the next unread
 newsgroup will be selected without any confirmation, and if it is
 `almost-quietly', the next group will be selected without any
 confirmation if you are located on the last article in the group.
-Finally, if this variable is `slightly-quietly', the `Z n' command
+Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
 will go to the next group without confirmation."
   :group 'gnus-summary-maneuvering
   :type '(choice (const :tag "off" nil)
@@ -343,6 +351,23 @@ the first unread article."
   :group 'gnus-summary-maneuvering
   :type 'boolean)
 
+(defcustom gnus-auto-goto-ignores 'unfetched
+  "*Says how to handle unfetched articles when maneuvering.
+
+This variable can either be the symbols nil (maneuver to any
+article), `undownloaded' (maneuvering while unplugged ignores articles
+that have not been fetched), `always-undownloaded' (maneuvering always
+ignores articles that have not been fetched), `unfetched' (maneuvering
+ignores articles whose headers have not been fetched).
+
+NOTE: The list of unfetched articles will always be nil when plugged
+and, when unplugged, a subset of the undownloaded article list."
+  :group 'gnus-summary-maneuvering
+  :type '(choice (const :tag "None" nil)
+                 (const :tag "Undownloaded when unplugged" undownloaded)
+                 (const :tag "Undownloaded" always-undownloaded)
+                 (const :tag "Unfetched" unfetched)))
+
 (defcustom gnus-summary-check-current nil
   "*If non-nil, consider the current article when moving.
 The \"unread\" movement commands will stay on the same line if the
@@ -397,6 +422,13 @@ this variable specifies group names."
                         (cons :value ("" "") regexp (repeat string))
                         (sexp :value nil))))
 
+(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
+  "Function used to compute default prefix for article move/copy/etc prompts.
+The function should take one argument, a group name, and return a
+string with the suggested prefix."
+  :group 'gnus-summary-mail
+  :type 'function)
+
 (defcustom gnus-unread-mark ?           ;Whitespace
   "*Mark used for unread articles."
   :group 'gnus-summary-marks
@@ -647,6 +679,41 @@ score file."
   :group 'gnus-score-default
   :type 'integer)
 
+(defun gnus-widget-reversible-match (widget value)
+  "Ignoring WIDGET, convert VALUE to internal form.
+VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
+  ;; (debug value)
+  (or (symbolp value)
+      (and (listp value)
+           (eq (length value) 2)
+           (eq (nth 0 value) 'not)
+           (symbolp (nth 1 value)))))
+
+(defun gnus-widget-reversible-to-internal (widget value)
+  "Ignoring WIDGET, convert VALUE to internal form.
+VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
+FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
+  ;; (debug value)
+  (if (atom value)
+      (list value nil)
+    (list (nth 1 value) t)))
+
+(defun gnus-widget-reversible-to-external (widget value)
+  "Ignoring WIDGET, convert VALUE to external form.
+VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
+\(FOO  nil) is converted to FOO and (FOO t) is converted to (not FOO)."
+  ;; (debug value)
+  (if (nth 1 value)
+      (list 'not (nth 0 value))
+    (nth 0 value)))
+
+(define-widget 'gnus-widget-reversible 'group
+  "A `group' that convert values."
+  :match 'gnus-widget-reversible-match
+  :value-to-internal 'gnus-widget-reversible-to-internal
+  :value-to-external 'gnus-widget-reversible-to-external)
+                        
+
 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
   "*List of functions used for sorting articles in the summary buffer.
 
@@ -659,6 +726,9 @@ is often much slower than sorting by number, and the sorting order is
 very similar.  (Sorting by date means sorting by the time the message
 was sent, sorting by number means sorting by arrival time.)
 
+Each item can also be a list `(not F)' where F is a function;
+this reverses the sort order.
+
 Ready-made functions include `gnus-article-sort-by-number',
 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
@@ -667,13 +737,16 @@ and `gnus-article-sort-by-score'.
 When threading is turned on, the variable `gnus-thread-sort-functions'
 controls how articles are sorted."
   :group 'gnus-summary-sort
-  :type '(repeat (choice (function-item gnus-article-sort-by-number)
-                        (function-item gnus-article-sort-by-author)
-                        (function-item gnus-article-sort-by-subject)
-                        (function-item gnus-article-sort-by-date)
-                        (function-item gnus-article-sort-by-score)
-                        (function-item gnus-article-sort-by-random)
-                        (function :tag "other"))))
+  :type '(repeat (gnus-widget-reversible
+                  (choice (function-item gnus-article-sort-by-number)
+                          (function-item gnus-article-sort-by-author)
+                          (function-item gnus-article-sort-by-subject)
+                          (function-item gnus-article-sort-by-date)
+                          (function-item gnus-article-sort-by-score)
+                          (function-item gnus-article-sort-by-random)
+                          (function :tag "other"))
+                  (boolean :tag "Reverse order"))))
+
 
 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
   "*List of functions used for sorting threads in the summary buffer.
@@ -688,6 +761,9 @@ is often much slower than sorting by number, and the sorting order is
 very similar.  (Sorting by date means sorting by the time the message
 was sent, sorting by number means sorting by arrival time.)
 
+Each list item can also be a list `(not F)' where F is a
+function; this specifies reversed sort order.
+
 Ready-made functions include `gnus-thread-sort-by-number',
 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
@@ -699,14 +775,19 @@ Ready-made functions include `gnus-thread-sort-by-number',
 When threading is turned off, the variable
 `gnus-article-sort-functions' controls how articles are sorted."
   :group 'gnus-summary-sort
-  :type '(repeat (choice (function-item gnus-thread-sort-by-number)
-                        (function-item gnus-thread-sort-by-author)
-                        (function-item gnus-thread-sort-by-subject)
-                        (function-item gnus-thread-sort-by-date)
-                        (function-item gnus-thread-sort-by-score)
-                        (function-item gnus-thread-sort-by-total-score)
-                        (function-item gnus-thread-sort-by-random)
-                        (function :tag "other"))))
+  :type '(repeat 
+          (gnus-widget-reversible
+           (choice (function-item gnus-thread-sort-by-number)
+                   (function-item gnus-thread-sort-by-author)
+                   (function-item gnus-thread-sort-by-subject)
+                   (function-item gnus-thread-sort-by-date)
+                   (function-item gnus-thread-sort-by-score)
+                   (function-item gnus-thread-sort-by-most-recent-number)
+                   (function-item gnus-thread-sort-by-most-recent-date)
+                   (function-item gnus-thread-sort-by-random)
+                   (function-item gnus-thread-sort-by-total-score)
+                   (function :tag "other"))
+           (boolean :tag "Reverse order"))))
 
 (defcustom gnus-thread-score-function '+
   "*Function used for calculating the total score of a thread.
@@ -932,7 +1013,8 @@ default:      The default article score.
 default-high: The default score for high scored articles.
 default-low:  The default score for low scored articles.
 below:        The score below which articles are automatically marked as read.
-mark:         The articles mark."
+mark:         The article's mark.
+uncached:     Non-nil if the article is uncached."
   :group 'gnus-summary-visual
   :type '(repeat (cons (sexp :tag "Form" nil)
                       face)))
@@ -1034,15 +1116,16 @@ For example: ((1 . cn-gb-2312) (2 . big5))."
                 integer))
 
 (defcustom gnus-summary-save-parts-default-mime "image/.*"
-  "*A regexp to match MIME parts when saving multiple parts of a message
-with gnus-summary-save-parts (X m). This regexp will be used by default
-when prompting the user for which type of files to save."
+  "*A regexp to match MIME parts when saving multiple parts of a
+message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
+This regexp will be used by default when prompting the user for which
+type of files to save."
   :group 'gnus-summary
   :type 'regexp)
 
 (defcustom gnus-read-all-available-headers nil
   "Whether Gnus should parse all headers made available to it.
-This is mostly relevant for slow backends where the user may
+This is mostly relevant for slow back ends where the user may
 wish to widen the summary buffer to include all headers
 that were fetched.  Say, for nnultimate groups."
   :group 'gnus-summary
@@ -1062,7 +1145,7 @@ Set it to non-nil, Gnus will treat some articles as MIME even if
 the MIME-Version header is missed."
   :version "21.3"
   :type 'boolean
-  :group 'gnus-article)
+  :group 'gnus-article-mime)
 
 (defcustom gnus-article-emulate-mime t
   "If non-nil, use MIME emulation for uuencode and the like.
@@ -1070,7 +1153,7 @@ This means that Gnus will search message bodies for text that look
 like uuencoded bits, yEncoded bits, and so on, and present that using
 the normal Gnus MIME machinery."
   :type 'boolean
-  :group 'gnus-article)
+  :group 'gnus-article-mime)
 
 ;;; Internal variables
 
@@ -1092,7 +1175,7 @@ the normal Gnus MIME machinery."
   "Function called to sort the articles within a thread after it has been gathered together.")
 
 (defvar gnus-summary-save-parts-type-history nil)
-(defvar gnus-summary-save-parts-last-directory nil)
+(defvar gnus-summary-save-parts-last-directory mm-default-directory)
 
 ;; Avoid highlighting in kill files.
 (defvar gnus-summary-inhibit-highlight nil)
@@ -1140,7 +1223,6 @@ the normal Gnus MIME machinery."
     (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
     (?i gnus-tmp-score ?d)
     (?z gnus-tmp-score-char ?c)
-    (?l (bbb-grouplens-score gnus-tmp-header) ?s)
     (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
     (?U gnus-tmp-unread ?c)
     (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
@@ -1205,6 +1287,7 @@ the type of the variable (string, integer, character, etc).")
 (defvar gnus-newsgroup-data-reverse nil)
 (defvar gnus-newsgroup-limit nil)
 (defvar gnus-newsgroup-limits nil)
+(defvar gnus-summary-use-undownloaded-faces nil)
 
 (defvar gnus-newsgroup-unreads nil
   "Sorted list of unread articles in the current newsgroup.")
@@ -1253,10 +1336,13 @@ the type of the variable (string, integer, character, etc).")
   "Sorted list of articles in the current newsgroup that can be processed.")
 
 (defvar gnus-newsgroup-unfetched nil
-  "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
+  "Sorted list of articles in the current newsgroup whose headers have
+not been fetched into the agent.
+
+This list will always be a subset of gnus-newsgroup-undownloaded.")
 
 (defvar gnus-newsgroup-undownloaded nil
-  "List of articles in the current newsgroup that haven't been downloaded..")
+  "List of articles in the current newsgroup that haven't been downloaded.")
 
 (defvar gnus-newsgroup-unsendable nil
   "List of articles in the current newsgroup that won't be sent.")
@@ -1304,7 +1390,7 @@ the type of the variable (string, integer, character, etc).")
 
 (defvar gnus-article-before-search nil)
 
-(defconst gnus-summary-local-variables
+(defvar gnus-summary-local-variables
   '(gnus-newsgroup-name
     gnus-newsgroup-begin gnus-newsgroup-end
     gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
@@ -1342,17 +1428,26 @@ the type of the variable (string, integer, character, etc).")
     gnus-cache-removable-articles gnus-newsgroup-cached
     gnus-newsgroup-data gnus-newsgroup-data-reverse
     gnus-newsgroup-limit gnus-newsgroup-limits
-    gnus-newsgroup-charset gnus-newsgroup-display)
+    gnus-newsgroup-charset gnus-newsgroup-display
+    gnus-summary-use-undownloaded-faces)
   "Variables that are buffer-local to the summary buffers.")
 
 (defvar gnus-newsgroup-variables nil
   "A list of variables that have separate values in different newsgroups.
 A list of newsgroup (summary buffer) local variables, or cons of
-variables and their default values (when the default values are not
-nil), that should be made global while the summary buffer is active.
+variables and their default expressions to be evalled (when the default
+values are not nil), that should be made global while the summary buffer
+is active.
+
+Note: The default expressions will be evaluated (using function `eval')
+before assignment to the local variable rather than just assigned to it.
+If the default expression is the symbol `global', that symbol will not
+be evaluated but the global value of the local variable will be used
+instead.
+
 These variables can be used to set variables in the group parameters
-while still allowing them to affect operations done in other
-buffers. For example:
+while still allowing them to affect operations done in other buffers.
+For example:
 
 \(setq gnus-newsgroup-variables
      '(message-use-followup-to
@@ -1361,9 +1456,18 @@ buffers. For example:
 ")
 
 ;; Byte-compiler warning.
-;(eval-when-compile (defvar gnus-article-mode-map))
 (eval-when-compile
+  ;; Bind features so that require will believe that gnus-sum has
+  ;; already been loaded (avoids infinite recursion)
   (let ((features (cons 'gnus-sum features)))
+    ;; Several of the declarations in gnus-sum are needed to load the
+    ;; following files. Right now, these definitions have been
+    ;; compiled but not defined (evaluated).  We could either do a
+    ;; eval-and-compile about all of the declarations or evaluate the
+    ;; source file.
+    (if (boundp 'gnus-newsgroup-variables)
+        nil
+      (load "gnus-sum.el" t t t))
     (require 'gnus)
     (require 'gnus-agent)
     (require 'gnus-art)))
@@ -1505,7 +1609,7 @@ See `gnus-simplify-buffer-fuzzy' for details."
       (buffer-string))))
 
 (defsubst gnus-simplify-subject-fully (subject)
-  "Simplify a subject string according to gnus-summary-gather-subject-limit."
+  "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
   (cond
    (gnus-simplify-subject-functions
     (gnus-map-function gnus-simplify-subject-functions subject))
@@ -1521,7 +1625,7 @@ See `gnus-simplify-buffer-fuzzy' for details."
 
 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
   "Check whether two subjects are equal.
-If optional argument simple-first is t, first argument is already
+If optional argument SIMPLE-FIRST is t, first argument is already
 simplified."
   (cond
    ((null simple-first)
@@ -1715,7 +1819,8 @@ increase the score of each group you read."
   "c" gnus-summary-limit-exclude-childless-dormant
   "C" gnus-summary-limit-mark-excluded-as-read
   "o" gnus-summary-insert-old-articles
-  "N" gnus-summary-insert-new-articles)
+  "N" gnus-summary-insert-new-articles
+  "r" gnus-summary-limit-to-replied)
 
 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
   "n" gnus-summary-next-unread-article
@@ -1805,6 +1910,7 @@ increase the score of each group you read."
   "q" gnus-article-de-quoted-unreadable
   "6" gnus-article-de-base64-unreadable
   "Z" gnus-article-decode-HZ
+  "A" gnus-article-treat-ansi-sequences
   "h" gnus-article-wash-html
   "u" gnus-article-unsplit-urls
   "s" gnus-summary-force-verify-and-decrypt
@@ -2065,18 +2171,23 @@ increase the score of each group you read."
              ["View MIME buttons" gnus-summary-display-buttonized t]
              ["View all" gnus-mime-view-all-parts t]
              ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
-             ["Encrypt body" gnus-article-encrypt-body t]
-             ["Extract all parts" gnus-summary-save-parts t]
+             ["Encrypt body" gnus-article-encrypt-body
+              :active (not (gnus-group-read-only-p))
+              ,@(if (featurep 'xemacs) nil
+                  '(:help "Encrypt the message body on disk"))]
+             ["Extract all parts..." gnus-summary-save-parts t]
              ("Multipart"
               ["Repair multipart" gnus-summary-repair-multipart t]
-              ["Add buttons" gnus-summary-display-buttonized t]
-              ["Pipe part" gnus-article-pipe-part t]
+              ["Pipe part..." gnus-article-pipe-part t]
               ["Inline part" gnus-article-inline-part t]
-              ["Encrypt body" gnus-article-encrypt-body t]
+              ["Encrypt body" gnus-article-encrypt-body
+               :active (not (gnus-group-read-only-p))
+              ,@(if (featurep 'xemacs) nil
+                  '(:help "Encrypt the message body on disk"))]
               ["View part externally" gnus-article-view-part-externally t]
-              ["View part with charset" gnus-article-view-part-as-charset t]
+              ["View part with charset..." gnus-article-view-part-as-charset t]
               ["Copy part" gnus-article-copy-part t]
-              ["Save part" gnus-article-save-part t]
+              ["Save part..." gnus-article-save-part t]
               ["View part" gnus-article-view-part t]))
             ("Date"
              ["Local" gnus-article-date-local t]
@@ -2096,9 +2207,9 @@ increase the score of each group you read."
               ,@(gnus-summary-menu-split
                  (mapcar
                   (lambda (cs)
-                    ;; Since easymenu under FSF Emacs doesn't allow lambda
-                    ;; forms for menu commands, we should provide intern'ed
-                    ;; function symbols.
+                    ;; Since easymenu under Emacs doesn't allow
+                    ;; lambda forms for menu commands, we should
+                    ;; provide intern'ed function symbols.
                     (let ((command (intern (format "\
 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
                       (fset command
@@ -2129,7 +2240,7 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
              ["Word wrap" gnus-article-fill-cited-article t]
              ["Fill long lines" gnus-article-fill-long-lines t]
              ["Capitalize sentences" gnus-article-capitalize-sentences t]
-             ["CR" gnus-article-remove-cr t]
+             ["Remove CR" gnus-article-remove-cr t]
              ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
              ["Base64" gnus-article-de-base64-unreadable t]
              ["Rot 13" gnus-summary-caesar-message
@@ -2145,9 +2256,10 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
              ["Unfold headers" gnus-article-treat-unfold-headers t]
              ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
              ["Html" gnus-article-wash-html t]
-             ["URLs" gnus-article-unsplit-urls t]
+             ["Unsplit URLs" gnus-article-unsplit-urls t]
              ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
-             ["HZ" gnus-article-decode-HZ t]
+             ["Decode HZ" gnus-article-decode-HZ t]
+             ["ANSI sequences" gnus-article-treat-ansi-sequences t]
              ("(Outlook) Deuglify"
               ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
               ["Repair attribution" gnus-article-outlook-repair-attribution t]
@@ -2156,20 +2268,20 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
                gnus-article-outlook-deuglify-article t])
              )
             ("Output"
-             ["Save in default format" gnus-summary-save-article
+             ["Save in default format..." gnus-summary-save-article
               ,@(if (featurep 'xemacs) '(t)
                   '(:help "Save article using default method"))]
-             ["Save in file" gnus-summary-save-article-file
+             ["Save in file..." gnus-summary-save-article-file
               ,@(if (featurep 'xemacs) '(t)
                   '(:help "Save article in file"))]
-             ["Save in Unix mail format" gnus-summary-save-article-mail t]
-             ["Save in MH folder" gnus-summary-save-article-folder t]
-             ["Save in VM folder" gnus-summary-save-article-vm t]
-             ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
-             ["Save body in file" gnus-summary-save-article-body-file t]
-             ["Pipe through a filter" gnus-summary-pipe-output t]
+             ["Save in Unix mail format..." gnus-summary-save-article-mail t]
+             ["Save in MH folder..." gnus-summary-save-article-folder t]
+             ["Save in VM folder..." gnus-summary-save-article-vm t]
+             ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
+             ["Save body in file..." gnus-summary-save-article-body-file t]
+             ["Pipe through a filter..." gnus-summary-pipe-output t]
              ["Add to SOUP packet" gnus-soup-add-article t]
-             ["Print with Muttprint" gnus-summary-muttprint t]
+             ["Print with Muttprint..." gnus-summary-muttprint t]
              ["Print" gnus-summary-print-article t])
             ("Backend"
              ["Respool article..." gnus-summary-respool-article t]
@@ -2180,8 +2292,12 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
              ["Crosspost article..." gnus-summary-crosspost-article
               (gnus-check-backend-function
                'request-replace-article gnus-newsgroup-name)]
-             ["Import file..." gnus-summary-import-article t]
-             ["Create article..." gnus-summary-create-article t]
+             ["Import file..." gnus-summary-import-article
+              (gnus-check-backend-function
+               'request-accept-article gnus-newsgroup-name)]
+             ["Create article..." gnus-summary-create-article
+              (gnus-check-backend-function
+               'request-accept-article gnus-newsgroup-name)]
              ["Check if posted" gnus-summary-article-posted-p t]
              ["Edit article" gnus-summary-edit-article
               (not (gnus-group-read-only-p))]
@@ -2323,7 +2439,7 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
         ["Catchup all" gnus-summary-catchup-all t]
         ["Catchup to here" gnus-summary-catchup-to-here t]
         ["Catchup from here" gnus-summary-catchup-from-here t]
-        ["Catchup region" gnus-summary-mark-region-as-read 
+        ["Catchup region" gnus-summary-mark-region-as-read
          (gnus-mark-active-p)]
         ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
        ("Mark Various"
@@ -2343,6 +2459,7 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
         ["Display Predicate" gnus-summary-limit-to-display-predicate t]
         ["Unread" gnus-summary-limit-to-unread t]
         ["Unseen" gnus-summary-limit-to-unseen t]
+        ["Replied" gnus-summary-limit-to-replied t]
         ["Non-dormant" gnus-summary-limit-exclude-dormant t]
         ["Next articles" gnus-summary-limit-to-articles t]
         ["Pop limit" gnus-summary-pop-limit t]
@@ -2492,6 +2609,8 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
               'gnus-summary-save-article "save-art" gnus-summary-mode-map)
              (tool-bar-add-item-from-menu
               'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
+             (tool-bar-add-item-from-menu
+              'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
              (tool-bar-add-item-from-menu
               'gnus-summary-catchup "catchup" gnus-summary-mode-map)
              (tool-bar-add-item-from-menu
@@ -2600,7 +2719,7 @@ and backwards while displaying articles, type `\\[gnus-summary-next-unread-artic
 respectively.
 
 You can also post articles and send mail from this buffer.  To
-follow up an article, type `\\[gnus-summary-followup]'.         To mail a reply to the author
+follow up an article, type `\\[gnus-summary-followup]'.  To mail a reply to the author
 of an article, type `\\[gnus-summary-reply]'.
 
 There are approx. one gazillion commands you can execute in this
@@ -2624,7 +2743,8 @@ The following commands are available:
   (make-local-variable 'minor-mode-alist)
   (use-local-map gnus-summary-mode-map)
   (buffer-disable-undo)
-  (setq buffer-read-only t)            ;Disable modification
+  (setq buffer-read-only t             ;Disable modification
+       show-trailing-whitespace nil)
   (setq truncate-lines t)
   (setq selective-display t)
   (setq selective-display-ellipses t)  ;Display `...'
@@ -2636,7 +2756,7 @@ The following commands are available:
   (make-local-variable 'gnus-summary-dummy-line-format)
   (make-local-variable 'gnus-summary-dummy-line-format-spec)
   (make-local-variable 'gnus-summary-mark-positions)
-  (make-local-hook 'pre-command-hook)
+  (gnus-make-local-hook 'pre-command-hook)
   (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
   (gnus-run-hooks 'gnus-summary-mode-hook)
   (turn-on-gnus-mailing-list-mode)
@@ -3035,10 +3155,6 @@ display only a single character."
                                               (point)
                                               (current-buffer))))))
 
-(defun gnus-summary-buffer-name (group)
-  "Return the summary buffer name of GROUP."
-  (concat "*Summary " (gnus-group-decoded-name group) "*"))
-
 (defun gnus-summary-setup-buffer (group)
   "Initialize summary buffer."
   (let ((buffer (gnus-summary-buffer-name group))
@@ -3093,8 +3209,7 @@ buffer that was in action when the last article was fetched."
            (push (eval (car locals)) vlist))
          (setq locals (cdr locals)))
        (setq vlist (nreverse vlist)))
-      (save-excursion
-       (set-buffer gnus-group-buffer)
+      (with-current-buffer gnus-group-buffer
        (setq gnus-newsgroup-name name
              gnus-newsgroup-marked marked
              gnus-newsgroup-spam-marked spam
@@ -3199,8 +3314,8 @@ buffer that was in action when the last article was fetched."
        ; Is it really necessary to do this next part for each summary line?
        ; Luckily, doesn't seem to slow things down much.
        (mail-parse-ignored-charsets
-        (save-excursion (set-buffer gnus-summary-buffer)
-                        gnus-newsgroup-ignored-charsets)))
+        (with-current-buffer gnus-summary-buffer
+          gnus-newsgroup-ignored-charsets)))
     (or
      (and gnus-ignored-from-addresses
          (string-match gnus-ignored-from-addresses gnus-tmp-from)
@@ -3249,7 +3364,7 @@ buffer that was in action when the last article was fetched."
                 gnus-unseen-mark)
                (t gnus-no-mark)))
         (gnus-tmp-downloaded
-         (cond (undownloaded 
+         (cond (undownloaded
                  gnus-undownloaded-mark)
                 (gnus-newsgroup-agentized
                  gnus-downloaded-mark)
@@ -3277,7 +3392,7 @@ buffer that was in action when the last article was fetched."
       (setq gnus-tmp-lines -1))
     (if (= gnus-tmp-lines -1)
        (setq gnus-tmp-lines "?")
-      (setq gnus-tmp-lines (number-to-string gnus-tmp-lines))) 
+      (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
       (gnus-put-text-property
      (point)
      (progn (eval gnus-summary-line-format-spec) (point))
@@ -3351,7 +3466,7 @@ the thread are to be displayed."
 (defsubst gnus-summary-line-message-size (head)
   "Return pretty-printed version of message size.
 This function is intended to be used in
-`gnus-summary-line-format-alist', which see."
+`gnus-summary-line-format-alist'."
   (let ((c (or (mail-header-chars head) -1)))
     (cond ((< c 0) "n/a")              ; chars not available
          ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
@@ -3578,7 +3693,7 @@ If NO-DISPLAY, don't generate a summary buffer."
    ((eq gnus-auto-select-subject 'first)
     ;; Do nothing.
     )
-   ((gnus-functionp gnus-auto-select-subject)
+   ((functionp gnus-auto-select-subject)
     (funcall gnus-auto-select-subject))))
 
 (defun gnus-summary-prepare ()
@@ -3605,7 +3720,7 @@ If NO-DISPLAY, don't generate a summary buffer."
     (gnus-run-hooks 'gnus-summary-prepare-hook)))
 
 (defsubst gnus-general-simplify-subject (subject)
-  "Simply subject by the same rules as gnus-gather-threads-by-subject."
+  "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
   (setq subject
        (cond
         ;; Truncate the subject.
@@ -3931,10 +4046,16 @@ Returns HEADER if it was entered in the DEPENDENCIES.  Returns nil otherwise."
             (setq heads nil)))))
      gnus-newsgroup-dependencies)))
 
+(defsubst gnus-remove-odd-characters (string)
+  "Translate STRING into something that doesn't contain weird characters."
+  (mm-subst-char-in-string
+   ?\r ?\-
+   (mm-subst-char-in-string ?\n ?\- string t) t))
+
 ;; This function has to be called with point after the article number
 ;; on the beginning of the line.
 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
-  (let ((eol (gnus-point-at-eol))
+  (let ((eol (point-at-eol))
        (buffer (current-buffer))
        header references in-reply-to)
 
@@ -3949,12 +4070,14 @@ Returns HEADER if it was entered in the DEPENDENCIES.  Returns nil otherwise."
                (make-full-mail-header
                 number                 ; number
                 (condition-case ()     ; subject
-                    (funcall gnus-decode-encoded-word-function
-                             (setq x (nnheader-nov-field)))
+                    (gnus-remove-odd-characters
+                     (funcall gnus-decode-encoded-word-function
+                              (setq x (nnheader-nov-field))))
                   (error x))
                 (condition-case ()     ; from
-                    (funcall gnus-decode-encoded-word-function
-                             (setq x (nnheader-nov-field)))
+                    (gnus-remove-odd-characters
+                     (funcall gnus-decode-encoded-word-function
+                              (setq x (nnheader-nov-field))))
                   (error x))
                 (nnheader-nov-field)   ; date
                 (nnheader-nov-read-message-id) ; id
@@ -4031,8 +4154,7 @@ the id of the parent article (if any)."
            (setq article (read (current-buffer))
                  header (gnus-nov-parse-line article dependencies)))
          (when header
-           (save-excursion
-             (set-buffer gnus-summary-buffer)
+           (with-current-buffer gnus-summary-buffer
              (push header gnus-newsgroup-headers)
              (if (memq (setq article (mail-header-number header))
                        gnus-newsgroup-unselected)
@@ -4046,7 +4168,7 @@ the id of the parent article (if any)."
            (forward-line 1)))))))
 
 (defun gnus-summary-update-article-line (article header)
-  "Update the line for ARTICLE using HEADERS."
+  "Update the line for ARTICLE using HEADER."
   (let* ((id (mail-header-id header))
         (thread (gnus-id-to-thread id)))
     (unless thread
@@ -4062,7 +4184,7 @@ the id of the parent article (if any)."
       (let ((inserted (- (point)
                          (progn
                            (gnus-summary-insert-line
-                            header level nil 
+                            header level nil
                             (memq article gnus-newsgroup-undownloaded)
                             (gnus-article-mark article)
                             (memq article gnus-newsgroup-replied)
@@ -4089,7 +4211,7 @@ the id of the parent article (if any)."
                            (point)))))
         (when (cdr datal)
           (gnus-data-update-list
-           (cdr datal) 
+           (cdr datal)
            (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
 
 (defun gnus-summary-update-article (article &optional iheader)
@@ -4129,7 +4251,7 @@ If LINE, insert the rebuilt thread starting on line LINE."
        (setq thread (list (car (gnus-id-to-thread id))))
       ;; Get the thread this article is part of.
       (setq thread (gnus-remove-thread id)))
-    (setq old-pos (gnus-point-at-bol))
+    (setq old-pos (point-at-bol))
     (setq current (save-excursion
                    (and (re-search-backward "[\r\n]" nil t)
                         (gnus-summary-article-number))))
@@ -4311,9 +4433,9 @@ If LINE, insert the rebuilt thread starting on line LINE."
       (gnus-summary-show-thread)
       (gnus-data-remove
        number
-       (- (gnus-point-at-bol)
+       (- (point-at-bol)
          (prog1
-             (1+ (gnus-point-at-eol))
+             (1+ (point-at-eol))
            (gnus-delete-line)))))))
 
 (defun gnus-sort-threads-1 (threads func)
@@ -4486,10 +4608,10 @@ Unscored articles will be counted as having a score of zero."
           (mapcar
            (lambda (header)
              (setq previous-time
-                   (time-to-seconds
-                    (condition-case ()
-                        (mail-header-parse-date (mail-header-date header))
-                      (error previous-time)))))
+                   (condition-case ()
+                       (time-to-seconds (mail-header-parse-date
+                                         (mail-header-date header)))
+                     (error previous-time))))
            (sort
             (message-flatten-list thread)
             (lambda (h1 h2)
@@ -4527,12 +4649,17 @@ Unscored articles will be counted as having a score of zero."
 (defcustom gnus-sum-thread-tree-root "> "
   "With %B spec, used for the root of a thread.
 If nil, use subject instead."
-  :type 'string
+  :type '(radio (const :format "%v  " nil) (string :size 0))
+  :group 'gnus-thread)
+(defcustom gnus-sum-thread-tree-false-root "> "
+  "With %B spec, used for a false root of a thread.
+If nil, use subject instead."
+  :type '(radio (const :format "%v  " nil) (string :size 0))
   :group 'gnus-thread)
 (defcustom gnus-sum-thread-tree-single-indent ""
   "With %B spec, used for a thread with just one message.
 If nil, use subject instead."
-  :type 'string
+  :type '(radio (const :format "%v  " nil) (string :size 0))
   :group 'gnus-thread)
 (defcustom gnus-sum-thread-tree-vertical "| "
   "With %B spec, used for drawing a vertical line."
@@ -4775,7 +4902,7 @@ or a straight list of headers."
                    gnus-unseen-mark)
                   (t gnus-no-mark))
             gnus-tmp-downloaded
-             (cond ((memq number gnus-newsgroup-undownloaded) 
+             (cond ((memq number gnus-newsgroup-undownloaded)
                     gnus-undownloaded-mark)
                    (gnus-newsgroup-agentized
                     gnus-downloaded-mark)
@@ -4793,13 +4920,18 @@ or a straight list of headers."
               (substring gnus-tmp-from
                          (1+ (match-beginning 0)) (1- (match-end 0))))
              (t gnus-tmp-from))
+
+            ;; Do the %B string
             gnus-tmp-thread-tree-header-string
             (cond
              ((not gnus-show-threads) "")
              ((zerop gnus-tmp-level)
-              (if (cdar thread)
-                  (or gnus-sum-thread-tree-root subject)
-                (or gnus-sum-thread-tree-single-indent subject)))
+              (cond ((cdar thread)
+                     (or gnus-sum-thread-tree-root subject))
+                    (gnus-tmp-new-adopts
+                     (or gnus-sum-thread-tree-false-root subject))
+                    (t
+                     (or gnus-sum-thread-tree-single-indent subject))))
              (t
               (concat (apply 'concat
                              (mapcar (lambda (item)
@@ -4830,7 +4962,7 @@ or a straight list of headers."
 
        (when (nth 1 thread)
          (push (list (max 0 gnus-tmp-level)
-                     (copy-list tree-stack)
+                     (copy-sequence tree-stack)
                      (nthcdr 1 thread))
                stack))
        (push (if (nth 1 thread) 1 0) tree-stack)
@@ -4894,23 +5026,20 @@ or a straight list of headers."
                  gnus-list-identifiers))
        changed subject)
     (when regexp
+      (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
       (dolist (header gnus-newsgroup-headers)
        (setq subject (mail-header-subject header)
              changed nil)
-       (while (string-match
-               (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
-               subject)
+       (while (string-match regexp subject)
          (setq subject
-               (concat (substring subject 0 (match-beginning 2))
+               (concat (substring subject 0 (match-beginning 1))
                        (substring subject (match-end 0)))
                changed t))
-       (when (and changed
-                  (string-match
-                   "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
-         (setq subject
-               (concat (substring subject 0 (match-beginning 1))
-                       (substring subject (match-end 1)))))
        (when changed
+         (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
+           (setq subject
+                 (concat (substring subject 0 (match-beginning 1))
+                         (substring subject (match-end 1)))))
          (mail-header-set-subject header subject))))))
 
 (defun gnus-fetch-headers (articles)
@@ -4938,7 +5067,7 @@ or a straight list of headers."
   "Select newsgroup GROUP.
 If READ-ALL is non-nil, all articles in the group are selected.
 If SELECT-ARTICLES, only select those articles from GROUP."
-  (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
+  (let* ((entry (gnus-group-entry group))
         ;;!!! Dirty hack; should be removed.
         (gnus-summary-ignore-duplicates
          (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
@@ -4966,6 +5095,14 @@ If SELECT-ARTICLES, only select those articles from GROUP."
       (error "Couldn't request group %s: %s"
             group (gnus-status-message group)))
 
+    (when gnus-agent
+      (gnus-agent-possibly-alter-active group (gnus-active group) info)
+      
+      (setq gnus-summary-use-undownloaded-faces
+           (gnus-agent-find-parameter
+            group
+            'agent-enable-undownloaded-faces)))
+
     (setq gnus-newsgroup-name group
          gnus-newsgroup-unselected nil
          gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
@@ -5279,7 +5416,7 @@ If SELECT-ARTICLES, only select those articles from GROUP."
       'list))
 
 (defun gnus-article-unpropagatable-p (mark)
-  "Return whether MARK should be propagated to backend."
+  "Return whether MARK should be propagated to back end."
   (memq mark gnus-article-unpropagated-mark-lists))
 
 (defun gnus-adjust-marked-articles (info)
@@ -5289,7 +5426,8 @@ If SELECT-ARTICLES, only select those articles from GROUP."
         (min (car active))
         (max (cdr active))
         (types gnus-article-mark-lists)
-        marks var articles article mark mark-type)
+        marks var articles article mark mark-type
+         bgn end)
 
     (dolist (marks marked-lists)
       (setq mark (car marks)
@@ -5299,13 +5437,30 @@ If SELECT-ARTICLES, only select those articles from GROUP."
       ;; We set the variable according to the type of the marks list,
       ;; and then adjust the marks to a subset of the active articles.
       (cond
-       ;; Adjust "simple" lists.
+       ;; Adjust "simple" lists - compressed yet unsorted
        ((eq mark-type 'list)
-       (set var (setq articles (gnus-uncompress-range (cdr marks))))
-       (when (memq mark '(tick dormant expire reply save))
-         (while articles
-           (when (or (< (setq article (pop articles)) min) (> article max))
-             (set var (delq article (symbol-value var)))))))
+        ;; Simultaneously uncompress and clip to active range
+        ;; See gnus-uncompress-range for a description of possible marks
+        (let (l lh)
+          (if (not (cadr marks))
+              (set var nil)
+            (setq articles (if (numberp (cddr marks))
+                               (list (cdr marks))
+                             (cdr marks))
+                  lh (cons nil nil)
+                  l lh)
+
+            (while (setq article (pop articles))
+              (cond ((consp article)
+                     (setq bgn (max (car article) min)
+                           end (min (cdr article) max))
+                     (while (<= bgn end)
+                       (setq l (setcdr l (cons bgn nil))
+                             bgn (1+ bgn))))
+                    ((and (<= min article)
+                          (>= max article))
+                     (setq l (setcdr l (cons article nil))))))
+            (set var (cdr lh)))))
        ;; Adjust assocs.
        ((eq mark-type 'tuple)
        (set var (setq articles (cdr marks)))
@@ -5515,7 +5670,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
   "Look through all the headers and mark the Xrefs as read."
   (let ((virtual (gnus-virtual-group-p from-newsgroup))
-       name entry info xref-hashtb idlist method nth4)
+       name info xref-hashtb idlist method nth4)
     (save-excursion
       (set-buffer gnus-group-buffer)
       (when (setq xref-hashtb
@@ -5526,8 +5681,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
             (setq idlist (symbol-value group))
             ;; Dead groups are not updated.
             (and (prog1
-                     (setq entry (gnus-gethash name gnus-newsrc-hashtb)
-                           info (nth 2 entry))
+                     (setq info (gnus-get-info name))
                    (when (stringp (setq nth4 (gnus-info-method info)))
                      (setq nth4 (gnus-server-to-method nth4))))
                  ;; Only do the xrefs if the group has the same
@@ -5549,7 +5703,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
         xref-hashtb)))))
 
 (defun gnus-compute-read-articles (group articles)
-  (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
+  (let* ((entry (gnus-group-entry group))
         (info (nth 2 entry))
         (active (gnus-active group))
         ninfo)
@@ -5586,14 +5740,13 @@ The resulting hash table is returned, or nil if no Xrefs were found."
 (defun gnus-group-make-articles-read (group articles)
   "Update the info of GROUP to say that ARTICLES are read."
   (let* ((num 0)
-        (entry (gnus-gethash group gnus-newsrc-hashtb))
+        (entry (gnus-group-entry group))
         (info (nth 2 entry))
         (active (gnus-active group))
         range)
     (when entry
       (setq range (gnus-compute-read-articles group articles))
-      (save-excursion
-       (set-buffer gnus-group-buffer)
+      (with-current-buffer gnus-group-buffer
        (gnus-undo-register
          `(progn
             (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
@@ -5632,8 +5785,8 @@ The resulting hash table is returned, or nil if no Xrefs were found."
   (let ((cur nntp-server-buffer)
        (dependencies
         (or dependencies
-            (save-excursion (set-buffer gnus-summary-buffer)
-                            gnus-newsgroup-dependencies)))
+            (with-current-buffer gnus-summary-buffer
+              gnus-newsgroup-dependencies)))
        headers id end ref
        (mail-parse-charset gnus-newsgroup-charset)
        (mail-parse-ignored-charsets
@@ -5646,6 +5799,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
       ;; Translate all TAB characters into SPACE characters.
       (subst-char-in-region (point-min) (point-max) ?\t ?  t)
       (subst-char-in-region (point-min) (point-max) ?\r ?  t)
+      (ietf-drums-unfold-fws)
       (gnus-run-hooks 'gnus-parse-headers-hook)
       (let ((case-fold-search t)
            in-reply-to header p lines chars)
@@ -5849,8 +6003,8 @@ Return a list of headers that match SEQUENCE (see
 (defun gnus-article-get-xrefs ()
   "Fill in the Xref value in `gnus-current-headers', if necessary.
 This is meant to be called in `gnus-article-internal-prepare-hook'."
-  (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
-                                gnus-current-headers)))
+  (let ((headers (with-current-buffer gnus-summary-buffer
+                  gnus-current-headers)))
     (or (not gnus-use-cross-reference)
        (not headers)
        (and (mail-header-xref headers)
@@ -5865,8 +6019,7 @@ This is meant to be called in `gnus-article-internal-prepare-hook'."
                           (looking-at "Xref:"))
                      (search-forward "\nXref:" nil t))
              (goto-char (1+ (match-end 0)))
-             (setq xref (buffer-substring (point)
-                                          (progn (end-of-line) (point))))
+             (setq xref (buffer-substring (point) (point-at-eol)))
              (mail-header-set-xref headers xref)))))))
 
 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
@@ -5894,9 +6047,9 @@ the subject line on."
          (goto-char (gnus-data-pos d))
          (gnus-data-remove
           number
-          (- (gnus-point-at-bol)
+          (- (point-at-bol)
              (prog1
-                 (1+ (gnus-point-at-eol))
+                 (1+ (point-at-eol))
                (gnus-delete-line))))))
       (when old-header
        (mail-header-set-number header (mail-header-number old-header)))
@@ -6023,13 +6176,13 @@ If optional argument BACKWARD is non-nil, search backward instead."
 (defun gnus-summary-best-group (&optional exclude-group)
   "Find the name of the best unread group.
 If EXCLUDE-GROUP, do not go to this group."
-  (save-excursion
-    (set-buffer gnus-group-buffer)
+  (with-current-buffer gnus-group-buffer
     (save-excursion
       (gnus-group-best-unread-group exclude-group))))
 
 (defun gnus-summary-find-next (&optional unread article backward)
-  (if backward (gnus-summary-find-prev)
+  (if backward
+      (gnus-summary-find-prev unread article)
     (let* ((dummy (gnus-summary-article-intangible-p))
           (article (or article (gnus-summary-article-number)))
           (data (gnus-data-find-list article))
@@ -6043,8 +6196,19 @@ If EXCLUDE-GROUP, do not go to this group."
                  (if unread
                      (progn
                        (while data
-                          (unless (memq (gnus-data-number (car data)) 
-                                        gnus-newsgroup-unfetched)
+                          (unless (memq (gnus-data-number (car data))
+                                        (cond
+                                        ((eq gnus-auto-goto-ignores
+                                             'always-undownloaded)
+                                         gnus-newsgroup-undownloaded)
+                                        (gnus-plugged
+                                         nil)
+                                        ((eq gnus-auto-goto-ignores
+                                             'unfetched)
+                                         gnus-newsgroup-unfetched)
+                                        ((eq gnus-auto-goto-ignores
+                                             'undownloaded)
+                                         gnus-newsgroup-undownloaded)))
                             (when (gnus-data-unread-p (car data))
                               (setq result (car data)
                                     data nil)))
@@ -6068,7 +6232,19 @@ If EXCLUDE-GROUP, do not go to this group."
                (if unread
                    (progn
                      (while data
-                        (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
+                        (unless (memq (gnus-data-number (car data))
+                                      (cond
+                                      ((eq gnus-auto-goto-ignores
+                                           'always-undownloaded)
+                                       gnus-newsgroup-undownloaded)
+                                      (gnus-plugged
+                                       nil)
+                                      ((eq gnus-auto-goto-ignores
+                                           'unfetched)
+                                       gnus-newsgroup-unfetched)
+                                      ((eq gnus-auto-goto-ignores
+                                           'undownloaded)
+                                       gnus-newsgroup-undownloaded)))
                           (when (gnus-data-unread-p (car data))
                             (setq result (car data)
                                   data nil)))
@@ -6210,15 +6386,15 @@ displayed, no centering will be performed."
        (while read
          (when first
            (while (< first nlast)
-             (push first unread)
-             (setq first (1+ first))))
+             (setq unread (cons first unread)
+                    first (1+ first))))
          (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
          (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
          (setq read (cdr read)))))
     ;; And add the last unread articles.
     (while (<= first last)
-      (push first unread)
-      (setq first (1+ first)))
+      (setq unread (cons first unread)
+            first (1+ first)))
     ;; Return the list of unread articles.
     (delq 0 (nreverse unread))))
 
@@ -6236,6 +6412,44 @@ displayed, no centering will be performed."
           (cdr (assq 'dormant marked)))
          (cdr (assq 'tick marked))))))
 
+;; This function returns a sequence of article numbers based on the
+;; difference between the ranges of read articles in this group and
+;; the range of active articles.
+(defun gnus-sequence-of-unread-articles (group)
+  (let* ((read (gnus-info-read (gnus-get-info group)))
+        (active (or (gnus-active group) (gnus-activate-group group)))
+        (last (cdr active))
+        first nlast unread)
+    ;; If none are read, then all are unread.
+    (if (not read)
+       (setq first (car active))
+      ;; If the range of read articles is a single range, then the
+      ;; first unread article is the article after the last read
+      ;; article.  Sounds logical, doesn't it?
+      (if (and (not (listp (cdr read)))
+              (or (< (car read) (car active))
+                  (progn (setq read (list read))
+                         nil)))
+         (setq first (max (car active) (1+ (cdr read))))
+       ;; `read' is a list of ranges.
+       (when (/= (setq nlast (or (and (numberp (car read)) (car read))
+                                 (caar read)))
+                 1)
+         (setq first (car active)))
+       (while read
+         (when first
+            (push (cons first nlast) unread))
+         (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
+         (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
+         (setq read (cdr read)))))
+    ;; And add the last unread articles.
+    (cond ((< first last)
+           (push (cons first last) unread))
+          ((= first last)
+           (push first unread)))
+    ;; Return the sequence of unread articles.
+    (delq 0 (nreverse unread))))
+
 ;; Various summary commands
 
 (defun gnus-summary-select-article-buffer ()
@@ -6270,24 +6484,26 @@ displayed, no centering will be performed."
 
 (defun gnus-summary-toggle-truncation (&optional arg)
   "Toggle truncation of summary lines.
-With arg, turn line truncation on if arg is positive."
+With ARG, turn line truncation on if ARG is positive."
   (interactive "P")
   (setq truncate-lines
        (if (null arg) (not truncate-lines)
          (> (prefix-numeric-value arg) 0)))
   (redraw-display))
 
-(defun gnus-summary-find-uncancelled ()
-  "Return the number of an uncancelled article.
+(defun gnus-summary-find-for-reselect ()
+  "Return the number of an article to stay on across a reselect.
 The current article is considered, then following articles, then previous
-articles.  If all articles are cancelled then return a dummy 0."
+articles.  An article is sought which is not cancelled and isn't a temporary
+insertion from another group.  If there's no such then return a dummy 0."
   (let (found)
     (dolist (rev '(nil t))
       (unless found      ; don't demand the reverse list if we don't need it
         (let ((data (gnus-data-find-list
                      (gnus-summary-article-number) (gnus-data-list rev))))
           (while (and data (not found))
-            (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
+            (if (and (< 0 (gnus-data-number (car data)))
+                     (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
                 (setq found (gnus-data-number (car data))))
             (setq data (cdr data))))))
     (or found 0)))
@@ -6298,10 +6514,10 @@ The prefix argument ALL means to select all articles."
   (interactive "P")
   (when (gnus-ephemeral-group-p gnus-newsgroup-name)
     (error "Ephemeral groups can't be reselected"))
-  (let ((current-subject (gnus-summary-find-uncancelled))
+  (let ((current-subject (gnus-summary-find-for-reselect))
        (group gnus-newsgroup-name))
     (setq gnus-newsgroup-begin nil)
-    (gnus-summary-exit)
+    (gnus-summary-exit nil 'leave-hidden)
     ;; We have to adjust the point of group mode buffer because
     ;; point was moved to the next unread newsgroup by exiting.
     (gnus-summary-jump-to-group group)
@@ -6332,8 +6548,7 @@ The prefix argument ALL means to select all articles."
          (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
        (let ((headers gnus-newsgroup-headers))
          ;; Set the new ranges of read articles.
-         (save-excursion
-           (set-buffer gnus-group-buffer)
+         (with-current-buffer gnus-group-buffer
            (gnus-undo-force-boundary))
          (gnus-update-read-articles
           group (gnus-sorted-union
@@ -6364,7 +6579,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
       (gnus-save-newsrc-file)
     (gnus-dribble-save)))
 
-(defun gnus-summary-exit (&optional temporary)
+(defun gnus-summary-exit (&optional temporary leave-hidden)
   "Exit reading current newsgroup, and then return to group selection mode.
 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
   (interactive)
@@ -6454,11 +6669,14 @@ If FORCE (the prefix), also save the .newsrc file(s)."
        (when (eq mode 'gnus-summary-mode)
          (gnus-kill-buffer buf)))
       (setq gnus-current-select-method gnus-select-method)
-      (pop-to-buffer gnus-group-buffer)
+      (if leave-hidden
+         (set-buffer gnus-group-buffer)
+       (pop-to-buffer gnus-group-buffer))
       (if (not quit-config)
          (progn
            (goto-char group-point)
-           (gnus-configure-windows 'group 'force))
+           (unless leave-hidden
+             (gnus-configure-windows 'group 'force)))
        (gnus-handle-ephemeral-exit quit-config))
       ;; Clear the current group name.
       (unless quit-config
@@ -6470,14 +6688,13 @@ If FORCE (the prefix), also save the .newsrc file(s)."
   (interactive)
   (let* ((group gnus-newsgroup-name)
         (gnus-group-is-exiting-p t)
+        (gnus-group-is-exiting-without-update-p t)
         (quit-config (gnus-group-quit-config group)))
     (when (or no-questions
              gnus-expert-user
              (gnus-y-or-n-p "Discard changes to this group and exit? "))
       (gnus-async-halt-prefetch)
-      (mapcar 'funcall
-             (delq 'gnus-summary-expire-articles
-                   (copy-sequence gnus-summary-prepare-exit-hook)))
+      (run-hooks 'gnus-summary-prepare-exit-hook)
       (when (gnus-buffer-live-p gnus-article-buffer)
        (save-excursion
          (set-buffer gnus-article-buffer)
@@ -6500,8 +6717,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
        (gnus-summary-clear-local-variables)
        (let ((gnus-summary-local-variables gnus-newsgroup-variables))
          (gnus-summary-clear-local-variables))
-       (when (get-buffer gnus-summary-buffer)
-         (kill-buffer gnus-summary-buffer)))
+       (gnus-kill-buffer gnus-summary-buffer))
       (unless gnus-single-article-buffer
        (setq gnus-article-current nil))
       (when gnus-use-trees
@@ -6542,7 +6758,10 @@ The state which existed when entering the ephemeral is reset."
        (progn
          ;; The current article may be from the ephemeral group
          ;; thus it is best that we reload this article
-         (gnus-summary-show-article)
+         ;;
+         ;; If we're exiting from a large digest, this can be
+         ;; extremely slow.  So, it's better not to reload it. -- jh.
+         ;;(gnus-summary-show-article)
          (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
              (gnus-configure-windows 'pick 'force)
            (gnus-configure-windows (cdr quit-config) 'force)))
@@ -6579,7 +6798,7 @@ The state which existed when entering the ephemeral is reset."
          (if (null arg) (not gnus-dead-summary-mode)
            (> (prefix-numeric-value arg) 0)))
     (when gnus-dead-summary-mode
-      (gnus-add-minor-mode
+      (add-minor-mode
        'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
 
 (defun gnus-deaden-summary ()
@@ -6587,8 +6806,7 @@ The state which existed when entering the ephemeral is reset."
   ;; Kill any previous dead summary buffer.
   (when (and gnus-dead-summary
             (buffer-name gnus-dead-summary))
-    (save-excursion
-      (set-buffer gnus-dead-summary)
+    (with-current-buffer gnus-dead-summary
       (when gnus-dead-summary-mode
        (kill-buffer (current-buffer)))))
   ;; Make this the current dead summary.
@@ -6607,8 +6825,7 @@ The state which existed when entering the ephemeral is reset."
   (save-excursion
     (when (and (buffer-name buffer)
               (not gnus-single-article-buffer))
-      (save-excursion
-       (set-buffer buffer)
+      (with-current-buffer buffer
        (gnus-kill-buffer gnus-article-buffer)
        (gnus-kill-buffer gnus-original-article-buffer)))
     (cond
@@ -6648,7 +6865,7 @@ in."
     (when current-prefix-arg
       (completing-read
        "FAQ dir: " (and (listp gnus-group-faq-directory)
-                       (mapcar (lambda (file) (list file))
+                       (mapcar 'list
                                gnus-group-faq-directory))))))
   (let (gnus-faq-buffer)
     (when (setq gnus-faq-buffer
@@ -6679,6 +6896,11 @@ previous group instead."
   (let ((current-group gnus-newsgroup-name)
        (current-buffer (current-buffer))
        entered)
+    ;; First we semi-exit this group to update Xrefs and all variables.
+    ;; We can't do a real exit, because the window conf must remain
+    ;; the same in case the user is prompted for info, and we don't
+    ;; want the window conf to change before that...
+    (gnus-summary-exit t)
     (while (not entered)
       ;; Then we find what group we are supposed to enter.
       (set-buffer gnus-group-buffer)
@@ -6703,20 +6925,10 @@ previous group instead."
        (let ((unreads (gnus-group-group-unread)))
          (if (and (or (eq t unreads)
                       (and unreads (not (zerop unreads))))
-                  (progn
-                    ;; Now we semi-exit this group to update Xrefs
-                    ;; and all variables.  We can't do a real exit,
-                    ;; because the window conf must remain the same
-                    ;; in case the user is prompted for info, and we
-                    ;; don't want the window conf to change before
-                    ;; that...
-                    (when (gnus-buffer-live-p current-buffer)
-                      (set-buffer current-buffer)
-                      (gnus-summary-exit t))
-                    (gnus-summary-read-group
-                     target-group nil no-article
-                     (and (buffer-name current-buffer) current-buffer)
-                     nil backward)))
+                  (gnus-summary-read-group
+                   target-group nil no-article
+                   (and (buffer-name current-buffer) current-buffer)
+                   nil backward))
              (setq entered t)
            (setq current-group target-group
                  target-group nil)))))))
@@ -6733,7 +6945,7 @@ If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
   "Go to the first subject satisfying any non-nil constraint.
 If UNREAD is non-nil, the article should be unread.
 If UNDOWNLOADED is non-nil, the article should be undownloaded.
-If UNSEED is non-nil, the article should be unseen.
+If UNSEEN is non-nil, the article should be unseen.
 Returns the article selected or nil if there are no matching articles."
   (interactive "P")
   (cond
@@ -6758,7 +6970,7 @@ Returns the article selected or nil if there are no matching articles."
                                  (and unseen
                                       (memq num gnus-newsgroup-unseen)))))))
         (setq data (cdr data)))
-      (prog1 
+      (prog1
           (if data
               (progn
                 (goto-char (gnus-data-pos (car data)))
@@ -6939,6 +7151,7 @@ be displayed."
   (interactive)
   (let ((mm-verify-option 'known)
        (mm-decrypt-option 'known)
+       (gnus-article-emulate-mime t)
        (gnus-buttonized-mime-types (append (list "multipart/signed"
                                                  "multipart/encrypted")
                                            gnus-buttonized-mime-types)))
@@ -6978,8 +7191,7 @@ If BACKWARD, the previous article is selected instead of the next."
       (gnus-summary-jump-to-group gnus-newsgroup-name))
     (let ((cmd last-command-char)
          (point
-          (save-excursion
-            (set-buffer gnus-group-buffer)
+          (with-current-buffer gnus-group-buffer
             (point)))
          (group
           (if (eq gnus-keep-same-level 'best)
@@ -7031,7 +7243,7 @@ If BACKWARD, the previous article is selected instead of the next."
                      (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
                 (format " (Type %s for %s [%s])"
                         (single-key-description cmd) group
-                        (car (gnus-gethash group gnus-newsrc-hashtb)))
+                        (gnus-group-unread group))
               (format " (Type %s to exit %s)"
                       (single-key-description cmd)
                       gnus-newsgroup-name))))
@@ -7089,7 +7301,9 @@ If CIRCULAR is non-nil, go to the start of the article instead of
 selecting the next article when reaching the end of the current
 article.
 
-If STOP is non-nil, just stop when reaching the end of the message."
+If STOP is non-nil, just stop when reaching the end of the message.
+
+Also see the variable `gnus-article-skip-boring'."
   (interactive "P")
   (setq gnus-summary-buffer (current-buffer))
   (gnus-set-global-variables)
@@ -7332,7 +7546,7 @@ is a number, it is the line the article is to be displayed on."
     t))
   (prog1
       (if (and (stringp article)
-              (string-match "@" article))
+              (string-match "@\\|%40" article))
          (gnus-summary-refer-article article)
        (when (stringp article)
          (setq article (string-to-number article)))
@@ -7435,10 +7649,9 @@ articles that are younger than AGE days."
        (if (numberp days)
           (progn
             (setq days-got t)
-            (if (< days 0)
-                (progn
-                  (setq younger (not younger))
-                  (setq days (* days -1)))))
+            (when (< days 0)
+              (setq younger (not younger))
+              (setq days (* days -1))))
         (message "Please enter a number.")
         (sleep-for 1)))
      (list days younger)))
@@ -7523,6 +7736,17 @@ If ALL is non-nil, limit strictly to unread articles."
           gnus-duplicate-mark gnus-souped-mark)
      'reverse)))
 
+(defun gnus-summary-limit-to-replied (&optional unreplied)
+  "Limit the summary buffer to replied articles.
+If UNREPLIED (the prefix), limit to unreplied articles."
+  (interactive "P")
+  (if unreplied
+      (gnus-summary-limit
+       (gnus-set-difference gnus-newsgroup-articles
+       gnus-newsgroup-replied))
+    (gnus-summary-limit gnus-newsgroup-replied))
+  (gnus-summary-position-point))
+
 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
 (make-obsolete 'gnus-summary-delete-marked-with
               'gnus-summary-limit-exclude-marks)
@@ -7601,7 +7825,7 @@ article."
       (gnus-summary-position-point))))
 
 (defun gnus-summary-insert-dormant-articles ()
-  "Insert all the dormat articles for this group into the current buffer."
+  "Insert all the dormant articles for this group into the current buffer."
   (interactive)
   (let ((gnus-verbose (max 6 gnus-verbose)))
     (if (not gnus-newsgroup-dormant)
@@ -7754,7 +7978,7 @@ If ALL, mark even excluded ticked and dormants as read."
   thread)
 
 (defun gnus-cut-threads (threads)
-  "Cut off all uninteresting articles from the beginning of threads."
+  "Cut off all uninteresting articles from the beginning of THREADS."
   (when (or (eq gnus-fetch-old-headers 'some)
            (eq gnus-fetch-old-headers 'invisible)
            (numberp gnus-fetch-old-headers)
@@ -7868,13 +8092,12 @@ fetch-old-headers verbiage, and so on."
            (and gnus-newsgroup-display
                 (not (funcall gnus-newsgroup-display)))
            ;; Check NoCeM things.
-           (if (and gnus-use-nocem
-                    (gnus-nocem-unwanted-article-p
-                     (mail-header-id (car thread))))
-               (progn
-                 (setq gnus-newsgroup-unreads
-                       (delq number gnus-newsgroup-unreads))
-                 t))))
+           (when (and gnus-use-nocem
+                      (gnus-nocem-unwanted-article-p
+                       (mail-header-id (car thread))))
+             (setq gnus-newsgroup-unreads
+                   (delq number gnus-newsgroup-unreads))
+             t)))
          ;; Nope, invisible article.
          0
        ;; Ok, this article is to be visible, so we add it to the limit
@@ -7924,7 +8147,8 @@ The difference between N and the number of articles fetched is returned."
            (set-buffer gnus-original-article-buffer)
            (nnheader-narrow-to-headers)
            (unless (setq ref (message-fetch-field "references"))
-             (setq ref (message-fetch-field "in-reply-to")))
+             (when (setq ref (message-fetch-field "in-reply-to"))
+               (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
            (widen))
        (setq ref
              ;; It's not the current article, so we take a bet on
@@ -7987,7 +8211,7 @@ of what's specified by the `gnus-refer-thread-limit' variable."
                                       gnus-newsgroup-name limit))
              'nov)
          (gnus-build-all-threads)
-       (error "Can't fetch thread from backends that don't support NOV"))
+       (error "Can't fetch thread from back ends that don't support NOV"))
       (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
     (gnus-summary-limit-include-thread id)))
 
@@ -7996,12 +8220,16 @@ of what's specified by the `gnus-refer-thread-limit' variable."
   (interactive "sMessage-ID: ")
   (when (and (stringp message-id)
             (not (zerop (length message-id))))
+    (setq message-id (gnus-replace-in-string message-id " " ""))
     ;; Construct the correct Message-ID if necessary.
     ;; Suggested by tale@pawl.rpi.edu.
     (unless (string-match "^<" message-id)
       (setq message-id (concat "<" message-id)))
     (unless (string-match ">$" message-id)
       (setq message-id (concat message-id ">")))
+    ;; People often post MIDs from URLs, so unhex it:
+    (unless (string-match "@" message-id)
+      (setq message-id (gnus-url-unhex-string message-id)))
     (let* ((header (gnus-id-to-header message-id))
           (sparse (and header
                        (gnus-summary-article-sparse-p
@@ -8024,9 +8252,10 @@ of what's specified by the `gnus-refer-thread-limit' variable."
        ;; We fetch the article.
        (catch 'found
          (dolist (gnus-override-method (gnus-refer-article-methods))
-           (gnus-check-server gnus-override-method)
-           ;; Fetch the header, and display the article.
-           (when (setq number (gnus-summary-insert-subject message-id))
+           (when (and (gnus-check-server gnus-override-method)
+                      ;; Fetch the header,
+                      (setq number (gnus-summary-insert-subject message-id)))
+             ;; and display the article.
              (gnus-summary-select-article nil nil nil number)
              (throw 'found t)))
          (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
@@ -8070,18 +8299,22 @@ If FORCE, force a digest interpretation.  If not, try
 to guess what the document format is."
   (interactive "P")
   (let ((conf gnus-current-window-configuration))
-    (save-excursion
-      (gnus-summary-select-article))
+    (save-window-excursion
+      (save-excursion
+       (let (gnus-article-prepare-hook
+             gnus-display-mime-function
+             gnus-break-pages)
+         (gnus-summary-select-article))))
     (setq gnus-current-window-configuration conf)
     (let* ((name (format "%s-%d"
                         (gnus-group-prefixed-name
                          gnus-newsgroup-name (list 'nndoc ""))
-                        (save-excursion
-                          (set-buffer gnus-summary-buffer)
+                        (with-current-buffer gnus-summary-buffer
                           gnus-current-article)))
           (ogroup gnus-newsgroup-name)
           (params (append (gnus-info-params (gnus-get-info ogroup))
                           (list (cons 'to-group ogroup))
+                          (list (cons 'parent-group ogroup))
                           (list (cons 'save-article-group ogroup))))
           (case-fold-search t)
           (buf (current-buffer))
@@ -8149,7 +8382,7 @@ Obeys the standard process/prefix convention."
            ;; the wrong guess.
            (message-narrow-to-head)
            (goto-char (point-min))
-           (delete-matching-lines "^\\(Path\\):\\|^From ")
+           (delete-matching-lines "^Path:\\|^From ")
            (widen)
            (if (setq egroup
                      (gnus-group-read-ephemeral-group
@@ -8389,7 +8622,7 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
   (gnus-eval-in-buffer-window gnus-article-buffer
     (widen)
     (goto-char (point-min))
-    (when gnus-page-broken
+    (when gnus-break-pages
       (gnus-narrow-to-page))))
 
 (defun gnus-summary-end-of-article ()
@@ -8401,7 +8634,9 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
     (widen)
     (goto-char (point-max))
     (recenter -3)
-    (when gnus-page-broken
+    (when gnus-break-pages
+      (when (re-search-backward page-delimiter nil t)
+       (narrow-to-region (match-end 0) (point-max)))
       (gnus-narrow-to-page))))
 
 (defun gnus-summary-print-truncate-and-quote (string &optional len)
@@ -8412,10 +8647,16 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
                          "[()]" "\\\\\\&"))
 
 (defun gnus-summary-print-article (&optional filename n)
-  "Generate and print a PostScript image of the N next (mail) articles.
+  "Generate and print a PostScript image of the process-marked (mail) articles.
+
+If used interactively, print the current article if none are
+process-marked.  With prefix arg, prompt the user for the name of the
+file to save in.
 
-If N is negative, print the N previous articles.  If N is nil and articles
-have been marked with the process mark, print these instead.
+When used from Lisp, accept two optional args FILENAME and N.  N means
+to print the next N articles.  If N is negative, print the N previous
+articles.  If N is nil and articles have been marked with the process
+mark, print these instead.
 
 If the optional first argument FILENAME is nil, send the image to the
 printer.  If FILENAME is a string, save the PostScript image in a file with
@@ -8435,14 +8676,15 @@ to save in."
        (progn
          (copy-to-buffer buffer (point-min) (point-max))
          (set-buffer buffer)
-         (gnus-article-delete-invisible-text)
          (gnus-remove-text-with-property 'gnus-decoration)
          (when (gnus-visual-p 'article-highlight 'highlight)
            ;; Copy-to-buffer doesn't copy overlay.  So redo
            ;; highlight.
            (let ((gnus-article-buffer buffer))
              (gnus-article-highlight-citation t)
-             (gnus-article-highlight-signature)))
+             (gnus-article-highlight-signature)
+             (gnus-article-emphasize)
+             (gnus-article-delete-invisible-text)))
          (let ((ps-left-header
                 (list
                  (concat "("
@@ -8471,8 +8713,8 @@ If ARG (the prefix) is a number, show the article with the charset
 defined in `gnus-summary-show-article-charset-alist', or the charset
 input.
 If ARG (the prefix) is non-nil and not a number, show the raw article
-without any article massaging functions being run.  Normally, the key strokes
-are `C-u g'."
+without any article massaging functions being run.  Normally, the key
+strokes are `C-u g'."
   (interactive "P")
   (cond
    ((numberp arg)
@@ -8580,7 +8822,7 @@ If ARG is a negative number, hide the unwanted header lines."
                      (1- (point))
                    (point-max))))
        (insert-buffer-substring gnus-original-article-buffer s e)
-       (article-decode-encoded-words)
+       (run-hooks 'gnus-article-decode-hook)
        (if hidden
            (let ((gnus-treat-hide-headers nil)
                  (gnus-treat-hide-boring-headers nil))
@@ -8590,10 +8832,12 @@ If ARG is a negative number, hide the unwanted header lines."
        (widen)
        (if window
            (set-window-start window (goto-char (point-min))))
-       (setq gnus-page-broken
-             (when gnus-break-pages
-               (gnus-narrow-to-page)
-               t))
+       (if gnus-break-pages
+           (gnus-narrow-to-page)
+         (when (gnus-visual-p 'page-marker)
+           (let ((buffer-read-only nil))
+             (gnus-remove-text-with-property 'gnus-prev)
+             (gnus-remove-text-with-property 'gnus-next))))
        (gnus-set-mode-line 'article)))))
 
 (defun gnus-summary-show-all-headers ()
@@ -8688,7 +8932,8 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
   (let ((articles (gnus-summary-work-articles n))
        (prefix (if (gnus-check-backend-function
                     'request-move-article gnus-newsgroup-name)
-                   (gnus-group-real-prefix gnus-newsgroup-name)
+                   (funcall gnus-move-group-prefix-function
+                            gnus-newsgroup-name)
                  ""))
        (names '((move "Move" "Moving")
                 (copy "Copy" "Copying")
@@ -8794,20 +9039,19 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
                      (nnheader-get-report (car to-method))))
        ((eq art-group 'junk)
        (when (eq action 'move)
-         (let ((id (mail-header-id (gnus-data-header 
-                                    (assoc article (gnus-data-list nil))))))
-           (gnus-summary-mark-article article gnus-canceled-mark)
-           (gnus-message 4 "Deleted article %s" article)
-           ;; run the move/copy/crosspost/respool hook
-           (run-hook-with-args 'gnus-summary-article-delete-hook 
-                               action id gnus-newsgroup-name nil
-                               select-method))))
+         (gnus-summary-mark-article article gnus-canceled-mark)
+         (gnus-message 4 "Deleted article %s" article)
+         ;; run the delete hook
+         (run-hook-with-args 'gnus-summary-article-delete-hook
+                             action
+                             (gnus-data-header
+                              (assoc article (gnus-data-list nil)))
+                             gnus-newsgroup-name nil
+                             select-method)))
        (t
        (let* ((pto-group (gnus-group-prefixed-name
                           (car art-group) to-method))
-              (entry
-               (gnus-gethash pto-group gnus-newsrc-hashtb))
-              (info (nth 2 entry))
+              (info (gnus-get-info pto-group))
               (to-group (gnus-info-group info))
               to-marks)
          ;; Update the group that has been moved to.
@@ -8823,7 +9067,10 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
                                       (list (cdr art-group)))))
 
            ;; See whether the article is to be put in the cache.
-           (let ((marks gnus-article-mark-lists)
+           (let ((marks (if (gnus-group-auto-expirable-p to-group)
+                            gnus-article-mark-lists
+                          (delete '(expirable . expire)
+                                  (copy-sequence gnus-article-mark-lists))))
                  (to-article (cdr art-group)))
 
              ;; Enter the article into the cache in the new group,
@@ -8882,15 +9129,17 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
               article gnus-newsgroup-name (current-buffer))))
 
          ;; run the move/copy/crosspost/respool hook
-         (let ((id (mail-header-id (gnus-data-header 
-                                  (assoc article (gnus-data-list nil))))))
-         (run-hook-with-args 'gnus-summary-article-move-hook 
-                             action id gnus-newsgroup-name to-newsgroup
-                             select-method)))
+         (run-hook-with-args 'gnus-summary-article-move-hook
+                             action
+                             (gnus-data-header
+                              (assoc article (gnus-data-list nil)))
+                             gnus-newsgroup-name
+                             to-newsgroup
+                             select-method))
 
        ;;;!!!Why is this necessary?
        (set-buffer gnus-summary-buffer)
-
+       
        (gnus-summary-goto-subject article)
        (when (eq action 'move)
          (gnus-summary-mark-article article gnus-canceled-mark))))
@@ -8928,7 +9177,7 @@ If nil, use to the current newsgroup method."
   :group 'gnus-summary-mail)
 
 (defcustom gnus-summary-display-while-building nil
-  "If not-nil, show and update the summary buffer as it's being built.
+  "If non-nil, show and update the summary buffer as it's being built.
 If the value is t, update the buffer after every line is inserted.  If
 the value is an integer (N), update the display every N lines."
   :group 'gnus-thread
@@ -9062,8 +9311,9 @@ This will be the case if the article has both been mailed and posted."
 (defun gnus-summary-expire-articles (&optional now)
   "Expire all articles that are marked as expirable in the current group."
   (interactive)
-  (when (gnus-check-backend-function
-        'request-expire-articles gnus-newsgroup-name)
+  (when (and (not gnus-group-is-exiting-without-update-p)
+            (gnus-check-backend-function
+             'request-expire-articles gnus-newsgroup-name))
     ;; This backend supports expiry.
     (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
           (expirable (if total
@@ -9108,12 +9358,13 @@ This will be the case if the article has both been mailed and posted."
                (when (and (not (memq article es))
                           (gnus-data-find article))
                  (gnus-summary-mark-article article gnus-canceled-mark)
-                 (let ((id (mail-header-id (gnus-data-header 
-                                            (assoc article 
-                                                   (gnus-data-list nil))))))
-                   (run-hook-with-args 'gnus-summary-article-expire-hook
-                                       'delete id gnus-newsgroup-name nil
-                                       nil)))))))
+                 (run-hook-with-args 'gnus-summary-article-expire-hook
+                                     'delete
+                                     (gnus-data-header
+                                      (assoc article (gnus-data-list nil)))
+                                     gnus-newsgroup-name
+                                     nil
+                                     nil))))))
        (gnus-message 6 "Expiring articles...done")))))
 
 (defun gnus-summary-expire-articles-now ()
@@ -9133,9 +9384,13 @@ deleted forever, right now."
 This command actually deletes articles.         This is not a marking
 command.  The article will disappear forever from your life, never to
 return.
+
 If N is negative, delete backwards.
 If N is nil and articles have been marked with the process mark,
-delete these instead."
+delete these instead.
+
+If `gnus-novice-user' is non-nil you will be asked for
+confirmation before the articles are deleted."
   (interactive "P")
   (unless (gnus-check-backend-function 'request-expire-articles
                                       gnus-newsgroup-name)
@@ -9163,7 +9418,7 @@ delete these instead."
        (unless (memq (car articles) not-deleted)
          (gnus-summary-mark-article (car articles) gnus-canceled-mark))
        (let* ((article (car articles))
-              (id (mail-header-id (gnus-data-header 
+              (id (mail-header-id (gnus-data-header
                                    (assoc article (gnus-data-list nil))))))
          (run-hook-with-args 'gnus-summary-article-delete-hook
                              'delete id gnus-newsgroup-name nil
@@ -9231,7 +9486,7 @@ groups."
                (let ((mbl1 mml-buffer-list))
                  (setq mml-buffer-list mbl)
                  (set (make-local-variable 'mml-buffer-list) mbl1))
-               (make-local-hook 'kill-buffer-hook)
+               (gnus-make-local-hook 'kill-buffer-hook)
                (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
         `(lambda (no-highlight)
            (let ((mail-parse-charset ',gnus-newsgroup-charset)
@@ -9357,15 +9612,13 @@ groups."
     (gnus-summary-select-article)
     (save-excursion
       (set-buffer gnus-original-article-buffer)
-      (save-restriction
-       (message-narrow-to-head)
-       (let ((groups (nnmail-article-group 'identity trace)))
-         (unless silent
-           (if groups
-               (message "This message would go to %s"
-                        (mapconcat 'car groups ", "))
-             (message "This message would go to no groups"))
-           groups))))))
+      (let ((groups (nnmail-article-group 'identity trace)))
+       (unless silent
+         (if groups
+             (message "This message would go to %s"
+                      (mapconcat 'car groups ", "))
+           (message "This message would go to no groups"))
+         groups)))))
 
 (defun gnus-summary-respool-trace ()
   "Trace where the respool algorithm would put this article.
@@ -9547,8 +9800,7 @@ ARTICLE can also be a list of articles."
   ;; (article-number . line-number-in-body).
   (push
    (cons article
-        (save-excursion
-          (set-buffer gnus-article-buffer)
+        (with-current-buffer gnus-article-buffer
           (count-lines
            (min (point)
                 (save-excursion
@@ -9777,9 +10029,9 @@ If NO-EXPIRE, auto-expiry will be inhibited."
   t)
 
 (defun gnus-summary-update-download-mark (article)
-  "Update the secondary (read, process, cache) mark."
+  "Update the download mark."
   (gnus-summary-update-mark
-   (cond ((memq article gnus-newsgroup-undownloaded) 
+   (cond ((memq article gnus-newsgroup-undownloaded)
           gnus-undownloaded-mark)
          (gnus-newsgroup-agentized
           gnus-downloaded-mark)
@@ -9792,7 +10044,7 @@ If NO-EXPIRE, auto-expiry will be inhibited."
 (defun gnus-summary-update-mark (mark type)
   (let ((forward (cdr (assq type gnus-summary-mark-positions)))
        (buffer-read-only nil))
-    (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
+    (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
     (when forward
       (when (looking-at "\r")
        (incf forward))
@@ -9930,12 +10182,21 @@ The difference between N and the number of marks cleared is returned."
   (when (memq gnus-current-article gnus-newsgroup-unreads)
     (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
 
-(defun gnus-summary-mark-read-and-unread-as-read ()
+(defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
   "Intended to be used by `gnus-summary-mark-article-hook'."
   (let ((mark (gnus-summary-article-mark)))
     (when (or (gnus-unread-mark-p mark)
              (gnus-read-mark-p mark))
-      (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
+      (gnus-summary-mark-article gnus-current-article
+                                (or new-mark gnus-read-mark)))))
+
+(defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
+  "Intended to be used by `gnus-summary-mark-article-hook'."
+  (let ((mark (gnus-summary-article-mark)))
+    (when (or (gnus-unread-mark-p mark)
+             (gnus-read-mark-p mark))
+      (gnus-summary-mark-article (gnus-summary-article-number)
+                                (or new-mark gnus-read-mark)))))
 
 (defun gnus-summary-mark-unread-as-ticked ()
   "Intended to be used by `gnus-summary-mark-article-hook'."
@@ -10039,10 +10300,14 @@ even ticked and dormant ones."
 If prefix argument ALL is non-nil, ticked and dormant articles will
 also be marked as read.
 If QUIETLY is non-nil, no questions will be asked.
+
 If TO-HERE is non-nil, it should be a point in the buffer.  All
-articles before (after, if REVERSE is set) this point will be marked as read.
+articles before (after, if REVERSE is set) this point will be marked
+as read.
+
 Note that this function will only catch up the unread article
 in the current summary buffer limitation.
+
 The number of articles marked as read is returned."
   (interactive "P")
   (prog1
@@ -10076,9 +10341,10 @@ The number of articles marked as read is returned."
            (if (and to-here reverse)
                (progn
                  (goto-char to-here)
-                 (while (and
-                         (gnus-summary-mark-article-as-read gnus-catchup-mark)
-                         (gnus-summary-find-next (not all)))))
+                 (gnus-summary-mark-current-read-and-unread-as-read
+                  gnus-catchup-mark)
+                 (while (gnus-summary-find-next (not all))
+                   (gnus-summary-mark-article-as-read gnus-catchup-mark)))
              (when (gnus-summary-first-subject (not all))
                (while (and
                        (if to-here (< (point) to-here) t)
@@ -10101,7 +10367,7 @@ If ALL is non-nil, also mark ticked and dormant articles as read."
   (gnus-summary-position-point))
 
 (defun gnus-summary-catchup-from-here (&optional all)
-  "Mark all unticked articles after the current one as read.
+  "Mark all unticked articles after (and including) the current one as read.
 If ALL is non-nil, also mark ticked and dormant articles as read."
   (interactive "P")
   (save-excursion
@@ -10110,8 +10376,8 @@ If ALL is non-nil, also mark ticked and dormant articles as read."
        ;; We check that there are unread articles.
        (when (or all (gnus-summary-find-next))
          (gnus-summary-catchup all t beg nil t)))))
-
   (gnus-summary-position-point))
+
 (defun gnus-summary-catchup-all (&optional quietly)
   "Mark all articles in this newsgroup as read.
 This command is dangerous.  Normally, you want \\[gnus-summary-catchup]
@@ -10302,8 +10568,8 @@ Returns nil if no thread was there to be shown."
   (interactive)
   (let ((buffer-read-only nil)
        (orig (point))
-       ;; first goto end then to beg, to have point at beg after let
-       (end (progn (end-of-line) (point)))
+       (end (point-at-eol))
+       ;; Leave point at bol
        (beg (progn (beginning-of-line) (point))))
     (prog1
        ;; Any hidden lines here?
@@ -10318,7 +10584,7 @@ Returns nil if no thread was there to be shown."
             gnus-thread-hide-subtree)
     (gnus-summary-hide-all-threads
      (if (or (consp gnus-thread-hide-subtree)
-            (gnus-functionp gnus-thread-hide-subtree))
+            (functionp gnus-thread-hide-subtree))
         (gnus-make-predicate gnus-thread-hide-subtree)
        nil))))
 
@@ -10734,7 +11000,7 @@ save those articles instead."
                    ;; Regular expression.
                    (ignore-errors
                      (re-search-forward match nil t)))
-                  ((gnus-functionp match)
+                  ((functionp match)
                    ;; Function.
                    (save-restriction
                      (widen)
@@ -10789,8 +11055,7 @@ save those articles instead."
           (t
            (gnus-completing-read-with-default
             nil prom
-            (mapcar (lambda (el) (list el))
-                    (nreverse split-name))
+            (mapcar 'list (nreverse split-name))
             nil nil nil
             'gnus-group-history))))
         (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
@@ -10848,13 +11113,17 @@ If REVERSE, save parts that do not match TYPE."
              (not (string-match type (mm-handle-media-type handle)))
            (string-match type (mm-handle-media-type handle)))
       (let ((file (expand-file-name
-                  (file-name-nondirectory
-                   (or
-                    (mail-content-type-get
-                     (mm-handle-disposition handle) 'filename)
-                    (concat gnus-newsgroup-name
-                            "." (number-to-string
-                                 (cdr gnus-article-current)))))
+                  (gnus-map-function
+                   mm-file-name-rewrite-functions
+                   (file-name-nondirectory
+                    (or
+                     (mail-content-type-get
+                      (mm-handle-disposition handle) 'filename)
+                     (mail-content-type-get
+                      (mm-handle-type handle) 'name)
+                     (concat gnus-newsgroup-name
+                             "." (number-to-string
+                                  (cdr gnus-article-current))))))
                   dir)))
        (unless (file-exists-p file)
          (mm-save-part-to-file handle file))))))
@@ -10894,7 +11163,7 @@ If REVERSE, save parts that do not match TYPE."
                                (lambda (f)
                                  (if (equal f " ")
                                      f
-                                   (mm-quote-arg f)))
+                                   (shell-quote-argument f)))
                                files " ")))))
          (setq ps (cdr ps)))))
     (if (and gnus-view-pseudos (not not-view))
@@ -10989,14 +11258,6 @@ If REVERSE, save parts that do not match TYPE."
             (not (gnus-summary-article-sparse-p (mail-header-number header))))
        ;; We have found the header.
        header
-      ;; If this is a sparse article, we have to nix out its
-      ;; previous entry in the thread hashtb.
-      (when (and header
-                (gnus-summary-article-sparse-p (mail-header-number header)))
-       (let* ((parent (gnus-parent-id (mail-header-references header)))
-              (thread (and parent (gnus-id-to-thread parent))))
-         (when thread
-           (delq (assq header thread) thread))))
       ;; We have to really fetch the header to this article.
       (save-excursion
        (set-buffer nntp-server-buffer)
@@ -11054,8 +11315,8 @@ If REVERSE, save parts that do not match TYPE."
   ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
   (when gnus-summary-selected-face
     (save-excursion
-      (let* ((beg (progn (beginning-of-line) (point)))
-            (end (progn (end-of-line) (point)))
+      (let* ((beg (point-at-bol))
+            (end (point-at-eol))
             ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
             (from (if (get-text-property beg gnus-mouse-face-prop)
                       beg
@@ -11086,7 +11347,7 @@ If REVERSE, save parts that do not match TYPE."
 (defvar gnus-summary-highlight-line-trigger nil)
 
 (defun gnus-summary-highlight-line-0 ()
-  (if (and (eq gnus-summary-highlight-line-trigger 
+  (if (and (eq gnus-summary-highlight-line-trigger
                gnus-summary-highlight)
            gnus-summary-highlight-line-cached)
       gnus-summary-highlight-line-cached
@@ -11096,14 +11357,15 @@ If REVERSE, save parts that do not match TYPE."
                  (c cond)
                  (list gnus-summary-highlight))
             (while list
-              (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
+              (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
+                             nil))
               (setq c (cdr c)
                     list (cdr list)))
             (gnus-byte-compile (list 'lambda nil cond))))))
 
 (defun gnus-summary-highlight-line ()
   "Highlight current line according to `gnus-summary-highlight'."
-  (let* ((beg (gnus-point-at-bol))
+  (let* ((beg (point-at-bol))
         (article (or (gnus-summary-article-number) gnus-current-article))
         (score (or (cdr (assq article
                               gnus-newsgroup-scored))
@@ -11113,12 +11375,13 @@ If REVERSE, save parts that do not match TYPE."
         (default gnus-summary-default-score)
         (default-high gnus-summary-default-high-score)
         (default-low gnus-summary-default-low-score)
-        (uncached (memq article gnus-newsgroup-undownloaded))
-        (downloaded (not uncached)))
+        (uncached (and gnus-summary-use-undownloaded-faces
+                        (memq article gnus-newsgroup-undownloaded)
+                        (not (memq article gnus-newsgroup-cached)))))
     (let ((face (funcall (gnus-summary-highlight-line-0))))
       (unless (eq face (get-text-property beg 'face))
        (gnus-put-text-property-excluding-characters-with-faces
-        beg (gnus-point-at-eol) 'face
+        beg (point-at-eol) 'face
         (setq face (if (boundp face) (symbol-value face) face)))
        (when gnus-summary-highlight-line-function
          (funcall gnus-summary-highlight-line-function article face))))))
@@ -11126,11 +11389,10 @@ If REVERSE, save parts that do not match TYPE."
 (defun gnus-update-read-articles (group unread &optional compute)
   "Update the list of read articles in GROUP.
 UNREAD is a sorted list."
-  (let* ((active (or gnus-newsgroup-active (gnus-active group)))
-        (entry (gnus-gethash group gnus-newsrc-hashtb))
-        (info (nth 2 entry))
-        (prev 1)
-        read)
+  (let ((active (or gnus-newsgroup-active (gnus-active group)))
+       (info (gnus-get-info group))
+       (prev 1)
+       read)
     (if (or (not info) (not active))
        ;; There is no info on this group if it was, in fact,
        ;; killed.  Gnus stores no information on killed groups, so
@@ -11198,8 +11460,7 @@ UNREAD is a sorted list."
     (dolist (buffer (buffer-list))
       (when (and (setq buffer (buffer-name buffer))
                 (string-match "Summary" buffer)
-                (save-excursion
-                  (set-buffer buffer)
+                (with-current-buffer buffer
                   ;; We check that this is, indeed, a summary buffer.
                   (and (eq major-mode 'gnus-summary-mode)
                        ;; Also make sure this isn't bogus.
@@ -11260,7 +11521,7 @@ treated as multipart/mixed."
     (insert "Mime-Version: 1.0\n")
     (widen)
     (when (search-forward "\n--" nil t)
-      (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
+      (let ((separator (buffer-substring (point) (point-at-eol))))
        (message-narrow-to-head)
        (message-remove-header "Content-Type")
        (goto-char (point-max))
@@ -11363,10 +11624,10 @@ returned."
                                                (mail-header-number h))
                                              gnus-newsgroup-headers)))
     (setq gnus-newsgroup-headers
-         (merge 'list
-                gnus-newsgroup-headers
-                (gnus-fetch-headers articles)
-                'gnus-article-sort-by-number))
+         (gnus-merge 'list
+                     gnus-newsgroup-headers
+                     (gnus-fetch-headers articles)
+                     'gnus-article-sort-by-number))
     ;; Suppress duplicates?
     (when gnus-suppress-duplicates
       (gnus-dup-suppress-articles))
@@ -11480,7 +11741,7 @@ If ALL is a number, fetch this number of articles."
          (push i new)
          (decf i))
        (if (not new)
-           (message "No gnus is bad news.")
+           (message "No gnus is bad news")
          (gnus-summary-insert-articles new)
          (setq gnus-newsgroup-unreads
                (gnus-sorted-nunion gnus-newsgroup-unreads new))
@@ -11495,4 +11756,9 @@ If ALL is a number, fetch this number of articles."
 
 (run-hooks 'gnus-sum-load-hook)
 
+;; Local Variables:
+;; coding: iso-8859-1
+;; End:
+
+;;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
 ;;; gnus-sum.el ends here