[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8b64583 2/2: Mark marked images in Image-Dired mode
From: |
Lars Ingebrigtsen |
Subject: |
master 8b64583 2/2: Mark marked images in Image-Dired mode |
Date: |
Wed, 11 Aug 2021 08:04:12 -0400 (EDT) |
branch: master
commit 8b645837d228102a04005b98d75a56f9b78cabae
Author: Peter Münster <pm@a16n.net>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Mark marked images in Image-Dired mode
* lisp/image-dired.el (image-dired-thumb-update-marks): New
function that makes the marks visible in the thumbnail buffer
(bug#49988).
(image-dired-thumb-margin, image-dired-thumb-mark-color): New user
options.
---
doc/emacs/dired.texi | 5 +++++
etc/NEWS | 9 ++++++++-
lisp/image-dired.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 3fbaf8b..680b20c 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -1553,6 +1553,11 @@ image. You comment a file from the thumbnail buffer by
typing
@kbd{c}. You will be prompted for a comment. Type @kbd{C-t c} to add
a comment from Dired (@code{image-dired-dired-comment-files}).
+@vindex image-dired-thumb-visible-marks
+ Files that are marked in Dired will also be marked in Image-Dired if
+@code{image-dired-thumb-visible-marks} is non-@code{nil} (which is the
+default).
+
Image-Dired also provides simple image manipulation. In the
thumbnail buffer, type @kbd{L} to rotate the original image 90 degrees
anti clockwise, and @kbd{R} to rotate it 90 degrees clockwise. This
diff --git a/etc/NEWS b/etc/NEWS
index ac1fd34..523af6b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2396,11 +2396,18 @@ When non-nil, this option suppresses lock files for
remote files.
This command, called interactively, toggles the local value of
'create-lockfiles' in the current buffer.
-** Miscellaneous
+** image-dired
---
*** 'image-dired-mouse-toggle-mark' now toggles files in the active region.
++++
+*** New user option 'image-dired-thumb-visible-marks'.
+If non-nil (the default), use 'image-dired-thumb-mark' to say what
+images are marked.
+
+** Miscellaneous
+
---
*** 'shell-script-mode' now supports 'outline-minor-mode'.
The outline headings have lines that start with "###".
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index cef145e..2916323 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -460,6 +460,19 @@ This is where you see the cursor."
:type 'integer
:group 'image-dired)
+(defcustom image-dired-thumb-visible-marks t
+ "Make marks visible in thumbnail buffer.
+If non-nil, apply the `image-dired-thumb-mark' face to marked
+images."
+ :type 'boolean
+ :version "28.1")
+
+(defface image-dired-thumb-mark
+ '((t (:background "orange")))
+ "Background-color for marked images in thumbnail buffer."
+ :group 'image-dired
+ :version "28.1")
+
(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
@@ -1417,12 +1430,14 @@ dired."
"Mark original image file in associated dired buffer."
(interactive)
(image-dired-modify-mark-on-thumb-original-file 'mark)
+ (image-dired-thumb-update-marks)
(image-dired-forward-image))
(defun image-dired-unmark-thumb-original-file ()
"Unmark original image file in associated dired buffer."
(interactive)
(image-dired-modify-mark-on-thumb-original-file 'unmark)
+ (image-dired-thumb-update-marks)
(image-dired-forward-image))
(defun image-dired-flag-thumb-original-file ()
@@ -1434,7 +1449,8 @@ dired."
(defun image-dired-toggle-mark-thumb-original-file ()
"Toggle mark on original image file in associated dired buffer."
(interactive)
- (image-dired-modify-mark-on-thumb-original-file 'toggle))
+ (image-dired-modify-mark-on-thumb-original-file 'toggle)
+ (image-dired-thumb-update-marks))
(defun image-dired-jump-original-dired-buffer ()
"Jump to the dired buffer associated with the current image file.
@@ -2311,6 +2327,33 @@ 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)))
+ (when (and dired-buf file-name)
+ (with-current-buffer dired-buf
+ (when (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))
+ 'image-dired-thumb-mark)
+ (remove-text-properties (point) (1+ (point))
+ '(face image-dired-thumb-mark)))
+ (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 +2378,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."