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: Fri, 04 Aug 2023 09:44:41 +0200 Message-ID: <87bkfnjlp2.fsf@ledu-giraud.fr> References: <874jruy7xx.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> <87o7jojs98.fsf@ledu-giraud.fr> <833510xsnt.fsf@gnu.org> <87jzucjchb.fsf@ledu-giraud.fr> <83sf90vv06.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="18312"; 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 Fri Aug 04 09:45:12 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 1qRpUm-0004Ze-5g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Aug 2023 09:45:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRpUg-0007tJ-4m; Fri, 04 Aug 2023 03:45:06 -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 1qRpUd-0007sy-Ny for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 03:45: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 1qRpUd-0003Nw-4D for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 03:45:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRpUc-00015Q-GS for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 03:45: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: Fri, 04 Aug 2023 07:45: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.16911350884138 (code B ref 61394); Fri, 04 Aug 2023 07:45:02 +0000 Original-Received: (at 61394) by debbugs.gnu.org; 4 Aug 2023 07:44:48 +0000 Original-Received: from localhost ([127.0.0.1]:53352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRpUN-00014f-Pe for submit@debbugs.gnu.org; Fri, 04 Aug 2023 03:44:48 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:6245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRpUK-00014V-8H for 61394@debbugs.gnu.org; Fri, 04 Aug 2023 03:44:46 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=JiSDIthH Hz5+95JEBdtY+altVT9Eh3Gl/uWpmi49dRY=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=Xrj7x6zUlI3BhczZWFIwWduI6bK/3q obXxl/DzoUkCDWOUSwPA3Q4UYEmGUed2ykQ77PqqWki9t/oHX/M4VlDA== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=JiSDIthHHz5+95JE BdtY+altVT9Eh3Gl/uWpmi49dRY=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=XnSI5/xR9F6J+amSKveEHRsQs3koJ+XC8WBLYo IS9rbY87VOtTbCbszD0kD6pNsssWPaOiddIP/n+Dfj6bH0IGd1uZHFZlgS5C56zEsvTKMe 2BZUjB52wtv1P811IHJpAO4EEorzEdXfwq14qQNb4EuliabpaXYJ0nmUK3ag33JKhpXQ1w RKO26BbTGE5vLG3PzeG5K3VCUQdq6c6NYbU2ni2aGtJNHoh9AxX/2hLqLi4dF1JlkhAEHC wjXmTET7ZfLMOPeACyMQwHaAqKSHi/86PL+c6whw9tsAA2YzIC2YTlLVboGvpxYJ3SLhgp b7JZbgofauyBTMX9gKR+W6ow== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 00da3dc8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 4 Aug 2023 09:44:42 +0200 (CEST) In-Reply-To: <83sf90vv06.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 03 Aug 2023 21:30:33 +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:266650 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Manuel Giraud >> Cc: stefankangas@gmail.com, contovob@tcd.ie, 61394@debbugs.gnu.org >> Date: Thu, 03 Aug 2023 18:51:28 +0200 >> >> Eli Zaretskii writes: >> >> >> +(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." >> > >> > The first line of the doc string should be a single complete sentence. >> > (Just move the "modified" part to the first line, I think there's >> > enough space there.) >> >> I don't understand. "Update the thumbnail at point." does not seem >> sufficient because the fact that the original image might be modified is >> the main point of this function. > > What I had in mind is this: > > (defun image-dired-update-thumbnail-at-point () > "Update the thumbnail at point if the original image file has been modified. > This function uncaches and removes the thumbnail file under the old name." > > OK? Ok. Sorry I misread your reply ("move" not "remove"). BTW, I'm using 'M-q' on docstring and my fill-column is set to 70 (the default I guess): is there a better way? >> What about: >> >> "When 'image-dired-thumb-naming' is set to 'sha1-contents', 'thumb' and >> 'old-thumb' could be different file names. Update the thumbnail then." > > Much better, thanks. Ok, so here is a new patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-thumbnail-update-when-thumb-name-is-based-on-ima.patch >From b67f344f148dbabf8f2c0099aa9002af4570c5dd 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 | 17 +++++++++++++++++ lisp/image/image-dired.el | 2 +- 3 files changed, 20 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..53a5e274175 100644 --- a/lisp/image/image-dired-util.el +++ b/lisp/image/image-dired-util.el @@ -190,6 +190,23 @@ 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. +This function uncaches and removes the thumbnail file under the old name." + (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))) + ;; When 'image-dired-thumb-naming' is set to + ;; 'sha1-contents', 'thumb' and 'old-thumb' could be + ;; different file names. Update the thumbnail then. + (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 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--