unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49987: 27.2; Let image-dired-mouse-toggle-mark act on active region
@ 2021-08-10 20:27 Peter Münster
  2021-08-11 11:40 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Münster @ 2021-08-10 20:27 UTC (permalink / raw)
  To: 49987

[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]

Hi,

It would be nice, if one can toggle marks of all thumbnails in the
active region.

Here is a patch:

* lisp/image-dired.el (image-dired-mouse-toggle-mark): When region is
active, then toggle marks of all images within.


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)

What do think about that?

-- 
           Peter

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 211 bytes --]

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

* bug#49987: 27.2; Let image-dired-mouse-toggle-mark act on active region
  2021-08-10 20:27 bug#49987: 27.2; Let image-dired-mouse-toggle-mark act on active region Peter Münster
@ 2021-08-11 11:40 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-11 11:40 UTC (permalink / raw)
  To: Peter Münster; +Cc: 49987

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

> It would be nice, if one can toggle marks of all thumbnails in the
> active region.

Makes sense to me; applied to Emacs 28.

-- 
(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 11:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10 20:27 bug#49987: 27.2; Let image-dired-mouse-toggle-mark act on active region Peter Münster
2021-08-11 11:40 ` 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).