unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Peter Münster" <pm@a16n.net>
To: 49988@debbugs.gnu.org
Subject: bug#49988: 27.2; visible marks in the thumbnail buffer
Date: Tue, 10 Aug 2021 23:04:30 +0200	[thread overview]
Message-ID: <87fsvhko4h.fsf@a16n.net> (raw)

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	other threads:[~2021-08-10 21:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 21:04 Peter Münster [this message]
2021-08-11 12:03 ` bug#49988: 27.2; visible marks in the thumbnail buffer Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsvhko4h.fsf@a16n.net \
    --to=pm@a16n.net \
    --cc=49988@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).