Subject: Re: bug#70821: 29.3; image-dired: tagging in thumbnail buffer

From: Eli Zaretskii <[email-masked]>
Date: Tue, 07 May 2024 21:29:31 +0300

> From: Christopher Howard <[email-masked]>
> Date: Tue, 07 May 2024 08:57:14 -0800
> 
> 
> I'm trying to follow instructions in the Emacs reference manual for tagging image thumbnails, but am getting errors. Here is an error I get if I try to tag them from within the thumbnail buffer.
> 
> emacs -Q
> M-! (setq debug-on-error t)
> M-x image-dired ~/Pictures/tanana_20230713
> t t myphoto
> 
> ```
> Debugger entered--Lisp error: (invalid-function image-dired--with-marked)
>   image-dired--with-marked(nil nil)
>   image-dired-tag-thumbnail()
>   funcall-interactively(image-dired-tag-thumbnail)
>   command-execute(image-dired-tag-thumbnail)
> ```

Thanks.  Does the patch below help to resolve the issue?

diff --git a/lisp/image/image-dired-tags.el b/lisp/image/image-dired-tags.el
index 2b5248c..54595ad 100644
--- a/lisp/image/image-dired-tags.el
+++ b/lisp/image/image-dired-tags.el
@@ -32,8 +32,6 @@
 
 (require 'image-dired-util)
 
-(declare-function image-dired--with-marked "image-dired")
-
 (defvar image-dired-dir)
 (defvar image-dired-thumbnail-storage)
 (defvar image-dired-tags-db-file)
@@ -156,18 +154,6 @@ image-dired-tag-files
         (cons x tag))
       files))))
 
-(defun image-dired-tag-thumbnail ()
-  "Tag current or marked thumbnails."
-  (interactive nil image-dired-thumbnail-mode)
-  (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)))
-     (image-dired-update-property
-      'tags (image-dired-list-tags (image-dired-original-file-name))))))
-
 ;;;###autoload
 (defun image-dired-delete-tag (arg)
   "Remove tag for selected file(s).
@@ -181,16 +167,6 @@ image-dired-delete-tag
       (setq files (dired-get-marked-files)))
     (image-dired-remove-tag files tag)))
 
-(defun image-dired-tag-thumbnail-remove ()
-  "Remove tag from current or marked thumbnails."
-  (interactive nil image-dired-thumbnail-mode)
-  (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
-      'tags (image-dired-list-tags (image-dired-original-file-name))))))
-
 (defun image-dired-write-comments (file-comments)
   "Write file comments specified by FILE-COMMENTS comments to database.
 FILE-COMMENTS is an alist on the following form:
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 26d5811..00dc8e3 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -1714,6 +1714,28 @@ image-dired-add-to-tag-file-list
                   (cons (list tag file) (cdr image-dired-tag-file-list))))
       (setq image-dired-tag-file-list (list (list tag file))))))
 
+(defun image-dired-tag-thumbnail-remove ()
+  "Remove tag from current or marked thumbnails."
+  (interactive nil image-dired-thumbnail-mode)
+  (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
+      'tags (image-dired-list-tags (image-dired-original-file-name))))))
+
+(defun image-dired-tag-thumbnail ()
+  "Tag current or marked thumbnails."
+  (interactive nil image-dired-thumbnail-mode)
+  (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)))
+     (image-dired-update-property
+      'tags (image-dired-list-tags (image-dired-original-file-name))))))
+
 (defvar image-dired-slideshow-count 0
   "Keeping track on number of images in slideshow.")
 (make-obsolete-variable 'image-dired-slideshow-count "no longer used." "29.1")