Michael Heerdegen writes: > Tassilo Horn writes: > >> I have to declare emacs programming bankruptcy. The current version >> with dired--inhibit-auto-revert works fine. Now I wanted to change >> that into a more general inhibit-auto-revert. Here's the patch (with >> -b to make it easier to grasp): > > Unfortunately it doesn't apply here. Yeah, because of the "git diff -b" flag omitting whitespace changes. >> That last hunk in dired-internal-do-deletions is due to a wrong fix >> for the bug#71264. When auto-revert-mode itself is bound to nil when >> auto-revert kicks in, the buffer will be removed from >> auto-revert-buffer-list causing auto-revert to be disabled forever in >> that buffer. (At least that's my reading of the code...) > > I think your reading is correct. Thanks for validating. >> Anyway, the above solution with the new inhibit-auto-revert does not >> work. auto-revert-buffers is called from a timer and eventually >> auto-revert-handler is called for my dired buffer where the >> compression of 1000 is still ongoing but inhibit-auto-revert is nil >> there and revert-buffer is called causing the issue of this bug >> again. >> >> I can't understand why it doesn't see the non-nil inhibit-auto-revert >> binding in the expansion of dired-map-over-marks. Where is the >> difference to the current working solution with >> dired--inhibit-auto-revert? It's bound the same way and accessed >> from auto-revert-handler via the funcall to the dired buffer's >> buffer-stale-function, i.e., dired-buffer-stale-p. > > I hope it's not related to the auto-revert-mode -> nil binding? Nope, that's what I reverted first to check if that was the culprit. > Anyway, as Ship Mints already mentioned, you never created a buffer > local binding. A `let' binds the visible binding which is in your > case the global one - since there was no local variable binding yet. Ah, indeed. So now I (setq inhibit-auto-revert nil) in dired-mode to create a local variable in the buffer. > So you bind the global variable - which is not what we want but that > binding should be visible nonetheless. I'm not sure why it does not > work as expected. Me neither. > In some situations it can help to use a variable watcher to log > variable binding changes: > > (info "(elisp) Watching Variables") Oh, that's a great hint! I've tried with this watch: --8<---------------cut here---------------start------------->8--- (add-variable-watcher 'inhibit-auto-revert (lambda (sym new-val op where) (message "(%S %S %S) in %S" op sym new-val where))) --8<---------------cut here---------------end--------------->8--- And what should I say, it still didn't work in the beginning, i.e., the previous version of my last mail + (setq inhibit-auto-revert nil) in dired-mode to create a local variable. The watcher showed that after confirming the compression of my 1000 test files, a set with value nil was done but I have no clue from where. Then I edited a bit back and forth and recompiled and tested (with emacs -Q) after each edit without actually changing any significant part, e.g., I tried to also let-bind inhibit-auto-revert to t in the function dired-map-over-marks-check which uses the macro dired-map-over-marks. Still not working. So reverting that again. And now I have the patch at the end of this mail AND IT SUDDENLY WORKS. The output including the watcher is this (commented by me): ;; That's for the confirmation query (let inhibit-auto-revert t) in # (unlet inhibit-auto-revert nil) in # Compress or uncompress * [1000 files]? (y or n) y ;; That's the actual compression of the 1000 files (let inhibit-auto-revert t) in # (unlet inhibit-auto-revert nil) in # Compress or uncompress: 1000 files. Reverting buffer ‘test’ So exactly as one might expect. And the last line suggests that inhibiting some auto-reverts is not bad either, it'll be reverted in the next round. But I really wonder what could have caused that it didn't work initially. Yesterday, I've rebuilt emacs without native compiler in order to rule that out as the culprit. Could it be that a non-native-comp emacs still picks up outdated eln files? Well, then the question would be why it doesn't anymore... Anyway, below the current patch. It would be great if someone else could test it, too. Obviously, the new inhibit-auto-revert should be mentioned in NEWS and the elisp info docs which I'll do and post the final patch for review before committing. Bye, Tassilo