Subject: Re: bug#39112: 27.0.60; gnus-summary-attach-article 'S A' with multiple articles selected repeats latest article

From: Eric Abrahamsen <[email-masked]>
Date: Mon, 13 Jan 2020 13:49:59 -0800

Eric Abrahamsen <[email-masked]> writes:

> Pankaj Jangid <[email-masked]> writes:
>
>> New command 'S A' ('gnus-summary-attach-article') is not working
>> properly with multiple articles.
>>
>> * Steps
>> 1. Select multiple articles in summary buffer using process mark '#'
>> 2. 'S A'
>> 3. Creates a new message buffer with multiple articles attached. BUT all
>> the articles are same. The latest among the selected articles is
>> repeated multiple times.
>
> That command sets up the message-mode buffer and makes it current before
> iterating over the articles, so it's unable to actually find the
> articles and simply repeats the last value of
> gnus-original-article-buffer.

Okay, that was only right by accident. The real problem was that the
code inside the iterate was setting the buffer to the message-mode
buffer. Then the calls to `gnus-summary-select-article' kept re-setting
to the summary-buffer, but always on the same article.

Anyway, would you test this patch and confirm it fixes the problem?

Eric

diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index 466a62713e..de5ebd3409 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -1987,11 +1987,11 @@ gnus-summary-attach-article
       (setq destination (current-buffer)))
     (gnus-summary-iterate n
       (gnus-summary-select-article)
-      (set-buffer destination)
-      ;; Attach at the end of the buffer.
-      (save-excursion
-	(goto-char (point-max))
-	(message-forward-make-body-mime gnus-original-article-buffer)))
+      (with-current-buffer destination
+       ;; Attach at the end of the buffer.
+       (save-excursion
+	 (goto-char (point-max))
+	 (message-forward-make-body-mime gnus-original-article-buffer))))
     (gnus-configure-windows 'message t)))
 
 (provide 'gnus-msg)