Subject: Re: bug#73617: [PATCH] Correctly update image properties

From: Manuel Giraud <[email-masked]>
Date: Fri, 04 Oct 2024 16:36:24 +0200

Hi,

Same patch with a shorter version of image--update-properties.
>From 3ea82382dbd42d9e047c1c6c99cd7602b10c98f4 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Thu, 3 Oct 2024 16:20:19 +0200
Subject: [PATCH] Correctly update image properties

* lisp/image-mode.el (image--update-properties): New function to
update image properties.
(image-toggle-display-image): Use it.
---
 lisp/image-mode.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 7cf7845e935..e75f6ea918f 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -867,6 +867,13 @@ image--scale-within-limits-p
         (or (<= mw (* (car size) scale))
             (<= mh (* (cdr size) scale))))))
 
+(defun image--update-properties (image properties)
+  "Update IMAGE with the new PROPERTIES set."
+  (let (prop)
+    (while (setq prop (pop properties))
+      (plist-put (cdr image) prop (pop properties)))
+    image))
+
 (defun image-toggle-display-image ()
   "Show the image of the image file.
 Turn the image data into a real image, but only if the whole file
@@ -959,7 +966,7 @@ image-toggle-display-image
 
     ;; Discard any stale image data before looking it up again.
     (image-flush image)
-    (setq image (append image (image-transform-properties image)))
+    (setq image (image--update-properties image (image-transform-properties image)))
     (setq props
 	  `(display ,image
 		    ;; intangible ,image
-- 
2.46.1

-- 
Manuel Giraud