Subject: bug#75626: 31.0.50; Dired misses or double-processes files when auto-revert-mode is enabled

From: Tassilo Horn <[email-masked]>
Date: Sun, 02 Feb 2025 13:55:47 +0100

Michael Albinus <[email-masked]> writes:

>> Why is the macro inhibit-auto-revert defined in a progn?  I think,
>> I've never seen that before.
>
> This is a trick to bring the defmacro body into loaddefs.el. See also
> the declaration of define-short-documentation-group, for example.

Interesting, I didn't know.  Thanks!

>> And why does dired-buffer-stale-p check if the current dired buffer
>> is member of inhibit-auto-revert-buffers?  Isn't the point to move
>> the allowance check from packages' buffer-stale-function to
>> auto-revert itself?  In that case, the buffer-read-only check (set by
>> wdired-mode) should probably also be rewritten to add the currently
>> edited dired buffer to inhibit-auto-revert-buffers and to remove it
>> when wdired-mode is deactivated (wdired-finish-edit).
>
> Yes, I've moved the check of a buffer being member of
> inhibit-auto-revert-buffers to autorevert.el, see patch below. Thanks
> for the heads-up.

You're welcome.

>> Furthermore, the member check in auto-revert-buffer causes this
>> buffer to be removed from auto-revert-buffer-list meaning it will
>> never ever be reverted in the future, at least not by polling.
>
> Yes, and this is intended.  We disable auto-reverting for a given
> time.  With consequences.

That's the part I don't understand, yet.  Auto-reverts are skipped by
auto-revert-handler now for buffers in inhibit-auto-revert-buffers.
That's what I had expected and did in my previous inhibit-auto-revert
patch, too.

But my reading of the code is that the polling timer calls

  auto-revert-buffers -> auto-revert-buffer -> auto-revert-handler

where auto-revert-buffer now removes the inhibited buffer from
auto-revert-buffer-list.  So in addition to skipping it in
auto-revert-handler this time, the future polling rounds won't see it
anymore, too, because auto-revert--buffer-candidates uses
auto-revert--polled-buffers which is basically auto-revert-buffer-list +
auto-revert-remaining-buffers, at least if global-auto-revert-mode isn't
used.

So when you say "we disable auto-reverting for a given time" where I
assume "given time" is not "forever", what am I missing?  If anything, I
would expect that auto-revert-buffer pushes the inhibited buffer onto
auto-revert-remaining-buffers to prioritize it for next time.

Bye,
Tassilo