unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49988: 27.2; visible marks in the thumbnail buffer
@ 2021-08-10 21:04 Peter Münster
  2021-08-11 12:03 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Münster @ 2021-08-10 21:04 UTC (permalink / raw)
  To: 49988

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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#49988: 27.2; visible marks in the thumbnail buffer
  2021-08-10 21:04 bug#49988: 27.2; visible marks in the thumbnail buffer Peter Münster
@ 2021-08-11 12:03 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-11 12:03 UTC (permalink / raw)
  To: Peter Münster; +Cc: 49988

Peter Münster <pm@a16n.net> writes:

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

Thanks; applied to Emacs 28, but with some changes -- I made the colour
into a face.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-11 12:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10 21:04 bug#49988: 27.2; visible marks in the thumbnail buffer Peter Münster
2021-08-11 12:03 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).