Subject: bug#51152: 29.0.50; Fix deletion of marked thumbnails

From: Peter Münster <[email-masked]>
Date: Tue, 12 Oct 2021 09:53:12 +0200

Hello,

Since there is no movement tracking involved, the original commit
bf64342a8ffd8777df10051037ca13ec4f6857a5 was not needed. In contrast, it
introduced another problem: after deletion of the original files,
image-dired--with-marked doesn't see the marks any more.

Please find attached a new patch.

Kind regards,
-- 
           Peter
From be6d927abe3502748d32f08df8547f79bb0ba819 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <[email-masked]>
Date: Tue, 12 Oct 2021 09:50:16 +0200
Subject: [PATCH] Fix deletion of marked thumbnails

* lisp/image-dired.el (image-dired-thumb-file-marked-p): Don't move point
in associated dired buffer.
(image-dired-delete-marked): Revert "Fix deletion of associated image"
because it was wrong and introduced another problem, see bug#xxx.
---
 lisp/image-dired.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index ec3f988bfb..921215c603 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -2323,18 +2323,19 @@ image-dired-thumb-file-marked-p
         (dired-buf (image-dired-associated-dired-buffer)))
     (when (and dired-buf file-name)
       (with-current-buffer dired-buf
-        (when (dired-goto-file file-name)
-          (image-dired-dired-file-marked-p))))))
+        (save-excursion
+          (when (dired-goto-file file-name)
+            (image-dired-dired-file-marked-p)))))))
 
 (defun image-dired-delete-marked ()
   "Delete current or marked thumbnails and associated images."
   (interactive)
-  (with-current-buffer (image-dired-associated-dired-buffer)
-    (dired-do-delete))
   (image-dired--with-marked
    (image-dired-delete-char)
    (backward-char))
-  (image-dired--line-up-with-method))
+  (image-dired--line-up-with-method)
+  (with-current-buffer (image-dired-associated-dired-buffer)
+    (dired-do-delete)))
 
 (defun image-dired-thumb-update-marks ()
   "Update the marks in the thumbnail buffer."
-- 
2.31.1