From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Peter =?UTF-8?Q?M=C3=BCnster?= Newsgroups: gmane.emacs.bugs Subject: bug#50000: 27.2; tagging marked thumbnails Date: Fri, 13 Aug 2021 15:04:19 +0200 Message-ID: <87lf558pik.fsf@a16n.net> References: <874kbwl2qc.fsf@a16n.net> <87lf58rx3g.fsf@gnus.org> <87r1f0gijc.fsf@a16n.net> <87tujwotow.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26362"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: 50000@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 13 15:05:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEWs7-0006aW-7V for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Aug 2021 15:05:15 +0200 Original-Received: from localhost ([::1]:43592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEWs5-0005Vt-95 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Aug 2021 09:05:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEWru-0005VW-O5 for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 09:05:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEWru-0004cA-GT for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 09:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mEWru-00058x-Bp for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 09:05:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <874kbwl2qc.fsf@a16n.net> Resent-From: Peter =?UTF-8?Q?M=C3=BCnster?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Aug 2021 13:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50000 X-GNU-PR-Package: emacs Original-Received: via spool by 50000-submit@debbugs.gnu.org id=B50000.162885987019726 (code B ref 50000); Fri, 13 Aug 2021 13:05:02 +0000 Original-Received: (at 50000) by debbugs.gnu.org; 13 Aug 2021 13:04:30 +0000 Original-Received: from localhost ([127.0.0.1]:40835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEWrN-000585-Gw for submit@debbugs.gnu.org; Fri, 13 Aug 2021 09:04:29 -0400 Original-Received: from server.a16n.net ([178.33.238.77]:36686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEWrL-00057r-Hs for 50000@debbugs.gnu.org; Fri, 13 Aug 2021 09:04:28 -0400 Original-Received: from ws.localdomain (lfbn-ren-1-1338-34.w86-229.abo.wanadoo.fr [86.229.185.34]) by server.a16n.net (Postfix) with ESMTPSA id D22DC43E04CA; Fri, 13 Aug 2021 15:04:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a16n.net; s=a16n; t=1628859860; bh=IeYhSuGIhwAoHP3EtyI4+lvUXEVzqujmA4CbgBEZic4=; h=From:To:Cc:Subject:References:Date; b=EOyjJJOb/mGpSDzdryux9DkErvRBNBxRkVf9dRMauf5FP8KWUXb4d7wFKkUeu8reY mwPMBP8/g0Gl4wCwrsdB/ZzQzWlT/WhwNggqwPCjTKCj3xzPIdKBRElruYhYb0ygM3 Jd0ue0yUz9ibiPiXtAfOc/2NxNvDGGD4lQzLS1L2CAp66d5FWgko+rdjhRXE8qm5vQ 0c4xrqx1BEYWPYr9GgYrdR8WidimORt+T26OnlpLKc+oD50x5DdXZYoGMeCzKacjDP mny8Gx+fGLEJaOCzwNhQqUhrQe+k8VG6f3nUTut5C9CzYHd61OqrS0m8UbzI/96M8t 9Hymq7Cu0jDtA== Original-Received: by ws.localdomain (Postfix, from userid 1000) id CA75D7406D1; Fri, 13 Aug 2021 15:04:19 +0200 (CEST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211756 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, Aug 11 2021, Lars Ingebrigtsen wrote: > Makes sense. Applied to Emacs 28. Should these new commands have key > bindings? I don't know. And if yes, how to chose the best bindings? (I have private key-bindings in my init.el). Perhaps at least menu bindings. A patch is attached (with also some refactoring). =2D-=20 Peter --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-menu-bindings-to-new-functions-in-image-dired.el.patch Content-Transfer-Encoding: quoted-printable From=202bee2a5a92a4d3593a60ded577731966c09c68cb Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Peter=3D20M=3DC3=3DBCnster?=3D Date: Fri, 13 Aug 2021 15:02:03 +0200 Subject: [PATCH] Add menu bindings to new functions in image-dired.el * lisp/image-dired.el (image-dired--with-marked): New macro for cycling over marked thumbnails. (image-dired-tag-thumbnail, image-dired-tag-thumbnail-remove): Rename to plural forms, because they can handle now also all marked thumbnails. (image-dired-tag-marked-thumbnails): Remove it, because it's obsoleted by `image-dired-tag-thumbnails' now. (image-dired-delete-marked): Use new macro `image-dired--with-marked', and add command to menu. =2D-- etc/NEWS | 7 +++-- lisp/image-dired.el | 70 ++++++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 26ede71523..6aa574eda3 100644 =2D-- a/etc/NEWS +++ b/etc/NEWS @@ -2415,10 +2415,13 @@ This command, called interactively, toggles the loc= al value of If non-nil (the default), use 'image-dired-thumb-mark' to say what images are marked. =20 =2D*** New command 'image-dired-tag-marked-thumbnails'. =2D *** New command 'image-dired-delete-marked'. =20 +*** New names for some functions. +Function 'image-dired-tag-thumbnail' is renamed 'image-dired-tag-thumbnail= s'. +Function 'image-dired-tag-thumbnail-remove' is renamed +'image-dired-tag-thumbnails-remove'. + ** Miscellaneous =20 --- diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 7092f758db..520d8cdb34 100644 =2D-- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -797,6 +797,21 @@ Queued items live in `image-dired-queue'." (list (list original-file thumbnail-file)))) (run-at-time 0 nil #'image-dired-thumb-queue-run)) =20 +(defmacro image-dired--with-marked (&rest body) + "Eval BODY with point on each marked thumbnail. If no marked file could +be found, execute BODY on the current thumbnail." + `(with-current-buffer image-dired-thumbnail-buffer + (let (found) + (save-mark-and-excursion + (goto-char (point-min)) + (while (not (eobp)) + (when (image-dired-thumb-file-marked-p) + (setq found t) + ,@body) + (forward-char))) + (unless found + ,@body)))) + ;;;###autoload (defun image-dired-dired-toggle-marked-thumbs (&optional arg) "Toggle thumbnails in front of file names in the dired buffer. @@ -1145,20 +1160,15 @@ FILE-TAGS is an alist in the following form: (cons x tag)) files)))) =20 =2D(defun image-dired-tag-marked-thumbnails () =2D "Tag marked thumbnails." =2D (interactive) =2D (when-let ((dired-buf (image-dired-associated-dired-buffer))) =2D (with-current-buffer dired-buf =2D (image-dired-tag-files nil)))) =2D =2D(defun image-dired-tag-thumbnail () =2D "Tag current thumbnail." +(defun image-dired-tag-thumbnails () + "Tag current or marked thumbnails." (interactive) (let ((tag (read-string "Tags to add (separate tags with a semicolon): "= ))) =2D (image-dired-write-tags (list (cons (image-dired-original-file-name)= tag)))) =2D (image-dired-update-property =2D 'tags (image-dired-list-tags (image-dired-original-file-name)))) + (image-dired--with-marked + (image-dired-write-tags + (list (cons (image-dired-original-file-name) tag))) + (image-dired-update-property + 'tags (image-dired-list-tags (image-dired-original-file-name)))))) =20 ;;;###autoload (defun image-dired-delete-tag (arg) @@ -1172,13 +1182,14 @@ With prefix argument ARG, remove tag from file at p= oint." (setq files (dired-get-marked-files))) (image-dired-remove-tag files tag))) =20 =2D(defun image-dired-tag-thumbnail-remove () =2D "Remove tag from thumbnail." +(defun image-dired-tag-thumbnails-remove () + "Remove tag from current or marked thumbnails." (interactive) (let ((tag (read-string "Tag to remove: "))) =2D (image-dired-remove-tag (image-dired-original-file-name) tag)) =2D (image-dired-update-property =2D 'tags (image-dired-list-tags (image-dired-original-file-name)))) + (image-dired--with-marked + (image-dired-remove-tag (image-dired-original-file-name) tag) + (image-dired-update-property + 'tags (image-dired-list-tags (image-dired-original-file-name)))))) =20 (defun image-dired-original-file-name () "Get original file name for thumbnail or display image at point." @@ -1458,9 +1469,9 @@ You probably want to use this together with (defvar image-dired-thumbnail-mode-tag-map (let ((map (make-sparse-keymap))) ;; map it to "t" so that the user can press it more quickly =2D (define-key map "t" 'image-dired-tag-thumbnail) + (define-key map "t" 'image-dired-tag-thumbnails) ;; "r" for "remove" =2D (define-key map "r" 'image-dired-tag-thumbnail-remove) + (define-key map "r" 'image-dired-tag-thumbnails-remove) map) "Keymap for tag commands in `image-dired-thumbnail-mode'.") =20 @@ -1518,8 +1529,10 @@ You probably want to use this together with '("Image-Dired" ["Quit" quit-window] ["Delete thumbnail from buffer" image-dired-delete-char] =2D ["Remove tag from thumbnail" image-dired-tag-thumbnail-remove] =2D ["Tag thumbnail" image-dired-tag-thumbnail] + ["Delete marked images" image-dired-delete-marked] + ["Remove tag from current or marked thumbnails" + image-dired-tag-thumbnails-remove] + ["Tag current or marked thumbnails" image-dired-tag-thumbnails] ["Comment thumbnail" image-dired-comment-thumbnail] ["Refresh thumb" image-dired-refresh-thumb] ["Dynamic line up" image-dired-line-up-dynamic] @@ -2301,15 +2314,12 @@ non-nil." (defun image-dired-delete-marked () "Delete marked thumbnails and associated images." (interactive) =2D (goto-char (point-min)) =2D (let ((dired-buf (image-dired-associated-dired-buffer))) =2D (while (not (eobp)) =2D (if (image-dired-thumb-file-marked-p) =2D (image-dired-delete-char) =2D (forward-char))) =2D (image-dired--line-up-with-method) =2D (with-current-buffer dired-buf =2D (dired-do-delete)))) + (image-dired--with-marked + (image-dired-delete-char) + (backward-char)) + (image-dired--line-up-with-method) + (with-current-buffer (image-dired-associated-dired-buffer) + (dired-do-delete))) =20 (defun image-dired-thumb-update-marks () "Update the marks in the thumbnail buffer." =2D-=20 2.26.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iGoEARECACoWIQS/5hHRBUjla4uZVXU6jitvQ7HLaAUCYRZt0wwccG1AYTE2bi5u ZXQACgkQOo4rb0Oxy2io2wCePmP7qprzfxv5PaEVpZAv5ZWNEvIAmwQbDw1lApsD /Eo95x/lA0OD1Nus =o+bk -----END PGP SIGNATURE----- --==-=-=--