unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Bruno Victal <mirai@makinata.eu>
Cc: 66106-done@debbugs.gnu.org
Subject: bug#66106: 28.2; Undo on yanked message fills message body with headers
Date: Sat, 23 Sep 2023 15:40:27 -0700	[thread overview]
Message-ID: <87msxcldic.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <875y455w6o.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Tue, 19 Sep 2023 21:02:23 -0700")

[-- Attachment #1: Type: text/plain, Size: 2806 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Bruno Victal <mirai@makinata.eu> writes:
>
>> 1. Using debbugs (elpa), go to issue #66057.
>> 2. Open the 3rd reply. (from Jean Abou Samra)
>> 3. In the Article buffer (the buffer with the message) do `S v' to
>> start a wide reply.
>> 4. Within the message body, do `C-c C-y' to copy the original
>> message/yank.
>>
>> Issue #1: I get a “Jean Abou Samra writes:” line followed by nothing, it
>> didn't paste the contents of the message I'm replying to.
>>
>> 5. Press `Undo'.
>>
>> Issue #2: Instead of reverting to an empty message body, I get the
>> headers of the message I'm replying to in its place.
>>
>> Notes that might be of interest:
>> * I have set `message-generate-hashcash' to `t'.
>>
>> There's also another issue I've encountered when I reattempted to reply
>> but using `S V' (wide reply with yank): The message doesn't seem to be
>> properly quoted. I only see a single level of '>' whereas I'd expect to
>> see part of the body with '>>' corresponding to the quoted parts of the
>> original message that started the discussion.
>
> I don't see exactly what you're seeing -- I tried this out and always
> got the message headers (no message body) with one level of quoting.
> Hitting undo just removed the level of quoting. But the basic problem is there.
>
> It looks like the issue is in `gnus-summary-reply'. The function that
> prepares the original copy of the article for yanking is
> `gnus-copy-article-buffer', which is called once per article being
> replied to (note that "S V" is only wide; "S v" is very wide).
>
> Starting at line 1105 in `gnus-summary-reply', we go to the buffer
> containing the article text to yank, and run:
>
> 	(save-restriction
> 	  (message-narrow-to-head)
> 	  (when very-wide
> 	    (erase-buffer)
> 	    (insert headers))
> 	  (goto-char (point-max)))
>
> Perhaps the intention was that the narrowing would affect the behavior
> of `erase-buffer', so that in effect this is supposed to replace
> whatever headers were there with the contents of the "headers" variable.
> But of course `erase-buffer' doesn't respect buffer narrowing, so
> everything (including the actual text you wanted to reply to) gets
> deleted. If I replace (erase-buffer) with (delete-region (point-min)
> (point-max)), it appears to work correctly.
>
> Did `erase-buffer' used to respect narrowing, when this code was written
> 20 years ago? Anyway, the more I look at it, the more I think that's
> what's supposed to be happening here.

I've experimented with this a bit more, and am pushing the attached
patch. I believe it fixes this problem, but please re-open the bug if
you're still seeing undesirable behavior.

Thanks for the report,
Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-delete-region-in-Gnus-message-yanking.patch --]
[-- Type: text/x-patch, Size: 1356 bytes --]

From 450ca9951a87a055eb00bd161a372cc1de02736f Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 23 Sep 2023 15:33:53 -0700
Subject: [PATCH] Use delete-region in Gnus message yanking

See Bug#66106

* lisp/gnus/gnus-msg.el (gnus-summary-reply): Not erase-buffer. The
intention was to narrow the buffer to the headers, and then delete
just those headers. But erase-buffer doesn't respect narrowing, so
use (delete-region (point-min) (point-max)) instead.
---
 lisp/gnus/gnus-msg.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index 0439bf0d59b..b065ae34851 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -1104,12 +1104,12 @@ gnus-summary-reply
 		(setq headers (concat headers (buffer-string)))))))
 	(set-buffer (gnus-copy-article-buffer))
 	(gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
-	(save-restriction
-	  (message-narrow-to-head)
-	  (when very-wide
-	    (erase-buffer)
-	    (insert headers))
-	  (goto-char (point-max)))
+	(when very-wide
+          (save-restriction
+	    (message-narrow-to-head)
+	    (delete-region (point-min) (point-max))
+	    (insert headers)
+	    (goto-char (point-max))))
 	(mml-quote-region (point) (point-max))
 	(message-reply nil wide)
 	(when yank
-- 
2.42.0


      reply	other threads:[~2023-09-23 22:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 15:11 bug#66106: 28.2; Undo on yanked message fills message body with headers Bruno Victal
2023-09-20  4:02 ` Eric Abrahamsen
2023-09-23 22:40   ` Eric Abrahamsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87msxcldic.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=66106-done@debbugs.gnu.org \
    --cc=mirai@makinata.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).