From unknown Wed Jun 18 23:05:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#49893 <49893@debbugs.gnu.org> To: bug#49893 <49893@debbugs.gnu.org> Subject: Status: [PATCH] Reset mtime of a reverted buffer Reply-To: bug#49893 <49893@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:05:41 +0000 retitle 49893 [PATCH] Reset mtime of a reverted buffer reassign 49893 emacs submitter 49893 Konstantin Kharlamov severity 49893 normal tag 49893 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 05 11:28:42 2021 Received: (at submit) by debbugs.gnu.org; 5 Aug 2021 15:28:42 +0000 Received: from localhost ([127.0.0.1]:48109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBfIY-0000dH-IA for submit@debbugs.gnu.org; Thu, 05 Aug 2021 11:28:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:49570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBfIW-0000d8-E1 for submit@debbugs.gnu.org; Thu, 05 Aug 2021 11:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBfIW-0006iU-52 for bug-gnu-emacs@gnu.org; Thu, 05 Aug 2021 11:28:40 -0400 Received: from forward104j.mail.yandex.net ([2a02:6b8:0:801:2::107]:35558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBfIR-0006HH-1K for bug-gnu-emacs@gnu.org; Thu, 05 Aug 2021 11:28:39 -0400 Received: from forward102q.mail.yandex.net (forward102q.mail.yandex.net [IPv6:2a02:6b8:c0e:1ba:0:640:516:4e7d]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 97D214A3070 for ; Thu, 5 Aug 2021 18:28:28 +0300 (MSK) Received: from vla1-e8d3e6f22b4d.qloud-c.yandex.net (vla1-e8d3e6f22b4d.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:3603:0:640:e8d3:e6f2]) by forward102q.mail.yandex.net (Yandex) with ESMTP id 911463A20002 for ; Thu, 5 Aug 2021 18:28:28 +0300 (MSK) Received: from vla5-47b3f4751bc4.qloud-c.yandex.net (vla5-47b3f4751bc4.qloud-c.yandex.net [2a02:6b8:c18:3508:0:640:47b3:f475]) by vla1-e8d3e6f22b4d.qloud-c.yandex.net (mxback/Yandex) with ESMTP id le37UrYv66-SSIOGcVT; Thu, 05 Aug 2021 18:28:28 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1628177308; bh=cH11tz1g56WviR90syLZCPUMvAz6CtorV9FfurVJ0GE=; h=Date:To:From:Subject:Message-ID; b=D1mBk3n9koCTawCjDukMWUmAcZlhbzPZQbOX5Ss7QTBBzds/h8NxJ4+/xnqy/rgNp lKlAJvG6mNsF5QafX6T0ioTT6zovwM6Emc24u1sfEgXHjYgVhP7gpgKlc3r/DPV8xB lsDQUPiKNUnG1MT233DqeV2LTUL3GFELx4RrYhVU= Authentication-Results: vla1-e8d3e6f22b4d.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by vla5-47b3f4751bc4.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id Z237D98Y3x-SSTaZxvX; Thu, 05 Aug 2021 18:28:28 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <40b594e36f8d8d8b200b91238d2208c8d25fd2c9.camel@yandex.ru> Subject: [PATCH] Reset mtime of a reverted buffer From: Konstantin Kharlamov To: bug-gnu-emacs@gnu.org Date: Thu, 05 Aug 2021 18:28:28 +0300 Content-Type: multipart/mixed; boundary="=-2RZ8J9vOycEZOgiKxaMG" User-Agent: Evolution 3.40.3 MIME-Version: 1.0 Received-SPF: pass client-ip=2a02:6b8:0:801:2::107; envelope-from=hi-angel@yandex.ru; helo=forward104j.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-2RZ8J9vOycEZOgiKxaMG Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Patch is attached. This resolves the problem reported at https://github.com/emacs-evil/evil/issues/1504 --=-2RZ8J9vOycEZOgiKxaMG Content-Disposition: attachment; filename="1.patch" Content-Transfer-Encoding: base64 Content-Type: text/x-patch; name="1.patch"; charset="UTF-8" RnJvbSA5OTI2NmM0YmEyZDAzOTE1NzJhOWIwNjE0OWEwZjUwMDMxYmI0NGEyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBLb25zdGFudGluIEtoYXJsYW1vdiA8SGktQW5nZWxAeWFuZGV4 LnJ1PgpEYXRlOiBUaHUsIDUgQXVnIDIwMjEgMTg6MjU6NTYgKzAzMDAKU3ViamVjdDogW1BBVENI XSBSZXNldCBtdGltZSBvZiBhIHJldmVydGVkIGJ1ZmZlcgoKKiBsaXNwL2ZpbGVzLmVsIChyZXZl cnQtYnVmZmVyLWluc2VydC1maWxlLWNvbnRlbnRzLWRlbGljYXRlbHkpOgpPbmNlIGJ1ZmZlciBp cyByZXZlcnRlZCwgcmVzZXQgaXRzIG10aW1lIHRvIHRoYXQgb2YgdGhlIGZpbGUuCi0tLQogbGlz cC9maWxlcy5lbCB8IDMgKystCiAxIGZpbGUgY2hhbmdlZCwgMiBpbnNlcnRpb25zKCspLCAxIGRl bGV0aW9uKC0pCgpkaWZmIC0tZ2l0IGEvbGlzcC9maWxlcy5lbCBiL2xpc3AvZmlsZXMuZWwKaW5k ZXggMmIxM2QwNGJjYmUuLmMyNjA3OTU2OTE1IDEwMDY0NAotLS0gYS9saXNwL2ZpbGVzLmVsCisr KyBiL2xpc3AvZmlsZXMuZWwKQEAgLTY1MzMsNyArNjUzMyw4IEBAIHJldmVydC1idWZmZXItaW5z ZXJ0LWZpbGUtY29udGVudHMtZGVsaWNhdGVseQogICAgICAgOzsgU2VlIGNvbW1lbnRzIGluIHJl dmVydC1idWZmZXItd2l0aC1maW5lLWdyYWluIGZvciBhbiBleHBsYW5hdGlvbi4KICAgICAgIChk ZWZ1biByZXZlcnQtYnVmZmVyLXdpdGgtZmluZS1ncmFpbi1zdWNjZXNzLXAgKCkKICAgICAgICAg c3VjY2VzcykpCi0gICAgKHNldC1idWZmZXItbW9kaWZpZWQtcCBuaWwpKSkpCisgICAgKHNldC1i dWZmZXItbW9kaWZpZWQtcCBuaWwpCisgICAgKHNldC12aXNpdGVkLWZpbGUtbW9kdGltZSkpKSkK IAogKGRlZnVuIHJldmVydC1idWZmZXItd2l0aC1maW5lLWdyYWluICgmb3B0aW9uYWwgaWdub3Jl LWF1dG8gbm9jb25maXJtKQogICAiUmV2ZXJ0IGJ1ZmZlciBwcmVzZXJ2aW5nIG1hcmtlcnMsIG92 ZXJsYXlzLCBldGMuCi0tIAoyLjMyLjAKCg== --=-2RZ8J9vOycEZOgiKxaMG-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 05 12:36:58 2021 Received: (at 49893) by debbugs.gnu.org; 5 Aug 2021 16:36:58 +0000 Received: from localhost ([127.0.0.1]:48219 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBgMc-0002Sd-9Y for submit@debbugs.gnu.org; Thu, 05 Aug 2021 12:36:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBgMb-0002SR-CF for 49893@debbugs.gnu.org; Thu, 05 Aug 2021 12:36:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46344) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBgMW-0000vX-2L; Thu, 05 Aug 2021 12:36:52 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3802 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBgMV-0005C6-Bz; Thu, 05 Aug 2021 12:36:51 -0400 Date: Thu, 05 Aug 2021 19:36:48 +0300 Message-Id: <838s1fkfvj.fsf@gnu.org> From: Eli Zaretskii To: Konstantin Kharlamov In-Reply-To: <40b594e36f8d8d8b200b91238d2208c8d25fd2c9.camel@yandex.ru> (message from Konstantin Kharlamov on Thu, 05 Aug 2021 18:28:28 +0300) Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer References: <40b594e36f8d8d8b200b91238d2208c8d25fd2c9.camel@yandex.ru> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 49893 Cc: 49893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Konstantin Kharlamov > Date: Thu, 05 Aug 2021 18:28:28 +0300 > > Patch is attached. This resolves the problem reported at https://github.com/emacs-evil/evil/issues/1504 Could you please describe the problem you are trying to solve, preferably without involving Evil? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 05 12:54:13 2021 Received: (at 49893) by debbugs.gnu.org; 5 Aug 2021 16:54:13 +0000 Received: from localhost ([127.0.0.1]:48263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBgdI-0002wU-Ok for submit@debbugs.gnu.org; Thu, 05 Aug 2021 12:54:13 -0400 Received: from forward101p.mail.yandex.net ([77.88.28.101]:40464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBgdG-0002wH-Qy for 49893@debbugs.gnu.org; Thu, 05 Aug 2021 12:54:11 -0400 Received: from forward103q.mail.yandex.net (forward103q.mail.yandex.net [IPv6:2a02:6b8:c0e:50:0:640:b21c:d009]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 005A032830D6; Thu, 5 Aug 2021 19:54:04 +0300 (MSK) Received: from vla5-53b4ceaf8148.qloud-c.yandex.net (vla5-53b4ceaf8148.qloud-c.yandex.net [IPv6:2a02:6b8:c18:341a:0:640:53b4:ceaf]) by forward103q.mail.yandex.net (Yandex) with ESMTP id EFFE661E0004; Thu, 5 Aug 2021 19:54:03 +0300 (MSK) Received: from vla5-3832771863b8.qloud-c.yandex.net (vla5-3832771863b8.qloud-c.yandex.net [2a02:6b8:c18:3417:0:640:3832:7718]) by vla5-53b4ceaf8148.qloud-c.yandex.net (mxback/Yandex) with ESMTP id jsOgDImU31-s3ISaPoh; Thu, 05 Aug 2021 19:54:03 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1628182443; bh=rtntcs/DS+qyrPmJRFuD/JB5znHXNnqcAJFePth1ivg=; h=In-Reply-To:References:Date:To:From:Subject:Message-ID:Cc; b=KsW0z7pz7lyVjDIM5iuYmyiIS5iAvjveUH5vHl5/Aa1XOIJTLfFvnagjLeY4/UXgn HV9zuuUVObqpxJBun79eGdbr4QJNIhScbbqZi1hfw7ja1vnsZj83RhAAzG5SgeUOm7 86gML2rzGtcP9F9tjs3kqfVy0D01sp9VeuI5FYOc= Authentication-Results: vla5-53b4ceaf8148.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by vla5-3832771863b8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id hOdCrGQPDL-s3JOmbIW; Thu, 05 Aug 2021 19:54:03 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru> Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer From: Konstantin Kharlamov To: Eli Zaretskii Date: Thu, 05 Aug 2021 19:54:03 +0300 In-Reply-To: <838s1fkfvj.fsf@gnu.org> References: <40b594e36f8d8d8b200b91238d2208c8d25fd2c9.camel@yandex.ru> <838s1fkfvj.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49893 Cc: 49893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Thu, 2021-08-05 at 19:36 +0300, Eli Zaretskii wrote: > > From: Konstantin Kharlamov > > Date: Thu, 05 Aug 2021 18:28:28 +0300 > > > > Patch is attached. This resolves the problem reported at > > https://github.com/emacs-evil/evil/issues/1504 > > Could you please describe the problem you are trying to solve, > preferably without involving Evil? Sure. The auto-revert-mode by default works with ‘revert-buffer-insert-file-contents--default-function’ function. This function is known to break markers in buffers, which is why recently Emacs has added a replacement function revert-buffer-insert-file-contents-delicately (the one I modify in the patch). However, actually trying to use this new function revealed a regression in behavior of another function: the `find-file`. Basically, if you have a file `/tmp/foo` opened in Emacs (IOW Emacs has a buffer associated with this file), and then file `/tmp/foo` gets "auto-reverted", then if you execute (find-file "/tmp/foo"), the new function causes Emacs ask a user "File foo was modified, do you want to revert it? (yes/no)". It now gives that prompt always, until you make a change to the buffer. That's a regression compared to the default behavior with `revert-buffer-insert-file-contents--default-function`. And the reason turned out to be that the function `revert-buffer-insert-file-contents--default-function` after having succesfully reverted a file, sets the buffer mtime to the mtime of the file. However the function revert-buffer-insert-file-contents-delicately didn't set mtime before that patch. I assume it is an omission from implementation, because technically that's incorrect: if the revert-buffer-insert-file-contents-delicately has successfully reverted a buffer, then we know that it has same content as the associated file, and hence it should have the same mtime. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 05 13:51:57 2021 Received: (at 49893-done) by debbugs.gnu.org; 5 Aug 2021 17:51:57 +0000 Received: from localhost ([127.0.0.1]:48356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBhXA-0006Ye-Jj for submit@debbugs.gnu.org; Thu, 05 Aug 2021 13:51:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBhX9-0006YR-2z for 49893-done@debbugs.gnu.org; Thu, 05 Aug 2021 13:51:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48822) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBhX3-0004Xv-6a; Thu, 05 Aug 2021 13:51:49 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4433 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBhX1-0003Ql-2h; Thu, 05 Aug 2021 13:51:49 -0400 Date: Thu, 05 Aug 2021 20:51:31 +0300 Message-Id: <8335rnkcf0.fsf@gnu.org> From: Eli Zaretskii To: Konstantin Kharlamov In-Reply-To: <7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru> (message from Konstantin Kharlamov on Thu, 05 Aug 2021 19:54:03 +0300) Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer References: <40b594e36f8d8d8b200b91238d2208c8d25fd2c9.camel@yandex.ru> <838s1fkfvj.fsf@gnu.org> <7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 49893-done Cc: 49893-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Konstantin Kharlamov > Cc: 49893@debbugs.gnu.org > Date: Thu, 05 Aug 2021 19:54:03 +0300 > > On Thu, 2021-08-05 at 19:36 +0300, Eli Zaretskii wrote: > > > From: Konstantin Kharlamov > > > Date: Thu, 05 Aug 2021 18:28:28 +0300 > > > > > > Patch is attached. This resolves the problem reported at > > > https://github.com/emacs-evil/evil/issues/1504 > > > > Could you please describe the problem you are trying to solve, > > preferably without involving Evil? > > Sure. The auto-revert-mode by default works with ‘revert-buffer-insert-file-contents--default-function’ function. This function is known to break markers in buffers, which is why recently Emacs has added a replacement function revert-buffer-insert-file-contents-delicately (the one I modify in the patch). > > However, actually trying to use this new function revealed a regression in behavior of another function: the `find-file`. Basically, if you have a file `/tmp/foo` opened in Emacs (IOW Emacs has a buffer associated with this file), and then file `/tmp/foo` gets "auto-reverted", then if you execute (find-file "/tmp/foo"), the new function causes Emacs ask a user "File foo was modified, do you want to revert it? (yes/no)". It now gives that prompt always, until you make a change to the buffer. > > That's a regression compared to the default behavior with `revert-buffer-insert-file-contents--default-function`. And the reason turned out to be that the function `revert-buffer-insert-file-contents--default-function` after having succesfully reverted a file, sets the buffer mtime to the mtime of the file. However the function revert-buffer-insert-file-contents-delicately didn't set mtime before that patch. I assume it is an omission from implementation, because technically that's incorrect: if the revert-buffer-insert-file-contents-delicately has successfully reverted a buffer, then we know that it has same content as the associated file, and hence it should have the same mtime. Thanks. I installed the change on the master branch. From unknown Wed Jun 18 23:05:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 03 Sep 2021 11:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator