From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#53207: 28.0.91; create-lockfiles nil breaks file change detection Date: Fri, 14 Jan 2022 15:26:18 +0100 Message-ID: <87fspqz94l.fsf@gmx.de> References: <509ddd0f-589c-45b0-9b60-5820f4c1d716@www.fastmail.com> <83sftr3nyx.fsf@gnu.org> <83h7a73fab.fsf@gnu.org> 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="3366"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Glenn Morris , Lars Ingebrigtsen , 53207@debbugs.gnu.org To: "Jay Berkenbilt" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 14 16:02:55 2022 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 1n8O6R-0000i8-3X for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Jan 2022 16:02:55 +0100 Original-Received: from localhost ([::1]:53020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8O6P-0006m8-Q1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Jan 2022 10:02:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8NXi-0001HH-Qs for bug-gnu-emacs@gnu.org; Fri, 14 Jan 2022 09:27:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8NXi-000640-Gf for bug-gnu-emacs@gnu.org; Fri, 14 Jan 2022 09:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8NXi-0007vV-8U for bug-gnu-emacs@gnu.org; Fri, 14 Jan 2022 09:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Jan 2022 14:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53207 X-GNU-PR-Package: emacs Original-Received: via spool by 53207-submit@debbugs.gnu.org id=B53207.164217039430406 (code B ref 53207); Fri, 14 Jan 2022 14:27:02 +0000 Original-Received: (at 53207) by debbugs.gnu.org; 14 Jan 2022 14:26:34 +0000 Original-Received: from localhost ([127.0.0.1]:35975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8NXF-0007uM-7F for submit@debbugs.gnu.org; Fri, 14 Jan 2022 09:26:33 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:32885) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8NXB-0007u0-Dv for 53207@debbugs.gnu.org; Fri, 14 Jan 2022 09:26:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1642170380; bh=PMqgfV/AlzoEHwAiRhGPFkHjWEHwW/nvAMc9WgnBD60=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=BOtr8Gzzh2+6HyQRJ4FQldUW4DVzh1hQIcg34QkAnMf0OcB0l6GbP/9eJPtSBZpmP 2JQVSgluh0ky5F5/rpreo6uXKikXMjBikOBpH1vfGusTCQNKEOKyhOU58OpRYBmOUQ 9DwbXmf50Q8lNNiTFxQOeFqKzeLEBJSI/ewTJ0iE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.118.160]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M72oH-1nGMx23ixz-008aWu; Fri, 14 Jan 2022 15:26:20 +0100 In-Reply-To: (Jay Berkenbilt's message of "Thu, 13 Jan 2022 10:47:21 -0500") X-Provags-ID: V03:K1:1OYW+gyltftKVVAzTUnn4JQMlItsbwZ24B0AOXtcsLmh5HtNAbu bWGKS7YkV5MWtetGNuUBFwk/E1+hPrcxLsO0wMZUJFJG11UiI+o7zOD9hW6+PJxnN46YEou tJCnXJffnSkh5ko6boMvPk7D4VJ3H2moKA4egtzB7ZVn5wgBSazX2BYtlwiTK9Bdn892XsQ +Auiha2iigTtZfWr/ORmw== X-UI-Out-Filterresults: notjunk:1;V03:K0:+GvkJrTmFmk=:Ja23IA2mdc40NV4HBJ2B9U jS213nuVG2ejsPKKidkzij/er3zQnnOIc7MfjfdKiD3iocJGLXRJ2g+r0e2/sOmMleOTPYS64 9uO9zc/Fu+hcgQwx0irP8tKi9BraKGEjwcxsSgxcm6e5pJFwZw2TxqfgcO3En0Ih7QGG5Urbp xGvT9FPanNe8Zoxh1LMSKup1A8kX9RMHX/q9UapOoneCtPZOb/v6ao6j6Rh6obc2D6ExkLmXA tr0+BmKqDhuhfg+130ybq8SAtBbPyG3yu09d2uwNesT9wjIIpsBk8/ZpkiErnt0A0q7viUMyx UwPp5+GPD+O2LPHyaz5VyiicnpafBjHlFKSQEXBAJQAnyFVOxqF1s0zNtjysSnjiYJRi7fWuG gaASNwn3MkfjjfSUgYrcT8flXVDWq/UrBB+z0dIjFSdmy5s5dDqr7zP3DACcdVhI0C0+NjcKW dYSYSKLaa/wQT2ZTB13crdCKtAAUgfhnajGtJwSBLrBYlJoWKg6XihisXPZvyXlpFAr/pRvq2 3Cjo+QWJRJMRBGeZicb7COtXG12mvY5b3a/Ty9fLaO04q15oOcchH5SBJhxunGSZrytZbwrQP O7F3oFBPxpH/WnrEUU4AwfWSXPfrYefbIt0jJEbIE42pgdmZW9JF8ssmmLvmaqTL9DwzL8ohG 1a97TWjesjuV9Qs+hxKjlqcU8LtMmryKz/FrtoIzQKwKPrS2Im6zDPUlSI8mzEx0nkCgxlkOj nZoBA+NgXv+GMYQJU+RJEh7eVRPt+6RKxDRIc2Q82+ufY1y5KDRt4g6lXS8kruL3zuzgzvHH 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" Xref: news.gmane.io gmane.emacs.bugs:224212 Archived-At: "Jay Berkenbilt" writes: Hi Jay, > On Thu, Jan 13, 2022, at 9:02 AM, Eli Zaretskii wrote: >> > Date: Thu, 13 Jan 2022 08:11:34 -0500 >> > From: "Jay Berkenbilt" >> > Cc: 53207@debbugs.gnu.org >> >=20 >> > For my edification, can you explain how the 27.2 behavior of noticing >> > when a file's contents had changed immediately is not adequate without >> > lockfiles? >>=20 >> First, Emacs 27 wasn't looking at the file's contents, it was looking >> at the file's modification time. > > My original recipe for reproducing the issue demonstrated that, after > "touch file", you can continue editing freely and save, but after > changing the contents, you can't. I don't remember when this first > changed, maybe emacs 27 or 26. For ages before that, it was > modification time. I remember noticing when updating the modtime > without changing the content stopped triggering that. I was delighted. > > It is definitely the case that just updating the modification time on > emacs 27.2 does not trigger this. You can try it. In emacs -Q, edit a > file and save. From the shell, touch the file. No continue editing the > file and save again. No warning. At least this is the case on my > Ubuntu Linux 20.04 system with emacs compiled from source. Same here. In lock_file of Emacs 27, there is the check --8<---------------cut here---------------start------------->8--- if (!NILP (subject_buf) && NILP (Fverify_visited_file_modtime (subject_buf)) && !NILP (Ffile_exists_p (fn))) call1 (intern ("userlock--ask-user-about-supersession-threat"), fn); --8<---------------cut here---------------end--------------->8--- It checks the file modification time. But then, if changed, it calls userlock--ask-user-about-supersession-threat, which also checks the file contents before warning. Therefore, a simple touch doesn't trigger the user question. >> > It seems to me that there are two separate issues here. A lock file >> > would enable you to immediately notice if a user on a *different >> > system* is in the process of editing a file and has unsaved changes. >>=20 >> No, it also works when the same user on the same system edited the >> file from another Emacs session. That is a valid use case: some >> people start more than a single Emacs session on the same system. > > Granted. Of course it doesn't protect against another very common use > case, which is people opening the same file in emacs and > simultaneously in something like VS Code or another IDE. I know > developers that work this way day in and day out -- they use emacs for > most of their editing but hop over to an IDE to take advantage of > project-wide integrations, better test integration, a more advanced > debugger, or better out-of-the-box functionality with their > programming language or environment of choice. So lock files remain a > solution that only works in an emacs-only environment, while noticing > that the file's modification time has changed is universal, and > noticing that a file's content has changed is a great advancement over > just noticing modtime since it allows for workflows like git rebase. > >> > On the other hand, the other behavior I'm talking about allows you to >> > notice immediately when you begin editing if the file on disk has >> > become out of sync with the buffer contents. >>=20 >> That part is done when you save the buffer. It is unaffected by >> create-lockfiles. > > It is also done when you start editing a buffer, as shown in my original > message. Really. Try it. Sure. That's because there's no visited file modification time yet for that buffer. In Emacs 28, the check above has been extended to --8<---------------cut here---------------start------------->8--- if (!NILP (subject_buf) && NILP (Fverify_visited_file_modtime (subject_buf)) && !NILP (Ffile_exists_p (fn)) && current_lock_owner (NULL, lfname) !=3D I_OWN_IT) call1 (intern ("userlock--ask-user-about-supersession-threat"), fn); --8<---------------cut here---------------end--------------->8--- So it checks also the owner of the lock file. This makes only sense, if create-lockfiles is non-nil; otherwise there is no lock file owner ... I agree with Eli, that the current behavior in Emacs 28 is consistent. Since this is an incompatible change, we shall document it. The Emacs 28 manual says --8<---------------cut here---------------start------------->8--- You can prevent the creation of lock files by setting the variable =E2=80=98create-lockfiles=E2=80=99 to =E2=80=98nil=E2=80=99. *Caution:* by= doing so you will lose the benefits that this feature provides. --8<---------------cut here---------------end--------------->8--- Maybe it shall be more explicit saying, that also detection of changing the modification time is lost when create-lockfiles is nil. etc/NEWS is silent about this, it should explain this subtle change as well. Best regards, Michael.