Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / gnus-sum.el
index af835dd..b12878c 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
-;; Copyright (C) 1996, 1997, 1998, 1999, 2000
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -29,6 +29,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(eval-when-compile (require 'gnus-clfns))
 
 (require 'gnus)
 (require 'gnus-group)
@@ -212,6 +213,20 @@ If this variable is nil, scoring will be disabled."
   :type '(choice (const :tag "disable")
                 integer))
 
+(defcustom gnus-summary-default-high-score 0
+  "*Default threshold for a high scored article.
+An article will be highlighted as high scored if its score is greater
+than this score."
+  :group 'gnus-score-default
+  :type 'integer)
+
+(defcustom gnus-summary-default-low-score 0
+  "*Default threshold for a low scored article.
+An article will be highlighted as low scored if its score is smaller
+than this score."
+  :group 'gnus-score-default
+  :type 'integer)
+
 (defcustom gnus-summary-zcore-fuzz 0
   "*Fuzziness factor for the zcore in the summary buffer.
 Articles with scores closer than this to `gnus-summary-default-score'
@@ -424,7 +439,7 @@ this variable specifies group names."
   :type 'character)
 
 (defcustom gnus-souped-mark ?F
-  "*Mark used for killed articles."
+  "*Mark used for souped articles."
   :group 'gnus-summary-marks
   :type 'character)
 
@@ -448,6 +463,11 @@ this variable specifies group names."
   :group 'gnus-summary-marks
   :type 'character)
 
+(defcustom gnus-forwarded-mark ?O
+  "*Mark used for articles that have been forwarded."
+  :group 'gnus-summary-marks
+  :type 'character)
+
 (defcustom gnus-cached-mark ?*
   "*Mark used for articles that are in the cache."
   :group 'gnus-summary-marks
@@ -611,7 +631,22 @@ score file."
 
 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
   "*List of functions used for sorting articles in the summary buffer.
-This variable is only used when not using a threaded display."
+
+Each function takes two articles and returns non-nil if the first
+article should be sorted before the other.  If you use more than one
+function, the primary sort function should be the last.  You should
+probably always include `gnus-article-sort-by-number' in the list of
+sorting functions -- preferably first.  Also note that sorting by date
+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.)
+
+Ready-made functions include `gnus-article-sort-by-number',
+`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
+`gnus-article-sort-by-date' 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)
@@ -624,16 +659,22 @@ This variable is only used when not using a threaded display."
   "*List of functions used for sorting threads in the summary buffer.
 By default, threads are sorted by article number.
 
-Each function takes two threads and return non-nil if the first thread
-should be sorted before the other.  If you use more than one function,
-the primary sort function should be the last.  You should probably
-always include `gnus-thread-sort-by-number' in the list of sorting
-functions -- preferably first.
+Each function takes two threads and returns non-nil if the first
+thread should be sorted before the other.  If you use more than one
+function, the primary sort function should be the last.  You should
+probably always include `gnus-thread-sort-by-number' in the list of
+sorting functions -- preferably first.  Also note that sorting by date
+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.)
 
 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' and
-`gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
+`gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
+
+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)
@@ -793,43 +834,43 @@ automatically when it is selected."
 (defcustom gnus-summary-highlight
   '(((= mark gnus-canceled-mark)
      . gnus-summary-cancelled-face)
-    ((and (> score default)
+    ((and (> score default-high)
          (or (= mark gnus-dormant-mark)
              (= mark gnus-ticked-mark)))
      . gnus-summary-high-ticked-face)
-    ((and (< score default)
+    ((and (< score default-low)
          (or (= mark gnus-dormant-mark)
              (= mark gnus-ticked-mark)))
      . gnus-summary-low-ticked-face)
     ((or (= mark gnus-dormant-mark)
         (= mark gnus-ticked-mark))
      . gnus-summary-normal-ticked-face)
-    ((and (> score default) (= mark gnus-ancient-mark))
+    ((and (> score default-high) (= mark gnus-ancient-mark))
      . gnus-summary-high-ancient-face)
-    ((and (< score default) (= mark gnus-ancient-mark))
+    ((and (< score default-low) (= mark gnus-ancient-mark))
      . gnus-summary-low-ancient-face)
     ((= mark gnus-ancient-mark)
      . gnus-summary-normal-ancient-face)
-    ((and (> score default) (= mark gnus-unread-mark))
+    ((and (> score default-high) (= mark gnus-unread-mark))
      . gnus-summary-high-unread-face)
-    ((and (< score default) (= mark gnus-unread-mark))
+    ((and (< score default-low) (= mark gnus-unread-mark))
      . gnus-summary-low-unread-face)
-    ((and (memq article gnus-newsgroup-incorporated)
-         (= mark gnus-unread-mark))
-     . gnus-summary-incorporated-face)
     ((= mark gnus-unread-mark)
      . gnus-summary-normal-unread-face)
-    ((and (> score default) (memq mark (list gnus-downloadable-mark
+    ((and (> score default-high) (memq mark (list gnus-downloadable-mark
                                             gnus-undownloaded-mark)))
      . gnus-summary-high-unread-face)
-    ((and (< score default) (memq mark (list gnus-downloadable-mark
+    ((and (< score default-low) (memq mark (list gnus-downloadable-mark
                                             gnus-undownloaded-mark)))
      . gnus-summary-low-unread-face)
-    ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
+    ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
+         (memq article gnus-newsgroup-unreads))
      . gnus-summary-normal-unread-face)
-    ((> score default)
+    ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
+     . gnus-summary-normal-read-face)
+    ((> score default-high)
      . gnus-summary-high-read-face)
-    ((< score default)
+    ((< score default-low)
      . gnus-summary-low-read-face)
     (t
      . gnus-summary-normal-read-face))
@@ -842,10 +883,12 @@ how those summary lines are displayed, by editing the face field.
 
 You can use the following variables in the FORM field.
 
-score:   The articles score
-default: The default article score.
-below:   The score below which articles are automatically marked as read.
-mark:    The articles mark."
+score:        The article's score
+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."
   :group 'gnus-summary-visual
   :type '(repeat (cons (sexp :tag "Form" nil)
                       face)))
@@ -872,25 +915,6 @@ which it may alter in any way.")
   :group 'gnus-summary
   :type 'regexp)
 
-(defcustom gnus-group-charset-alist
-  '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
-    ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
-    ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
-    ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
-    ("^relcom\\>" koi8-r)
-    ("^fido7\\>" koi8-r)
-    ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
-    ("^israel\\>" iso-8859-1)
-    ("^han\\>" euc-kr)
-    ("^alt.chinese.text.big5\\>" chinese-big5)
-    ("^soc.culture.vietnamese\\>" vietnamese-viqr)
-    ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
-    (".*" iso-8859-1))
-  "Alist of regexps (to match group names) and default charsets to be used when reading."
-  :type '(repeat (list (regexp :tag "Group")
-                      (symbol :tag "Charset")))
-  :group 'gnus-charset)
-
 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
   "List of charsets that should be ignored.
 When these charsets are used in the \"charset\" parameter, the
@@ -899,14 +923,29 @@ default charset will be used instead."
   :type '(repeat symbol)
   :group 'gnus-charset)
 
-(defcustom gnus-group-ignored-charsets-alist
-  '(("alt\\.chinese\\.text" iso-8859-1))
-  "Alist of regexps (to match group names) and charsets that should be ignored.
+(gnus-define-group-parameter
+ ignored-charsets
+ :type list
+ :function-document
+ "Return the ignored charsets of GROUP."
+ :variable gnus-group-ignored-charsets-alist
+ :variable-default 
+ '(("alt\\.chinese\\.text" iso-8859-1))
+ :variable-document
+ "Alist of regexps (to match group names) and charsets that should be ignored.
 When these charsets are used in the \"charset\" parameter, the
 default charset will be used instead."
-  :type '(repeat (cons (regexp :tag "Group")
-                      (repeat symbol)))
-  :group 'gnus-charset)
+ :variable-group gnus-charset
+ :variable-type '(repeat (cons (regexp :tag "Group")
+                              (repeat symbol)))
+ :parameter-type '(choice :tag "Ignored charsets" 
+                         :value nil
+                         (repeat (symbol)))
+ :parameter-document       "\
+List of charsets that should be ignored.
+
+When these charsets are used in the \"charset\" parameter, the
+default charset will be used instead.")
 
 (defcustom gnus-group-highlight-words-alist nil
   "Alist of group regexps and highlight regexps.
@@ -958,7 +997,7 @@ For example: ((1 . cn-gb-2312) (2 . big5))."
 
 (defcustom gnus-alter-articles-to-read-function nil
   "Function to be called to alter the list of articles to be selected."
-  :type 'function
+  :type '(choice (const nil) function)
   :group 'gnus-summary)
 
 (defcustom gnus-orphan-score nil
@@ -982,6 +1021,13 @@ 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
+wish to widen the summary buffer to include all headers
+that were fetched.  Say, for nnultimate groups."
+  :group 'gnus-summary
+  :type '(choice boolean regexp))
 
 ;;; Internal variables
 
@@ -1042,7 +1088,7 @@ when prompting the user for which type of files to save."
     (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
     (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
     (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
-    (?L gnus-tmp-lines ?d)
+    (?L gnus-tmp-lines ?s)
     (?I gnus-tmp-indentation ?s)
     (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
     (?R gnus-tmp-replied ?c)
@@ -1144,6 +1190,9 @@ end position and text.")
 (defvar gnus-newsgroup-replied nil
   "List of articles that have been replied to in the current newsgroup.")
 
+(defvar gnus-newsgroup-forwarded nil
+  "List of articles that have been forwarded in the current newsgroup.")
+
 (defvar gnus-newsgroup-expirable nil
   "List of articles in the current newsgroup that can be expired.")
 
@@ -1204,7 +1253,8 @@ end position and text.")
     gnus-newsgroup-auto-expire gnus-newsgroup-unreads
     gnus-newsgroup-unselected gnus-newsgroup-marked
     gnus-newsgroup-reads gnus-newsgroup-saved
-    gnus-newsgroup-replied gnus-newsgroup-expirable
+    gnus-newsgroup-replied gnus-newsgroup-forwarded
+    gnus-newsgroup-expirable
     gnus-newsgroup-processable gnus-newsgroup-killed
     gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
     gnus-newsgroup-unsendable
@@ -1259,7 +1309,7 @@ end position and text.")
 
 (defsubst gnus-simplify-subject-re (subject)
   "Remove \"Re:\" from subject lines."
-  (if (string-match "^[Rr][Ee]: *" subject)
+  (if (string-match message-subject-re-regexp subject)
       (substring subject (match-end 0))
     subject))
 
@@ -1372,6 +1422,8 @@ increase the score of each group you read."
 
 (put 'gnus-summary-mode 'mode-class 'special)
 
+(defvar gnus-article-commands-menu)
+
 (when t
   ;; Non-orthogonal keys
 
@@ -1436,6 +1488,7 @@ increase the score of each group you read."
     "\C-c\C-s\C-s" gnus-summary-sort-by-subject
     "\C-c\C-s\C-d" gnus-summary-sort-by-date
     "\C-c\C-s\C-i" gnus-summary-sort-by-score
+    "\C-c\C-s\C-o" gnus-summary-sort-by-original
     "=" gnus-summary-expand-window
     "\C-x\C-s" gnus-summary-reselect-current-group
     "\M-g" gnus-summary-rescan-group
@@ -1504,6 +1557,7 @@ increase the score of each group you read."
     "S" gnus-summary-limit-include-expunged
     "C" gnus-summary-catchup
     "H" gnus-summary-catchup-to-here
+    "h" gnus-summary-catchup-from-here
     "\C-c" gnus-summary-catchup-all
     "k" gnus-summary-kill-same-subject-and-select
     "K" gnus-summary-kill-same-subject
@@ -1533,7 +1587,9 @@ increase the score of each group you read."
     "x" gnus-summary-limit-to-extra
     "E" gnus-summary-limit-include-expunged
     "c" gnus-summary-limit-exclude-childless-dormant
-    "C" gnus-summary-limit-mark-excluded-as-read)
+    "C" gnus-summary-limit-mark-excluded-as-read
+    "o" gnus-summary-insert-old-articles
+    "N" gnus-summary-insert-new-articles)
 
   (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
     "n" gnus-summary-next-unread-article
@@ -1627,7 +1683,7 @@ increase the score of each group you read."
     "t" gnus-article-toggle-headers
     "v" gnus-summary-verbose-headers
     "m" gnus-summary-toggle-mime
-    "H" gnus-article-strip-headers-in-body
+    "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
     "p" gnus-article-verify-x-pgp-sig
     "d" gnus-article-treat-dumbquotes
     "s" gnus-smiley-display)
@@ -1668,7 +1724,8 @@ increase the score of each group you read."
     "a" gnus-article-strip-blank-lines
     "A" gnus-article-strip-all-blank-lines
     "s" gnus-article-strip-leading-space
-    "e" gnus-article-strip-trailing-space)
+    "e" gnus-article-strip-trailing-space
+    "w" gnus-article-remove-leading-whitespace)
 
   (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
     "v" gnus-version
@@ -1691,6 +1748,7 @@ increase the score of each group you read."
     "q" gnus-summary-respool-query
     "t" gnus-summary-respool-trace
     "i" gnus-summary-import-article
+    "I" gnus-summary-create-article
     "p" gnus-summary-article-posted-p)
 
   (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
@@ -1717,6 +1775,8 @@ increase the score of each group you read."
     "i" gnus-article-inline-part
     "|" gnus-article-pipe-part))
 
+(defvar gnus-article-post-menu nil)
+
 (defun gnus-summary-make-menu-bar ()
   (gnus-turn-off-edit-menu 'summary)
 
@@ -1781,7 +1841,9 @@ increase the score of each group you read."
                ["All of the above" gnus-article-strip-blank-lines t]
                ["All" gnus-article-strip-all-blank-lines t]
                ["Leading space" gnus-article-strip-leading-space t]
-              ["Trailing space" gnus-article-strip-trailing-space t])
+              ["Trailing space" gnus-article-strip-trailing-space t]
+               ["Leading space in headers" 
+               gnus-article-remove-leading-whitespace t])
               ["Overstrike" gnus-article-treat-overstrike t]
               ["Dumb quotes" gnus-article-treat-dumbquotes t]
               ["Emphasis" gnus-article-emphasize t]
@@ -1791,7 +1853,7 @@ increase the score of each group you read."
               ["CR" gnus-article-remove-cr t]
               ["Show X-Face" gnus-article-display-x-face t]
              ["Rot 13" gnus-summary-caesar-message
-              ,@(if (featurep 'xemacs) nil
+              ,@(if (featurep 'xemacs) '(t)
                   '(:help "\"Caesar rotate\" article by 13"))]
               ["Unix pipe" gnus-summary-pipe-message t]
               ["Add buttons" gnus-article-add-buttons t]
@@ -1805,10 +1867,10 @@ increase the score of each group you read."
              ["HZ" gnus-article-decode-HZ t])
              ("Output"
               ["Save in default format" gnus-summary-save-article
-              ,@(if (featurep 'xemacs) nil
+              ,@(if (featurep 'xemacs) '(t)
                   '(:help "Save article using default method"))]
               ["Save in file" gnus-summary-save-article-file
-              ,@(if (featurep 'xemacs) nil
+              ,@(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]
@@ -1828,6 +1890,7 @@ increase the score of each group you read."
                (gnus-check-backend-function
                 'request-replace-article gnus-newsgroup-name)]
               ["Import file..." gnus-summary-import-article t]
+              ["Create article..." gnus-summary-create-article t]
               ["Check if posted" gnus-summary-article-posted-p t]
               ["Edit article" gnus-summary-edit-article
                (not (gnus-group-read-only-p))]
@@ -1841,7 +1904,7 @@ increase the score of each group you read."
                 'request-expire-articles gnus-newsgroup-name)])
              ("Extract"
               ["Uudecode" gnus-uu-decode-uu
-              ,@(if (featurep 'xemacs) nil
+              ,@(if (featurep 'xemacs) '(t)
                   '(:help "Decode uuencoded article(s)"))]
               ["Uudecode and save" gnus-uu-decode-uu-and-save t]
               ["Unshar" gnus-uu-decode-unshar t]
@@ -1863,14 +1926,21 @@ increase the score of each group you read."
              ["Fetch current thread" gnus-summary-refer-thread t]
              ["Fetch article with id..." gnus-summary-refer-article t]
              ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
-             ["Redisplay" gnus-summary-show-article t])))
+             ["Redisplay" gnus-summary-show-article t]
+             ["Raw article" gnus-summary-show-raw-article t])))
       (easy-menu-define
        gnus-summary-article-menu gnus-summary-mode-map ""
        (cons "Article" innards))
 
-      (easy-menu-define
-       gnus-article-commands-menu gnus-article-mode-map ""
-       (cons "Commands" innards)))
+      (if (not (keymapp gnus-summary-article-menu))
+         (easy-menu-define
+           gnus-article-commands-menu gnus-article-mode-map ""
+           (cons "Commands" innards))
+       ;; in Emacs, don't share menu.
+       (setq gnus-article-commands-menu 
+             (copy-keymap gnus-summary-article-menu))
+       (define-key gnus-article-mode-map [menu-bar commands]
+         (cons "Commands" gnus-article-commands-menu))))
 
     (easy-menu-define
      gnus-summary-thread-menu gnus-summary-mode-map ""
@@ -1894,33 +1964,33 @@ increase the score of each group you read."
      gnus-summary-post-menu gnus-summary-mode-map ""
      `("Post"
        ["Post an article" gnus-summary-post-news
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Post an article"))]
        ["Followup" gnus-summary-followup
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Post followup to this article"))]
        ["Followup and yank" gnus-summary-followup-with-original
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Post followup to this article, quoting its contents"))]
        ["Supersede article" gnus-summary-supersede-article t]
        ["Cancel article" gnus-summary-cancel-article
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Cancel an article you posted"))]
        ["Reply" gnus-summary-reply t]
        ["Reply and yank" gnus-summary-reply-with-original t]
        ["Wide reply" gnus-summary-wide-reply t]
        ["Wide reply and yank" gnus-summary-wide-reply-with-original
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Mail a reply, quoting this article"))]
        ["Mail forward" gnus-summary-mail-forward t]
        ["Post forward" gnus-summary-post-forward t]
-       ["Digest and mail" gnus-uu-digest-mail-forward t]
-       ["Digest and post" gnus-uu-digest-post-forward t]
+       ["Digest and mail" gnus-summary-digest-mail-forward t]
+       ["Digest and post" gnus-summary-digest-post-forward t]
        ["Resend message" gnus-summary-resend-message t]
        ["Send bounced mail" gnus-summary-resend-bounced-mail t]
        ["Send a mail" gnus-summary-mail-other-window t]
        ["Uuencode and post" gnus-uu-post-news
-       ,@(if (featurep 'xemacs) nil
+       ,@(if (featurep 'xemacs) '(t)
            '(:help "Post a uuencoded article"))]
        ["Followup via news" gnus-summary-followup-to-mail t]
        ["Followup via news and yank"
@@ -1930,6 +2000,16 @@ increase the score of each group you read."
        ;;["Send bounced" gnus-resend-bounced-mail t])
        ))
 
+    (cond 
+     ((not (keymapp gnus-summary-post-menu))
+      (setq gnus-article-post-menu gnus-summary-post-menu))
+     ((not gnus-article-post-menu)
+      ;; Don't share post menu.
+      (setq gnus-article-post-menu
+           (copy-keymap gnus-summary-post-menu))))
+    (define-key gnus-article-mode-map [menu-bar post]
+      (cons "Post" gnus-article-post-menu))
+
     (easy-menu-define
      gnus-summary-misc-menu gnus-summary-mode-map ""
      `("Misc"
@@ -1939,10 +2019,11 @@ increase the score of each group you read."
         gnus-summary-kill-same-subject-and-select t]
        ["Mark same subject" gnus-summary-kill-same-subject t]
        ["Catchup" gnus-summary-catchup
-        ,@(if (featurep 'xemacs) nil
+        ,@(if (featurep 'xemacs) '(t)
             '(:help "Mark unread articles in this group as read"))]
        ["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 t]
        ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
        ("Mark Various"
@@ -1968,7 +2049,7 @@ increase the score of each group you read."
         gnus-summary-limit-exclude-childless-dormant t]
        ;;["Hide thread" gnus-summary-limit-exclude-thread t]
        ["Hide marked" gnus-summary-limit-exclude-marks t]
-       ["Show expunged" gnus-summary-show-all-expunged t])
+       ["Show expunged" gnus-summary-limit-include-expunged t])
        ("Process Mark"
        ["Set mark" gnus-summary-mark-as-processable t]
        ["Remove mark" gnus-summary-unmark-as-processable t]
@@ -1991,10 +2072,10 @@ increase the score of each group you read."
         ["Save" gnus-summary-save-process-mark t]))
        ("Scroll article"
        ["Page forward" gnus-summary-next-page
-        ,@(if (featurep 'xemacs) nil
+        ,@(if (featurep 'xemacs) '(t)
             '(:help "Show next page of article"))]
        ["Page backward" gnus-summary-prev-page
-        ,@(if (featurep 'xemacs) nil
+        ,@(if (featurep 'xemacs) '(t)
             '(:help "Show previous page of article"))]
        ["Line forward" gnus-summary-scroll-up t])
        ("Move"
@@ -2019,7 +2100,8 @@ increase the score of each group you read."
        ["Sort by date" gnus-summary-sort-by-date t]
        ["Sort by score" gnus-summary-sort-by-score t]
        ["Sort by lines" gnus-summary-sort-by-lines t]
-       ["Sort by characters" gnus-summary-sort-by-chars t])
+       ["Sort by characters" gnus-summary-sort-by-chars t]
+       ["Original sort" gnus-summary-sort-by-original t])
        ("Help"
        ["Fetch group FAQ" gnus-summary-fetch-faq t]
        ["Describe group" gnus-summary-describe-group t]
@@ -2031,6 +2113,8 @@ increase the score of each group you read."
        ["Regenerate" gnus-summary-prepare t]
        ["Insert cached articles" gnus-summary-insert-cached-articles t]
        ["Toggle threading" gnus-summary-toggle-threads t])
+       ["See old articles" gnus-summary-insert-old-articles t]
+       ["See new articles" gnus-summary-insert-new-articles t]
        ["Filter articles..." gnus-summary-execute-command t]
        ["Run command on subjects..." gnus-summary-universal-argument t]
        ["Search articles forward..." gnus-summary-search-article-forward t]
@@ -2047,12 +2131,12 @@ increase the score of each group you read."
        ["Send a bug report" gnus-bug t]
        ("Exit"
        ["Catchup and exit" gnus-summary-catchup-and-exit
-        ,@(if (featurep 'xemacs) nil
+        ,@(if (featurep 'xemacs) '(t)
             '(:help "Mark unread articles in this group as read, then exit"))]
        ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
        ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
        ["Exit group" gnus-summary-exit
-        ,@(if (featurep 'xemacs) nil
+        ,@(if (featurep 'xemacs) '(t)
             '(:help "Exit current group, return to group selection mode"))]
        ["Exit group without updating" gnus-summary-exit-no-update t]
        ["Exit and goto next group" gnus-summary-next-group t]
@@ -2648,6 +2732,8 @@ display only a single character."
        (make-local-variable 'gnus-article-current)
        (make-local-variable 'gnus-original-article-buffer))
       (setq gnus-newsgroup-name group)
+      ;; Set any local variables in the group parameters.
+      (gnus-summary-set-local-parameters gnus-newsgroup-name)
       t)))
 
 (defun gnus-set-global-variables ()
@@ -2745,7 +2831,9 @@ buffer that was in action when the last article was fetched."
        (let ((gnus-summary-line-format-spec spec)
              (gnus-newsgroup-downloadable '((0 . t))))
          (gnus-summary-insert-line
-          (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
+          (make-full-mail-header 0 "" "nobody"
+                                 "05 Apr 2001 23:33:09 +0400"
+                                 "" "" 0 0 "" nil)
           0 nil 128 t nil "" nil 1)
          (goto-char (point-min))
          (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
@@ -2839,7 +2927,9 @@ buffer that was in action when the last article was fetched."
     (when (string= gnus-tmp-name "")
       (setq gnus-tmp-name gnus-tmp-from))
     (unless (numberp gnus-tmp-lines)
-      (setq gnus-tmp-lines 0))
+      (setq gnus-tmp-lines -1))
+    (when (= gnus-tmp-lines -1)
+      (setq gnus-tmp-lines "?"))
     (gnus-put-text-property-excluding-characters-with-faces
      (point)
      (progn (eval gnus-summary-line-format-spec) (point))
@@ -2913,6 +3003,7 @@ the thread are to be displayed."
 (defun gnus-summary-set-local-parameters (group)
   "Go through the local params of GROUP and set all variable specs in that list."
   (let ((params (gnus-group-find-parameter group))
+        (vars '(quit-config)) ; Ignore quit-config.
        elem)
     (while params
       (setq elem (car params)
@@ -2920,8 +3011,9 @@ the thread are to be displayed."
       (and (consp elem)                        ; Has to be a cons.
           (consp (cdr elem))           ; The cdr has to be a list.
           (symbolp (car elem))         ; Has to be a symbol in there.
-          (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
+           (not (memq (car elem) vars))
           (ignore-errors               ; So we set it.
+             (push (car elem) vars)
             (make-local-variable (car elem))
             (set (car elem) (eval (nth 1 elem))))))))
 
@@ -2981,7 +3073,8 @@ If SHOW-ALL is non-nil, already read articles are also listed."
   ;;  (when (and (not (gnus-group-native-p group))
   ;;        (not (gnus-gethash group gnus-newsrc-hashtb)))
   ;;    (error "Dead non-native groups can't be entered"))
-  (gnus-message 5 "Retrieving newsgroup: %s..." group)
+  (gnus-message 5 "Retrieving newsgroup: %s..."
+               (gnus-group-decoded-name group))
   (let* ((new-group (gnus-summary-setup-buffer group))
         (quit-config (gnus-group-quit-config group))
         (did-select (and new-group (gnus-select-newsgroup
@@ -3013,7 +3106,8 @@ If SHOW-ALL is non-nil, already read articles are also listed."
          (gnus-handle-ephemeral-exit quit-config)))
       (let ((grpinfo (gnus-get-info group)))
         (if (null (gnus-info-read grpinfo))
-            (gnus-message 3 "Group %s contains no messages" group)
+            (gnus-message 3 "Group %s contains no messages" 
+                         (gnus-group-decoded-name group))
           (gnus-message 3 "Can't select group")))
       nil)
      ;; The user did a `C-g' while prompting for number of articles,
@@ -3042,8 +3136,6 @@ If SHOW-ALL is non-nil, already read articles are also listed."
             (gnus-active gnus-newsgroup-name)))
       ;; You can change the summary buffer in some way with this hook.
       (gnus-run-hooks 'gnus-select-group-hook)
-      ;; Set any local variables in the group parameters.
-      (gnus-summary-set-local-parameters gnus-newsgroup-name)
       (gnus-update-format-specifications
        nil 'summary 'summary-mode 'summary-dummy)
       (gnus-update-summary-mark-positions)
@@ -3649,7 +3741,7 @@ If LINE, insert the rebuilt thread starting on line LINE."
       (setq thread (gnus-remove-thread id)))
     (setq old-pos (gnus-point-at-bol))
     (setq current (save-excursion
-                   (and (zerop (forward-line -1))
+                   (and (re-search-backward "[\r\n]" nil t)
                         (gnus-summary-article-number))))
     ;; If this is a gathered thread, we have to go some re-gathering.
     (when (stringp (car thread))
@@ -4207,6 +4299,8 @@ or a straight list of headers."
                    gnus-cached-mark)
                   ((memq number gnus-newsgroup-replied)
                    gnus-replied-mark)
+                  ((memq number gnus-newsgroup-forwarded)
+                   gnus-forwarded-mark)
                   ((memq number gnus-newsgroup-saved)
                    gnus-saved-mark)
                   (t gnus-no-mark))
@@ -4225,7 +4319,9 @@ or a straight list of headers."
            (when (string= gnus-tmp-name "")
              (setq gnus-tmp-name gnus-tmp-from))
            (unless (numberp gnus-tmp-lines)
-             (setq gnus-tmp-lines 0))
+             (setq gnus-tmp-lines -1))
+           (when (= gnus-tmp-lines -1)
+             (setq gnus-tmp-lines "?"))
            (gnus-put-text-property
             (point)
             (progn (eval gnus-summary-line-format-spec) (point))
@@ -4282,21 +4378,60 @@ or a straight list of headers."
 
 (defun gnus-summary-remove-list-identifiers ()
   "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
-  (let ((regexp (if (stringp gnus-list-identifiers)
-                   gnus-list-identifiers
-                 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
-    (dolist (header gnus-newsgroup-headers)
-      (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
-                                 " *\\)\\)+\\(Re: +\\)?\\)")
-                         (mail-header-subject header))
-       (mail-header-set-subject
-        header (concat (substring (mail-header-subject header)
-                                  0 (match-beginning 1))
-                       (or
-                        (match-string 3 (mail-header-subject header))
-                        (match-string 5 (mail-header-subject header)))
-                       (substring (mail-header-subject header)
-                                  (match-end 1))))))))
+  (let ((regexp (if (consp gnus-list-identifiers)
+                   (mapconcat 'identity gnus-list-identifiers " *\\|")
+                 gnus-list-identifiers))
+       changed subject)
+    (when regexp
+      (dolist (header gnus-newsgroup-headers)
+       (setq subject (mail-header-subject header)
+             changed nil)
+       (while (string-match
+               (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
+               subject)
+         (setq subject
+               (concat (substring subject 0 (match-beginning 2))
+                       (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
+         (mail-header-set-subject header subject))))))
+
+(defun gnus-fetch-headers (articles)
+  "Fetch headers of ARTICLES."
+  (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
+    (gnus-message 5 "Fetching headers for %s..." name)
+    (prog1
+       ;;;!!! FIXME: temporary fix for an infloop on nnimap.
+       (if (eq 'nnimap (car (gnus-find-method-for-group name)))
+           (if (eq 'nov
+                   (setq gnus-headers-retrieved-by
+                         (gnus-retrieve-headers
+                          articles gnus-newsgroup-name
+                          ;; We might want to fetch old headers, but
+                          ;; not if there is only 1 article.
+                          (and (or (and
+                                    (not (eq gnus-fetch-old-headers 'some))
+                                    (not (numberp gnus-fetch-old-headers)))
+                                   (> (length articles) 1))
+                               gnus-fetch-old-headers))))
+               (gnus-get-newsgroup-headers-xover
+                articles nil nil gnus-newsgroup-name t)
+             (gnus-get-newsgroup-headers))
+         (gnus-retrieve-parsed-headers
+          articles gnus-newsgroup-name
+          ;; We might want to fetch old headers, but
+          ;; not if there is only 1 article.
+          (and (or (and (not (eq gnus-fetch-old-headers 'some))
+                        (not (numberp gnus-fetch-old-headers)))
+                   (> (length articles) 1))
+               gnus-fetch-old-headers)))
+      (gnus-message 5 "Fetching headers for %s...done" name))))
 
 (defun gnus-select-newsgroup (group &optional read-all select-articles)
   "Select newsgroup GROUP.
@@ -4372,17 +4507,7 @@ If SELECT-ARTICLES, only select those articles from GROUP."
            (gnus-make-hashtable (length articles)))
       (gnus-set-global-variables)
       ;; Retrieve the headers and read them in.
-      (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
-      (setq gnus-newsgroup-headers
-           (gnus-retrieve-parsed-headers
-            articles gnus-newsgroup-name
-            ;; We might want to fetch old headers, but
-            ;; not if there is only 1 article.
-            (and (or (and (not (eq gnus-fetch-old-headers 'some))
-                          (not (numberp gnus-fetch-old-headers)))
-                     (> (length articles) 1))
-                 gnus-fetch-old-headers)))
-      (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
+      (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
 
       ;; Suppress duplicates?
       (when gnus-suppress-duplicates
@@ -4680,11 +4805,8 @@ If WHERE is `summary', the summary mode line format will be used."
        (let* ((mformat (symbol-value
                         (intern
                          (format "gnus-%s-mode-line-format-spec" where))))
-              (gnus-tmp-group-name (gnus-group-name-decode
-                                    gnus-newsgroup-name
-                                    (gnus-group-name-charset
-                                     nil
-                                     gnus-newsgroup-name)))
+              (gnus-tmp-group-name (gnus-group-decoded-name 
+                                    gnus-newsgroup-name))
               (gnus-tmp-article-number (or gnus-current-article 0))
               (gnus-tmp-unread gnus-newsgroup-unreads)
               (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
@@ -4920,22 +5042,20 @@ The resulting hash table is returned, or nil if no Xrefs were found."
            ;; Subject.
            (progn
              (goto-char p)
-             (if (search-forward "\nsubject: " nil t)
+             (if (search-forward "\nsubject:" nil t)
                  (nnheader-header-value)
                "(none)"))
            ;; From.
            (progn
              (goto-char p)
-             (if (or (search-forward "\nfrom: " nil t)
-                     (search-forward "\nfrom:" nil t))
+             (if (search-forward "\nfrom:" nil t)
                  (nnheader-header-value)
                "(nobody)"))
            ;; Date.
            (progn
              (goto-char p)
-             (if (search-forward "\ndate: " nil t)
-                 (nnheader-header-value)
-               ""))
+             (if (search-forward "\ndate:" nil t)
+                 (nnheader-header-value) ""))
            ;; Message-ID.
            (progn
              (goto-char p)
@@ -4951,7 +5071,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
            ;; References.
            (progn
              (goto-char p)
-             (if (search-forward "\nreferences: " nil t)
+             (if (search-forward "\nreferences:" nil t)
                  (progn
                    (setq end (point))
                    (prog1
@@ -4968,7 +5088,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
                ;; Get the references from the in-reply-to header if there
                ;; were no references and the in-reply-to header looks
                ;; promising.
-               (if (and (search-forward "\nin-reply-to: " nil t)
+               (if (and (search-forward "\nin-reply-to:" nil t)
                         (setq in-reply-to (nnheader-header-value))
                         (string-match "<[^>]+>" in-reply-to))
                    (let (ref2)
@@ -4986,19 +5106,19 @@ The resulting hash table is returned, or nil if no Xrefs were found."
              (goto-char p)
              (if (search-forward "\nchars: " nil t)
                  (if (numberp (setq chars (ignore-errors (read cur))))
-                     chars 0)
-               0))
+                     chars -1)
+               -1))
            ;; Lines.
            (progn
              (goto-char p)
              (if (search-forward "\nlines: " nil t)
                  (if (numberp (setq lines (ignore-errors (read cur))))
-                     lines 0)
-               0))
+                     lines -1)
+               -1))
            ;; Xref.
            (progn
              (goto-char p)
-             (and (search-forward "\nxref: " nil t)
+             (and (search-forward "\nxref:" nil t)
                   (nnheader-header-value)))
            ;; Extra.
            (when gnus-extra-headers
@@ -5007,7 +5127,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
                (while extra
                  (goto-char p)
                  (when (search-forward
-                        (concat "\n" (symbol-name (car extra)) ": ") nil t)
+                        (concat "\n" (symbol-name (car extra)) ":") nil t)
                    (push (cons (car extra) (nnheader-header-value)) out))
                  (pop extra))
                out))))
@@ -5046,6 +5166,13 @@ Return a list of headers that match SEQUENCE (see
        (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
        (cur nntp-server-buffer)
        (dependencies (or dependencies gnus-newsgroup-dependencies))
+       (allp (cond
+              ((eq gnus-read-all-available-headers t)
+               t)
+              ((stringp gnus-read-all-available-headers)
+               (string-match gnus-read-all-available-headers group))
+              (t
+               nil)))
        number headers header)
     (save-excursion
       (set-buffer nntp-server-buffer)
@@ -5055,19 +5182,22 @@ Return a list of headers that match SEQUENCE (see
       (goto-char (point-min))
       (while (not (eobp))
        (condition-case ()
-           (while (and sequence (not (eobp)))
+           (while (and (or sequence allp)
+                       (not (eobp)))
              (setq number (read cur))
-             (while (and sequence
-                         (< (car sequence) number))
-               (setq sequence (cdr sequence)))
-             (and sequence
-                  (eq number (car sequence))
-                  (progn
-                    (setq sequence (cdr sequence))
-                    (setq header (inline
-                                   (gnus-nov-parse-line
-                                    number dependencies force-new))))
-                  (push header headers))
+             (when (not allp)
+               (while (and sequence
+                           (< (car sequence) number))
+                 (setq sequence (cdr sequence))))
+             (when (and (or allp
+                            (and sequence
+                                 (eq number (car sequence))))
+                        (progn
+                          (setq sequence (cdr sequence))
+                          (setq header (inline
+                                         (gnus-nov-parse-line
+                                          number dependencies force-new)))))
+               (push header headers))
              (forward-line 1))
          (error
           (gnus-error 4 "Strange nov line (%d)"
@@ -5086,8 +5216,11 @@ Return a list of headers that match SEQUENCE (see
        (let ((gnus-nov-is-evil t))
          (nconc
           (nreverse headers)
-          (gnus-retrieve-parsed-headers sequence group)
-          ))))))
+          ;;;!!! FIXME: temporary fix for an infloop on nnimap.
+          (if (eq 'nnimap (car (gnus-find-method-for-group group)))
+              (when (eq (gnus-retrieve-headers sequence group) 'headers)
+                (gnus-get-newsgroup-headers))
+            (gnus-retrieve-parsed-headers sequence group))))))))
 
 (defun gnus-article-get-xrefs ()
   "Fill in the Xref value in `gnus-current-headers', if necessary.
@@ -5657,7 +5790,9 @@ If FORCE (the prefix), also save the .newsrc file(s)."
        (setq gnus-article-current nil))
       (set-buffer buf)
       (if (not gnus-kill-summary-on-exit)
-         (gnus-deaden-summary)
+         (progn
+           (gnus-deaden-summary)
+           (setq mode nil))
        ;; We set all buffer-local variables to nil.  It is unclear why
        ;; this is needed, but if we don't, buffer-local variables are
        ;; not garbage-collected, it seems.  This would the lead to en
@@ -5672,10 +5807,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
        (set-buffer gnus-group-buffer)
        (gnus-summary-clear-local-variables)
        (let ((gnus-summary-local-variables gnus-newsgroup-variables))
-         (gnus-summary-clear-local-variables))
-       ;; Return to group mode buffer.
-       (when (eq mode 'gnus-summary-mode)
-         (gnus-kill-buffer buf)))
+         (gnus-summary-clear-local-variables)))
       (setq gnus-current-select-method gnus-select-method)
       (pop-to-buffer gnus-group-buffer)
       (if (not quit-config)
@@ -5690,6 +5822,9 @@ If FORCE (the prefix), also save the .newsrc file(s)."
              (set-window-start (selected-window) (point))
              (goto-char group-point)))
        (gnus-handle-ephemeral-exit quit-config))
+      ;; Return to group mode buffer.
+      (when (eq mode 'gnus-summary-mode)
+       (gnus-kill-buffer buf))
       ;; Clear the current group name.
       (unless quit-config
        (setq gnus-newsgroup-name nil)))))
@@ -6058,7 +6193,7 @@ Given a prefix, will force an `article' buffer configuration."
   "Display ARTICLE in article buffer."
   (when (gnus-buffer-live-p gnus-article-buffer)
     (with-current-buffer gnus-article-buffer
-      (mm-enable-multibyte-mule4)))
+      (set-buffer-multibyte t)))
   (gnus-set-global-variables)
   (when (gnus-buffer-live-p gnus-article-buffer)
     (with-current-buffer gnus-article-buffer
@@ -6669,12 +6804,27 @@ Returns how many articles were removed."
       (gnus-summary-position-point))))
 
 (defun gnus-summary-limit-include-thread (id)
-  "Display all the hidden articles that in the current thread."
+  "Display all the hidden articles that is in the thread with ID in it.
+When called interactively, ID is the Message-ID of the current
+article."
   (interactive (list (mail-header-id (gnus-summary-article-header))))
   (let ((articles (gnus-articles-in-thread
                   (gnus-id-to-thread (gnus-root-id id)))))
     (prog1
        (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
+       (gnus-summary-limit-include-matching-articles
+        "subject"
+        (regexp-quote (gnus-simplify-subject-re
+                       (mail-header-subject (gnus-id-to-header id)))))
+      (gnus-summary-position-point))))
+
+(defun gnus-summary-limit-include-matching-articles (header regexp)
+  "Display all the hidden articles that have HEADERs that match REGEXP."
+  (interactive (list (read-string "Match on header: ")
+                    (read-string "Regexp: ")))
+  (let ((articles (gnus-find-matching-articles header regexp)))
+    (prog1
+       (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
       (gnus-summary-position-point))))
 
 (defun gnus-summary-limit-include-dormant ()
@@ -7367,7 +7517,6 @@ Optional argument BACKWARD means do search for backward.
   (require 'gnus-async)
   (require 'gnus-art)
   (let ((gnus-select-article-hook nil) ;Disable hook.
-       (gnus-article-display-hook nil)
        (gnus-article-prepare-hook nil)
        (gnus-mark-article-hook nil)    ;Inhibit marking as read.
        (gnus-use-article-prefetch nil)
@@ -7452,6 +7601,18 @@ Optional argument BACKWARD means do search for backward.
       (gnus-summary-position-point)
       t)))
 
+(defun gnus-find-matching-articles (header regexp)
+  "Return a list of all articles that match REGEXP on HEADER.
+This search includes all articles in the current group that Gnus has
+fetched headers for, whether they are displayed or not."
+  (let ((articles nil)
+       (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
+       (case-fold-search t))
+    (dolist (header gnus-newsgroup-headers)
+      (when (string-match regexp (funcall func header))
+       (push (mail-header-number header) articles)))
+    (nreverse articles)))
+
 (defun gnus-summary-find-matching (header regexp &optional backward unread
                                          not-case-fold)
   "Return a list of all articles that match REGEXP on HEADER.
@@ -7460,10 +7621,7 @@ BACKWARD is non-nil.  If BACKWARD is `all', do all articles.
 If UNREAD is non-nil, only unread articles will
 be taken into consideration.  If NOT-CASE-FOLD, case won't be folded
 in the comparisons."
-  (let ((data (if (eq backward 'all) gnus-newsgroup-data
-               (gnus-data-find-list
-                (gnus-summary-article-number) (gnus-data-list backward))))
-       (case-fold-search (not not-case-fold))
+  (let ((case-fold-search (not not-case-fold))
        articles d func)
     (if (consp header)
        (if (eq (car header) 'extra)
@@ -7475,14 +7633,17 @@ in the comparisons."
       (unless (fboundp (intern (concat "mail-header-" header)))
        (error "%s is not a valid header" header))
       (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
-    (while data
-      (setq d (car data))
-      (and (or (not unread)            ; We want all articles...
-              (gnus-data-unread-p d))  ; Or just unreads.
-          (vectorp (gnus-data-header d)) ; It's not a pseudo.
-          (string-match regexp (funcall func (gnus-data-header d))) ; Match.
-          (push (gnus-data-number d) articles)) ; Success!
-      (setq data (cdr data)))
+    (dolist (d (if (eq backward 'all)
+                  gnus-newsgroup-data
+                (gnus-data-find-list
+                 (gnus-summary-article-number)
+                 (gnus-data-list backward))))
+      (when (and (or (not unread)      ; We want all articles...
+                    (gnus-data-unread-p d)) ; Or just unreads.
+                (vectorp (gnus-data-header d)) ; It's not a pseudo.
+                (string-match regexp
+                              (funcall func (gnus-data-header d)))) ; Match.
+       (push (gnus-data-number d) articles))) ; Success!
     (nreverse articles)))
 
 (defun gnus-summary-execute-command (header regexp command &optional backward)
@@ -7493,9 +7654,11 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
    (list (let ((completion-ignore-case t))
           (completing-read
            "Header name: "
-           (mapcar (lambda (string) (list string))
-                   '("Number" "Subject" "From" "Lines" "Date"
-                     "Message-ID" "Xref" "References" "Body"))
+           (mapcar (lambda (header) (list (format "%s" header)))
+                   (append
+                    '("Number" "Subject" "From" "Lines" "Date"
+                      "Message-ID" "Xref" "References" "Body")
+                    gnus-extra-headers))
            nil 'require-match))
         (read-string "Regexp: ")
         (read-key-sequence "Command: ")
@@ -7547,8 +7710,7 @@ 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
 that name.  If FILENAME is a number, prompt the user for the name of the file
 to save in."
-  (interactive (list (ps-print-preprint current-prefix-arg)
-                    current-prefix-arg))
+  (interactive (list (ps-print-preprint current-prefix-arg)))
   (dolist (article (gnus-summary-work-articles n))
     (gnus-summary-select-article nil nil 'pseudo article)
     (gnus-eval-in-buffer-window gnus-article-buffer
@@ -7558,6 +7720,12 @@ to save in."
              (copy-to-buffer buffer (point-min) (point-max))
              (set-buffer buffer)
              (gnus-article-delete-invisible-text)
+             (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)))
              (let ((ps-left-header
                     (list
                      (concat "("
@@ -7571,8 +7739,12 @@ to save in."
                              (mail-header-date gnus-current-headers) ")"))))
                (gnus-run-hooks 'gnus-ps-print-hook)
                (save-excursion
-                 (ps-print-buffer-with-faces filename))))
-         (kill-buffer buffer))))))
+                 (if window-system
+                     (ps-spool-buffer-with-faces)
+                   (ps-spool-buffer)))))
+         (kill-buffer buffer))))
+    (gnus-summary-remove-process-mark article))
+  (ps-despool filename))
 
 (defun gnus-summary-show-article (&optional arg)
   "Force re-fetching of the current article.
@@ -7618,15 +7790,20 @@ without any article massaging functions being run."
     (require 'gnus-art)
     ;; Bind the article treatment functions to nil.
     (let ((gnus-have-all-headers t)
-         gnus-article-display-hook
          gnus-article-prepare-hook
          gnus-article-decode-hook
          gnus-break-pages
-         gnus-show-mime)
+         gnus-show-mime
+         (gnus-inhibit-treatment t))
       (gnus-summary-select-article nil 'force))))
   (gnus-summary-goto-subject gnus-current-article)
   (gnus-summary-position-point))
 
+(defun gnus-summary-show-raw-article ()
+  "Show the raw article without any article massaging functions being run."
+  (interactive)
+  (gnus-summary-show-article t))
+
 (defun gnus-summary-verbose-headers (&optional arg)
   "Toggle permanent full header display.
 If ARG is a positive number, turn header display on.
@@ -7681,7 +7858,7 @@ If ARG is a negative number, hide the unwanted header lines."
 (defun gnus-summary-show-all-headers ()
   "Make all header lines visible."
   (interactive)
-  (gnus-article-show-all-headers))
+  (gnus-summary-toggle-header 1))
 
 (defun gnus-summary-toggle-mime (&optional arg)
   "Toggle MIME processing.
@@ -8021,12 +8198,12 @@ latter case, they will be copied into the relevant groups."
       (gnus-summary-move-article n nil method)
     (gnus-summary-copy-article n nil method)))
 
-(defun gnus-summary-import-article (file)
+(defun gnus-summary-import-article (file &optional edit)
   "Import an arbitrary file into a mail newsgroup."
-  (interactive "fImport file: ")
+  (interactive "fImport file: \nP")
   (let ((group gnus-newsgroup-name)
        (now (current-time))
-       atts lines)
+       atts lines group-art)
     (unless (gnus-check-backend-function 'request-accept-article group)
       (error "%s does not support article importing" group))
     (or (file-readable-p file)
@@ -8037,19 +8214,55 @@ latter case, they will be copied into the relevant groups."
       (erase-buffer)
       (nnheader-insert-file-contents file)
       (goto-char (point-min))
-      (unless (nnheader-article-p)
+      (if (nnheader-article-p)
+          (save-restriction
+            (goto-char (point-min))
+            (search-forward "\n\n" nil t)
+            (narrow-to-region (point-min) (1- (point)))
+            (goto-char (point-min))
+            (unless (re-search-forward "^date:" nil t)
+              (goto-char (point-max))
+              (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
        ;; This doesn't look like an article, so we fudge some headers.
        (setq atts (file-attributes file)
              lines (count-lines (point-min) (point-max)))
        (insert "From: " (read-string "From: ") "\n"
                "Subject: " (read-string "Subject: ") "\n"
-               "Date: " (message-make-date (nth 5 atts))
-               "\n"
+               "Date: " (message-make-date (nth 5 atts)) "\n"
                "Message-ID: " (message-make-message-id) "\n"
                "Lines: " (int-to-string lines) "\n"
                "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
-      (gnus-request-accept-article group nil t)
-      (kill-buffer (current-buffer)))))
+      (setq group-art (gnus-request-accept-article group nil t))
+      (kill-buffer (current-buffer)))
+    (setq gnus-newsgroup-active (gnus-activate-group group))
+    (forward-line 1)
+    (gnus-summary-goto-article (cdr group-art) nil t)
+    (when edit
+      (gnus-summary-edit-article))))
+
+(defun gnus-summary-create-article ()
+  "Create an article in a mail newsgroup."
+  (interactive)
+  (let ((group gnus-newsgroup-name)
+       (now (current-time))
+       group-art)
+    (unless (gnus-check-backend-function 'request-accept-article group)
+      (error "%s does not support article importing" group))
+    (save-excursion
+      (set-buffer (gnus-get-buffer-create " *import file*"))
+      (erase-buffer)
+      (goto-char (point-min))
+      ;; This doesn't look like an article, so we fudge some headers.
+      (insert "From: " (read-string "From: ") "\n"
+             "Subject: " (read-string "Subject: ") "\n"
+             "Date: " (message-make-date now) "\n"
+             "Message-ID: " (message-make-message-id) "\n")
+      (setq group-art (gnus-request-accept-article group nil t))
+      (kill-buffer (current-buffer)))
+    (setq gnus-newsgroup-active (gnus-activate-group group))
+    (forward-line 1)
+    (gnus-summary-goto-article (cdr group-art) nil t)
+    (gnus-summary-edit-article)))
 
 (defun gnus-summary-article-posted-p ()
   "Say whether the current (mail) article is available from news as well.
@@ -8389,28 +8602,31 @@ If optional argument UNMARK is negative, mark articles as unread instead."
 If N is negative, mark backward instead.  If UNMARK is non-nil, remove
 the process mark instead.  The difference between N and the actual
 number of articles marked is returned."
-  (interactive "p")
-  (let ((backward (< n 0))
-       (n (abs n)))
-    (while (and
-           (> n 0)
-           (if unmark
+  (interactive "P")
+  (if (and (null n) (gnus-region-active-p))
+      (gnus-uu-mark-region (region-beginning) (region-end) unmark)
+    (setq n (prefix-numeric-value n))
+    (let ((backward (< n 0))
+         (n (abs n)))
+      (while (and
+             (> n 0)
+             (if unmark
                (gnus-summary-remove-process-mark
                 (gnus-summary-article-number))
-             (gnus-summary-set-process-mark (gnus-summary-article-number)))
-           (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
-      (setq n (1- n)))
-    (when (/= 0 n)
-      (gnus-message 7 "No more articles"))
-    (gnus-summary-recenter)
-    (gnus-summary-position-point)
-    n))
+               (gnus-summary-set-process-mark (gnus-summary-article-number)))
+             (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
+       (setq n (1- n)))
+      (when (/= 0 n)
+       (gnus-message 7 "No more articles"))
+      (gnus-summary-recenter)
+      (gnus-summary-position-point)
+      n)))
 
 (defun gnus-summary-unmark-as-processable (n)
   "Remove the process mark from the next N articles.
 If N is negative, unmark backward instead.  The difference between N and
 the actual number of articles unmarked is returned."
-  (interactive "p")
+  (interactive "P")
   (gnus-summary-mark-as-processable n t))
 
 (defun gnus-summary-unmark-all-processable ()
@@ -8429,7 +8645,7 @@ the actual number of articles unmarked is returned."
        (error "No such mark type: %s" type)
       (setq var (intern (format "gnus-newsgroup-%s" type)))
       (set var (cons article (symbol-value var)))
-      (if (memq type '(processable cached replied saved))
+      (if (memq type '(processable cached replied forwarded saved))
          (gnus-summary-update-secondary-mark article)
        ;;; !!! This is bobus.  We should find out what primary
        ;;; !!! mark we want to set.
@@ -8443,11 +8659,25 @@ the actual number of articles marked is returned."
   (gnus-summary-mark-forward n gnus-expirable-mark))
 
 (defun gnus-summary-mark-article-as-replied (article)
-  "Mark ARTICLE replied and update the summary line."
-  (push article gnus-newsgroup-replied)
-  (let ((buffer-read-only nil))
-    (when (gnus-summary-goto-subject article nil t)
-      (gnus-summary-update-secondary-mark article))))
+  "Mark ARTICLE as replied to and update the summary line.
+ARTICLE can also be a list of articles."
+  (interactive (list (gnus-summary-article-number)))
+  (let ((articles (if (listp article) article (list article))))
+    (dolist (article articles)
+      (push article gnus-newsgroup-replied)
+      (let ((buffer-read-only nil))
+       (when (gnus-summary-goto-subject article nil t)
+         (gnus-summary-update-secondary-mark article))))))
+
+(defun gnus-summary-mark-article-as-forwarded (article)
+  "Mark ARTICLE as forwarded and update the summary line.
+ARTICLE can also be a list of articles."
+  (let ((articles (if (listp article) article (list article))))
+    (dolist (article articles)
+      (push article gnus-newsgroup-forwarded)
+      (let ((buffer-read-only nil))
+       (when (gnus-summary-goto-subject article nil t)
+         (gnus-summary-update-secondary-mark article))))))
 
 (defun gnus-summary-set-bookmark (article)
   "Set a bookmark in current article."
@@ -8673,6 +8903,8 @@ Iff NO-EXPIRE, auto-expiry will be inhibited."
          gnus-cached-mark)
         ((memq article gnus-newsgroup-replied)
          gnus-replied-mark)
+        ((memq article gnus-newsgroup-forwarded)
+         gnus-forwarded-mark)
         ((memq article gnus-newsgroup-saved)
          gnus-saved-mark)
         (t gnus-no-mark))
@@ -8897,8 +9129,8 @@ even ticked and dormant ones."
     (let ((scored gnus-newsgroup-scored)
          headers h)
       (while scored
-       (unless (gnus-number-to-header (caar scored))
-         (and (setq h (gnus-summary-article-header (caar scored)))
+       (unless (gnus-summary-article-header (caar scored))
+         (and (setq h (gnus-number-to-header (caar scored)))
               (< (cdar scored) gnus-summary-expunge-below)
               (push h headers)))
        (setq scored (cdr scored)))
@@ -8906,18 +9138,23 @@ even ticked and dormant ones."
          (when (not no-error)
            (error "No expunged articles hidden"))
        (goto-char (point-min))
+       (push gnus-newsgroup-limit gnus-newsgroup-limits)
+       (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
+       (mapcar (lambda (x) (push (mail-header-number x) 
+                                 gnus-newsgroup-limit))
+               headers)
        (gnus-summary-prepare-unthreaded (nreverse headers))
        (goto-char (point-min))
        (gnus-summary-position-point)
        t))))
 
-(defun gnus-summary-catchup (&optional all quietly to-here not-mark)
+(defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
   "Mark all unread articles in this newsgroup as read.
 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 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."
@@ -8945,11 +9182,17 @@ The number of articles marked as read is returned."
            ;; We actually mark all articles as canceled, which we
            ;; have to do when using auto-expiry or adaptive scoring.
            (gnus-summary-show-all-threads)
-           (when (gnus-summary-first-subject (not all) t)
-             (while (and
-                     (if to-here (< (point) to-here) t)
-                     (gnus-summary-mark-article-as-read gnus-catchup-mark)
-                     (gnus-summary-find-next (not all) nil nil t))))
+           (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) nil nil t))))
+             (when (gnus-summary-first-subject (not all) t)
+               (while (and
+                       (if to-here (< (point) to-here) t)
+                       (gnus-summary-mark-article-as-read gnus-catchup-mark)
+                       (gnus-summary-find-next (not all) nil nil t)))))
            (gnus-set-mode-line 'summary))
          t))
     (gnus-summary-position-point)))
@@ -8966,6 +9209,18 @@ If ALL is non-nil, also mark ticked and dormant articles as read."
          (gnus-summary-catchup all t beg)))))
   (gnus-summary-position-point))
 
+(defun gnus-summary-catchup-from-here (&optional all)
+  "Mark all unticked articles after the current one as read.
+If ALL is non-nil, also mark ticked and dormant articles as read."
+  (interactive "P")
+  (save-excursion
+    (gnus-save-hidden-threads
+      (let ((beg (point)))
+       ;; 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."
   (interactive "P")
@@ -8973,7 +9228,8 @@ If ALL is non-nil, also mark ticked and dormant articles as read."
 
 (defun gnus-summary-catchup-and-exit (&optional all quietly)
   "Mark all unread articles in this group as read, then exit.
-If prefix argument ALL is non-nil, all articles are marked as read."
+If prefix argument ALL is non-nil, all articles are marked as read.
+If QUIETLY is non-nil, no questions will be asked."
   (interactive "P")
   (when (gnus-summary-catchup all quietly nil 'fast)
     ;; Select next newsgroup or exit.
@@ -9268,7 +9524,7 @@ taken."
 
 (defun gnus-summary-up-thread (n)
   "Go up thread N steps.
-If N is negative, go up instead.
+If N is negative, go down instead.
 Returns the difference between N and how many steps down that were
 taken."
   (interactive "p")
@@ -9357,6 +9613,18 @@ Argument REVERSE means reverse order."
   (interactive "P")
   (gnus-summary-sort 'chars reverse))
 
+(defun gnus-summary-sort-by-original (&optional reverse)
+  "Sort the summary buffer using the default sorting method.
+Argument REVERSE means reverse order."
+  (interactive "P")
+  (let* ((buffer-read-only)
+        (gnus-summary-prepare-hook nil))
+    ;; We do the sorting by regenerating the threads.
+    (gnus-summary-prepare)
+    ;; Hide subthreads if needed.
+    (when (and gnus-show-threads gnus-thread-hide-subtree)
+      (gnus-summary-hide-all-threads))))
+
 (defun gnus-summary-sort (predicate reverse)
   "Sort summary buffer by PREDICATE.  REVERSE means reverse order."
   (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
@@ -9429,7 +9697,10 @@ pipe those articles instead."
   (require 'gnus-art)
   (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
     (gnus-summary-save-article arg t))
-  (gnus-configure-windows 'pipe))
+  (let ((buffer (get-buffer "*Shell Command Output*")))
+    (if (and buffer 
+             (with-current-buffer buffer (> (point-max) (point-min))))
+        (gnus-configure-windows 'pipe))))
 
 (defun gnus-summary-save-article-mail (&optional arg)
   "Append the current article to an mail file.
@@ -9872,7 +10143,9 @@ If REVERSE, save parts that do not match TYPE."
         (mark (or (gnus-summary-article-mark) gnus-unread-mark))
         (inhibit-read-only t))
     ;; Eval the cars of the lists until we find a match.
-    (let ((default gnus-summary-default-score))
+    (let ((default gnus-summary-default-score)
+         (default-high gnus-summary-default-high-score)
+         (default-low gnus-summary-default-low-score))
       (while (and list
                  (not (eval (caar list))))
        (setq list (cdr list))))
@@ -9955,25 +10228,24 @@ If REVERSE, save parts that do not match TYPE."
 
 (defun gnus-offer-save-summaries ()
   "Offer to save all active summary buffers."
-  (save-excursion
-    (let ((buflist (buffer-list))
-         buffers bufname)
-      ;; Go through all buffers and find all summaries.
-      (while buflist
-       (and (setq bufname (buffer-name (car buflist)))
-            (string-match "Summary" bufname)
-            (save-excursion
-              (set-buffer bufname)
-              ;; We check that this is, indeed, a summary buffer.
-              (and (eq major-mode 'gnus-summary-mode)
-                   ;; Also make sure this isn't bogus.
-                   gnus-newsgroup-prepared
-                   ;; Also make sure that this isn't a dead summary buffer.
-                   (not gnus-dead-summary-mode)))
-            (push bufname buffers))
-       (setq buflist (cdr buflist)))
-      ;; Go through all these summary buffers and offer to save them.
-      (when buffers
+  (let (buffers)
+    ;; Go through all buffers and find all summaries.
+    (dolist (buffer (buffer-list))
+      (when (and (setq buffer (buffer-name buffer))
+                (string-match "Summary" buffer)
+                (save-excursion
+                  (set-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.
+                       gnus-newsgroup-prepared
+                       ;; Also make sure that this isn't a
+                       ;; dead summary buffer.
+                       (not gnus-dead-summary-mode))))
+       (push buffer buffers)))
+    ;; Go through all these summary buffers and offer to save them.
+    (when buffers
+      (save-excursion
        (map-y-or-n-p
         "Update summary buffer %s? "
         (lambda (buf)
@@ -10098,35 +10370,16 @@ If REVERSE, save parts that do not match TYPE."
   "Setup newsgroup default charset."
   (if (equal gnus-newsgroup-name "nndraft:drafts")
       (setq gnus-newsgroup-charset nil)
-    (let* ((name (and gnus-newsgroup-name
-                     (gnus-group-real-name gnus-newsgroup-name)))
-          (ignored-charsets
+    (let* ((ignored-charsets
            (or gnus-newsgroup-ephemeral-ignored-charsets
                (append
                 (and gnus-newsgroup-name
-                     (or (gnus-group-find-parameter gnus-newsgroup-name
-                                                    'ignored-charsets t)
-                         (let ((alist gnus-group-ignored-charsets-alist)
-                               elem (charsets nil))
-                           (while (setq elem (pop alist))
-                             (when (and name
-                                        (string-match (car elem) name))
-                               (setq alist nil
-                                     charsets (cdr elem))))
-                           charsets)))
+                     (gnus-parameter-ignored-charsets gnus-newsgroup-name))
                 gnus-newsgroup-ignored-charsets))))
       (setq gnus-newsgroup-charset
            (or gnus-newsgroup-ephemeral-charset
                (and gnus-newsgroup-name
-                    (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
-                        (let ((alist gnus-group-charset-alist)
-                              elem charset)
-                          (while (setq elem (pop alist))
-                            (when (and name
-                                       (string-match (car elem) name))
-                              (setq alist nil
-                                    charset (cadr elem))))
-                          charset)))
+                    (gnus-parameter-charset gnus-newsgroup-name))
                gnus-default-charset))
       (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
           ignored-charsets))))
@@ -10349,6 +10602,104 @@ returned."
     (gnus-set-mode-line 'summary)
     n))
 
+(defun gnus-summary-insert-articles (articles)
+  (when (setq articles
+             (gnus-set-difference articles
+                                  (mapcar (lambda (h) (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))
+    ;; Suppress duplicates?
+    (when gnus-suppress-duplicates
+      (gnus-dup-suppress-articles))
+    
+    ;; We might want to build some more threads first.
+    (when (and gnus-fetch-old-headers
+              (eq gnus-headers-retrieved-by 'nov))
+      (if (eq gnus-fetch-old-headers 'invisible)
+       (gnus-build-all-threads)
+       (gnus-build-old-threads)))
+    ;; Let the Gnus agent mark articles as read.
+    (when gnus-agent
+      (gnus-agent-get-undownloaded-list))
+    ;; Remove list identifiers from subject
+    (when gnus-list-identifiers
+      (gnus-summary-remove-list-identifiers))
+    ;; First and last article in this newsgroup.
+    (when gnus-newsgroup-headers
+      (setq gnus-newsgroup-begin
+           (mail-header-number (car gnus-newsgroup-headers))
+           gnus-newsgroup-end
+           (mail-header-number
+            (gnus-last-element gnus-newsgroup-headers))))
+    (when gnus-use-scoring
+      (gnus-possibly-score-headers))))
+
+(defun gnus-summary-insert-old-articles (&optional all)
+  "Insert all old articles in this group.
+If ALL is non-nil, already read articles become readable.
+If ALL is a number, fetch this number of articles."
+  (interactive "P")
+  (prog1
+      (let ((old (mapcar 'car gnus-newsgroup-data))
+           (i (car gnus-newsgroup-active))
+           older len)
+       (while (<= i (cdr gnus-newsgroup-active))
+         (or (memq i old) (push i older))
+         (incf i))
+       (setq len (length older))
+       (cond 
+        ((null older) nil)
+        ((numberp all) 
+         (if (< all len)
+             (setq older (subseq older 0 all))))
+        (all nil)
+        (t
+         (if (and (numberp gnus-large-newsgroup)
+                  (> len gnus-large-newsgroup))
+             (let ((input
+                    (read-string
+                     (format
+                      "How many articles from %s (default %d): "
+                      (gnus-limit-string 
+                       (gnus-group-decoded-name gnus-newsgroup-name) 35)
+                      len))))
+               (unless (string-match "^[ \t]*$" input) 
+                 (setq all (string-to-number input))
+                 (if (< all len)
+                     (setq older (subseq older 0 all))))))))
+       (if (not older)
+           (message "No old news.")
+         (gnus-summary-insert-articles older)
+         (gnus-summary-limit (gnus-union older old))))
+    (gnus-summary-position-point)))
+
+(defun gnus-summary-insert-new-articles ()
+  "Insert all new articles in this group."
+  (interactive)
+  (prog1
+      (let ((old (mapcar 'car gnus-newsgroup-data))
+           (old-active gnus-newsgroup-active)
+           (nnmail-fetched-sources (list t))
+           i new)
+       (setq gnus-newsgroup-active 
+             (gnus-activate-group gnus-newsgroup-name 'scan))
+       (setq i (1+ (cdr old-active)))
+       (while (<= i (cdr gnus-newsgroup-active))
+         (push i new)
+         (incf i))
+       (if (not new)
+           (message "No gnus is bad news.")
+         (setq new (nreverse new))
+         (gnus-summary-insert-articles new)
+         (setq gnus-newsgroup-unreads
+               (append gnus-newsgroup-unreads new))
+         (gnus-summary-limit (gnus-union old new))))
+    (gnus-summary-position-point)))
+
 (gnus-summary-make-all-marking-commands)
 
 (gnus-ems-redefine)