]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't skip or double-process files in dired with auto-revert-mode (bug#75626)
authorTassilo Horn <tsdh@gnu.org>
Mon, 20 Jan 2025 15:21:24 +0000 (16:21 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 23 Jan 2025 10:20:42 +0000 (11:20 +0100)
* lisp/dired.el (dired--inhibit-auto-revert): New variable.
(dired-map-over-marks): Make the generated code bind it.
(dired-buffer-stale-p): Return nil if dired--inhibit-auto-revert is
non-nil.

(cherry picked from commit 40d5ff01e51ed6319933e18df0fbe9ef55d9bece)

lisp/dired.el

index c3cfa908942f5586faf6888bd4adc0a9befae4c9..21dec6ac57d3a4f4a8ddbbdc449d55d118615907 100644 (file)
@@ -936,6 +936,9 @@ Return value is the number of files marked, or nil if none were marked."
                           ""))))
     (and (> count 0) count)))
 
+(defvar-local dired--inhibit-auto-revert nil
+  "A non-nil value prevents `auto-revert-mode' from reverting the buffer.")
+
 (defmacro dired-map-over-marks (body arg &optional show-progress
                                     distinguish-one-marked)
   "Eval BODY with point on each marked line.  Return a list of BODY's results.
@@ -972,7 +975,8 @@ marked file, return (t FILENAME) instead of (FILENAME)."
   ;;endless loop.
   ;;This warning should not apply any longer, sk  2-Sep-1991 14:10.
   `(prog1
-       (let ((inhibit-read-only t) case-fold-search found results)
+       (let ((dired--inhibit-auto-revert t) (inhibit-read-only t)
+             case-fold-search found results)
          ,(let ((else `(let ((regexp (dired-marker-regexp)) next-position)
                         (save-excursion
                           (goto-char (point-min))
@@ -1282,6 +1286,12 @@ This feature is used by Auto Revert mode."
         ;; Do not auto-revert when the dired buffer can be currently
         ;; written by the user as in `wdired-mode'.
         buffer-read-only
+         ;; When a dired operation using dired-map-over-marks is in
+         ;; progress, dired--inhibit-auto-revert is bound to some
+         ;; non-nil value and we must not auto-revert because that could
+         ;; change the order of files leading to skipping or
+         ;; double-processing (see bug#75626).
+         (not dired--inhibit-auto-revert)
         (dired-directory-changed-p dirname))))
 
 (defcustom dired-auto-revert-buffer nil