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#49893: [PATCH] Reset mtime of a reverted buffer Date: Thu, 05 Aug 2021 20:51:31 +0300 Message-ID: <8335rnkcf0.fsf@gnu.org> 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 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29751"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49893-done@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 05 19:52:09 2021 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 1mBhXN-0007VF-3w for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Aug 2021 19:52:09 +0200 Original-Received: from localhost ([::1]:34296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBhXL-0006Zc-EG for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Aug 2021 13:52:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBhXG-0006ZK-Is for bug-gnu-emacs@gnu.org; Thu, 05 Aug 2021 13:52:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mBhXG-0004gL-BB for bug-gnu-emacs@gnu.org; Thu, 05 Aug 2021 13:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mBhXG-0006Z1-8f for bug-gnu-emacs@gnu.org; Thu, 05 Aug 2021 13:52:02 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Aug 2021 17:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 49893 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 49893@debbugs.gnu.org, eliz@gnu.org, hi-angel@yandex.ru Original-Received: via spool by 49893-done@debbugs.gnu.org id=D49893.162818591725217 (code D ref 49893); Thu, 05 Aug 2021 17:52:02 +0000 Original-Received: (at 49893-done) by debbugs.gnu.org; 5 Aug 2021 17:51:57 +0000 Original-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 Original-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 Original-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 Original-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 In-Reply-To: <7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru> (message from Konstantin Kharlamov on Thu, 05 Aug 2021 19:54:03 +0300) 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:211260 Archived-At: > 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.