unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 49893@debbugs.gnu.org
Subject: bug#49893: [PATCH] Reset mtime of a reverted buffer
Date: Thu, 05 Aug 2021 19:54:03 +0300	[thread overview]
Message-ID: <7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru> (raw)
In-Reply-To: <838s1fkfvj.fsf@gnu.org>

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.






  reply	other threads:[~2021-08-05 16:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-08-05 17:51     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dc543c6f2294f48b5ff11f2274b983b2e3ce03e.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=49893@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).