From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content Date: Tue, 01 Aug 2023 19:05:52 +0200 Message-ID: <87h6piu1zj.fsf@ledu-giraud.fr> References: <874jruy7xx.fsf@ledu-giraud.fr> <877cwmo8ij.fsf@ledu-giraud.fr> <87y1oz54bn.fsf@ledu-giraud.fr> <87wn4dra0h.fsf@ledu-giraud.fr> <87bklhtwhd.fsf@ledu-giraud.fr> <871qgumqh7.fsf@ledu-giraud.fr> <83ila5n8co.fsf@gnu.org> <87fs59qx54.fsf@ledu-giraud.fr> <83wmyll9s5.fsf@gnu.org> <87bkfxcaa2.fsf@ledu-giraud.fr> <83wmykjzji.fsf@gnu.org> <877cqkcrds.fsf@ledu-giraud.fr> <83bkfwjkh8.fsf@gnu.org> <871qgsc9fv.fsf@ledu-giraud.fr> <83y1izj2q6.fsf@gnu.org> <87leezhwq0.fsf@ledu-giraud.fr> <87edko9ixu.fsf@ledu-giraud.fr> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35369"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: contovob@tcd.ie, stefankangas@gmail.com, 61394@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 01 19:06:16 2023 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 1qQsp6-0008z7-AS for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Aug 2023 19:06:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQsou-0006Iq-K2; Tue, 01 Aug 2023 13:06:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQsos-0006If-S5 for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 13:06:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQsos-0001Un-K1 for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 13:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQsos-0004U1-2R for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 13:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Aug 2023 17:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61394 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61394-submit@debbugs.gnu.org id=B61394.169090956017225 (code B ref 61394); Tue, 01 Aug 2023 17:06:02 +0000 Original-Received: (at 61394) by debbugs.gnu.org; 1 Aug 2023 17:06:00 +0000 Original-Received: from localhost ([127.0.0.1]:48263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQsop-0004Tl-PC for submit@debbugs.gnu.org; Tue, 01 Aug 2023 13:06:00 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:37519) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQsom-0004Ta-E3 for 61394@debbugs.gnu.org; Tue, 01 Aug 2023 13:05:57 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=hNUiLpqC 6+/GanByU1cumACdDczqUIIGZ6n8Hg5PySw=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=vOA8s7mSdclAlMPlZ6PsXoyVQmXjD0 koTINveqIj2gnnxU83qz8apCHGaqNV5Aiy3J/Yds1BH2Nc3UWZa6LaAA== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=hNUiLpqC6+/GanBy U1cumACdDczqUIIGZ6n8Hg5PySw=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=WpUhWXM7uYdOQ4krMr1T+FgyqNPDfztNdvUDIx bGipGlU9Nfi3eydNzEHa9pk1MiyBt98Kx3Wz76uQFfqTm1LlxK/ovsADJXT+E7RjKg/nlw YZvSkLLNPO04CuVaOHypVYkvSkzENTot/qZOZXTo3xZtdDY7BbEUAmtss0LnFMlnrdXYy2 ZOaQMuFQlItUIkS7yynVuGnoUSt8npJsASJNZYFL2OVTn51yZeIL2ZbeKJ1SWRFh98SOOx TFHbtWc/r2/l4/RAMKDNXZN4t87YD30+rmVHS7+XT6vKXJnoepHbMQsU5ICQZVLbS+Paf8 Gu+yt3gYVhcCP75cOJ8vgbhQ== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 338ec390 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Aug 2023 19:05:53 +0200 (CEST) In-Reply-To: <87edko9ixu.fsf@ledu-giraud.fr> (Manuel Giraud's message of "Mon, 31 Jul 2023 17:53:01 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266462 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Manuel Giraud writes: > Hi, > > FTR, there is a thing that does not work with this "thumb name based on > content": upon rotation the thumb is not updated properly. > > This comes from the fact that the image content has changed (obviously) > so the new thumb will have a new name and is not displayed in the > *image-dired* buffer =F0=9F=98=85. I'd have to find a way around it. Hi, So here is a patch that fixes this issue. Thanks. --=20 Manuel Giraud --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-thumbnail-update-when-thumb-name-is-based-on-ima.patch >From 5716e77a61a7a7459a00e266c4d6236be48c02c4 Mon Sep 17 00:00:00 2001 From: Manuel Giraud 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 | 15 +++++++++++++++ lisp/image/image-dired.el | 2 +- 3 files changed, 18 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)))))) diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el index 3f6880fc807..1114f50477c 100644 --- a/lisp/image/image-dired-util.el +++ b/lisp/image/image-dired-util.el @@ -190,6 +190,21 @@ 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))) + (unless (string= thumb old-thumb) + (clear-image-cache old-thumb) + (delete-file old-thumb) + (setf (plist-get (cdr image) :file) 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 96a0c2ef9bc..7b0059e2f7a 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 --=-=-=--