From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70077: An easier way to track buffer changes Date: Fri, 29 Mar 2024 18:59:38 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10518"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) 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: phillip.lord@russet.org.uk Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 30 00:00:31 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 1rqLD4-0002Ww-Ii for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Mar 2024 00:00:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqLCj-0002kq-Us; Fri, 29 Mar 2024 19:00:09 -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 1rqLCf-0002ii-T9 for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 19:00:06 -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 1rqLCb-0000L8-JD for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 19:00:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqLCd-0000B2-2g for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 19:00:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Mar 2024 23:00: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.1711753193628 (code B ref 70077); Fri, 29 Mar 2024 23:00:02 +0000 Original-Received: (at 70077) by debbugs.gnu.org; 29 Mar 2024 22:59:53 +0000 Original-Received: from localhost ([127.0.0.1]:43614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqLCT-0000A3-Hf for submit@debbugs.gnu.org; Fri, 29 Mar 2024 18:59:53 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqLCQ-00009k-12 for 70077@debbugs.gnu.org; Fri, 29 Mar 2024 18:59:51 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CEA964429F7; Fri, 29 Mar 2024 18:59:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1711753180; bh=49XqOxnI8GhRIaUhGknCF7y19BWQaxFhEo758rOPwa4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mtixeX0K01O+3DrDkARYXWLDaaKptg7xRGC6bpGnxvaA+hsuEHmkHf93eW0ZApMBd UQTKUUVM0Hd06u+xIItUBU8ENXFSjVoE+B8Y97PAPoxoVXvZvgk6PutDKRyynElmlo fz+NrkCcfK1RHSwjEZ+aBuAyjwTmp2MVBUwaPiTSOTnkOqm/EzxMmjRWoJXeFbXpjE CXHpnSfK//xjIMU2MBJukB94wACVPcfGHDbvxXemUVBxiPDXAT9YQmzlHurIWnysUp NgMd1WcJBKfKL9B/OVZ/M35qMtEp3obCgl+uk06pxeutvRds18iqXZ+yYZqJ7ezEq3 YIRfXrymneGgw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 47B544429DC; Fri, 29 Mar 2024 18:59:40 -0400 (EDT) Original-Received: from pastel (104-222-113-60.cpe.teksavvy.com [104.222.113.60]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B63F5120550; Fri, 29 Mar 2024 18:59:39 -0400 (EDT) In-Reply-To: (phillip lord's message of "Fri, 29 Mar 2024 18:20:32 -0400") 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:282318 Archived-At: > 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. > 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. Stefan