From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Tracking buffer positions across time, without markers (was Re: PL support) Date: Sun, 10 May 2020 16:46:29 -0400 Message-ID: References: <6a2c7d18-344e-fefb-63d5-79a99d0532fc@gmail.com> <942a8cb1-0382-cf83-5ff9-4e776c2660f0@gmail.com> <7f8bdd43-f4d7-e0a8-dcfa-6679215f9d44@gmail.com> <9e98ccbd-6b01-d076-79eb-6bd06ab803fb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="16967"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Zaretskii , =?windows-1252?B?Sm/jbyBU4XZvcmE=?= , emacs-devel@gnu.org To: =?windows-1252?Q?Cl=E9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 10 22:47:16 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jXsqx-0004IW-Fm for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 22:47:15 +0200 Original-Received: from localhost ([::1]:38554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXsqw-000183-Gu for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 16:47:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXsqK-0000ZC-NK for emacs-devel@gnu.org; Sun, 10 May 2020 16:46:36 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXsqI-0006ea-VJ; Sun, 10 May 2020 16:46:35 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5ECEB10082B; Sun, 10 May 2020 16:46:33 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6C53210045B; Sun, 10 May 2020 16:46:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1589143591; bh=lLRe9lGX+j1EE7WHXOVeY0hkyCgOjgKP3WGB0tfBcEk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Lxd33OIfKGr/MQydhZRgQ3Oy8Yx2W3IYHcdvy+6b/0454G4LAsZdK4eZyqTu6vgpR TsH/arEXLd9DOQFuw0bSMcebraHT7QzYcP5ajeQ3meKcUjy/J8QiL045gGQA+E/7Fo voJS66ZyA/acKqGoR8s8yXkUeALdvKSBAWxViXKOp9XiLB0o3NXpRM8Z0+oeR/Rf14 YxTF8yn1g72j87utUGyZrWIzGOJXEEBGU6EpT+kHc0f1yGn/wTmZ4WwBhpj64df/mC nD3QU+Xmota9K7bKXe7r95zrPFSuccg83Cvmk/E9Kckgek+2US2FZ5bPpmVxJ7oBWP mwKDTka0D+8tA== Original-Received: from alfajor (unknown [216.154.3.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A2FC5120769; Sun, 10 May 2020 16:46:30 -0400 (EDT) In-Reply-To: <9e98ccbd-6b01-d076-79eb-6bd06ab803fb@gmail.com> (=?windows-1252?Q?=22Cl=E9ment?= Pit-Claudel"'s message of "Sun, 10 May 2020 15:27:47 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 12:34:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249721 Archived-At: > The general problem is this: I send the contents of a buffer to > a subprocess. Some time later, the subprocess returns a list of positions > (offsets from the beginning of the buffer, or line/column pairs, etc). > At that point, these positions may be stale, since the contents of the > buffer may have changed. I need a way to translate these positions > (relative to the old buffer contents) into positions relative to the new > buffer contents. As you said you should be able to use the undo-list for that. It'll require a bit of work, but hopefully that can be used in several places, justifying the investment. If you have the option to ask for a more up-to-date version of the data to be sent, you can obviously throw the data away, but even in that case you should be able to do better with fairly little work: use an after-change-function to keep track of just 2 markers that indicate the beginning and end of the part of the buffer that's been modified. Then you can easily translate all the positions before the first and after the second marker and only discard the data between the two. Stefan