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: Wed, 18 Aug 2021 17:01:36 +0200 Message-ID: <87bl5uhk4v.fsf@a16n.net> References: <874kbwl2qc.fsf@a16n.net> <87lf58rx3g.fsf@gnus.org> <87r1f0gijc.fsf@a16n.net> <87tujwotow.fsf@gnus.org> <87lf558pik.fsf@a16n.net> <87k0koutv3.fsf@gnus.org> <87o89xsuto.fsf@a16n.net> <8735r9fv9j.fsf@gnus.org> <87sfz9o13s.fsf@a16n.net> <87fsv6dib9.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="34589"; 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 Wed Aug 18 17:02:30 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 1mGN5J-0008em-6q for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 18 Aug 2021 17:02:29 +0200 Original-Received: from localhost ([::1]:55412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGN5H-0004Wz-Bc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 18 Aug 2021 11:02:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGN4t-0004Vk-2W for bug-gnu-emacs@gnu.org; Wed, 18 Aug 2021 11:02:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGN4s-0004tB-6d for bug-gnu-emacs@gnu.org; Wed, 18 Aug 2021 11:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mGN4s-00077m-25 for bug-gnu-emacs@gnu.org; Wed, 18 Aug 2021 11:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Peter =?UTF-8?Q?M=C3=BCnster?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Aug 2021 15:02: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.162929891427035 (code B ref 50000); Wed, 18 Aug 2021 15:02:02 +0000 Original-Received: (at 50000) by debbugs.gnu.org; 18 Aug 2021 15:01:54 +0000 Original-Received: from localhost ([127.0.0.1]:57236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGN4g-0006yS-7V for submit@debbugs.gnu.org; Wed, 18 Aug 2021 11:01:54 -0400 Original-Received: from server.a16n.net ([178.33.238.77]:55946) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGN4a-0006p7-HH for 50000@debbugs.gnu.org; Wed, 18 Aug 2021 11:01:48 -0400 Original-Received: from ws.localdomain (arennes-556-1-251-22.w2-14.abo.wanadoo.fr [2.14.250.22]) by server.a16n.net (Postfix) with ESMTPSA id B028643E04C0; Wed, 18 Aug 2021 17:01:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a16n.net; s=a16n; t=1629298897; bh=QuVDi6yfMV+W4v4H5NiY2RS8TLwoIFNQoxbfVh/cXYo=; h=From:To:Cc:Subject:References:Date:In-Reply-To; b=pQKj+3FPOR1r69542UQaC7HtxdkT2NZu6wuoJrTxr3kEBZ+y73+YX9Pq+nPEnCBqj QsnGW/Bz6ciBTJWSDrZtbdrAgBKnSg8tm6MCzuc+8JBr/pscUfI9v2upAmKHq4UYxC crNUs6eSz0UF9dyVK+sXhgf9IXTiVcBJT4W7AINdMmmtKVzdEj92rKi5ypWVnAZhkO eKP1dZnIATo5UbeeGfFd52gq/qFMnaF/ePACbR/S0GBY9aJ5eGN2HDf299NBkFz3jn RwB5kXlDriph1+6P57stmaMHljR59+Ulenjo0zYRzcTAPIS6PRlkXJkPJGSzMs/2e7 hV5zVCP0907mA== Original-Received: by ws.localdomain (Postfix, from userid 1000) id 322887426DC; Wed, 18 Aug 2021 17:01:37 +0200 (CEST) In-Reply-To: <87fsv6dib9.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 18 Aug 2021 14:54:34 +0200") 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:212151 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, Aug 18 2021, Lars Ingebrigtsen wrote: > Thanks; applied with one minor change: Thanks. Please find attached some further patches for image-dired.el. I hope that they are useful. =2D-=20 Peter --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-Fix-deletion-of-associated-image.patch Content-Transfer-Encoding: quoted-printable From=207cfc8ad4effd5820d1bdef2027148df8219b8408 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Peter=3D20M=3DC3=3DBCnster?=3D Date: Tue, 17 Aug 2021 00:19:08 +0200 Subject: [PATCH 3/6] Fix deletion of associated image * lisp/image-dired.el (image-dired-delete-marked): Treat original images first, because point position is used when there are no marked files. =2D-- lisp/image-dired.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 1d8e27d39e..5ae6b21766 100644 =2D-- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -2312,14 +2312,14 @@ image-dired-thumb-file-marked-p (image-dired-dired-file-marked-p)))))) =20 (defun image-dired-delete-marked () =2D "Delete marked thumbnails and associated images." + "Delete current or marked thumbnails and associated images." (interactive) + (with-current-buffer (image-dired-associated-dired-buffer) + (dired-do-delete)) (image-dired--with-marked (image-dired-delete-char) (backward-char)) =2D (image-dired--line-up-with-method) =2D (with-current-buffer (image-dired-associated-dired-buffer) =2D (dired-do-delete))) + (image-dired--line-up-with-method)) =20 (defun image-dired-thumb-update-marks () "Update the marks in the thumbnail buffer." =2D-=20 2.26.2 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0004-New-placement-of-newline-characters-in-image-dired-d.patch Content-Transfer-Encoding: quoted-printable From=20ba6e4282f69c13dc57d00fdd7ff63f9565b8afe9 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Peter=3D20M=3DC3=3DBCnster?=3D Date: Wed, 18 Aug 2021 01:37:43 +0200 Subject: [PATCH 4/6] New placement of newline characters in image-dired-db-file It's more usual to have the newline at the end of the line, instead of the beginning. This change avoids missing newline at the end of the file, an empty line at the start and eventually a lot of empty lines when `require-final-newline' is not nil. * lisp/image-dired.el (image-dired-write-tags): Insert newline at the end of the line, instead of the beginning. (image-dired-remove-tag): Do not delete empty line at end of buffer. =2D-- lisp/image-dired.el | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 5ae6b21766..428b20d6eb 100644 =2D-- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -1095,7 +1095,7 @@ image-dired-write-tags (end-of-line) (insert (format ";%s" tag)))) (goto-char (point-max)) =2D (insert (format "\n%s;%s" file tag)))) + (insert (format "%s;%s\n" file tag)))) (save-buffer)))) =20 (defun image-dired-remove-tag (files tag) @@ -1122,11 +1122,7 @@ image-dired-remove-tag (setq end (point)) (beginning-of-line) (when (not (search-forward ";" end t)) =2D (kill-line 1) =2D ;; If on empty line at end of buffer =2D (and (eobp) =2D (looking-at "^$") =2D (delete-char -1))))))) + (kill-line 1)))))) (save-buffer))) =20 (defun image-dired-list-tags (file) @@ -2184,7 +2180,7 @@ image-dired-write-comments (insert (format "comment:%s;" comment))) ;; File does not exist in database - add it. (goto-char (point-max)) =2D (insert (format "\n%s;comment:%s" file comment)))) + (insert (format "%s;comment:%s\n" file comment)))) (save-buffer)))) =20 (defun image-dired-update-property (prop value) =2D-=20 2.26.2 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0005-Avoid-problems-when-one-tag-file-is-a-substring-of-a.patch Content-Transfer-Encoding: quoted-printable From=202163c4c3894272d2022e5fb78d2c0be1310d9da9 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Peter=3D20M=3DC3=3DBCnster?=3D Date: Wed, 18 Aug 2021 02:02:02 +0200 Subject: [PATCH 5/6] Avoid problems when one tag/file is a substring of another * lisp/image-dired.el (image-dired-remove-tag): End of filename is bound by ";" and end of tag is bound by ";" or end of line. =2D-- lisp/image-dired.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 428b20d6eb..5ee66b0e90 100644 =2D-- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -1110,11 +1110,12 @@ image-dired-remove-tag (error "Files must be a string or a list of strings!"))) (dolist (file files) (goto-char (point-min)) =2D (when (search-forward-regexp (format "^%s" file) nil t) + (when (search-forward-regexp (format "^%s;" file) nil t) (end-of-line) (setq end (point)) (beginning-of-line) =2D (when (search-forward-regexp (format "\\(;%s\\)" tag) end t) + (when (search-forward-regexp + (format "\\(;%s\\)\\($\\|;\\)" tag) end t) (delete-region (match-beginning 1) (match-end 1)) ;; Check if file should still be in the database. If ;; it has no tags or comments, it will be removed. =2D-=20 2.26.2 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0006-Add-support-for-history-of-image-tags-and-completion.patch Content-Transfer-Encoding: quoted-printable From=20364beec6d1470712415a36f5810e4f7d320c6b0f Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Peter=3D20M=3DC3=3DBCnster?=3D Date: Wed, 18 Aug 2021 11:21:51 +0200 Subject: [PATCH 6/6] Add support for history of image tags and completion in the minibuffer * lisp/image-dired.el (image-dired-tag-history): New variable holding the tag history. (image-dired-tag-files, image-dired-tag-thumbnail, image-dired-delete-tag) (image-dired-tag-thumbnail-remove): Use it for the user input. =2D-- lisp/image-dired.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 5ee66b0e90..5a332964d5 100644 =2D-- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -652,6 +652,8 @@ image-dired-queue-active-limit "Maximum number of concurrent jobs permitted for generating images. Increase at own risk.") =20 +(defvar image-dired-tag-history nil "Variable holding the tag history.") + (defun image-dired-pngnq-thumb (spec) "Quantize thumbnail described by format SPEC with pngnq(1)." (let ((process @@ -1146,7 +1148,9 @@ image-dired-list-tags (defun image-dired-tag-files (arg) "Tag marked file(s) in dired. With prefix ARG, tag file at point." (interactive "P") =2D (let ((tag (read-string "Tags to add (separate tags with a semicolon):= ")) + (let ((tag (completing-read + "Tags to add (separate tags with a semicolon): " + image-dired-tag-history nil nil nil 'image-dired-tag-history= )) files) (if arg (setq files (list (dired-get-filename))) @@ -1160,7 +1164,9 @@ image-dired-tag-files (defun image-dired-tag-thumbnail () "Tag current or marked thumbnails." (interactive) =2D (let ((tag (read-string "Tags to add (separate tags with a semicolon):= "))) + (let ((tag (completing-read + "Tags to add (separate tags with a semicolon): " + image-dired-tag-history nil nil nil 'image-dired-tag-history= ))) (image-dired--with-marked (image-dired-write-tags (list (cons (image-dired-original-file-name) tag))) @@ -1172,7 +1178,8 @@ image-dired-delete-tag "Remove tag for selected file(s). With prefix argument ARG, remove tag from file at point." (interactive "P") =2D (let ((tag (read-string "Tag to remove: ")) + (let ((tag (completing-read "Tag to remove: " image-dired-tag-history + nil nil nil 'image-dired-tag-history)) files) (if arg (setq files (list (dired-get-filename))) @@ -1182,7 +1189,8 @@ image-dired-delete-tag (defun image-dired-tag-thumbnail-remove () "Remove tag from current or marked thumbnails." (interactive) =2D (let ((tag (read-string "Tag to remove: "))) + (let ((tag (completing-read "Tag to remove: " image-dired-tag-history + nil nil nil 'image-dired-tag-history))) (image-dired--with-marked (image-dired-remove-tag (image-dired-original-file-name) tag) (image-dired-update-property =2D-=20 2.26.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iGoEARECACoWIQS/5hHRBUjla4uZVXU6jitvQ7HLaAUCYR0g0AwccG1AYTE2bi5u ZXQACgkQOo4rb0Oxy2j8ywCglwH/5fp8+3WOAV2NbOvbuZ7UxtoAnRtOhsliLcuv o/UixA3tLXC7np0Y =Lu7Z -----END PGP SIGNATURE----- --==-=-=--