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: Fri, 29 Mar 2024 21:12:54 +0300 Message-ID: <86frw8ewk9.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="25335"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 70077@debbugs.gnu.org, yantar92@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, monnier@iro.umontreal.ca, 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 Fri Mar 29 19:14:24 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 1rqGkB-0006PB-Ey for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Mar 2024 19:14:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqGjt-00061K-1D; Fri, 29 Mar 2024 14:14:05 -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 1rqGjp-000615-Vo for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 14:14:02 -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 1rqGjo-0003c8-8g for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 14:14:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqGjp-0007bT-Ke for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 14:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Mar 2024 18:14: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.171173599429092 (code B ref 70077); Fri, 29 Mar 2024 18:14:01 +0000 Original-Received: (at 70077) by debbugs.gnu.org; 29 Mar 2024 18:13:14 +0000 Original-Received: from localhost ([127.0.0.1]:43408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqGj3-0007Z7-AS for submit@debbugs.gnu.org; Fri, 29 Mar 2024 14:13:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqGj0-0007Yt-V6 for 70077@debbugs.gnu.org; Fri, 29 Mar 2024 14:13:11 -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 1rqGio-0003TJ-HS; Fri, 29 Mar 2024 14:12:59 -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=X8zNmtRQP0SLSAhAM7kbSkQ28wGf9dwkPmEku0/N82Y=; b=qbQ7X67dWxhtmuykI5tr 1Ssi4B2AfE+T6CW4QD0O2+UShg/9sV5xfwMcM2yhijgqc1NFBw3eRB9s2mUsBfn7Wo/AXykVzYQtA QwNK7zu+RFqyoEMK2tEVurK+uB1hPs8p35zZxZYiLaGBKl3fXnMYhDpXIOaOip00/sTnnCP6qA6qQ Gkw31Z+dAXT6zNLG+K+kZjqTc2b2IImKwXoh0EHk8aJuWc74GuPcPWgGUgHdPuitpqRYxW5NM+iT7 qAgui7RZlmDktB2pIGkP/RpTTrGM9j0Xrx/E2S5w75tzbeaJVuIhnEF9JdAh3H7yWd6Mj5TdcC1xb BPu19HDJS+TUOA==; 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:282315 Archived-At: > Cc: Nicolas Goaziou , > Ihor Radchenko , Alan Mackenzie , > João Távora , > Alan Zimmerman , > Frédéric Bour , > Phillip Lord , > Stephen Leake , Yuan Fu , > Qiantan Hong , monnier@iro.umontreal.ca > Date: Fri, 29 Mar 2024 12:15:53 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > (defun track-changes-register ( signal) > "Register a new tracker and return a new tracker ID. > SIGNAL is a function that will be called with no argument when > the current buffer is modified, so that we can react to the change. > Once called, SIGNAL is not called again until `track-changes-fetch' > is called with the corresponding tracker ID." > > (defun track-changes-unregister (id) > "Remove the tracker denoted by ID. > Trackers can consume resources (especially if `track-changes-fetch' is > not called), so it is good practice to unregister them when you don't > need them any more." > > (defun track-changes-fetch (id func) > "Fetch the pending changes. > ID is the tracker ID returned by a previous `track-changes-register'. > FUNC is a function. It is called with 3 arguments (BEGIN END BEFORE) > where BEGIN..END delimit the region that was changed since the last > time `track-changes-fetch' was called and BEFORE is a string containing > the previous content of that region. > > If no changes occurred since the last time, FUNC is not called and > we return nil, otherwise we return the value returned by FUNC, > and re-enable the TRACKER corresponding to ID." I cannot imagine how applications would use these APIs. I'm probably missing something, org the above documentation does. Can you show some real-life examples?