GNU bug report logs - #49893
[PATCH] Reset mtime of a reverted buffer

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Thu, 5 Aug 2021 15:29:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49893 in the body.
You can then email your comments to 49893 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49893; Package emacs. (Thu, 05 Aug 2021 15:29:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Konstantin Kharlamov <hi-angel <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 05 Aug 2021 15:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Reset mtime of a reverted buffer
Date: Thu, 05 Aug 2021 18:28:28 +0300
[Message part 1 (text/plain, inline)]
Patch is attached. This resolves the problem reported at https://github.com/emacs-evil/evil/issues/1504


[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49893; Package emacs. (Thu, 05 Aug 2021 16:37:01 GMT) Full text and rfc822 format available.

Message #8 received at 49893 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 49893 <at> debbugs.gnu.org
Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer
Date: Thu, 05 Aug 2021 19:36:48 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49893; Package emacs. (Thu, 05 Aug 2021 16:55:02 GMT) Full text and rfc822 format available.

Message #11 received at 49893 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49893 <at> debbugs.gnu.org
Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer
Date: Thu, 05 Aug 2021 19:54:03 +0300
On Thu, 2021-08-05 at 19:36 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > 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.





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 05 Aug 2021 17:52:02 GMT) Full text and rfc822 format available.

Notification sent to Konstantin Kharlamov <hi-angel <at> yandex.ru>:
bug acknowledged by developer. (Thu, 05 Aug 2021 17:52:02 GMT) Full text and rfc822 format available.

Message #16 received at 49893-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 49893-done <at> debbugs.gnu.org
Subject: Re: bug#49893: [PATCH] Reset mtime of a reverted buffer
Date: Thu, 05 Aug 2021 20:51:31 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> Cc: 49893 <at> 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 <hi-angel <at> yandex.ru>
> > > 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 03 Sep 2021 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.