* improving usage of marks in image-dired
@ 2021-08-06 23:33 Peter Münster
0 siblings, 0 replies; only message in thread
From: Peter Münster @ 2021-08-06 23:33 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 175 bytes --]
Hi,
Please find here attached 2 patches for image-dired. I find them useful,
because I would like to make heavy usage of marks in the thumbnail
buffer.
--
Peter
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Let-image-dired-mouse-toggle-mark-act-on-active-regi.patch --]
[-- Type: text/x-patch, Size: 2033 bytes --]
From 22b4a09ca5d14c1dda82a9f5b96c05ce662d791f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
Date: Fri, 6 Aug 2021 23:53:23 +0200
Subject: [PATCH 1/2] Let image-dired-mouse-toggle-mark act on active region
* lisp/image-dired.el (image-dired-mouse-toggle-mark): When region is
active, then toggle marks of all images within.
---
lisp/image-dired.el | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 2509ecf8f8..8a065f2e6f 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -2311,17 +2311,32 @@ non-nil."
(image-dired-track-original-file))
(image-dired-display-thumb-properties))
-(defun image-dired-mouse-toggle-mark (event)
- "Use mouse EVENT to toggle dired mark for thumbnail.
+(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
non-nil."
- (interactive "e")
- (mouse-set-point event)
- (goto-char (posn-point (event-end event)))
(if image-dired-track-movement
(image-dired-track-original-file))
(image-dired-toggle-mark-thumb-original-file))
+(defun image-dired-mouse-toggle-mark (event)
+ "Use mouse EVENT to toggle dired mark for thumbnail.
+Toggle marks of all thumbnails in region, if it's active.
+Track this in associated dired buffer if `image-dired-track-movement' is
+non-nil."
+ (interactive "e")
+ (if (use-region-p)
+ (let ((end (region-end)))
+ (save-excursion
+ (goto-char (region-beginning))
+ (while (<= (point) end)
+ (when (image-dired-image-at-point-p)
+ (image-dired-mouse-toggle-mark-1))
+ (forward-char))))
+ (mouse-set-point event)
+ (goto-char (posn-point (event-end event)))
+ (image-dired-mouse-toggle-mark-1)))
+
(defun image-dired-dired-display-properties ()
"Display properties for dired file in the echo area."
(interactive)
--
2.26.2
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Make-the-marks-visible-in-the-thumbnail-buffer.patch --]
[-- Type: text/x-patch, Size: 3070 bytes --]
From 16f668d9607bee0436e8a9527340fb7d92efc93a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
Date: Sat, 7 Aug 2021 01:21:23 +0200
Subject: [PATCH 2/2] Make the marks visible in the thumbnail buffer
* lisp/image-dired.el (image-dired-thumb-update-marks): New function that
makes the marks visible in the thumbnail buffer.
---
lisp/image-dired.el | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
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."
--
2.26.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-06 23:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 23:33 improving usage of marks in image-dired Peter Münster
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).