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, 18 Aug 2021 17:01:36 +0200	[thread overview]
Message-ID: <87bl5uhk4v.fsf@a16n.net> (raw)
In-Reply-To: <87fsv6dib9.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 18 Aug 2021 14:54:34 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 219 bytes --]

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.

-- 
           Peter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0003-Fix-deletion-of-associated-image.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]

From 7cfc8ad4effd5820d1bdef2027148df8219b8408 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
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.
---
 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
--- 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))))))
 
 (defun image-dired-delete-marked ()
-  "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))
-  (image-dired--line-up-with-method)
-  (with-current-buffer (image-dired-associated-dired-buffer)
-    (dired-do-delete)))
+  (image-dired--line-up-with-method))
 
 (defun image-dired-thumb-update-marks ()
   "Update the marks in the thumbnail buffer."
-- 
2.26.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0004-New-placement-of-newline-characters-in-image-dired-d.patch --]
[-- Type: text/x-patch, Size: 1977 bytes --]

From ba6e4282f69c13dc57d00fdd7ff63f9565b8afe9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
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.
---
 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
--- 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))
-	 (insert (format "\n%s;%s" file tag))))
+	 (insert (format "%s;%s\n" file tag))))
      (save-buffer))))
 
 (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))
-	     (kill-line 1)
-	     ;; If on empty line at end of buffer
-	     (and (eobp)
-		  (looking-at "^$")
-		  (delete-char -1)))))))
+	     (kill-line 1))))))
    (save-buffer)))
 
 (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))
-	 (insert (format "\n%s;comment:%s" file comment))))
+	 (insert (format "%s;comment:%s\n" file comment))))
      (save-buffer))))
 
 (defun image-dired-update-property (prop value)
-- 
2.26.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: 0005-Avoid-problems-when-one-tag-file-is-a-substring-of-a.patch --]
[-- Type: text/x-patch, Size: 1327 bytes --]

From 2163c4c3894272d2022e5fb78d2c0be1310d9da9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
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.
---
 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
--- 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))
-       (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)
-	 (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.
-- 
2.26.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: 0006-Add-support-for-history-of-image-tags-and-completion.patch --]
[-- Type: text/x-patch, Size: 3078 bytes --]

From 364beec6d1470712415a36f5810e4f7d320c6b0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
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.
---
 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
--- 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.")
 
+(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")
-  (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)
-  (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")
-  (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)
-  (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
-- 
2.26.2


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

  reply	other threads:[~2021-08-18 15:01 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
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 [this message]
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=87bl5uhk4v.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).