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

From: Michael Heerdegen <[email-masked]>
Date: Sat, 01 Feb 2025 01:18:41 +0100

Tassilo Horn <[email-masked]> writes:

> That doesn't work when the command switches to some other buffer.  Then
> that other buffer's post-command-hook is run meaning the dired buffer
> stays in dired--inhibit-auto-revert state forever. :-|

Hmm.

If the approach makes sense in general we will find a way.  How about
checking `this-command' and `current-minibuffer-command'?  When any of
these is non-nil, we may want to prevent autorevert.

But this alone is too general - we should know if the are processing a
dired command.  If the current buffer is a dired mode buffer, this is
ok.  But the case with the popups is tricky, it seems we can't know in
which buffer a command had really been envoked.  Also
`minibuffer--original-buffer' is not usable - it's only bound by
`completing-read'.  Hmm.

How about saving the result of (buffer-chars-modified-tick) in the local
pre-command-hook and post-command-hook, into a local variable?  If
`dired-buffer-stale-p' finds a different current value we know that the
current command has modified the buffer, and we should not auto-revert.
Though, this will still fail if a command first changes the buffer
contents and then the current buffer...

Maybe it is really easier to go through the commands...or use a
heuristic, like looking whether `this-command',
`current-minibuffer-command' match "dired".  Using the global binding of
`pre-command-hook' and `post-command-hook' would probably also work
reliably but I would not want to clutter those with a function only for
the sake of this detail.

Michael.