* bug#49893: [PATCH] Reset mtime of a reverted buffer
@ 2021-08-05 15:28 Konstantin Kharlamov
2021-08-05 16:36 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Kharlamov @ 2021-08-05 15:28 UTC (permalink / raw)
To: 49893
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
Patch is attached. This resolves the problem reported at https://github.com/emacs-evil/evil/issues/1504
[-- Attachment #2: 1.patch --]
[-- Type: text/x-patch, Size: 994 bytes --]
From 99266c4ba2d0391572a9b06149a0f50031bb44a2 Mon Sep 17 00:00:00 2001
From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Date: Thu, 5 Aug 2021 18:25:56 +0300
Subject: [PATCH] Reset mtime of a reverted buffer
* lisp/files.el (revert-buffer-insert-file-contents-delicately):
Once buffer is reverted, reset its mtime to that of the file.
---
lisp/files.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/files.el b/lisp/files.el
index 2b13d04bcbe..c2607956915 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6533,7 +6533,8 @@ revert-buffer-insert-file-contents-delicately
;; See comments in revert-buffer-with-fine-grain for an explanation.
(defun revert-buffer-with-fine-grain-success-p ()
success))
- (set-buffer-modified-p nil))))
+ (set-buffer-modified-p nil)
+ (set-visited-file-modtime))))
(defun revert-buffer-with-fine-grain (&optional ignore-auto noconfirm)
"Revert buffer preserving markers, overlays, etc.
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#49893: [PATCH] Reset mtime of a reverted buffer
2021-08-05 15:28 bug#49893: [PATCH] Reset mtime of a reverted buffer Konstantin Kharlamov
@ 2021-08-05 16:36 ` Eli Zaretskii
2021-08-05 16:54 ` Konstantin Kharlamov
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-05 16:36 UTC (permalink / raw)
To: Konstantin Kharlamov; +Cc: 49893
> From: Konstantin Kharlamov <hi-angel@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#49893: [PATCH] Reset mtime of a reverted buffer
2021-08-05 16:36 ` Eli Zaretskii
@ 2021-08-05 16:54 ` Konstantin Kharlamov
2021-08-05 17:51 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Kharlamov @ 2021-08-05 16:54 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 49893
On Thu, 2021-08-05 at 19:36 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <hi-angel@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#49893: [PATCH] Reset mtime of a reverted buffer
2021-08-05 16:54 ` Konstantin Kharlamov
@ 2021-08-05 17:51 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-05 17:51 UTC (permalink / raw)
To: Konstantin Kharlamov; +Cc: 49893-done
> From: Konstantin Kharlamov <hi-angel@yandex.ru>
> 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 <hi-angel@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-05 17:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-05 15:28 bug#49893: [PATCH] Reset mtime of a reverted buffer Konstantin Kharlamov
2021-08-05 16:36 ` Eli Zaretskii
2021-08-05 16:54 ` Konstantin Kharlamov
2021-08-05 17:51 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.