*** empty log message ***
[gnus] / lisp / gnus-sum.el
index e15f934..19ab7e6 100644 (file)
 (require 'gnus-int)
 (require 'gnus-undo)
 
-;; Belongs to to gnus.el
-(defgroup gnus-various nil
-  "Other Gnus options."
-  :link '(custom-manual "(gnus)Various Various")
-  :group 'gnus)
-
-;; Belongs to to gnus-group.el
-(defgroup gnus-group-select nil
-  "Selecting a Group."
-  :link '(custom-manual "(gnus)Selecting a Group")
-  :group 'gnus-group)
-
-;; Belongs to to gnus-uu.el
-(defgroup gnus-extract-view nil
-  "Viewing extracted files."
-  :link '(custom-manual "(gnus)Viewing Files")
-  :group 'gnus-extract)
-
-;; These belong here.
-(defgroup gnus-summary nil
-  "Summary buffers."
-  :link '(custom-manual "(gnus)The Summary Buffer")
-  :group 'gnus)
-
-(defgroup gnus-summary-exit nil
-  "Leaving summary buffers."
-  :link '(custom-manual "(gnus)Exiting the Summary Buffer")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-marks nil
-  "Marks used in summary buffers."
-  :link '(custom-manual "(gnus)Marking Articles")
-  :group 'gnus-summary)
-
-(defgroup gnus-thread nil
-  "Ordering articles according to replies."
-  :link '(custom-manual "(gnus)Threading")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-format nil
-  "Formatting of the summary buffer."
-  :link '(custom-manual "(gnus)Summary Buffer Format")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-choose nil
-  "Choosing Articles."
-  :link '(custom-manual "(gnus)Choosing Articles")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-maneuvering nil
-  "Summary movement commands."
-  :link '(custom-manual "(gnus)Summary Maneuvering")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-mail nil
-  "Mail group commands."
-  :link '(custom-manual "(gnus)Mail Group Commands")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-sort nil
-  "Sorting the summary buffer."
-  :link '(custom-manual "(gnus)Sorting")
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-visual nil
-  "Highlighting and menus in the summary buffer."
-  :link '(custom-manual "(gnus)Summary Highlighting")
-  :group 'gnus-visual
-  :group 'gnus-summary)
-
-(defgroup gnus-summary-various nil
-  "Various summary buffer options."
-  :link '(custom-manual "(gnus)Various Summary Stuff")
-  :group 'gnus-summary)
-
 (defcustom gnus-kill-summary-on-exit t
   "*If non-nil, kill the summary buffer when you exit from it.
 If nil, the summary will become a \"*Dead Summary*\" buffer, and
@@ -234,7 +159,7 @@ If nil, only the marking commands will go to the next (un)read article."
 (defcustom gnus-summary-default-score 0
   "*Default article score level.
 If this variable is nil, scoring will be disabled."
-  :group 'gnus-score
+  :group 'gnus-score-default
   :type '(choice (const :tag "disable")
                 integer))
 
@@ -389,9 +314,6 @@ It uses the same syntax as the `gnus-split-methods' variable."
                         (cons regexp (repeat string))
                         sexp)))
 
-;; Mark variables suggested by Thomas Michanek
-;; <Thomas.Michanek@telelogic.se>.
-
 (defcustom gnus-unread-mark ? 
   "*Mark used for unread articles."
   :group 'gnus-summary-marks
@@ -564,7 +486,7 @@ with some simple extensions:
   "*Mark all articles with a score below this variable as read.
 This variable is local to each summary buffer and usually set by the
 score file."
-  :group 'gnus-score
+  :group 'gnus-score-default
   :type 'integer)
 
 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
@@ -613,7 +535,7 @@ Some functions you can use are `+', `max', or `min'."
 
 (defcustom gnus-summary-expunge-below nil
   "All articles that have a score less than this variable will be expunged."
-  :group 'gnus-score
+  :group 'gnus-score-default
   :type '(choice (const :tag "off" nil)
                 integer))
 
@@ -622,7 +544,7 @@ Some functions you can use are `+', `max', or `min'."
 See `gnus-thread-score-function' for en explanation of what a
 \"thread score\" is."
   :group 'gnus-treading
-  :group 'gnus-score
+  :group 'gnus-score-default
   :type '(choice (const :tag "off" nil)
                 integer))
 
@@ -638,7 +560,8 @@ This hook is run before any variables are set in the summary buffer."
   :type 'hook)
 
 (defcustom gnus-summary-exit-hook nil
-  "*A hook called on exit from the summary buffer."
+  "*A hook called on exit from the summary buffer.
+It will be called with point in the group buffer."
   :group 'gnus-summary-exit
   :type 'hook)
 
@@ -687,7 +610,7 @@ is not run if `gnus-visual' is nil."
   :group 'gnus-summary-visual
   :type 'hook)
 
-(defcustom gnus-parse-headers-hook 
+(defcustom gnus-parse-headers-hook
   (list 'gnus-decode-rfc1522)
   "*A hook called before parsing the headers."
   :group 'gnus-various
@@ -721,12 +644,17 @@ automatically when it is selected."
   :group 'gnus-group-select
   :type 'hook)
 
+(defcustom gnus-ps-print-hook nil
+  "*A hook run before ps-printing something from Gnus."
+  :group 'gnus-summary
+  :type 'hook)
+
 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
   "Face used for highlighting the current article in the summary buffer."
   :group 'gnus-summary-visual
   :type 'face)
 
-(defcustom gnus-summary-highlight 
+(defcustom gnus-summary-highlight
   '(((= mark gnus-canceled-mark)
      . gnus-summary-cancelled-face)
     ((and (> score default)
@@ -752,13 +680,13 @@ automatically when it is selected."
      . gnus-summary-low-unread-face)
     ((and (= mark gnus-unread-mark))
      . gnus-summary-normal-unread-face)
-    ((> score default) 
+    ((> score default)
      . gnus-summary-high-read-face)
-    ((< score default) 
+    ((< score default)
      . gnus-summary-low-read-face)
-    (t 
+    (t
      . gnus-summary-normal-read-face))
-  "Controls the highlighting of summary buffer lines. 
+  "Controls the highlighting of summary buffer lines.
 
 A list of (FORM . FACE) pairs.  When deciding how a a particular
 summary line should be displayed, each form is evaluated.  The content
@@ -769,17 +697,18 @@ 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. 
+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)))
 
+
 ;;; Internal variables
 
 (defvar gnus-scores-exclude-files nil)
 
-(defvar gnus-summary-display-table 
+(defvar gnus-summary-display-table
   ;; Change the display table. Odd characters have a tendency to mess
   ;; up nicely formatted displays - we make all possible glyphs
   ;; display only a single character.
@@ -1105,30 +1034,6 @@ simple-first is t, first argument is already simplified."
     (equal s1
           (gnus-simplify-subject-fully s2)))))
 
-(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))
-            (push bufname buffers))
-       (setq buflist (cdr buflist)))
-      ;; Go through all these summary buffers and offer to save them.
-      (when buffers
-       (map-y-or-n-p
-        "Update summary buffer %s? "
-        (lambda (buf) (set-buffer buf) (gnus-summary-exit))
-        buffers)))))
-
 (defun gnus-summary-bubble-group ()
   "Increase the score of the current group.
 This is a handy function to add to `gnus-summary-exit-hook' to
@@ -1327,7 +1232,7 @@ increase the score of each group you read."
     "\M-#" gnus-uu-unmark-thread)
 
   (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
-    "g" gnus-summary-prepare 
+    "g" gnus-summary-prepare
     "c" gnus-summary-insert-cached-articles)
 
   (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
@@ -1374,7 +1279,8 @@ increase the score of each group you read."
     "r" gnus-summary-caesar-message
     "t" gnus-article-hide-headers
     "v" gnus-summary-verbose-headers
-    "m" gnus-summary-toggle-mime)
+    "m" gnus-summary-toggle-mime
+    "h" gnus-article-treat-html)
 
   (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
     "a" gnus-article-hide
@@ -1474,51 +1380,51 @@ increase the score of each group you read."
 
     '(("Default header"
        ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
-       :style radio 
+       :style radio
        :selected (null gnus-score-default-header)]
        ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'a)]
        ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 's)]
        ["Article body"
        (gnus-score-set-default 'gnus-score-default-header 'b)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'b )]
        ["All headers"
        (gnus-score-set-default 'gnus-score-default-header 'h)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'h )]
        ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'i )]
        ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 't )]
        ["Crossposting"
        (gnus-score-set-default 'gnus-score-default-header 'x)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'x )]
        ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'l )]
        ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'd )]
        ["Followups to author"
        (gnus-score-set-default 'gnus-score-default-header 'f)
-       :style radio 
+       :style radio
        :selected (eq gnus-score-default-header 'f )])
       ("Default type"
        ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
-       :style radio 
+       :style radio
        :selected (null gnus-score-default-type)]
        ;; The `:active' key is commented out in the following,
        ;; because the GNU Emacs hack to support radio buttons use
-       ;; active to indicate which button is selected.  
+       ;; active to indicate which button is selected.
        ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
-       :style radio 
+       :style radio
        ;; :active (not (memq gnus-score-default-header '(l d)))
        :selected (eq gnus-score-default-type 's)]
        ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
@@ -1530,34 +1436,34 @@ increase the score of each group you read."
        ;; :active (not (memq gnus-score-default-header '(l d)))
        :selected (eq gnus-score-default-type 'e)]
        ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
-       :style radio 
+       :style radio
        ;; :active (not (memq gnus-score-default-header '(l d)))
        :selected (eq gnus-score-default-type 'f)]
        ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'd))
        :selected (eq gnus-score-default-type 'b)]
        ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'd))
        :selected (eq gnus-score-default-type 'n)]
        ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'd))
        :selected (eq gnus-score-default-type 'a)]
        ["Less than number"
        (gnus-score-set-default 'gnus-score-default-type '<)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'l))
        :selected (eq gnus-score-default-type '<)]
        ["Equal to number"
        (gnus-score-set-default 'gnus-score-default-type '=)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'l))
        :selected (eq gnus-score-default-type '=)]
-       ["Greater than number" 
+       ["Greater than number"
        (gnus-score-set-default 'gnus-score-default-type '>)
-       :style radio 
+       :style radio
        ;; :active (eq (gnus-score-default-header 'l))
        :selected (eq gnus-score-default-type '>)])
       ["Default fold" gnus-score-default-fold-toggle
@@ -1575,7 +1481,7 @@ increase the score of each group you read."
        (gnus-score-set-default 'gnus-score-default-duration 't)
        :style radio
        :selected (eq gnus-score-default-duration 't)]
-       ["Immediate" 
+       ["Immediate"
        (gnus-score-set-default 'gnus-score-default-duration 'i)
        :style radio
        :selected (eq gnus-score-default-duration 'i)]))
@@ -1601,7 +1507,7 @@ increase the score of each group you read."
        ["Original" gnus-article-date-original t]
        ["Lapsed" gnus-article-date-lapsed t]
        ["User-defined" gnus-article-date-user t])
-       ("Filter"
+       ("Washing"
        ("Remove Blanks"
         ["Leading" gnus-article-strip-leading-blank-lines t]
         ["Multiple" gnus-article-strip-multiple-blank-lines t]
@@ -1613,6 +1519,7 @@ increase the score of each group you read."
        ["CR" gnus-article-remove-cr t]
        ["Show X-Face" gnus-article-display-x-face t]
        ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
+       ["UnHTMLize" gnus-article-treat-html t]
        ["Rot 13" gnus-summary-caesar-message t]
        ["Unix pipe" gnus-summary-pipe-message t]
        ["Add buttons" gnus-article-add-buttons t]
@@ -1666,8 +1573,6 @@ increase the score of each group you read."
        ["Remove article" gnus-cache-remove-article t])
        ["Enter digest buffer" gnus-summary-enter-digest-group t]
        ["Isearch article..." gnus-summary-isearch-article t]
-       ["Search articles forward..." gnus-summary-search-article-forward t]
-       ["Search articles backward..." gnus-summary-search-article-backward t]
        ["Beginning of the article" gnus-summary-beginning-of-article t]
        ["End of the article" gnus-summary-end-of-article t]
        ["Fetch parent of article" gnus-summary-refer-parent-article t]
@@ -1753,7 +1658,7 @@ increase the score of each group you read."
        ["Articles" gnus-summary-limit-to-articles t]
        ["Pop limit" gnus-summary-pop-limit t]
        ["Show dormant" gnus-summary-limit-include-dormant t]
-       ["Hide childless dormant" 
+       ["Hide childless dormant"
         gnus-summary-limit-exclude-childless-dormant t]
        ;;["Hide thread" gnus-summary-limit-exclude-thread t]
        ["Show expunged" gnus-summary-show-all-expunged t])
@@ -1814,6 +1719,8 @@ increase the score of each group you read."
        ["Toggle threading" gnus-summary-toggle-threads 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]
+       ["Search articles backward..." gnus-summary-search-article-backward t]
        ["Toggle line truncation" gnus-summary-toggle-truncation t]
        ["Expand window" gnus-summary-expand-window t]
        ["Expire expirable articles" gnus-summary-expire-articles
@@ -1863,8 +1770,8 @@ increase the score of each group you read."
                   ("permanent" nil)
                   ("immediate" now)))
          header)
-      (list 
-       (apply 
+      (list
+       (apply
        'nconc
        (list
         (if (eq type 'lower)
@@ -1873,17 +1780,17 @@ increase the score of each group you read."
        (let (outh)
          (while headers
            (setq header (car headers))
-           (setq outh 
-                 (cons 
-                  (apply 
+           (setq outh
+                 (cons
+                  (apply
                    'nconc
                    (list (car header))
                    (let ((ts (cdr (assoc (nth 2 header) types)))
                          outt)
                      (while ts
                        (setq outt
-                             (cons 
-                              (apply 
+                             (cons
+                              (apply
                                'nconc
                                (list (caar ts))
                                (let ((ps perms)
@@ -1901,7 +1808,7 @@ increase the score of each group you read."
                                                     (string= (nth 1 header)
                                                              "body"))
                                                 ""
-                                              (list 'gnus-summary-header 
+                                              (list 'gnus-summary-header
                                                     (nth 1 header)))
                                             (list 'quote (nth 1 (car ts)))
                                             (list 'gnus-score-default nil)
@@ -1962,7 +1869,7 @@ The following commands are available:
   (make-local-variable 'gnus-summary-line-format)
   (make-local-variable 'gnus-summary-line-format-spec)
   (make-local-variable 'gnus-summary-mark-positions)
-  (gnus-make-local-hook 'post-command-hook)
+  (make-local-hook 'post-command-hook)
   (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
   (run-hooks 'gnus-summary-mode-hook)
   (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
@@ -2019,6 +1926,9 @@ The following commands are available:
 (defmacro gnus-data-header (data)
   `(nth 3 ,data))
 
+(defmacro gnus-data-set-header (data header)
+  `(setf (nth 3 ,data) ,header))
+
 (defmacro gnus-data-level (data)
   `(nth 4 ,data))
 
@@ -2138,7 +2048,7 @@ The following commands are available:
         (level (gnus-data-level (car data)))
         children)
     (setq data (cdr data))
-    (while (and data           
+    (while (and data
                (= (gnus-data-level (car data)) (1+ level)))
       (push (gnus-data-number (car data)) children)
       (setq data (cdr data)))
@@ -2410,11 +2320,11 @@ This is all marks except unread, ticked, dormant, and expirable."
    (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
    (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
 
-(defun gnus-summary-insert-line (gnus-tmp-header 
-                                gnus-tmp-level gnus-tmp-current 
-                                gnus-tmp-unread gnus-tmp-replied 
+(defun gnus-summary-insert-line (gnus-tmp-header
+                                gnus-tmp-level gnus-tmp-current
+                                gnus-tmp-unread gnus-tmp-replied
                                 gnus-tmp-expirable gnus-tmp-subject-or-nil
-                                &optional gnus-tmp-dummy gnus-tmp-score 
+                                &optional gnus-tmp-dummy gnus-tmp-score
                                 gnus-tmp-process)
   (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
         (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
@@ -2499,7 +2409,7 @@ This is all marks except unread, ticked, dormant, and expirable."
 (defvar gnus-tmp-new-adopts nil)
 
 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
-  "Return the number of articles in THREAD.  
+  "Return the number of articles in THREAD.
 This may be 0 in some cases -- if none of the articles in
 the thread are to be displayed."
   (let* ((number
@@ -2548,6 +2458,10 @@ the thread are to be displayed."
 If SHOW-ALL is non-nil, already read articles are also listed.
 If NO-ARTICLE is non-nil, no article is selected initially.
 If NO-DISPLAY, don't generate a summary buffer."
+  ;; Killed foreign groups can't be entered.
+  (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)
   (let* ((new-group (gnus-summary-setup-buffer group))
         (quit-config (gnus-group-quit-config group))
@@ -2618,8 +2532,8 @@ If NO-DISPLAY, don't generate a summary buffer."
              (let ((gnus-newsgroup-dormant nil))
                (gnus-summary-initial-limit show-all))
            (gnus-summary-initial-limit show-all))
-       (setq gnus-newsgroup-limit 
-             (mapcar 
+       (setq gnus-newsgroup-limit
+             (mapcar
               (lambda (header) (mail-header-number header))
               gnus-newsgroup-headers)))
       ;; Generate the summary buffer.
@@ -2724,7 +2638,7 @@ If NO-DISPLAY, don't generate a summary buffer."
         ;; Just remove the leading "Re:".
         (t
          (gnus-simplify-subject-re subject))))
-  
+
   (if (and gnus-summary-gather-exclude-subject
           (string-match gnus-summary-gather-exclude-subject subject))
       nil                              ; This article shouldn't be gathered
@@ -2747,7 +2661,7 @@ If NO-DISPLAY, don't generate a summary buffer."
          subject hthread whole-subject)
       (while threads
        (setq subject (gnus-general-simplify-subject
-                      (setq whole-subject (mail-header-subject 
+                      (setq whole-subject (mail-header-subject
                                            (caar threads)))))
        (when subject
          (if (setq hthread (gnus-gethash subject hashtb))
@@ -2850,7 +2764,7 @@ If NO-DISPLAY, don't generate a summary buffer."
                ;; Deal with self-referencing References loops.
                (when (and (car (symbol-value refs))
                           (not (zerop
-                                (apply 
+                                (apply
                                  '+
                                  (mapcar
                                   (lambda (thread)
@@ -2869,9 +2783,9 @@ If NO-DISPLAY, don't generate a summary buffer."
 (defun gnus-build-sparse-threads ()
   (let ((headers gnus-newsgroup-headers)
        (deps gnus-newsgroup-dependencies)
-       header references generation relations 
+       header references generation relations
        cthread subject child end pthread relation)
-    ;; First we create an alist of generations/relations, where 
+    ;; First we create an alist of generations/relations, where
     ;; generations is how much we trust the relation, and the relation
     ;; is parent/child.
     (gnus-message 7 "Making sparse threads...")
@@ -2901,7 +2815,7 @@ If NO-DISPLAY, don't generate a summary buffer."
                (unless (car (symbol-value cthread))
                  ;; Make this article the parent of these threads.
                  (setcar (symbol-value cthread)
-                         (vector gnus-reffed-article-number 
+                         (vector gnus-reffed-article-number
                                  (cadddr relation)
                                  "" ""
                                  (cadr relation)
@@ -2998,13 +2912,25 @@ If NO-DISPLAY, don't generate a summary buffer."
        header level nil (gnus-article-mark article)
        (memq article gnus-newsgroup-replied)
        (memq article gnus-newsgroup-expirable)
-       (mail-header-subject header)
+       ;; Only insert the Subject string when it's different
+       ;; from the previous Subject string.
+       (unless (gnus-subject-equal
+               (condition-case ()
+                   (mail-header-subject
+                    (gnus-data-header
+                     (cadr
+                      (gnus-data-find-list
+                       article
+                       (gnus-data-list t)))))
+                 (error ""))
+               (mail-header-subject header))
+        (mail-header-subject header))
        nil (cdr (assq article gnus-newsgroup-scored))
        (memq article gnus-newsgroup-processable))
       (when length
        (gnus-data-update-list
         (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
-     
+
 (defun gnus-summary-update-article (article &optional iheader)
   "Update ARTICLE in the summary buffer."
   (set-buffer gnus-summary-buffer)
@@ -3015,7 +2941,7 @@ If NO-DISPLAY, don't generate a summary buffer."
         (references (mail-header-references header))
         (parent
          (gnus-id-to-thread
-          (or (gnus-parent-id 
+          (or (gnus-parent-id
                (when (and references
                           (not (equal "" references)))
                  references))
@@ -3088,7 +3014,7 @@ If NO-DISPLAY, don't generate a summary buffer."
 
 (defun gnus-parent-headers (headers &optional generation)
   "Return the headers of the GENERATIONeth parent of HEADERS."
-  (unless generation 
+  (unless generation
     (setq generation 1))
   (let (references parent)
     (while (and headers (not (zerop generation)))
@@ -3119,7 +3045,7 @@ If NO-DISPLAY, don't generate a summary buffer."
   (let ((level (gnus-summary-thread-level article))
        (refs (mail-header-references  (gnus-summary-article-header article)))
        particle)
-    (cond 
+    (cond
      ((null level) nil)
      ((zerop level) t)
      ((null refs) t)
@@ -3132,7 +3058,7 @@ If NO-DISPLAY, don't generate a summary buffer."
 (defun gnus-root-id (id)
   "Return the id of the root of the thread where ID appears."
   (let (last-id prev)
-    (while (and id (setq prev (car (gnus-gethash 
+    (while (and id (setq prev (car (gnus-gethash
                                    id gnus-newsgroup-dependencies))))
       (setq last-id id
            id (gnus-parent-id (mail-header-references prev))))
@@ -3201,7 +3127,7 @@ If NO-DISPLAY, don't generate a summary buffer."
       (gnus-remove-thread-1 (pop thread)))
     (when (setq d (gnus-data-find number))
       (goto-char (gnus-data-pos d))
-      (gnus-data-remove 
+      (gnus-data-remove
        number
        (- (gnus-point-at-bol)
          (prog1
@@ -3223,7 +3149,7 @@ If NO-DISPLAY, don't generate a summary buffer."
     (gnus-message 7 "Sorting articles...")
     (prog1
        (setq gnus-newsgroup-headers
-             (sort articles (gnus-make-sort-function 
+             (sort articles (gnus-make-sort-function
                              gnus-article-sort-functions)))
       (gnus-message 7 "Sorting articles...done"))))
 
@@ -3597,6 +3523,8 @@ or a straight list of headers."
   "Generate an unthreaded summary buffer based on HEADERS."
   (let (header number mark)
 
+    (beginning-of-line)
+
     (while headers
       ;; We may have to root out some bad articles...
       (when (memq (setq number (mail-header-number
@@ -3634,7 +3562,7 @@ If READ-ALL is non-nil, all articles in the group are selected."
         articles fetched-articles cached)
 
     (unless (gnus-check-server
-            (setq gnus-current-select-method 
+            (setq gnus-current-select-method
                   (gnus-find-method-for-group group)))
       (error "Couldn't open server"))
 
@@ -3671,6 +3599,10 @@ If READ-ALL is non-nil, all articles in the group are selected."
 
     (setq gnus-newsgroup-processable nil)
 
+    (gnus-update-read-articles group gnus-newsgroup-unreads)
+    (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
+      (gnus-group-update-group group))
+
     (setq articles (gnus-articles-to-read group read-all))
 
     (cond
@@ -3696,7 +3628,7 @@ If READ-ALL is non-nil, all articles in the group are selected."
                                     (not (eq gnus-fetch-old-headers 'some))
                                     (not (numberp gnus-fetch-old-headers)))
                                    (> (length articles) 1))))))
-               (gnus-get-newsgroup-headers-xover 
+               (gnus-get-newsgroup-headers-xover
                 articles nil nil gnus-newsgroup-name t)
              (gnus-get-newsgroup-headers)))
       (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
@@ -3894,7 +3826,7 @@ If READ-ALL is non-nil, all articles in the group are selected."
                                                (car type))))))
          (push (cons (cdr type)
                      (if (memq (cdr type) uncompressed) list
-                       (gnus-compress-sequence 
+                       (gnus-compress-sequence
                         (set symbol (sort list '<)) t)))
                newmarked)))
 
@@ -3947,12 +3879,21 @@ If WHERE is `summary', the summary mode line format will be used."
                    (gnus-mode-string-quote
                     (mail-header-subject gnus-current-headers))
                  ""))
-              max-len
+              bufname-length max-len
               gnus-tmp-header);; passed as argument to any user-format-funcs
          (setq mode-string (eval mformat))
+         (setq bufname-length (if (string-match "%b" mode-string)
+                                  (- (length
+                                      (buffer-name
+                                       (if (eq where 'summary)
+                                           nil
+                                         (get-buffer gnus-article-buffer))))
+                                     2)
+                                0))
          (setq max-len (max 4 (if gnus-mode-non-string-length
                                   (- (window-width)
-                                     gnus-mode-non-string-length)
+                                     gnus-mode-non-string-length
+                                     bufname-length)
                                 (length mode-string))))
          ;; We might have to chop a bit of the string off...
          (when (> (length mode-string) max-len)
@@ -3962,9 +3903,8 @@ If WHERE is `summary', the summary mode line format will be used."
          ;; Pad the mode string a bit.
          (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
       ;; Update the mode line.
-      (setq mode-line-buffer-identification 
-           (gnus-mode-line-buffer-identification
-            (list mode-string)))
+      (setq mode-line-buffer-identification
+           (gnus-mode-line-buffer-identification (list mode-string)))
       (set-buffer-modified-p t))))
 
 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
@@ -4218,18 +4158,14 @@ The resulting hash table is returned, or nil if no Xrefs were found."
          (if (boundp (setq id-dep (intern id dependencies)))
              (if (and (car (symbol-value id-dep))
                       (not force-new))
-                 ;; An article with this Message-ID has already
-                 ;; been seen, so we ignore this one, except we add
-                 ;; any additional Xrefs (in case the two articles
-                 ;; came from different servers).
+                 ;; An article with this Message-ID has already been seen,
+                 ;; so we rename the Message-ID.
                  (progn
-                   (mail-header-set-xref
-                    (car (symbol-value id-dep))
-                    (concat (or (mail-header-xref
-                                 (car (symbol-value id-dep)))
-                                "")
-                            (or (mail-header-xref header) "")))
-                   (setq header nil))
+                   (set
+                    (setq id-dep (intern (setq id (nnmail-message-id))
+                                         dependencies))
+                    (list header))
+                   (mail-header-set-id header id))
                (setcar (symbol-value id-dep) header))
            (set id-dep (list header)))
          (when  header
@@ -4300,8 +4236,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
                 (gnus-nov-read-integer) ; lines
                 (if (= (following-char) ?\n)
                     nil
-                  (gnus-nov-field))    ; misc
-                )))
+                  (gnus-nov-field))))) ; misc
 
       (widen))
 
@@ -4313,17 +4248,13 @@ The resulting hash table is returned, or nil if no Xrefs were found."
        (if (and (car (symbol-value id-dep))
                 (not force-new))
            ;; An article with this Message-ID has already been seen,
-           ;; so we ignore this one, except we add any additional
-           ;; Xrefs (in case the two articles came from different
-           ;; servers.
+           ;; so we rename the Message-ID.
            (progn
-             (mail-header-set-xref
-              (car (symbol-value id-dep))
-              (concat (or (mail-header-xref
-                           (car (symbol-value id-dep)))
-                          "")
-                      (or (mail-header-xref header) "")))
-             (setq header nil))
+             (set
+              (setq id-dep (intern (setq id (nnmail-message-id))
+                                   dependencies))
+              (list header))
+             (mail-header-set-id header id))
          (setcar (symbol-value id-dep) header))
       (set id-dep (list header)))
     (when header
@@ -4335,7 +4266,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
     header))
 
 ;; Goes through the xover lines and returns a list of vectors
-(defun gnus-get-newsgroup-headers-xover (sequence &optional 
+(defun gnus-get-newsgroup-headers-xover (sequence &optional
                                                  force-new dependencies
                                                  group also-fetch-heads)
   "Parse the news overview data in the server buffer, and return a
@@ -4379,9 +4310,9 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
       ;; headers using HEAD.
       (if (or (not also-fetch-heads)
              (not sequence))
+         ;; We (probably) got all the headers.
          (nreverse headers)
-       (let ((gnus-nov-is-evil t)
-             (nntp-nov-is-evil t))
+       (let ((gnus-nov-is-evil t))
          (nconc
           (nreverse headers)
           (when (gnus-retrieve-headers sequence group)
@@ -4422,7 +4353,7 @@ This is meant to be called in `gnus-article-internal-prepare-hook'."
                 old-header)
        (when (setq d (gnus-data-find (mail-header-number old-header)))
          (goto-char (gnus-data-pos d))
-         (gnus-data-remove 
+         (gnus-data-remove
           number
           (- (gnus-point-at-bol)
              (prog1
@@ -4474,10 +4405,7 @@ taken into consideration."
                   (gnus-summary-find-next nil article)))
          (decf n)))
       (nreverse articles)))
-   ((and (boundp 'transient-mark-mode)
-        transient-mark-mode
-        (boundp 'mark-active)
-        mark-active)
+   ((gnus-region-active-p)
     ;; Work on the region between point and mark.
     (let ((max (max (point) (mark)))
          articles article)
@@ -4652,7 +4580,7 @@ displayed, no centering will be performed."
        ;; possible valid number, or the second line from the top,
        ;; whichever is the least.
        (set-window-start
-        window (min bottom (save-excursion 
+        window (min bottom (save-excursion
                              (forward-line (- top)) (point)))))
       ;; Do horizontal recentering while we're at it.
       (when (and (get-buffer-window (current-buffer) t)
@@ -4775,9 +4703,8 @@ The prefix argument ALL means to select all articles."
        (group gnus-newsgroup-name))
     (setq gnus-newsgroup-begin nil)
     (gnus-summary-exit)
-    ;; We have to adjust the point of group mode buffer because the
-    ;; current point was moved to the next unread newsgroup by
-    ;; exiting.
+    ;; 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)
     (when rescan
       (save-excursion
@@ -5344,6 +5271,10 @@ If BACKWARD, the previous article is selected instead of the next."
     (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
       (gnus-summary-jump-to-group gnus-newsgroup-name))
     (let ((cmd last-command-char)
+         (point
+          (save-excursion
+            (set-buffer gnus-group-buffer)
+            (point)))
          (group
           (if (eq gnus-keep-same-level 'best)
               (gnus-summary-best-group gnus-newsgroup-name)
@@ -5372,16 +5303,16 @@ If BACKWARD, the previous article is selected instead of the next."
        (t
        (when (gnus-key-press-event-p last-input-event)
          (gnus-summary-walk-group-buffer
-          gnus-newsgroup-name cmd unread backward))))))))
+          gnus-newsgroup-name cmd unread backward point))))))))
 
-(defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
+(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
   (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
                      (?\C-p (gnus-group-prev-unread-group 1))))
        (cursor-in-echo-area t)
        keve key group ended)
     (save-excursion
       (set-buffer gnus-group-buffer)
-      (gnus-summary-jump-to-group from-group)
+      (goto-char start)
       (setq group
            (if (eq gnus-keep-same-level 'best)
                (gnus-summary-best-group gnus-newsgroup-name)
@@ -5421,7 +5352,7 @@ If BACKWARD, the previous article is selected instead of the next."
 (defun gnus-summary-next-unread-article ()
   "Select unread article after current one."
   (interactive)
-  (gnus-summary-next-article 
+  (gnus-summary-next-article
    (or (not (eq gnus-summary-goto-unread 'never))
        (gnus-summary-last-article-p (gnus-summary-article-number)))
    (and gnus-auto-select-same
@@ -5454,7 +5385,7 @@ article."
   (setq gnus-summary-buffer (current-buffer))
   (gnus-set-global-variables)
   (let ((article (gnus-summary-article-number))
-       (article-window (get-buffer-window gnus-article-buffer))
+       (article-window (get-buffer-window gnus-article-buffer t))
        (endp nil))
     (gnus-configure-windows 'article)
     (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
@@ -5489,7 +5420,8 @@ article."
 Argument LINES specifies lines to be scrolled down."
   (interactive "P")
   (gnus-set-global-variables)
-  (let ((article (gnus-summary-article-number)))
+  (let ((article (gnus-summary-article-number))
+       (article-window (get-buffer-window gnus-article-buffer t)))
     (gnus-configure-windows 'article)
     (if (or (null gnus-current-article)
            (null gnus-article-current)
@@ -5498,8 +5430,9 @@ Argument LINES specifies lines to be scrolled down."
        ;; Selected subject is different from current article's.
        (gnus-summary-display-article article)
       (gnus-summary-recenter)
-      (gnus-eval-in-buffer-window gnus-article-buffer
-       (gnus-article-prev-page lines))))
+      (when article-window
+       (gnus-eval-in-buffer-window gnus-article-buffer
+         (gnus-article-prev-page lines)))))
   (gnus-summary-position-point))
 
 (defun gnus-summary-scroll-up (lines)
@@ -5650,7 +5583,7 @@ If not given a prefix, use the process marked articles instead."
 If given a prefix, remove all limits."
   (interactive "P")
   (gnus-set-global-variables)
-  (when total 
+  (when total
     (setq gnus-newsgroup-limits
          (list (mapcar (lambda (h) (mail-header-number h))
                        gnus-newsgroup-headers))))
@@ -5680,7 +5613,7 @@ If given a prefix, remove all limits."
   (gnus-summary-limit-to-subject from "from"))
 
 (defun gnus-summary-limit-to-age (age &optional younger-p)
-  "Limit the summary buffer to articles that are older than (or equal) AGE days. 
+  "Limit the summary buffer to articles that are older than (or equal) AGE days.
 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
 articles that are younger than AGE days."
   (interactive "nTime in days: \nP")
@@ -5730,7 +5663,7 @@ with MARKS.  MARKS can either be a string of marks or a list of marks.
 Returns how many articles were removed."
   (interactive "sMarks: ")
   (gnus-summary-limit-to-marks marks t))
-  
+
 (defun gnus-summary-limit-to-marks (marks &optional reverse)
   "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
 If REVERSE (the prefix), limit the summary buffer to articles that are
@@ -5798,7 +5731,7 @@ Returns how many articles were removed."
     ;; children.
     (while (setq d (pop data))
       (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
-               (and (setq children 
+               (and (setq children
                           (gnus-article-children (gnus-data-number d)))
                     (let (found)
                       (while children
@@ -6015,7 +5948,7 @@ fetch-old-headers verbiage, and so on."
                     (gnus-nocem-unwanted-article-p
                      (mail-header-id (car thread))))
                (progn
-                 (setq gnus-newsgroup-reads 
+                 (setq gnus-newsgroup-reads
                        (delq number gnus-newsgroup-unreads))
                  t))))
          ;; Nope, invisible article.
@@ -6120,17 +6053,17 @@ Return how many articles were fetched."
       (setq message-id (concat message-id ">")))
     (let* ((header (gnus-id-to-header message-id))
           (sparse (and header
-                       (gnus-summary-article-sparse-p 
+                       (gnus-summary-article-sparse-p
                         (mail-header-number header)))))
       (if header
          (prog1
              ;; The article is present in the buffer, to we just go to it.
-             (gnus-summary-goto-article 
+             (gnus-summary-goto-article
               (mail-header-number header) nil header)
            (when sparse
              (gnus-summary-update-article (mail-header-number header))))
        ;; We fetch the article
-       (let ((gnus-override-method 
+       (let ((gnus-override-method
               (and (gnus-news-group-p gnus-newsgroup-name)
                    gnus-refer-article-method))
              number)
@@ -6179,7 +6112,7 @@ to guess what the document format is."
       (unwind-protect
           (if (gnus-group-read-ephemeral-group
                name `(nndoc ,name (nndoc-address ,(get-buffer dig))
-                            (nndoc-article-type 
+                            (nndoc-article-type
                              ,(if force 'digest 'guess))) t)
               ;; Make all postings to this group go to the parent group.
               (nconc (gnus-info-params (gnus-get-info name))
@@ -6240,7 +6173,7 @@ Obeys the standard process/prefix convention."
        (cons (current-buffer) 'summary)))
      (t
       (error "Couldn't select virtual nndoc group")))))
-      
+
 (defun gnus-summary-isearch-article (&optional regexp-p)
   "Do incremental search forward on the current article.
 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
@@ -6289,6 +6222,7 @@ Optional argument BACKWARD means do search for backward.
        (gnus-article-display-hook nil)
        (gnus-mark-article-hook nil)    ;Inhibit marking as read.
        (gnus-use-article-prefetch nil)
+       (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
        (sum (current-buffer))
        (found nil)
        point)
@@ -6434,6 +6368,7 @@ to save in."
            (copy-to-buffer buffer (point-min) (point-max))
            (set-buffer buffer)
            (gnus-article-delete-invisible-text)
+           (run-hooks 'gnus-ps-print-hook)
            (ps-print-buffer-with-faces filename))
        (kill-buffer buffer)))))
 
@@ -6543,7 +6478,7 @@ forward."
        (gnus-remove-text-with-property 'gnus-prev)
        (gnus-remove-text-with-property 'gnus-next)))))
 
-(defun gnus-summary-move-article (&optional n to-newsgroup 
+(defun gnus-summary-move-article (&optional n to-newsgroup
                                            select-method action)
   "Move the current article to a different newsgroup.
 If N is a positive number, move the N next articles.
@@ -6593,10 +6528,10 @@ and `request-accept' functions."
             (symbol-value (intern (format "gnus-current-%s-group" action)))
             articles prefix))
       (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
-    (setq to-method (or select-method 
+    (setq to-method (or select-method
                        (gnus-group-name-to-method to-newsgroup)))
     ;; Check the method we are to move this article to...
-    (unless (gnus-check-backend-function 
+    (unless (gnus-check-backend-function
             'request-accept-article (car to-method))
       (error "%s does not support article copying" (car to-method)))
     (unless (gnus-check-server to-method)
@@ -6634,20 +6569,29 @@ and `request-accept' functions."
                      " ")))
           (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
                                  ":" article))
-          (unless xref 
+          (unless xref
             (setq xref (list (system-name))))
           (setq new-xref
                 (concat
-                 (mapconcat 'identity 
+                 (mapconcat 'identity
                             (delete "Xref:" (delete new-xref xref))
                             " ")
-                 new-xref))
+                 " " new-xref))
           (save-excursion
             (set-buffer copy-buf)
+            ;; First put the article in the destination group.
             (gnus-request-article-this-buffer article gnus-newsgroup-name)
-            (nnheader-replace-header "xref" new-xref)
-            (gnus-request-accept-article
-             to-newsgroup select-method (not articles)))))))
+            (setq art-group
+                  (gnus-request-accept-article
+                   to-newsgroup select-method (not articles)))
+            (setq new-xref (concat new-xref " " (car art-group)
+                                   ":" (cdr art-group)))
+            ;; Now we have the new Xrefs header, so we insert
+            ;; it and replace the new article.
+            (nnheader-replace-header "Xref" new-xref)
+            (gnus-request-replace-article
+             (cdr art-group) to-newsgroup (current-buffer))
+            art-group)))))
       (if (not art-group)
          (gnus-message 1 "Couldn't %s article %s"
                        (cadr (assq action names)) article)
@@ -6657,7 +6601,7 @@ and `request-accept' functions."
                 (gnus-gethash
                  (gnus-group-prefixed-name
                   (car art-group)
-                  (or select-method 
+                  (or select-method
                       (gnus-find-method-for-group to-newsgroup)))
                  gnus-newsrc-hashtb)))
               (info (nth 2 entry))
@@ -6689,6 +6633,13 @@ and `request-accept' functions."
                 (memq article gnus-newsgroup-dormant)
                 (memq article gnus-newsgroup-unreads)))
 
+             (when (and (equal to-group gnus-newsgroup-name)
+                        (not (memq article gnus-newsgroup-unreads)))
+               ;; Mark this article as read in this group.
+               (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
+               (setcdr (gnus-active to-group) to-article)
+               (setcdr gnus-newsgroup-active to-article))
+
              (while marks
                (when (memq article (symbol-value
                                     (intern (format "gnus-newsgroup-%s"
@@ -6701,7 +6652,7 @@ and `request-accept' functions."
                               (symbol-value
                                (intern (format "gnus-newsgroup-%s"
                                                (caar marks)))))))
-                 ;; Copy mark to other group.
+                 ;; Copy the marks to other group.
                  (gnus-add-marked-articles
                   to-group (cdar marks) (list to-article) info))
                (setq marks (cdr marks)))))
@@ -6712,9 +6663,7 @@ and `request-accept' functions."
            (save-excursion
              (set-buffer copy-buf)
              (gnus-request-article-this-buffer article gnus-newsgroup-name)
-             (nnheader-replace-header
-              "xref" (concat new-xref " " (car art-group)
-                             ":" (cdr art-group)))
+             (nnheader-replace-header "Xref" new-xref)
              (gnus-request-replace-article
               article gnus-newsgroup-name (current-buffer)))))
 
@@ -6725,7 +6674,7 @@ and `request-accept' functions."
     ;; Re-activate all groups that have been moved to.
     (while to-groups
       (gnus-activate-group (pop to-groups)))
-    
+
     (gnus-kill-buffer copy-buf)
     (gnus-summary-position-point)
     (gnus-set-mode-line 'summary)))
@@ -6736,7 +6685,7 @@ If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
 re-spool using this method."
   (interactive "P")
-  (gnus-summary-move-article n nil select-method 'copy))
+  (gnus-summary-move-article n to-newsgroup select-method 'copy))
 
 (defun gnus-summary-crosspost-article (&optional n)
   "Crosspost the current article to some other group."
@@ -6744,7 +6693,7 @@ re-spool using this method."
   (gnus-summary-move-article n nil nil 'crosspost))
 
 (defcustom gnus-summary-respool-default-method nil
-  "Default method for respooling an article.  
+  "Default method for respooling an article.
 If nil, use to the current newsgroup method."
   :type 'gnus-select-method-name
   :group 'gnus-summary-mail)
@@ -6763,7 +6712,7 @@ Respooling can be done both from mail groups and \"real\" newsgroups.
 In the former case, the articles in question will be moved from the
 current group into whatever groups they are destined to.  In the
 latter case, they will be copied into the relevant groups."
-  (interactive 
+  (interactive
    (list current-prefix-arg
         (let* ((methods (gnus-methods-using 'respool))
                (methname
@@ -6771,12 +6720,12 @@ latter case, they will be copied into the relevant groups."
                                  (car (gnus-find-method-for-group
                                        gnus-newsgroup-name)))))
                (method
-                (gnus-completing-read 
+                (gnus-completing-read
                  methname "What backend do you want to use when respooling?"
                  methods nil t nil 'gnus-mail-method-history))
                ms)
           (cond
-           ((zerop (length (setq ms (gnus-servers-using-backend 
+           ((zerop (length (setq ms (gnus-servers-using-backend
                                      (intern method)))))
             (list (intern method) ""))
            ((= 1 (length ms))
@@ -6936,7 +6885,9 @@ delete these instead."
        ;; after all.
        (unless (memq (car articles) not-deleted)
          (gnus-summary-mark-article (car articles) gnus-canceled-mark))
-       (setq articles (cdr articles))))
+       (setq articles (cdr articles)))
+      (when not-deleted
+       (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
     (gnus-summary-position-point)
     (gnus-set-mode-line 'summary)
     not-deleted))
@@ -6945,7 +6896,7 @@ delete these instead."
   "Edit the current article.
 This will have permanent effect only in mail groups.
 If FORCE is non-nil, allow editing of articles even in read-only
-groups." 
+groups."
   (interactive "P")
   (save-excursion
     (set-buffer gnus-summary-buffer)
@@ -6983,25 +6934,43 @@ groups."
        (save-excursion
          (save-restriction
            (message-narrow-to-head)
-           (let ((header (nnheader-parse-head t)))
-             (set-buffer buffer)
-             (mail-header-set-number header (cdr gnus-article-current))
-             (gnus-summary-update-article-line
-              (cdr gnus-article-current) header))))
+           (let ((head (buffer-string))
+                 header)
+             (nnheader-temp-write nil
+               (insert (format "211 %d Article retrieved.\n"
+                               (cdr gnus-article-current)))
+               (insert head)
+               (insert ".\n")
+               (let ((nntp-server-buffer (current-buffer)))
+                 (setq header (car (gnus-get-newsgroup-headers
+                                    (save-excursion
+                                      (set-buffer gnus-summary-buffer)
+                                      gnus-newsgroup-dependencies)
+                                    t))))
+               (save-excursion
+                 (set-buffer gnus-summary-buffer)
+                 (gnus-data-set-header
+                  (gnus-data-find (cdr gnus-article-current))
+                  header)
+                 (gnus-summary-update-article-line
+                  (cdr gnus-article-current) header))))))
       ;; Update threads.
       (set-buffer (or buffer gnus-summary-buffer))
       (gnus-summary-update-article (cdr gnus-article-current)))
     ;; Prettify the article buffer again.
     (save-excursion
       (set-buffer gnus-article-buffer)
-      (run-hooks 'gnus-article-display-hook))
+      (run-hooks 'gnus-article-display-hook)
+      (set-buffer gnus-original-article-buffer)
+      (gnus-request-article
+       (cdr gnus-article-current) (car gnus-article-current) (current-buffer)))
     ;; Prettify the summary buffer line.
     (when (gnus-visual-p 'summary-highlight 'highlight)
       (run-hooks 'gnus-visual-mark-article-hook))))
 
 (defun gnus-summary-edit-wash (key)
   "Perform editing command in the article buffer."
-  (interactive 
+  (interactive
    (list
     (progn
       (message "%s" (concat (this-command-keys) "- "))
@@ -7020,11 +6989,9 @@ groups."
   (let (gnus-mark-article-hook)
     (gnus-summary-select-article)
     (save-excursion
-      (set-buffer gnus-article-buffer)
+      (set-buffer gnus-original-article-buffer)
       (save-restriction
-       (goto-char (point-min))
-       (search-forward "\n\n")
-       (narrow-to-region (point-min) (point))
+       (message-narrow-to-head)
        (message "This message would go to %s"
                 (mapconcat 'car (nnmail-article-group 'identity) ", "))))))
 
@@ -7543,7 +7510,7 @@ even ticked and dormant ones."
   (save-excursion
     (set-buffer gnus-summary-buffer)
     (goto-char (point-min))
-    (while 
+    (while
        (progn
          (and (< (gnus-summary-article-score) score)
               (gnus-summary-mark-article nil mark))
@@ -7609,7 +7576,7 @@ even ticked and dormant ones."
 
 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
   "Mark all unread articles in this newsgroup as read.
-If prefix argument ALL is non-nil, ticked and dormant articles will 
+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
@@ -7749,7 +7716,7 @@ with that article."
     (gnus-summary-goto-subject article)))
 
 (defun gnus-summary-reparent-thread ()
-  "Make current article child of the marked (or previous) article.
+  "Make the current article child of the marked (or previous) article.
 
 Note that the re-threading will only work if `gnus-thread-ignore-subject'
 is non-nil or the Subject: of both articles are the same."
@@ -7761,7 +7728,7 @@ is non-nil or the Subject: of both articles are the same."
   (save-window-excursion
     (let ((gnus-article-buffer " *reparent*")
          (current-article (gnus-summary-article-number))
-                                       ; first grab the marked article, otherwise one line up.
+         ;; First grab the marked article, otherwise one line up.
          (parent-article (if (not (null gnus-newsgroup-processable))
                              (car gnus-newsgroup-processable)
                            (save-excursion
@@ -7770,24 +7737,23 @@ is non-nil or the Subject: of both articles are the same."
                                (error "Beginning of summary buffer."))))))
       (unless (not (eq current-article parent-article))
        (error "An article may not be self-referential."))
-      (let ((message-id (mail-header-id 
+      (let ((message-id (mail-header-id
                         (gnus-summary-article-header parent-article))))
        (unless (and message-id (not (equal message-id "")))
          (error "No message-id in desired parent."))
        (gnus-summary-select-article t t nil current-article)
-       (set-buffer gnus-article-buffer)
-       (setq buffer-read-only nil)
+       (set-buffer gnus-original-article-buffer)
        (let ((buf (format "%s" (buffer-string))))
-         (erase-buffer)
-         (insert buf))
-       (goto-char (point-min))
-       (if (search-forward-regexp "^References: " nil t)
-           (insert message-id " " )
-         (insert "References: " message-id "\n"))
-       (unless (gnus-request-replace-article current-article
-                                             (car gnus-article-current)
-                                             gnus-article-buffer)
-         (error "Couldn't replace article."))
+         (nnheader-temp-write nil
+           (insert buf)
+           (goto-char (point-min))
+           (if (search-forward-regexp "^References: " nil t)
+               (insert message-id " " )
+             (insert "References: " message-id "\n"))
+           (unless (gnus-request-replace-article
+                    current-article (car gnus-article-current)
+                    (current-buffer))
+             (error "Couldn't replace article."))))
        (set-buffer gnus-summary-buffer)
        (gnus-summary-unmark-all-processable)
        (gnus-summary-rethread-current)
@@ -7904,7 +7870,7 @@ If SILENT, don't output messages."
     (while (and (> n 0)
                (gnus-summary-go-to-next-thread backward))
       (decf n))
-    (unless silent 
+    (unless silent
       (gnus-summary-position-point))
     (when (and (not silent) (/= 0 n))
       (gnus-message 7 "No more threads"))
@@ -8073,7 +8039,7 @@ The variable `gnus-default-article-saver' specifies the saver function."
   (interactive "P")
   (gnus-set-global-variables)
   (let* ((articles (gnus-summary-work-articles n))
-        (save-buffer (save-excursion 
+        (save-buffer (save-excursion
                        (nnheader-set-temp-buffer " *Gnus Save*")))
         (num (length articles))
         header article file)
@@ -8253,7 +8219,7 @@ save those articles instead."
                                  nil nil
                                  'gnus-group-history))
           (t
-           (gnus-completing-read nil prom 
+           (gnus-completing-read nil prom
                                  (mapcar (lambda (el) (list el))
                                          (nreverse split-name))
                                  nil nil nil
@@ -8261,12 +8227,14 @@ save those articles instead."
     (when to-newsgroup
       (if (or (string= to-newsgroup "")
              (string= to-newsgroup prefix))
-         (setq to-newsgroup (or default "")))
+         (setq to-newsgroup default))
+      (unless to-newsgroup
+       (error "No group name entered"))
       (or (gnus-active to-newsgroup)
          (gnus-activate-group to-newsgroup)
          (if (gnus-y-or-n-p (format "No such group: %s.  Create it? "
                                     to-newsgroup))
-             (or (and (gnus-request-create-group 
+             (or (and (gnus-request-create-group
                        to-newsgroup (gnus-group-name-to-method to-newsgroup))
                       (gnus-activate-group to-newsgroup nil nil
                                            (gnus-group-name-to-method
@@ -8306,7 +8274,12 @@ save those articles instead."
                      (funcall (if (string-match "%s" action)
                                   'format 'concat)
                               action
-                              (mapconcat (lambda (f) f) files " ")))))
+                              (mapconcat
+                               (lambda (f)
+                                 (if (equal f " ")
+                                     f
+                                   (gnus-quote-arg-for-sh-or-csh f)))
+                               files " ")))))
          (setq ps (cdr ps)))))
     (if (and gnus-view-pseudos (not not-view))
        (while pslist
@@ -8354,7 +8327,7 @@ save those articles instead."
     (setq buffer-read-only nil)
     (let ((command (if automatic command (read-string "Command: " command)))
          ;; Just binding this here doesn't help, because there might
-         ;; be output from the process after exiting the scope of 
+         ;; be output from the process after exiting the scope of
          ;; this `let'.
          ;; (buffer-read-only nil)
          )
@@ -8388,7 +8361,7 @@ save those articles instead."
 (defun gnus-read-header (id &optional header)
   "Read the headers of article ID and enter them into the Gnus system."
   (let ((group gnus-newsgroup-name)
-       (gnus-override-method 
+       (gnus-override-method
         (and (gnus-news-group-p gnus-newsgroup-name)
              gnus-refer-article-method))
        where)
@@ -8419,7 +8392,8 @@ save those articles instead."
                  (t gnus-reffed-article-number))
                 (current-buffer))
          (insert " Article retrieved.\n"))
-       (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
+       (if (or (not where)
+               (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
            ()                          ; Malformed head.
          (unless (gnus-summary-article-sparse-p (mail-header-number header))
            (when (and (stringp id)
@@ -8464,7 +8438,7 @@ save those articles instead."
             ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
             (from (if (get-text-property beg gnus-mouse-face-prop)
                       beg
-                    (or (next-single-property-change 
+                    (or (next-single-property-change
                          beg gnus-mouse-face-prop nil end)
                         beg)))
             (to
@@ -8508,8 +8482,8 @@ save those articles instead."
        (setq list (cdr list))))
     (let ((face (cdar list)))
       (unless (eq face (get-text-property beg 'face))
-       (gnus-put-text-property 
-        beg end 'face 
+       (gnus-put-text-property
+        beg end 'face
         (setq face (if (boundp face) (symbol-value face) face)))
        (when gnus-summary-highlight-line-function
          (funcall gnus-summary-highlight-line-function article face))))
@@ -8562,6 +8536,32 @@ save those articles instead."
       (gnus-get-unread-articles-in-group info (gnus-active group))
       t)))
 
+(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
+       (map-y-or-n-p
+        "Update summary buffer %s? "
+        (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
+        buffers)))))
+
 (provide 'gnus-sum)
 
 (run-hooks 'gnus-sum-load-hook)