From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: phillip.lord@russet.org.uk Newsgroups: gmane.emacs.bugs Subject: bug#70077: An easier way to track buffer changes Date: Sat, 30 Mar 2024 08:06:03 -0400 Message-ID: <6081fabd1e9e701b1b26848fbe0e403d@russet.org.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26766"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Roundcube Webmail/1.6.0 Cc: Ihor Radchenko , 70077@debbugs.gnu.org, Yuan Fu , Qiantan Hong , =?UTF-8?Q?Fr=C3=A9d=C3=A9ric?= Bour , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Nicolas Goaziou , Alan Mackenzie , Stephen Leake , Alan Zimmerman To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 30 13:07:23 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 1rqXUY-0006hg-IC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Mar 2024 13:07:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqXUF-0007Wb-7a; Sat, 30 Mar 2024 08:07:03 -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 1rqXUC-0007WI-Rx for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 08:07:01 -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 1rqXUC-0002Pj-JT for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 08:07:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqXUE-00044Z-0j for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 08:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: phillip.lord@russet.org.uk Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Mar 2024 12:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70077 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70077-submit@debbugs.gnu.org id=B70077.171180037915525 (code B ref 70077); Sat, 30 Mar 2024 12:07:01 +0000 Original-Received: (at 70077) by debbugs.gnu.org; 30 Mar 2024 12:06:19 +0000 Original-Received: from localhost ([127.0.0.1]:44127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqXTX-00042L-5n for submit@debbugs.gnu.org; Sat, 30 Mar 2024 08:06:19 -0400 Original-Received: from cloud103.planethippo.com ([78.129.190.68]:35612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqXTR-00041d-Gk for 70077@debbugs.gnu.org; Sat, 30 Mar 2024 08:06:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/iaqUNq9u594bqzNvPbwgEfgIFIkxnHjUwAGwN54tTc=; b=KDbVD7g4wxOqCr/WLU2r3ajabg oAEY4sB+rhOsKUietK94vpVJrFDIGQpLrH908XxQsHNzm2CgqsPUgn3cz4Kp2/e8RrfQXGi614g/i HonVgKixLxMRtTHdrqIFwwRiX3CZBM5UORNfeF+9WF27+6Ey7lpqrYijN4+lD2X3KAgS2E8pNhq8Z /3KnLh0+yK/bwPKFCCjgg7FNx8ZYevWTn1bNDpn08wi/3doPr7UrT/dd0ytqbHNeepAK3dHigkjSt 9PYis+ncZNZ+jIdrP4fhWiaTBZr6jmdz+dsl1itngrrJ5hHNrGTxH1lVWSNKkW//zO7zldvv7Du1L zGDJyvpw==; Original-Received: from [::1] (port=45052 helo=cloud103.planethippo.com) by cloud103.planethippo.com with esmtpa (Exim 4.96.2) (envelope-from ) id 1rqXTA-000cwf-2M; Sat, 30 Mar 2024 08:06:04 -0400 In-Reply-To: X-Sender: phillip.lord@russet.org.uk X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk 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:282352 Archived-At: On 2024-03-29 18:59, Stefan Monnier wrote: >> If I remember correctly, I think this wouldn't be enough for my >> use. You keep two buffers in sync, you have to use >> before-change-function -- it is only before any change that the two >> buffers are guaranteed to be in sync and it is this that allows you to >> work out what the `start' and `end' positions mean in the copied >> buffer. Afterward, you cannot work out what the end position because >> you don't know if the change is a change, insertion, deletion or both. > > I believe the API I propose does provide that information: you can > recover the state of the buffer before the change (or more > specifically, > the state of the buffer as of the last time you called > track-changes-fetch) from the BEG/END/BEFORE arguments as follows: > > (concat (buffer-substring (point-min) beg) > before > (buffer-substring end (point-max))) > > I don't mean to suggest to do that, since it's costly for large > buffers, but to illustrate that the information is properly preserved. Ah, yes, you are correct, I had missed that one. As you note, it would be costly, especially because if you wanted to do anything with that data, you would probably end up dumping it into a temp buffer. >> Last time I checked, I did find relatively few primitives that were >> guilty >> of being inconsistent -- in the case of `subst-char-in-region', it >> returned >> the maximal area of effect before the and the minimal area of effect >> after. Would it not be easier to fix these? > > [ IIRC `revert-buffer` has a similar behavior, and in that case the > difference can be large since the "before" covers the whole buffer. > ] > > Also, it would fix only the problem of pairing, and not the other ones. Understood. It would be interesting to know how many primitives cause issues though. Phil