Subject: Re: bug#70122: 29.3.50; transpose-regions can crash Emacs

From: Eli Zaretskii <[email-masked]>
Date: Sat, 13 Apr 2024 13:34:29 +0300

> From: Braun Gábor <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 12 Apr 2024 11:39:34 +0200
> 
> Sorry for answering late.

No sweat.

> > Can we lift that restriction by augmenting the len1_byte ==
> > len2_byte branch so that the len1 == len2 condition is not needed?
> 
> I could only come up with one that has minimal difference to
> to the other branches.  I've attached it.
> 
> I've tried to preserve the undo entries as changes in the two 
> regions, but I couldn't make it (one of my tests failed),
> so now it is a change in the large region as in the other 
> branches, and the tests pass.

That doesn't sound like a serious problem, since the other branches
also do it.

> The issue I was unable to solve is that the functions
> set_text_properties_1 and graft_intervals_into_buffer
> record text property changes in undo history, but this is unwanted 
> here as transpose-regions handles undo history itself.
> These entries don't cause trouble because they happen to be 
> followed by a deletion of the text where properties change,
> and this applies to all branches of transpose-regions.
> 
> I'd really like to use a version of these functions with: "change 
> text properties, but leave it to us to record it in undo history".

But this is not a new problem, right?  The code called
set_text_properties_1 and graft_intervals_into_buffer before the
changes as well, and had the same effect on undo history.  Right?

If this is something caused by these changes, could you please explain
the issue in more detail, with references to the relevant parts of the
code?

> > Last, but not least: with the added tests your patch becomes
> > larger than what we can accept without your assigning the
> > copyright to the FSF.  Would you like to start the legal paperwork
> > of copyright assignment at this time
> 
> Let's start the paperwork.

Will send the form off-list shortly.