unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Peter Münster" <pm@a16n.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 50000@debbugs.gnu.org
Subject: bug#50000: 27.2; tagging marked thumbnails
Date: Wed, 11 Aug 2021 16:31:03 +0200	[thread overview]
Message-ID: <87r1f0gijc.fsf@a16n.net> (raw)
In-Reply-To: <874kbwl2qc.fsf@a16n.net>

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

On Wed, Aug 11 2021, Lars Ingebrigtsen wrote:

> Can you submit it as a patch?

Yes, I attach it here.

There are 2 more things: image-dired-delete-marked and a suggestion for
another placement of the calls to image-dired-thumb-update-marks.

--- image-dired.el-orig	2021-08-11 16:09:03.312541533 +0200
+++ image-dired.el	2021-08-11 13:13:01.561075067 +0200
@@ -1005,6 +1003,19 @@
       (set-window-configuration image-dired-saved-window-configuration)
     (message "No saved window configuration")))
 
+(defun image-dired-line-up-with-method ()
+  "Line up thumbnails according to `image-dired-line-up-method'."
+  (cond ((eq 'dynamic image-dired-line-up-method)
+         (image-dired-line-up-dynamic))
+        ((eq 'fixed image-dired-line-up-method)
+         (image-dired-line-up))
+        ((eq 'interactive image-dired-line-up-method)
+         (image-dired-line-up-interactive))
+        ((eq 'none image-dired-line-up-method)
+         nil)
+        (t
+         (image-dired-line-up-dynamic))))
+
 ;;;###autoload
 (defun image-dired-display-thumbs (&optional arg append do-not-pop)
   "Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'.
@@ -1046,16 +1057,7 @@
       (if do-not-pop
           (display-buffer buf)
         (pop-to-buffer buf))
-      (cond ((eq 'dynamic image-dired-line-up-method)
-             (image-dired-line-up-dynamic))
-            ((eq 'fixed image-dired-line-up-method)
-             (image-dired-line-up))
-            ((eq 'interactive image-dired-line-up-method)
-             (image-dired-line-up-interactive))
-            ((eq 'none image-dired-line-up-method)
-             nil)
-            (t
-             (image-dired-line-up-dynamic))))))
+      (image-dired-line-up-with-method))))
 
 ;;;###autoload
 (defun image-dired-show-all-from-dir (dir)
@@ -1186,6 +1188,14 @@
         (cons x tag))
       files))))
 
+(defun image-dired-tag-marked-thumbnails ()
+  "Tag marked thumbnails."
+  (interactive)
+  (let ((dired-buf (image-dired-associated-dired-buffer)))
+    (if dired-buf
+        (with-current-buffer dired-buf
+          (image-dired-tag-files nil)))))
+
 (defun image-dired-tag-thumbnail ()
   "Tag current thumbnail."
   (interactive)
@@ -1417,27 +1427,26 @@
         (message "No image, or image with correct properties, at point.")
     (with-current-buffer dired-buf
         (message "%s" file-name)
-        (if (dired-goto-file file-name)
-            (cond ((eq command 'mark) (dired-mark 1))
-                  ((eq command 'unmark) (dired-unmark 1))
-                  ((eq command 'toggle)
-                   (if (image-dired-dired-file-marked-p)
-                       (dired-unmark 1)
-                     (dired-mark 1)))
-                  ((eq command 'flag) (dired-flag-file-deletion 1))))))))
+        (when (dired-goto-file file-name)
+          (cond ((eq command 'mark) (dired-mark 1))
+                ((eq command 'unmark) (dired-unmark 1))
+                ((eq command 'toggle)
+                 (if (image-dired-dired-file-marked-p)
+                     (dired-unmark 1)
+                   (dired-mark 1)))
+                ((eq command 'flag) (dired-flag-file-deletion 1)))
+          (image-dired-thumb-update-marks))))))
 
 (defun image-dired-mark-thumb-original-file ()
   "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 ()
@@ -1449,8 +1458,7 @@
 (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-thumb-update-marks))
+  (image-dired-modify-mark-on-thumb-original-file 'toggle))
 
 (defun image-dired-jump-original-dired-buffer ()
   "Jump to the dired buffer associated with the current image file.
@@ -2331,19 +2339,32 @@
   "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-delete-marked ()
+  "Delete marked thumbnails and associated images."
+  (interactive)
+  (goto-char (point-min))
+  (let ((dired-buf (image-dired-associated-dired-buffer)))
+    (while (not (eobp))
+      (if (image-dired-thumb-file-marked-p)
+          (image-dired-delete-char)
+        (forward-char)))
+    (image-dired-line-up-with-method)
+    (with-current-buffer dired-buf
+      (dired-do-delete))))
 
 (defun image-dired-thumb-update-marks ()
   "Update the marks in the thumbnail buffer."
   (when image-dired-thumb-visible-marks
     (with-current-buffer image-dired-thumbnail-buffer
-      (save-excursion
+      (save-mark-and-excursion ; todo: mark-active is not restored, bug #49999
         (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))

-- 
           Peter

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

  reply	other threads:[~2021-08-11 14:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 10:01 bug#50000: 27.2; tagging marked thumbnails Peter Münster
2021-08-11 12:21 ` Lars Ingebrigtsen
2021-08-11 14:31   ` Peter Münster [this message]
2021-08-11 16:02     ` Lars Ingebrigtsen
2021-08-13 13:04       ` Peter Münster
2021-08-14 11:51         ` Lars Ingebrigtsen
2021-08-16  7:38           ` Peter Münster
2021-08-16 12:07             ` Lars Ingebrigtsen
2021-08-16 15:33               ` Peter Münster
2021-08-18 12:54                 ` Lars Ingebrigtsen
2021-08-18 15:01                   ` Peter Münster
2021-08-19 13:03                     ` Lars Ingebrigtsen
2021-08-20  7:13                       ` Peter Münster

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=87r1f0gijc.fsf@a16n.net \
    --to=pm@a16n.net \
    --cc=50000@debbugs.gnu.org \
    --cc=larsi@gnus.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).