all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Braun Gábor" <braungb88@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 70122@debbugs.gnu.org
Subject: bug#70122: 29.3.50; transpose-regions can crash Emacs
Date: Tue, 16 Apr 2024 16:26:46 +0200	[thread overview]
Message-ID: <3286832.oiGErgHkdL@gabor> (raw)
In-Reply-To: <86il0lpn4a.fsf@gnu.org>

Hi Eli,

> > 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.
...
> 
> 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?

I don't think it is a new problem, and the other branches have the 
same problem.

In detail, in all branches transpose-regions adds the undo entries 
early for its changes (calls to record_change),
then during making the changes already recorded in undo history
calls functions adding additional undo entries 
(set_text_properties_1, graft_intervals_into_buffer),
i.e. at a time when the buffer state and undo history does not 
match.  Luckily these entries are text property changes to a text 
deleted immediately by the following entries, so their effects are 
not visible, but this is due to the initial undo entries
recording change to a larger span of text than just the two 
swapped regions.

When not just the byte length but the character length of the 
swapped regions are the same, the original code didn't change text 
properties between the two regions, i.e., the text property 
changes were restricted to the swapped regions, and hence
restricting the initial undo entries to these region worked.

The new changes do make text property changes to the text between 
the swapped regions additionally (as interval positions need 
adjustment), which makes it harder for the undo entries,
and that's why I did what the other branches do.


All in all, the issue is not about correctness of code, but rather 
cleanness of code: separate responsibilities: which part of the 
code is responsible for (which) undo entries.

Best wishes,

	Gábor








  reply	other threads:[~2024-04-16 14:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 10:02 bug#70122: 29.3.50; transpose-regions can crash Emacs Braun Gábor
2024-04-01 11:55 ` Eli Zaretskii
2024-04-01 13:17   ` Eli Zaretskii
2024-04-03 18:52     ` Braun Gábor
2024-04-04  4:48       ` Eli Zaretskii
2024-04-12  9:39         ` Braun Gábor
2024-04-12  9:42           ` Braun Gábor
2024-04-13 10:34           ` Eli Zaretskii
2024-04-16 14:26             ` Braun Gábor [this message]
2024-04-20  7:50               ` Eli Zaretskii
2024-04-24 12:35                 ` Braun Gábor

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

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

  git send-email \
    --in-reply-to=3286832.oiGErgHkdL@gabor \
    --to=braungb88@gmail.com \
    --cc=70122@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.