bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49988: 27.2; visible marks in the thumbnail buffer


From: Peter Münster
Subject: bug#49988: 27.2; visible marks in the thumbnail buffer
Date: Tue, 10 Aug 2021 23:04:30 +0200

Hi,

It would be nice, if the marks were visible in
image-dired-thumbnail-mode.

Here is a patch, that uses a background color for the thumbnails:

* lisp/image-dired.el (image-dired-thumb-update-marks): New function that
makes the marks visible in the thumbnail buffer.


diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 8a065f2e6f..eb2b092059 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -460,6 +460,17 @@ This is where you see the cursor."
   :type 'integer
   :group 'image-dired)
 
+(defcustom image-dired-thumb-visible-marks nil
+  "Make marks visible in thumbnail buffer.
+If non-nil, apply `image-dired-thumb-mark-color' to background of marked 
images."
+  :type 'boolean
+  :group 'image-dired)
+
+(defcustom image-dired-thumb-mark-color "orange"
+  "Background-color for marked images in thumbnail buffer."
+  :type 'string
+  :group 'image-dired)
+
 (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
@@ -2311,6 +2322,32 @@ 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)))
+    (if (and dired-buf file-name)
+        (with-current-buffer dired-buf
+          (if (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))
+                 (list :background image-dired-thumb-mark-color))
+              (remove-text-properties (point) (1+ (point)) '(face nil)))
+            (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 +2372,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."


What do think about that?

-- 

           Peter





reply via email to

[Prev in Thread] Current Thread [Next in Thread]