]> git.eshelyaron.com Git - emacs.git/commitdiff
Mark marked images in Image-Dired mode
authorPeter Münster <pm@a16n.net>
Wed, 11 Aug 2021 12:03:23 +0000 (14:03 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 11 Aug 2021 12:03:23 +0000 (14:03 +0200)
* lisp/image-dired.el (image-dired-thumb-update-marks): New
function that makes the marks visible in the thumbnail buffer
(bug#49988).
(image-dired-thumb-margin, image-dired-thumb-mark-color): New user
options.

doc/emacs/dired.texi
etc/NEWS
lisp/image-dired.el

index 3fbaf8bab7a6648a5ebce78cd7a7eadd0bb7bd85..680b20c5938e0f576b4bc75d680657422247a991 100644 (file)
@@ -1553,6 +1553,11 @@ image.  You comment a file from the thumbnail buffer by typing
 @kbd{c}.  You will be prompted for a comment.  Type @kbd{C-t c} to add
 a comment from Dired (@code{image-dired-dired-comment-files}).
 
+@vindex image-dired-thumb-visible-marks
+  Files that are marked in Dired will also be marked in Image-Dired if
+@code{image-dired-thumb-visible-marks} is non-@code{nil} (which is the
+default).
+
   Image-Dired also provides simple image manipulation.  In the
 thumbnail buffer, type @kbd{L} to rotate the original image 90 degrees
 anti clockwise, and @kbd{R} to rotate it 90 degrees clockwise.  This
index ac1fd3421f989d89671ea9f596892fac9e2a885a..523af6b97d010f192709018a44ad12c92540517f 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2396,11 +2396,18 @@ When non-nil, this option suppresses lock files for remote files.
 This command, called interactively, toggles the local value of
 'create-lockfiles' in the current buffer.
 
-** Miscellaneous
+** image-dired
 
 ---
 *** 'image-dired-mouse-toggle-mark' now toggles files in the active region.
 
++++
+*** New user option 'image-dired-thumb-visible-marks'.
+If non-nil (the default), use 'image-dired-thumb-mark' to say what
+images are marked.
+
+** Miscellaneous
+
 ---
 *** 'shell-script-mode' now supports 'outline-minor-mode'.
 The outline headings have lines that start with "###".
index cef145e9c83e9c983b16b11014c64efe2fe40782..2916323937bcadccd431ee7e1ab2689a8cb1e3bc 100644 (file)
@@ -460,6 +460,19 @@ This is where you see the cursor."
   :type 'integer
   :group 'image-dired)
 
+(defcustom image-dired-thumb-visible-marks t
+  "Make marks visible in thumbnail buffer.
+If non-nil, apply the `image-dired-thumb-mark' face to marked
+images."
+  :type 'boolean
+  :version "28.1")
+
+(defface image-dired-thumb-mark
+  '((t (:background "orange")))
+  "Background-color for marked images in thumbnail buffer."
+  :group 'image-dired
+  :version "28.1")
+
 (defcustom image-dired-line-up-method 'dynamic
   "Default method for line-up of thumbnails in thumbnail buffer.
 Used by `image-dired-display-thumbs' and other functions that needs
@@ -1417,12 +1430,14 @@ dired."
   "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 ()
@@ -1434,7 +1449,8 @@ 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-modify-mark-on-thumb-original-file 'toggle)
+  (image-dired-thumb-update-marks))
 
 (defun image-dired-jump-original-dired-buffer ()
   "Jump to the dired buffer associated with the current image file.
@@ -2311,6 +2327,33 @@ non-nil."
       (image-dired-track-original-file))
   (image-dired-display-thumb-properties))
 
+(defun image-dired-thumb-file-marked-p ()
+  "Check if file is marked in associated dired buffer."
+  (let ((file-name (image-dired-original-file-name))
+        (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))))))
+
+(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
+  ;; certainly other places, where it should be called too.
+  (when image-dired-thumb-visible-marks
+    (with-current-buffer image-dired-thumbnail-buffer
+      (save-excursion
+        (goto-char (point-min))
+        (let ((inhibit-read-only t))
+          (while (not (eobp))
+            (if (image-dired-thumb-file-marked-p)
+                (add-face-text-property
+                 (point) (1+ (point))
+                 'image-dired-thumb-mark)
+              (remove-text-properties (point) (1+ (point))
+                                      '(face image-dired-thumb-mark)))
+            (forward-char)))))))
+
 (defun image-dired-mouse-toggle-mark-1 ()
   "Toggle dired mark for current thumbnail.
 Track this in associated dired buffer if `image-dired-track-movement' is
@@ -2335,7 +2378,8 @@ non-nil."
             (forward-char))))
     (mouse-set-point event)
     (goto-char (posn-point (event-end event)))
-    (image-dired-mouse-toggle-mark-1)))
+    (image-dired-mouse-toggle-mark-1))
+  (image-dired-thumb-update-marks))
 
 (defun image-dired-dired-display-properties ()
   "Display properties for dired file in the echo area."