From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Braun =?UTF-8?Q?G=C3=A1bor?= Newsgroups: gmane.emacs.bugs Subject: bug#70122: 29.3.50; transpose-regions can crash Emacs Date: Tue, 16 Apr 2024 16:26:46 +0200 Message-ID: <3286832.oiGErgHkdL@gabor> References: <2318820.ElGaqSPkdT@gabor> <8400498.NyiUUSuA9g@gabor> <86il0lpn4a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22512"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70122@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 16 16:28:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rwjnD-0005dW-Es for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Apr 2024 16:28:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwjmr-000255-O7; Tue, 16 Apr 2024 10:27:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwjmq-00024u-EN for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 10:27:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwjmq-00087z-3V for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 10:27:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwjn2-00056E-3b for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 10:28:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Braun =?UTF-8?Q?G=C3=A1bor?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Apr 2024 14:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70122 X-GNU-PR-Package: emacs Original-Received: via spool by 70122-submit@debbugs.gnu.org id=B70122.171327763219219 (code B ref 70122); Tue, 16 Apr 2024 14:28:03 +0000 Original-Received: (at 70122) by debbugs.gnu.org; 16 Apr 2024 14:27:12 +0000 Original-Received: from localhost ([127.0.0.1]:44230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwjmB-0004zk-4a for submit@debbugs.gnu.org; Tue, 16 Apr 2024 10:27:12 -0400 Original-Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:56630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwjm6-0004yM-PY for 70122@debbugs.gnu.org; Tue, 16 Apr 2024 10:27:09 -0400 Original-Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a554afec54eso33619466b.1 for <70122@debbugs.gnu.org>; Tue, 16 Apr 2024 07:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713277608; x=1713882408; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3l18JY1Irn1x31U/dTkNqB5WxmZbWbqDRwTWRxhtFxA=; b=LQ0+TcuPTnSXrzemXOOLMqo9kK+Y1Tym1u7sTJMItFe3dAd2ePV4LvzQNMfrpts6VA 2mKrwCC2MJ/ylBl0YNztyAIbKu/LM+e6kEa2CQ9OQKbIUQT96aLeUgH4RKY+ezUA8FzZ 0k0WxqZHDPKs42O4e8Rhnr6baBun4xOxXl2JZvNJ/s5mY92cywMXFZQFeVJ1xIGdquw0 noaCyS3ICAGy33aPBrAsCHA7OAQYIOSLqllS63hecy7kkwgKLRt3JI24dHaJj0QHLK0t pCvgYjW+1Hc4W6HFBYCv4xeL1SakQi7qv132aZAiRhK8hvsHl+eiAdojD5t2VVyxjCaq vuzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713277608; x=1713882408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3l18JY1Irn1x31U/dTkNqB5WxmZbWbqDRwTWRxhtFxA=; b=n7iKEwbEG83kl/6LOZffx7TT3UcFHqI9QL3+A0PAVy/wugrUGiSjt1Xhp0KFZMee98 iGOQdZQjf0UwkaNpJQHLlwrbZhPbc5FNjsnG66b7ZvBulrn7LFj7USmPZz2Fg79z7P56 WdX9O6cGXPi2gMDwJGPDLFCEdxWcXciq4oU8Odr4vvcVB3eTB4Az+2V+CUY33nC1WqAk Ce1jahkdPGEcEkGbaz+l0S+wdP3TEoM2QOMZNB7jj0KGqb9FsQnDsDxRdydx/JZrR2x7 3BfOBatbDFr8GglLl8XWDPtKJkzz8Iwo9EXOLOI+9UsAO4dsFjd7ww+GhNsiqcpsG5RS q6Xw== X-Gm-Message-State: AOJu0Yy8AvfePgRf3RjFdC4zcYSXZHm83FqbmI7gMfpe4rkTruuSuNFg Zed489tlBE/Ps0rq+Vt4B6fPI22phYUb2fDNbFLK23FBfkldR0+U X-Google-Smtp-Source: AGHT+IFzvGCnbHrhU0Y0HLTNVRkXgum8dXU3ZcEB6FpAY5slCx11ouTj/VwceK5bC3iaCekRaiYu/w== X-Received: by 2002:a17:907:2da8:b0:a51:895c:6820 with SMTP id gt40-20020a1709072da800b00a51895c6820mr9354951ejc.44.1713277608410; Tue, 16 Apr 2024 07:26:48 -0700 (PDT) Original-Received: from gabor.localnet ([2001:9e8:1545:f600:84db:1481:f03b:4330]) by smtp.gmail.com with ESMTPSA id e10-20020a170906c00a00b00a51d31924c6sm6913315ejz.189.2024.04.16.07.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:26:48 -0700 (PDT) In-Reply-To: <86il0lpn4a.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283434 Archived-At: 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=20 unwanted > > here as transpose-regions handles undo history itself. =2E.. >=20 > 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. =20 Right? >=20 > If this is something caused by these changes, could you please=20 explain > the issue in more detail, with references to the relevant parts=20 of the > code? I don't think it is a new problem, and the other branches have the=20 same problem. In detail, in all branches transpose-regions adds the undo entries=20 early for its changes (calls to record_change), then during making the changes already recorded in undo history calls functions adding additional undo entries=20 (set_text_properties_1, graft_intervals_into_buffer), i.e. at a time when the buffer state and undo history does not=20 match. Luckily these entries are text property changes to a text=20 deleted immediately by the following entries, so their effects are=20 not visible, but this is due to the initial undo entries recording change to a larger span of text than just the two=20 swapped regions. When not just the byte length but the character length of the=20 swapped regions are the same, the original code didn't change text=20 properties between the two regions, i.e., the text property=20 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=20 the swapped regions additionally (as interval positions need=20 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=20 cleanness of code: separate responsibilities: which part of the=20 code is responsible for (which) undo entries. Best wishes, G=C3=A1bor