*** empty log message ***
[gnus] / lisp / gnus-sum.el
index 6aeb579..678ad96 100644 (file)
@@ -618,7 +618,7 @@ is not run if `gnus-visual' is nil."
   :type 'hook)
 
 (defcustom gnus-parse-headers-hook
-  (list 'gnus-decode-rfc1522)
+  (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
   "*A hook called before parsing the headers."
   :group 'gnus-various
   :type 'hook)
@@ -714,31 +714,7 @@ mark:    The articles mark."
 ;;; Internal variables
 
 (defvar gnus-scores-exclude-files nil)
-
-(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.
-
-  ;; We start from the standard display table, if any.
-  (let ((table (or (copy-sequence standard-display-table)
-                  (make-display-table)))
-       ;; Nix out all the control chars...
-       (i 32))
-    (while (>= (setq i (1- i)) 0)
-      (aset table i [??]))
-    ;; ... but not newline and cr, of course.  (cr is necessary for the
-    ;; selective display).
-    (aset table ?\n nil)
-    (aset table ?\r nil)
-    ;; We nix out any glyphs over 126 that are not set already.
-    (let ((i 256))
-      (while (>= (setq i (1- i)) 127)
-       ;; Only modify if the entry is nil.
-       (or (aref table i)
-           (aset table i [??]))))
-    table)
-  "Display table used in summary mode buffers.")
+(defvar gnus-page-broken nil)
 
 (defvar gnus-original-article nil)
 (defvar gnus-article-internal-prepare-hook nil)
@@ -1217,7 +1193,7 @@ increase the score of each group you read."
     "j" gnus-summary-goto-article
     "g" gnus-summary-goto-subject
     "l" gnus-summary-goto-last-article
-    "p" gnus-summary-pop-article)
+    "o" gnus-summary-pop-article)
 
   (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
     "k" gnus-summary-kill-thread
@@ -1872,14 +1848,14 @@ The following commands are available:
   (setq truncate-lines t)
   (setq selective-display t)
   (setq selective-display-ellipses t)  ;Display `...'
-  (setq buffer-display-table gnus-summary-display-table)
+  (gnus-summary-set-display-table)
   (gnus-set-default-directory)
   (setq gnus-newsgroup-name group)
   (make-local-variable 'gnus-summary-line-format)
   (make-local-variable 'gnus-summary-line-format-spec)
   (make-local-variable 'gnus-summary-mark-positions)
   (make-local-hook 'post-command-hook)
-  (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
+  (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)
   (gnus-update-summary-mark-positions))
@@ -2038,7 +2014,7 @@ The following commands are available:
 
 (defmacro gnus-summary-article-sparse-p (article)
   "Say whether this article is a sparse article or not."
-  ` (memq ,article gnus-newsgroup-sparse))
+  `(memq ,article gnus-newsgroup-sparse))
 
 (defmacro gnus-summary-article-ancient-p (article)
   "Say whether this article is a sparse article or not."
@@ -2210,6 +2186,30 @@ This is all marks except unread, ticked, dormant, and expirable."
   (mouse-set-point e)
   (gnus-summary-next-page nil t))
 
+(defun gnus-summary-set-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.
+
+  ;; We start from the standard display table, if any.
+  (let ((table (or (copy-sequence standard-display-table)
+                  (make-display-table)))
+       (i 32))
+    ;; Nix out all the control chars...
+    (while (>= (setq i (1- i)) 0)
+      (aset table i [??]))
+    ;; ... but not newline and cr, of course.  (cr is necessary for the
+    ;; selective display).
+    (aset table ?\n nil)
+    (aset table ?\r nil)
+    ;; We nix out any glyphs over 126 that are not set already.
+    (let ((i 256))
+      (while (>= (setq i (1- i)) 127)
+       ;; Only modify if the entry is nil.
+       (unless (aref table i)
+         (aset table i [??]))))
+    (setq buffer-display-table table)))
+
 (defun gnus-summary-setup-buffer (group)
   "Initialize summary buffer."
   (let ((buffer (concat "*Summary " group "*")))
@@ -2619,10 +2619,10 @@ If NO-DISPLAY, don't generate a summary buffer."
            (select-window (get-buffer-window gnus-group-buffer t))
            (when (gnus-group-goto-group group)
              (recenter))
-           (select-window owin))))
-      ;; Mark this buffer as "prepared".
-      (setq gnus-newsgroup-prepared t)
-      t))))
+           (select-window owin)))
+       ;; Mark this buffer as "prepared".
+       (setq gnus-newsgroup-prepared t)
+       t)))))
 
 (defun gnus-summary-prepare ()
   "Generate the summary buffer."
@@ -2759,26 +2759,29 @@ If NO-DISPLAY, don't generate a summary buffer."
 
 (defun gnus-thread-loop-p (root thread)
   "Say whether ROOT is in THREAD."
-  (let ((th (cdr thread)))
-    (while (and th
-               (not (eq (caar th) root)))
-      (pop th))
-    (if th
-       ;; We have found a loop.
-       (let (ref-dep)
-         (setcdr thread (delq (car th) (cdr thread)))
-         (if (boundp (setq ref-dep (intern "none"
-                                           gnus-newsgroup-dependencies)))
-             (setcdr (symbol-value ref-dep)
-                     (nconc (cdr (symbol-value ref-dep))
-                            (list (car th))))
-           (set ref-dep (list nil (car th))))
-         1)
-      ;; Recurse down into the sub-threads and look for loops.
-      (apply '+
-            (mapcar
-             (lambda (thread) (gnus-thread-loop-p root thread))
-             (cdr thread))))))
+  (let ((stack (list thread))
+       (infloop 0)
+       th)
+    (while (setq thread (pop stack))
+      (setq th (cdr thread))
+      (while (and th
+                 (not (eq (caar th) root)))
+       (pop th))
+      (if th
+         ;; We have found a loop.
+         (let (ref-dep)
+           (setcdr thread (delq (car th) (cdr thread)))
+           (if (boundp (setq ref-dep (intern "none"
+                                             gnus-newsgroup-dependencies)))
+               (setcdr (symbol-value ref-dep)
+                       (nconc (cdr (symbol-value ref-dep))
+                              (list (car th))))
+             (set ref-dep (list nil (car th))))
+           (setq infloop 1
+                 stack nil))
+       ;; Push all the subthreads onto the stack.
+       (push (cdr thread) stack)))
+    infloop))
 
 (defun gnus-make-threads ()
   "Go through the dependency hashtb and find the roots.         Return all threads."
@@ -2892,19 +2895,21 @@ If NO-DISPLAY, don't generate a summary buffer."
     (prog1
        (save-excursion
          (set-buffer nntp-server-buffer)
-         (goto-char (point-min))
-         (while (and (not found) (search-forward id nil t))
-           (beginning-of-line)
-           (setq found (looking-at
-                        (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
-                                (regexp-quote id))))
-           (or found (beginning-of-line 2)))
-         (when found
-           (beginning-of-line)
-           (and
-            (setq header (gnus-nov-parse-line
-                          (read (current-buffer)) deps))
-            (gnus-parent-id (mail-header-references header)))))
+         (let ((case-fold-search nil))
+           (goto-char (point-min))
+           (while (and (not found)
+                       (search-forward id nil t))
+             (beginning-of-line)
+             (setq found (looking-at
+                          (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
+                                  (regexp-quote id))))
+             (or found (beginning-of-line 2)))
+           (when found
+             (beginning-of-line)
+             (and
+              (setq header (gnus-nov-parse-line
+                            (read (current-buffer)) deps))
+              (gnus-parent-id (mail-header-references header))))))
       (when header
        (let ((number (mail-header-number header)))
          (push number gnus-newsgroup-limit)
@@ -2947,10 +2952,11 @@ If NO-DISPLAY, don't generate a summary buffer."
                   (gnus-data-find-list
                    article
                    (gnus-data-list t)))))
+             ;; Error on the side of excessive subjects.
              (error ""))
            (mail-header-subject header))
-          (mail-header-subject header)
-        "")
+          ""
+        (mail-header-subject header))
        nil (cdr (assq article gnus-newsgroup-scored))
        (memq article gnus-newsgroup-processable))
       (when length
@@ -3584,6 +3590,11 @@ or a straight list of headers."
   "Select newsgroup GROUP.
 If READ-ALL is non-nil, all articles in the group are selected."
   (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
+        ;;!!! Dirty hack; should be removed.
+        (gnus-summary-ignore-duplicates
+         (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
+             t
+           gnus-summary-ignore-duplicates))
         (info (nth 2 entry))
         articles fetched-articles cached)
 
@@ -3809,12 +3820,16 @@ If READ-ALL is non-nil, all articles in the group are selected."
       ;; All articles have to be subsets of the active articles.
       (cond
        ;; Adjust "simple" lists.
-       ((memq mark '(tick dormant expirable reply save))
+       ((memq mark '(tick dormant expire reply save))
        (while articles
          (when (or (< (setq article (pop articles)) min) (> article max))
            (set var (delq article (symbol-value var))))))
        ;; Adjust assocs.
        ((memq mark uncompressed)
+       (when (not (listp (cdr (symbol-value var))))
+         (set var (list (symbol-value var))))
+       (when (not (listp (cdr articles)))
+         (setq articles (list articles)))
        (while articles
          (when (or (not (consp (setq article (pop articles))))
                    (< (car article) min)
@@ -4184,7 +4199,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
            (progn
              (goto-char p)
              (if (search-forward "\nlines: " nil t)
-                 (if (numberp (setq lines (read cur)))
+                 (if (numberp (setq lines (ignore-errors (read cur))))
                      lines 0)
                0))
            ;; Xref.
@@ -4804,6 +4819,9 @@ The prefix argument ALL means to select all articles."
                   (not non-destructive))
          (setq gnus-newsgroup-scored nil))
        ;; Set the new ranges of read articles.
+       (save-excursion
+         (set-buffer gnus-group-buffer)
+         (gnus-undo-force-boundary))
        (gnus-update-read-articles
         group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
        ;; Set the current article marks.
@@ -4840,6 +4858,7 @@ gnus-exit-group-hook is called with no arguments if that value is non-nil."
   (let* ((group gnus-newsgroup-name)
         (quit-config (gnus-group-quit-config gnus-newsgroup-name))
         (mode major-mode)
+         (group-point nil)
         (buf (current-buffer)))
     (run-hooks 'gnus-summary-prepare-exit-hook)
     ;; If we have several article buffers, we kill them at exit.
@@ -4859,13 +4878,14 @@ gnus-exit-group-hook is called with no arguments if that value is non-nil."
       (run-hooks 'gnus-exit-group-hook)
       (gnus-summary-update-info))
     (gnus-close-group group)
-    ;; Make sure where I was, and go to next newsgroup.
+    ;; Make sure where we were, and go to next newsgroup.
     (set-buffer gnus-group-buffer)
     (unless quit-config
       (gnus-group-jump-to-group group))
     (run-hooks 'gnus-summary-exit-hook)
     (unless quit-config
       (gnus-group-next-unread-group 1))
+    (setq group-point (point))
     (if temporary
        nil                             ;Nothing to do.
       ;; If we have several article buffers, we kill them at exit.
@@ -4895,8 +4915,7 @@ gnus-exit-group-hook is called with no arguments if that value is non-nil."
       ;; Clear the current group name.
       (if (not quit-config)
          (progn
-           (gnus-group-jump-to-group group)
-           (gnus-group-next-unread-group 1)
+           (goto-char group-point)
            (gnus-configure-windows 'group 'force))
        (gnus-handle-ephemeral-exit quit-config))
       (unless quit-config
@@ -4982,7 +5001,7 @@ which existed when entering the ephemeral is reset."
   (suppress-keymap gnus-dead-summary-mode-map)
   (substitute-key-definition
    'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
-  (let ((keys '("\C-d" "\r" "\177")))
+  (let ((keys '("\C-d" "\r" "\177" [delete])))
     (while keys
       (define-key gnus-dead-summary-mode-map
        (pop keys) 'gnus-summary-wake-up-the-dead))))
@@ -5068,7 +5087,8 @@ in."
     (when current-prefix-arg
       (completing-read
        "Faq dir: " (and (listp gnus-group-faq-directory)
-                       gnus-group-faq-directory)))))
+                       (mapcar (lambda (file) (list file))
+                               gnus-group-faq-directory))))))
   (let (gnus-faq-buffer)
     (when (setq gnus-faq-buffer
                (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
@@ -5120,8 +5140,9 @@ previous group instead."
          (progn
            (gnus-message 5 "Returning to the group buffer")
            (setq entered t)
-           (set-buffer current-buffer)
-           (gnus-summary-exit)
+           (when (gnus-buffer-live-p current-buffer)
+             (set-buffer current-buffer)
+             (gnus-summary-exit))
            (run-hooks 'gnus-group-no-more-groups-hook))
        ;; We try to enter the target group.
        (gnus-group-jump-to-group target-group)
@@ -5129,7 +5150,8 @@ previous group instead."
          (if (and (or (eq t unreads)
                       (and unreads (not (zerop unreads))))
                   (gnus-summary-read-group
-                   target-group nil no-article current-buffer))
+                   target-group nil no-article
+                   (and (buffer-name current-buffer) current-buffer)))
              (setq entered t)
            (setq current-group target-group
                  target-group nil)))))))
@@ -5841,7 +5863,7 @@ If ALL, mark even excluded ticked and dormants as read."
                    '<)
                   (sort gnus-newsgroup-limit '<)))
        article)
-    (setq gnus-newsgroup-unreads nil)
+    (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
     (if all
        (setq gnus-newsgroup-dormant nil
              gnus-newsgroup-marked nil
@@ -5915,7 +5937,10 @@ If ALL, mark even excluded ticked and dormants as read."
              (mail-header-number (car thread))))
            (progn
              (if (<= (length (cdr thread)) 1)
-                 (setq thread (cadr thread))
+                 (setq gnus-newsgroup-limit
+                       (delq (mail-header-number (car thread))
+                             gnus-newsgroup-limit)
+                       thread (cadr thread))
                (when (gnus-invisible-cut-children (cdr thread))
                  (let ((th (cdr thread)))
                    (while th
@@ -5923,8 +5948,7 @@ If ALL, mark even excluded ticked and dormants as read."
                                gnus-newsgroup-limit)
                          (setq thread (car th)
                                th nil)
-                       (setq th (cdr th)))))))))
-      ))
+                       (setq th (cdr th)))))))))))
   thread)
 
 (defun gnus-cut-threads (threads)
@@ -6033,7 +6057,7 @@ fetch-old-headers verbiage, and so on."
                      (mail-header-id (car thread))))
                (progn
                  (setq gnus-newsgroup-reads
-                       (delq number gnus-newsgroup-unreads))
+                       (delq number gnus-newsgroup-reads))
                  t))))
          ;; Nope, invisible article.
          0
@@ -6124,9 +6148,11 @@ Return how many articles were fetched."
       (gnus-summary-position-point)
       n)))
 
-(defun gnus-summary-refer-article (message-id)
-  "Fetch an article specified by MESSAGE-ID."
-  (interactive "sMessage-ID: ")
+(defun gnus-summary-refer-article (message-id &optional arg)
+  "Fetch an article specified by MESSAGE-ID.
+If ARG (the prefix), fetch the article using `gnus-refer-article-method'
+or `gnus-select-method', no matter what backend the article comes from."
+  (interactive "sMessage-ID: \nP")
   (when (and (stringp message-id)
             (not (zerop (length message-id))))
     ;; Construct the correct Message-ID if necessary.
@@ -6138,18 +6164,26 @@ Return how many articles were fetched."
     (let* ((header (gnus-id-to-header message-id))
           (sparse (and header
                        (gnus-summary-article-sparse-p
-                        (mail-header-number header)))))
-      (if header
+                        (mail-header-number header))
+                       (memq (mail-header-number header)
+                             gnus-newsgroup-limit))))
+      (if (and header
+              (or (not (gnus-summary-article-sparse-p
+                        (mail-header-number header)))
+                  sparse))
          (prog1
-             ;; The article is present in the buffer, to we just go to it.
+              ;; The article is present in the buffer, so we just go to it.
              (gnus-summary-goto-article
-              (mail-header-number header) nil header)
+               (mail-header-number header) nil t)
            (when sparse
              (gnus-summary-update-article (mail-header-number header))))
        ;; We fetch the article
        (let ((gnus-override-method
-              (and (gnus-news-group-p gnus-newsgroup-name)
-                   gnus-refer-article-method))
+              (cond ((gnus-news-group-p gnus-newsgroup-name)
+                     gnus-refer-article-method)
+                    (arg
+                     (or gnus-refer-article-method gnus-select-method))
+                    (t nil)))
              number)
          ;; Start the special refer-article method, if necessary.
          (when (and gnus-refer-article-method
@@ -6178,7 +6212,8 @@ to guess what the document format is."
                           gnus-current-article)))
           (ogroup gnus-newsgroup-name)
           (params (append (gnus-info-params (gnus-get-info ogroup))
-                          (list (cons 'to-group ogroup))))
+                          (list (cons 'to-group ogroup))
+                          (list (cons 'save-article-group ogroup))))
           (case-fold-search t)
           (buf (current-buffer))
           dig)
@@ -6302,11 +6337,15 @@ If BACKWARD, search backward instead."
   "Search for an article containing REGEXP.
 Optional argument BACKWARD means do search for backward.
 `gnus-select-article-hook' is not called during the search."
+  ;; We have to require this here to make sure that the following
+  ;; dynamic binding isn't shadowed by autoloading.
+  (require 'gnus-async)
   (let ((gnus-select-article-hook nil) ;Disable hook.
        (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.
+       (gnus-use-trees nil)            ;Inhibit updating tree buffer.
        (sum (current-buffer))
        (found nil)
        point)
@@ -6420,7 +6459,7 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
   (gnus-eval-in-buffer-window gnus-article-buffer
     (widen)
     (goto-char (point-min))
-    (when gnus-break-pages
+    (when gnus-page-broken
       (gnus-narrow-to-page))))
 
 (defun gnus-summary-end-of-article ()
@@ -6433,7 +6472,7 @@ article.  If BACKWARD (the prefix) is non-nil, search backward instead."
     (widen)
     (goto-char (point-max))
     (recenter -3)
-    (when gnus-break-pages
+    (when gnus-page-broken
       (gnus-narrow-to-page))))
 
 (defun gnus-summary-print-article (&optional filename)
@@ -6470,10 +6509,10 @@ article massaging functions being run."
          gnus-article-display-hook
          gnus-article-prepare-hook
          gnus-break-pages
+         gnus-show-mime
          gnus-visual)
       (gnus-summary-select-article nil 'force)))
   (gnus-summary-goto-subject gnus-current-article)
-                                       ;  (gnus-configure-windows 'article)
   (gnus-summary-position-point))
 
 (defun gnus-summary-verbose-headers (&optional arg)
@@ -6630,6 +6669,8 @@ and `request-accept' functions."
        (cond
        ;; Move the article.
        ((eq action 'move)
+        ;; Remove this article from future suppression.
+        (gnus-dup-unsuppress-article article)
         (gnus-request-move-article
          article                       ; Article to move
          gnus-newsgroup-name           ; From newsgroup
@@ -6665,20 +6706,26 @@ and `request-accept' functions."
             (set-buffer copy-buf)
             ;; First put the article in the destination group.
             (gnus-request-article-this-buffer article gnus-newsgroup-name)
-            (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)
+            (when (consp (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))))))
+      (cond
+       ((not art-group)
+       (gnus-message 1 "Couldn't %s article %s"
+                     (cadr (assq action names)) article))
+       ((and (eq art-group 'junk)
+            (eq action 'move))
+       (gnus-summary-mark-article article gnus-canceled-mark)
+       (gnus-message 4 "Deleted article %s" article))
+       (t
        (let* ((entry
                (or
                 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
@@ -6739,7 +6786,12 @@ and `request-accept' functions."
                  ;; Copy the marks to other group.
                  (gnus-add-marked-articles
                   to-group (cdar marks) (list to-article) info))
-               (setq marks (cdr marks)))))
+               (setq marks (cdr marks)))
+
+             (gnus-dribble-enter
+              (concat "(gnus-group-set-info '"
+                      (gnus-prin1-to-string (gnus-get-info to-group))
+                      ")"))))
 
          ;; Update the Xref header in this article to point to
          ;; the new crossposted article we have just created.
@@ -6753,11 +6805,15 @@ and `request-accept' functions."
 
        (gnus-summary-goto-subject article)
        (when (eq action 'move)
-         (gnus-summary-mark-article article gnus-canceled-mark)))
+         (gnus-summary-mark-article article gnus-canceled-mark))))
       (gnus-summary-remove-process-mark article))
     ;; Re-activate all groups that have been moved to.
     (while to-groups
-      (gnus-activate-group (pop to-groups)))
+      (save-excursion
+       (set-buffer gnus-group-buffer)
+       (when (gnus-group-goto-group (car to-groups) t)
+         (gnus-group-get-new-news-this-group 1 t))
+       (pop to-groups)))
 
     (gnus-kill-buffer copy-buf)
     (gnus-summary-position-point)
@@ -7066,7 +7122,7 @@ groups."
 
 ;;; Respooling
 
-(defun gnus-summary-respool-query ()
+(defun gnus-summary-respool-query (&optional silent)
   "Query where the respool algorithm would put this article."
   (interactive)
   (gnus-set-global-variables)
@@ -7076,8 +7132,13 @@ groups."
       (set-buffer gnus-original-article-buffer)
       (save-restriction
        (message-narrow-to-head)
-       (message "This message would go to %s"
-                (mapconcat 'car (nnmail-article-group 'identity) ", "))))))
+       (let ((groups (nnmail-article-group 'identity)))
+         (unless silent
+           (if groups
+               (message "This message would go to %s"
+                        (mapconcat 'car groups ", "))
+             (message "This message would go to no groups"))
+           groups))))))
 
 ;; Summary marking commands.
 
@@ -8409,7 +8470,8 @@ save those articles instead."
     (gnus-article-setup-buffer)
     (set-buffer gnus-article-buffer)
     (setq buffer-read-only nil)
-    (let ((command (if automatic command (read-string "Command: " command))))
+    (let ((command (if automatic command
+                    (read-string "Command: " (cons command 0)))))
       (erase-buffer)
       (insert "$ " command "\n\n")
       (if gnus-view-pseudo-asynchronously
@@ -8641,6 +8703,8 @@ save those articles instead."
         (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
         buffers)))))
 
+(gnus-ems-redefine)
+
 (provide 'gnus-sum)
 
 (run-hooks 'gnus-sum-load-hook)