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: Thu, 03 Aug 2023 13:10:43 +0200 Message-ID: <87o7jojs98.fsf@ledu-giraud.fr> References: <874jruy7xx.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> <87h6piu1zj.fsf@ledu-giraud.fr> <83wmydzn4z.fsf@gnu.org> <87sf91jpe4.fsf@ledu-giraud.fr> <83a5v9z4ve.fsf@gnu.org> 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="30513"; 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 Thu Aug 03 13:11:17 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 1qRWEf-0007kL-Bk for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Aug 2023 13:11:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRWES-0003q2-P0; Thu, 03 Aug 2023 07:11: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 1qRWER-0003Wr-4J for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 07:11:03 -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 1qRWEQ-0008Ly-NT for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 07:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRWEQ-00075G-6f for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 07:11: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: Thu, 03 Aug 2023 11:11: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.169106104927212 (code B ref 61394); Thu, 03 Aug 2023 11:11:02 +0000 Original-Received: (at 61394) by debbugs.gnu.org; 3 Aug 2023 11:10:49 +0000 Original-Received: from localhost ([127.0.0.1]:50952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRWEC-00074p-Kd for submit@debbugs.gnu.org; Thu, 03 Aug 2023 07:10:49 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:12670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRWEA-00074h-Ma for 61394@debbugs.gnu.org; Thu, 03 Aug 2023 07:10:48 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=CQaSBwRI T+BuXwNoxlDpKqiNSjlRQpwaOxwXB3narlU=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=wp0KCz8Em9CJimpSFYKCbBT1nqO6wH wLfxCyCEONdVjWcJ2Hz9MuLmTnpNSwhlxkXV11Erd/TMLOaW6MDaJqCw== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=CQaSBwRIT+BuXwNo xlDpKqiNSjlRQpwaOxwXB3narlU=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=P0KKcDP4AVKz+Xgs/GaHew1PGnNz++f5+5ymPh AW/RH0eSeWdwafzKiEJwE2IQEXgg2kXV5+hX+/99vSYaXNFSqu23fYIFGYEjD2E9S+W85S uf5j2rI9oi3ueUHfkqxW1SeJBLJyWxjXBe961SUgM6VRzSUAqMZ0nQGdTqOuGfAQiBptZ9 AQQP4uD6JqNrUq8tFsHLyGU/y5+l2PWf/kYl3XYh8hwrxKxXR5Kg8XKmctjFGzHT0Z+N3U lh/eJyIElfqPlV9ldBjHQr9erj0MPOOP4Nww7maG20CIACnYfFws/cPX5MI2aoP3+gyTdV faxDfo20VkQym39DVCVsnXwA== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 502e5f3a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 3 Aug 2023 13:10:45 +0200 (CEST) In-Reply-To: <83a5v9z4ve.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 02 Aug 2023 21:16:53 +0300") 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:266582 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Manuel Giraud >> Cc: stefankangas@gmail.com, contovob@tcd.ie, 61394@debbugs.gnu.org >> Date: Wed, 02 Aug 2023 20:00:19 +0200 >> >> Eli Zaretskii 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-thumbnail-update-when-thumb-name-is-based-on-ima.patch >From 4759066712e9cec4906f95a96b3c6b023149eade 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 | 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)))))) 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 --=-=-=--