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#72696: Track-changes errors out when file is overwritten using Node.js's fs.writeFile (at least on macOS) Date: Sun, 18 Aug 2024 12:10:37 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21420"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 72696@debbugs.gnu.org To: Dario Gjorgjevski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 18 18:11:36 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 1sfiVD-0005Mh-Un for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Aug 2024 18:11:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfiV1-0004tK-Vk; Sun, 18 Aug 2024 12:11:24 -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 1sfiV0-0004t4-1X for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 12:11:22 -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 1sfiUz-0002l6-Ou for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 12:11:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=Ml2N1HNWCsVSXifOTS0352H10fd27HCLFV78my9X+Vw=; b=pIBlboM6gL8g+v/ZNuNfVetC+3ABD5c32K0lWjpr/uJTYOJ7baVW/VeI/SBKq/VrvFqSlAPY4eB21g4IV8a2OfzK69EuOFC0hxyX7OzOsGmM2PPy/fVhTKtBG9vnjFQgo4Dsl+1FWHo87a6yJ4fU65u8gI91Wp6zCdATGV2xj6FfDBOm40wx+S5pvxjyWWt0vC2Rl5sn0ypgIiVk+XPSIUbZh85nMxSJGelCdn9Szf6+xL+D79wwa3mPd0Rdd6WAPUhNve1v4rsHIV6ySZxDuAlWasEx2wPEojr+QFu5q0vhSklY4oMQzEqHvexZZ5GZq7rkGOn1Si3zK8qwUSQPEg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sfiVe-0002h4-5S for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 12:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Aug 2024 16:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72696 X-GNU-PR-Package: emacs Original-Received: via spool by 72696-submit@debbugs.gnu.org id=B72696.172399748910305 (code B ref 72696); Sun, 18 Aug 2024 16:12:02 +0000 Original-Received: (at 72696) by debbugs.gnu.org; 18 Aug 2024 16:11:29 +0000 Original-Received: from localhost ([127.0.0.1]:56540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfiV7-0002g9-26 for submit@debbugs.gnu.org; Sun, 18 Aug 2024 12:11:29 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:1267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfiV5-0002ft-4k for 72696@debbugs.gnu.org; Sun, 18 Aug 2024 12:11:28 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 352A3442DA9; Sun, 18 Aug 2024 12:10:40 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1723997438; bh=+mb+hHrq11ytrYJmoykByC9hhxM3x0+3dP0UjYWHNJ0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CAhkbIXeWiYgE09W3AaZI1ne5zpqOPDE4IBdPVDj0K46p/nWYuQRnYeWrNHve7Nxr 0yAV1LRDzRs/kjzCzWQKcZTaMMAR6WxVC+Nl6zLBnJe1rNnfHndLJFMRDdGCKf6p2w e4C65qkFRIcfIaiJ0fMx+j1jBPZhLMXv6s+7WMs8hW0UF1d3zEFAJArg7hf8EbgJbh AZxynqmxh9H7Y54QFFExuhblq4c3kEIaWjy4BUbmzSmNg0RPU3OwLJ1z3G5/69oOch YN3RWiRPhKEDSqOnBfCTbcY8IuwhPnF20pyFps+NtNI6Bb5HC2MPeWnNeDNACP7q0C t9NftbosmQg6Q== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5EA06442DA7; Sun, 18 Aug 2024 12:10:38 -0400 (EDT) Original-Received: from alfajor (unknown [216.154.9.87]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 343D61204B0; Sun, 18 Aug 2024 12:10:38 -0400 (EDT) In-Reply-To: (Dario Gjorgjevski's message of "Sun, 18 Aug 2024 12:58:24 +0200") 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:290333 Archived-At: > 1. In one shell, fire up GNU Emacs, open a file, and start something > that uses track-changes; e.g., Eglot. In my case it was a Python file > called test.py with contents foo =3D 0. Everything is happy so far. > 2. In another shell, fire up a Node.js interpreter and execute const > fs =3D require("node:fs/promises") followed by await > fs.writeFile("test.py", "foo =3D 1"). This will overwrite the file. > 3. Track-changes (and by extension Eglot) will error out. Restarting > Eglot makes everything go back to normal. > > The *Warnings* buffer now contains: > > Warning (emacs): Missing/incorrect calls to > =E2=80=98before/after-change-functions=E2=80=99!! > Details logged to `track-changes--error-log' The above is only a "warning": it just logged the occurrence of something undesired, but track-changes supposedly recovered from that. IOW you describe two problems: - Somehow/somewhere there is a "Missing/incorrect calls to =E2=80=98before/after-change-functions". [ But these problems are sufficiently common that track-changes has code devoted to detecting and handling those cases. ] We want to try and fix the origin of this problem, but it's been with us "for ever", so it's not super extra urgent because there will still be other cases where it can show up. Eglot has had to deal with this problem since its inception, it just used to keep silent about it, contrary to track-changes (because I want to get rid of those problems). - Eglot errors out. This should definitely not happen and seems like a regression. Restarting Eglot should definitely not be needed. Could you clarify what you mean by Eglot erroring out and why restarting it is necessary? > And `track-changes--error-log' contains: > > (("test.py" #1=3D(unexpected-after 1 8 0) > ((t track-changes--recover-from-error (#1#) nil) > (t track-changes--after (1 8 0) nil) > (t revert-buffer-insert-file-contents--default-function > ("/path/to/test.py" > nil) > nil) > (t revert-buffer--default (ignore-auto dont-ask) nil) > (t revert-buffer (ignore-auto dont-ask preserve-modes) nil) Hmm... assuming the file really started with content "foo =3D 0" (and no terminating newline), "track-changes--after (1 8 0)" looks OK: the revert has changed the file size by 0 chars and the new content spans chars from 1 to 8. So my guess is that revert-buffer failed to call the `before-changes-functions` or that it called it with a smaller region (e.g. only the region that's actually modified (7..8), where "0" is turned into "1"). Will have to dig deeper. BTW, your recipe does not mention enabling auto-revert. Have you confirmed on your side that the problem shows up also in a vanilla config? Stefan