Subject: Re: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content

From: Manuel Giraud <[email-masked]>
Date: Sat, 29 Jul 2023 18:50:27 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Manuel Giraud <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Sat, 29 Jul 2023 11:51:19 +0200
>> 
>> So I think that this patch does that but then 5efc7b22cec should be
>> reverted.
>> 
>> I'm not so sure about the 'image-dired-thumb-name' docstring.
>
> Thanks, will look into that soon.

Here is a new version of this patch.  I missed some precision in a
docstring in the previous one (sorry).
>From 9db8988412a8d2463d3d44ff23b80e545e9e5b19 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Sat, 29 Jul 2023 10:59:32 +0200
Subject: [PATCH] Revert thumbnail naming for 'per-directory storage method

* lisp/image/image-dired-util.el (image-dired-thumb-name): Revert
to "filename.thumb.jpg" for 'per-directory storage.

* lisp/image/image-dired.el (image-dired-thumbnail-storage): Fix
documentation.
---
 lisp/image/image-dired-util.el | 12 ++++++------
 lisp/image/image-dired.el      |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el
index 3f6880fc807..70911bce45a 100644
--- a/lisp/image/image-dired-util.el
+++ b/lisp/image/image-dired-util.el
@@ -77,8 +77,9 @@ image-dired-thumb-name
   added to the file name.
 
 - Otherwise `image-dired-thumbnail-storage' is used to set the
-  directory where to store the thumbnail.  In this latter case
-  the name given to the thumbnail depends on the value of
+  directory where to store the thumbnail.  In this latter case,
+  if `image-dired-thumbnail-storage' is set to `image-dired' the
+  file name given to the thumbnail depends on the value of
   `image-dired-thumb-naming'.
 
 See also `image-dired-thumbnail-storage' and
@@ -99,15 +100,14 @@ image-dired-thumb-name
       (let ((name (if (eq 'sha1-contents image-dired-thumb-naming)
                       (image-dired-contents-sha1 file)
                     ;; Defaults to SHA-1 of file name
-                    (if (eq 'per-directory image-dired-thumbnail-storage)
-                        (sha1 (file-name-nondirectory file))
-                      (sha1 file)))))
+                    (sha1 file))))
         (cond ((or (eq 'image-dired image-dired-thumbnail-storage)
                    ;; Maintained for backwards compatibility:
                    (eq 'use-image-dired-dir image-dired-thumbnail-storage))
                (expand-file-name (format "%s.jpg" name) (image-dired-dir)))
               ((eq 'per-directory image-dired-thumbnail-storage)
-               (expand-file-name (format "%s.jpg" name)
+               (expand-file-name (format "%s.thumb.jpg"
+                                         (file-name-nondirectory file))
                                  (expand-file-name
                                   ".image-dired"
                                   (file-name-directory file)))))))))
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 96a0c2ef9bc..98596510ec1 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -174,8 +174,8 @@ image-dired-thumb-naming
 In both case, a \"jpg\" extension is appended to save as JPEG.
 
 The value of this option is ignored if Image-Dired is customized
-to use the Thumbnail Managing Standard.  See
-`image-dired-thumbnail-storage'."
+to use the Thumbnail Managing Standard or the per-directory
+thumbnails setting.  See `image-dired-thumbnail-storage'."
   :type '(choice :tag "How to name thumbnail files"
                  (const :tag "SHA-1 of the image file name" sha1-filename)
                  (const :tag "SHA-1 of the image contents" sha1-contents))
@@ -208,8 +208,8 @@ image-dired-thumbnail-storage
 
     Set this user option to `per-directory'.
 
-To control the naming of thumbnails for alternatives (2) and (3)
-above, customize the value of `image-dired-thumb-naming'.
+To control the naming of thumbnails for alternative (2) above,
+customize the value of `image-dired-thumb-naming'.
 
 To control the default size of thumbnails for alternatives (2)
 and (3) above, customize the value of `image-dired-thumb-size'.
-- 
2.40.0

>> BTW, I'm not running "make check" often but I have some failures here
>> and there (2 in TRAMP, 2 in EPG...): is it expected?
>
> Please report them as separate bugs.

Ok, I've created one for Tramp for the moment.
-- 
Manuel Giraud