]> git.eshelyaron.com Git - emacs.git/commitdiff
Delete thumbs in image-dired-do-flagged-delete after confirmation
authorPeter Münster <pm@a16n.net>
Sun, 2 Oct 2022 18:12:32 +0000 (20:12 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sun, 2 Oct 2022 18:16:37 +0000 (20:16 +0200)
* lisp/image/image-dired.el (image-dired-do-flagged-delete): Remove
thumbnails only after confirming deletion of the files.  (Bug#58255)

lisp/image/image-dired.el

index 8fb89d45023fa77adca590563a5b1d754cb10af9..c9d67411409dc42a86c9ea8f758a117c83546e91 100644 (file)
@@ -1347,17 +1347,21 @@ for deletion instead."
   (interactive nil image-dired-thumbnail-mode)
   (unless (derived-mode-p 'image-dired-thumbnail-mode)
     (user-error "Not in `image-dired-thumbnail-mode'"))
-  (let ((inhibit-read-only t))
-    (goto-char (point-min))
-    (while (not (eobp))
-      (if (image-dired-thumb-file-flagged-p)
-          (progn
-            (delete-char 1)
-            (forward-char))
-        (forward-char 2))))
-  (image-dired--line-up-with-method)
-  (image-dired--on-file-in-dired-buffer
-    (dired-do-flagged-delete)))
+  (image-dired--with-dired-buffer
+    (dired-do-flagged-delete))
+  (let (deletions)
+    (save-excursion
+      (let ((inhibit-read-only t))
+        (goto-char (point-min))
+        (while (not (eobp))
+          (let ((file-name (image-dired-original-file-name)))
+            (if (image-dired--with-dired-buffer (dired-goto-file file-name))
+                (forward-char 2)
+              (delete-char 1)
+              (forward-char)
+              (setq deletions t))))))
+    (if deletions
+        (image-dired--line-up-with-method))))
 
 (defun image-dired--thumb-update-mark-at-point ()
   (with-silent-modifications