From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: contovob@tcd.ie, stefankangas@gmail.com, 61394@debbugs.gnu.org
Subject: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content
Date: Thu, 03 Aug 2023 13:10:43 +0200 [thread overview]
Message-ID: <87o7jojs98.fsf@ledu-giraud.fr> (raw)
In-Reply-To: <83a5v9z4ve.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 02 Aug 2023 21:16:53 +0300")
[-- Attachment #1: Type: text/plain, Size: 954 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Manuel Giraud <manuel@ledu-giraud.fr>
>> Cc: stefankangas@gmail.com, contovob@tcd.ie, 61394@debbugs.gnu.org
>> Date: Wed, 02 Aug 2023 20:00:19 +0200
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> > Thanks. Maybe I'm missing something, but isn't the problem limited to
>> > just one method of naming the thumbnail files? If so, shouldn't these
>> > changes be limited to that method alone?
>>
>> Yes. First I had a test about the method around the call to
>> 'image-dired-update-thumbnail-at-point' but then I realize that nothing
>> will be done for others methods as I'm doing a test on the thumb name
>> change:
>> ... (unless (string= thumb old-thumb) ...
>
> This at least warrants a comment, so that others won't have to be
> bothered by the same questions.
What about this one? I've also permuted some instructions to avoid a
flicker when updating the thumbnail.
--
Manuel Giraud
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-thumbnail-update-when-thumb-name-is-based-on-ima.patch --]
[-- Type: text/x-patch, Size: 3303 bytes --]
From 4759066712e9cec4906f95a96b3c6b023149eade Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 1 Aug 2023 18:56:33 +0200
Subject: [PATCH] Fix thumbnail update when thumb name is based on image
content
* lisp/image/image-dired-util.el
(image-dired-update-thumbnail-at-point): New function to update
thumbnail when original image contents changed.
* lisp/image/image-dired-external.el
(image-dired-rotate-original): Use it.
* lisp/image/image-dired.el (image-dired-display-thumbs): Fix
spacing while here.
---
lisp/image/image-dired-external.el | 3 ++-
lisp/image/image-dired-util.el | 18 ++++++++++++++++++
lisp/image/image-dired.el | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lisp/image/image-dired-external.el b/lisp/image/image-dired-external.el
index 9f35e17a7e6..77352c25a3b 100644
--- a/lisp/image/image-dired-external.el
+++ b/lisp/image/image-dired-external.el
@@ -405,7 +405,8 @@ image-dired-rotate-original
(not image-dired-rotate-original-ask-before-overwrite))
(progn
(copy-file image-dired-temp-rotate-image-file file t)
- (image-dired-refresh-thumb))
+ (image-dired-refresh-thumb)
+ (image-dired-update-thumbnail-at-point))
(image-dired-display-image file))))))
\f
diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el
index 70911bce45a..40e90e6dcb8 100644
--- a/lisp/image/image-dired-util.el
+++ b/lisp/image/image-dired-util.el
@@ -190,6 +190,24 @@ image-dired-image-at-point-p
"Return non-nil if there is an `image-dired' thumbnail at point."
(get-text-property (point) 'image-dired-thumbnail))
+(defun image-dired-update-thumbnail-at-point ()
+ "Update the thumbnail at point if the original image file has been
+modified. Take care of uncaching and removing the old thumbnail
+file."
+ (when (image-dired-image-at-point-p)
+ (let* ((file (image-dired-original-file-name))
+ (thumb (expand-file-name (image-dired-thumb-name file)))
+ (image (get-text-property (point) 'display)))
+ (when image
+ (let ((old-thumb (plist-get (cdr image) :file)))
+ ;; If 'thumb' and 'old-thumb' are the same file names, do
+ ;; nothing. This would be the case when
+ ;; 'image-dired-thumb-naming' is set to 'sha1-filename'.
+ (unless (string= thumb old-thumb)
+ (setf (plist-get (cdr image) :file) thumb)
+ (clear-image-cache old-thumb)
+ (delete-file old-thumb)))))))
+
(defun image-dired-window-width-pixels (window)
"Calculate WINDOW width in pixels."
(declare (obsolete window-body-width "29.1"))
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 98596510ec1..33beb5b3e49 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -590,7 +590,7 @@ image-dired-display-thumbs
`image-dired-previous-line-and-display' where we do not want the
thumbnail buffer to be selected."
(interactive "P" nil dired-mode)
- (setq image-dired--generate-thumbs-start (current-time))
+ (setq image-dired--generate-thumbs-start (current-time))
(let ((buf (image-dired-create-thumbnail-buffer))
files dired-buf)
(if arg
--
2.40.0
next prev parent reply other threads:[~2023-08-03 11:10 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 19:06 bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-10 15:13 ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-10 18:46 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-11 9:50 ` Eli Zaretskii
2023-02-11 12:30 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-11 14:53 ` Eli Zaretskii
2023-02-11 22:33 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-11 23:06 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-12 3:02 ` Stefan Kangas
2023-02-12 21:53 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 14:19 ` Stefan Kangas
2023-02-15 15:35 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19 14:06 ` Stefan Kangas
2023-02-19 14:43 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19 16:19 ` Stefan Kangas
2023-02-20 9:20 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-25 18:45 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-26 19:18 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-27 7:04 ` Eli Zaretskii
2023-07-27 13:52 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-27 14:16 ` Eli Zaretskii
2023-07-27 21:30 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 6:55 ` Eli Zaretskii
2023-07-28 9:33 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 12:20 ` Eli Zaretskii
2023-07-28 16:00 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 18:44 ` Eli Zaretskii
2023-07-29 9:51 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 10:34 ` Eli Zaretskii
2023-07-29 16:50 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 8:43 ` Eli Zaretskii
2023-07-29 10:47 ` Michael Albinus
2023-07-31 15:53 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-01 17:05 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-02 11:42 ` Eli Zaretskii
2023-08-02 18:00 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-02 18:16 ` Eli Zaretskii
2023-08-03 11:10 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-03 11:38 ` Eli Zaretskii
2023-08-03 16:51 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 18:30 ` Eli Zaretskii
2023-08-04 7:44 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 10:55 ` Eli Zaretskii
2023-08-04 13:37 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 14:05 ` Eli Zaretskii
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=87o7jojs98.fsf@ledu-giraud.fr \
--to=bug-gnu-emacs@gnu.org \
--cc=61394@debbugs.gnu.org \
--cc=contovob@tcd.ie \
--cc=eliz@gnu.org \
--cc=manuel@ledu-giraud.fr \
--cc=stefankangas@gmail.com \
/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).