Subject: bug#71264: 30.0.50; Dired deletion moves point under auto-revert

From: Manuel Giraud <[email-masked]>
Date: Mon, 17 Jun 2024 11:29:01 +0200

Eli Zaretskii <[email-masked]> writes:

> I think we should install this, but byte-compiling it produces a
> warning:
>
>   In dired-internal-do-deletions:
>   dired.el:4021:28: Warning: Unused lexical variable `auto-revert-mode'
>
> Can you fix this and resubmit?

Thanks Eli.  Here is an updated version of this patch.  I also removed
the setting of `dired-auto-revert-buffer' that has nothing to do with
this bug and added a reference to the bug number in the comments.

> Also, I presume all the Dired tests in the test suite still pass after
> the change?

I have attached the following logs: dir-tests.log, dired-aux-tests.log
and dired-x-tests.log.
>From b4b3e32a7f1375ff228bc25311a56062d64aa049 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Mon, 17 Jun 2024 11:06:28 +0200
Subject: [PATCH] Prevent auto-revert when deleting entry(bug#71264)

* lisp/dired.el (require): Require "autorevert" for
`auto-revert-mode' usage.
(dired-internal-do-deletions): Temporarily prevent auto-revert.
---
 lisp/dired.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index c51e5e42c29..0adf06f471e 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -36,6 +36,7 @@
 
 (eval-when-compile (require 'subr-x))
 (eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'autorevert))
 ;; When bootstrapping dired-loaddefs has not been generated.
 (require 'dired-loaddefs nil t)
 (require 'dnd)
@@ -4015,7 +4016,11 @@ dired-internal-do-deletions
               (dired-move-to-filename)
 	      (let ((inhibit-read-only t))
 		(condition-case err
-		    (let ((fn (car (car l))))
+		    (let ((fn (car (car l)))
+                          ;; Temporarily prevent auto-revert while
+                          ;; deleting entry in the dired buffer
+                          ;; (bug#71264).
+                          (auto-revert-mode nil))
 		      (dired-delete-file fn dired-recursive-deletes trash)
 		      ;; if we get here, removing worked
 		      (setq succ (1+ succ))
-- 
2.45.2

-- 
Manuel Giraud