From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70077: An easier way to track buffer changes Date: Sat, 30 Mar 2024 09:46:15 +0300 Message-ID: <86bk6wdxoo.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25163"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yantar92@posteo.net, 70077@debbugs.gnu.org, casouri@gmail.com, qhong@alum.mit.edu, frederic.bour@lakaban.net, joaotavora@gmail.com, mail@nicolasgoaziou.fr, acm@muc.de, stephen_leake@stephe-leake.org, alan.zimm@gmail.com, phillip.lord@russet.org.uk To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 30 07:47:37 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 1rqSV6-0006Nj-6B for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Mar 2024 07:47:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqSUZ-0007AQ-5T; Sat, 30 Mar 2024 02:47: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 1rqSUX-0007A3-AA for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 02:47: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 1rqSUW-00070M-So for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 02:47:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqSUY-0001yl-IF for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 02:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Mar 2024 06:47:02 +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.17117811957518 (code B ref 70077); Sat, 30 Mar 2024 06:47:02 +0000 Original-Received: (at 70077) by debbugs.gnu.org; 30 Mar 2024 06:46:35 +0000 Original-Received: from localhost ([127.0.0.1]:43804 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqSU6-0001xC-Uk for submit@debbugs.gnu.org; Sat, 30 Mar 2024 02:46:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqSU3-0001wy-VE for 70077@debbugs.gnu.org; Sat, 30 Mar 2024 02:46:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqSTq-0005zL-VJ; Sat, 30 Mar 2024 02:46:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=eM/X+2XyayQZ85/xhQiFHwO1OZXdHxTi+afP3z1LxM8=; b=sX1m+k5euJ055Q8vlmP+ ACZu1bEILh82zeASRx3+pASQ5awOkiwZ5Mmorv4TPcEmmEPqoCrcqZC/OXLpDuB8MKCnxgF6Mvk/F ECjUezd4laitkubPDC1vEDXG13Vf6jSbF6z3FYKGepVh/8woPAZE3TK8hZVJoPvElM4eCQcjmC0mK RPn+dl1GmM0EB1zZVQQQfaQwssN5hP1lDR3leLUhBEw/pAMvZWnFx6d8Y1PCQrJWUQzaaG6VaV3PL gjdxHCs2WwMnhrKdNk+Xb7ME/H2HvbJJ1m9ZZo9i3/0kNg8y6a2w8IDwMG6p8J+iuAzSX+lRb89iU xpZwrL18+K0H4g==; In-Reply-To: (bug-gnu-emacs@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:282327 Archived-At: > Cc: Ihor Radchenko , 70077@debbugs.gnu.org, > Yuan Fu , Qiantan Hong , > Frédéric Bour , > João Távora , > Nicolas Goaziou , Alan Mackenzie , > Stephen Leake , > Alan Zimmerman > Date: Fri, 29 Mar 2024 18:59:38 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > 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))) But if you get several changes, the above will need to be done in reverse order, back-to-front, no? And before you do that, you cannot really handle the changes, right? > I don't mean to suggest to do that, since it's costly for large > buffers Exactly. But if the buffer _is_ large, then what to do? > Also, it would fix only the problem of pairing, and not the other ones. So the main/only problem this mechanism solves is the lack of pairing between before/after calls to modification hooks?