]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new image-dired commands
authorPeter Münster <pm@a16n.net>
Wed, 11 Aug 2021 16:02:25 +0000 (18:02 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 11 Aug 2021 16:06:19 +0000 (18:06 +0200)
* lisp/image-dired.el (image-dired-delete-marked): Factored out
(bug#50000).
(image-dired-display-thumbs): From here.
(image-dired-tag-marked-thumbnails): New command.
(image-dired-delete-marked): Ditto.

etc/NEWS
lisp/image-dired.el

index 523af6b97d010f192709018a44ad12c92540517f..18fa54b97e6b3ca6b00a92da9f0e4fec4fd76525 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2406,6 +2406,10 @@ This command, called interactively, toggles the local value of
 If non-nil (the default), use 'image-dired-thumb-mark' to say what
 images are marked.
 
+*** New command 'image-dired-tag-marked-thumbnails'.
+
+*** New command 'image-dired-delete-marked'.
+
 ** Miscellaneous
 
 ---
index 2916323937bcadccd431ee7e1ab2689a8cb1e3bc..76c7ae91f00ce8a09ede4b196eb55850a4bddde1 100644 (file)
@@ -1005,6 +1005,19 @@ Restore any changes to the window configuration made by calling
       (set-window-configuration image-dired-saved-window-configuration)
     (message "No saved window configuration")))
 
+(defun image-dired--line-up-with-method ()
+  "Line up thumbnails according to `image-dired-line-up-method'."
+  (cond ((eq 'dynamic image-dired-line-up-method)
+         (image-dired-line-up-dynamic))
+        ((eq 'fixed image-dired-line-up-method)
+         (image-dired-line-up))
+        ((eq 'interactive image-dired-line-up-method)
+         (image-dired-line-up-interactive))
+        ((eq 'none image-dired-line-up-method)
+         nil)
+        (t
+         (image-dired-line-up-dynamic))))
+
 ;;;###autoload
 (defun image-dired-display-thumbs (&optional arg append do-not-pop)
   "Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'.
@@ -1046,16 +1059,7 @@ thumbnail buffer to be selected."
       (if do-not-pop
           (display-buffer buf)
         (pop-to-buffer buf))
-      (cond ((eq 'dynamic image-dired-line-up-method)
-             (image-dired-line-up-dynamic))
-            ((eq 'fixed image-dired-line-up-method)
-             (image-dired-line-up))
-            ((eq 'interactive image-dired-line-up-method)
-             (image-dired-line-up-interactive))
-            ((eq 'none image-dired-line-up-method)
-             nil)
-            (t
-             (image-dired-line-up-dynamic))))))
+      (image-dired--line-up-with-method))))
 
 ;;;###autoload
 (defun image-dired-show-all-from-dir (dir)
@@ -1186,6 +1190,13 @@ FILE-TAGS is an alist in the following form:
         (cons x tag))
       files))))
 
+(defun image-dired-tag-marked-thumbnails ()
+  "Tag marked thumbnails."
+  (interactive)
+  (when-let ((dired-buf (image-dired-associated-dired-buffer)))
+    (with-current-buffer dired-buf
+      (image-dired-tag-files nil))))
+
 (defun image-dired-tag-thumbnail ()
   "Tag current thumbnail."
   (interactive)
@@ -1417,27 +1428,26 @@ dired."
         (message "No image, or image with correct properties, at point.")
     (with-current-buffer dired-buf
         (message "%s" file-name)
-        (if (dired-goto-file file-name)
-            (cond ((eq command 'mark) (dired-mark 1))
-                  ((eq command 'unmark) (dired-unmark 1))
-                  ((eq command 'toggle)
-                   (if (image-dired-dired-file-marked-p)
-                       (dired-unmark 1)
-                     (dired-mark 1)))
-                  ((eq command 'flag) (dired-flag-file-deletion 1))))))))
+        (when (dired-goto-file file-name)
+          (cond ((eq command 'mark) (dired-mark 1))
+                ((eq command 'unmark) (dired-unmark 1))
+                ((eq command 'toggle)
+                 (if (image-dired-dired-file-marked-p)
+                     (dired-unmark 1)
+                   (dired-mark 1)))
+                ((eq command 'flag) (dired-flag-file-deletion 1)))
+          (image-dired-thumb-update-marks))))))
 
 (defun image-dired-mark-thumb-original-file ()
   "Mark original image file in associated dired buffer."
   (interactive)
   (image-dired-modify-mark-on-thumb-original-file 'mark)
-  (image-dired-thumb-update-marks)
   (image-dired-forward-image))
 
 (defun image-dired-unmark-thumb-original-file ()
   "Unmark original image file in associated dired buffer."
   (interactive)
   (image-dired-modify-mark-on-thumb-original-file 'unmark)
-  (image-dired-thumb-update-marks)
   (image-dired-forward-image))
 
 (defun image-dired-flag-thumb-original-file ()
@@ -1449,8 +1459,7 @@ dired."
 (defun image-dired-toggle-mark-thumb-original-file ()
   "Toggle mark on original image file in associated dired buffer."
   (interactive)
-  (image-dired-modify-mark-on-thumb-original-file 'toggle)
-  (image-dired-thumb-update-marks))
+  (image-dired-modify-mark-on-thumb-original-file 'toggle))
 
 (defun image-dired-jump-original-dired-buffer ()
   "Jump to the dired buffer associated with the current image file.
@@ -2336,6 +2345,19 @@ non-nil."
         (when (dired-goto-file file-name)
           (image-dired-dired-file-marked-p))))))
 
+(defun image-dired-delete-marked ()
+  "Delete marked thumbnails and associated images."
+  (interactive)
+  (goto-char (point-min))
+  (let ((dired-buf (image-dired-associated-dired-buffer)))
+    (while (not (eobp))
+      (if (image-dired-thumb-file-marked-p)
+          (image-dired-delete-char)
+        (forward-char)))
+    (image-dired--line-up-with-method)
+    (with-current-buffer dired-buf
+      (dired-do-delete))))
+
 (defun image-dired-thumb-update-marks ()
   "Update the marks in the thumbnail buffer."
   ;; TODO: only called by image-dired-mouse-toggle-mark but there are