all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#73617: [PATCH] Correctly update image properties
@ 2024-10-03 14:58 Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-04 14:36 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-03 14:58 UTC (permalink / raw)
  To: 73617

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

Tags: patch

Hi,

Here is a patch that fixes how image's properties are updated.  You
could reproduce this issue as follow:

      - emacs -Q
      - C-x C-f etc/images/kitchen-sink.xpm <RET>
      - s s 8 <RET>
      - s m none <RET>  ;; -> the image is still smoothed

With this patch, the smoothing is updated accordingly.

In GNU Emacs 31.0.50 (build 9, x86_64-unknown-openbsd7.6, X toolkit) of
 2024-10-02 built on computer
Repository revision: 4bb62af3263057312021e076dc7e0c8ff195e38f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: OpenBSD computer 7.6 GENERIC.MP#344 amd64

Configured using:
 'configure CC=egcc CPPFLAGS=-I/usr/local/include
 LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs
 --bindir=/home/manuel/bin --with-x-toolkit=lucid
 --with-toolkit-scroll-bars=no --without-cairo
 --without-compress-install'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Correctly-update-image-properties.patch --]
[-- Type: text/patch, Size: 1587 bytes --]

From b59964af3c646efa79749e8d072784741ce57ac0 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
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 | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 7cf7845e935..6ad4c382d5f 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -867,6 +867,16 @@ 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 ((image-properties (cdr image))
+        prop val)
+    (while (setq prop (car properties))
+      (setq val (cadr properties)
+            properties (cddr properties))
+      (plist-put image-properties prop val))
+    (cons (car image) image-properties)))
+
 (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 +969,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


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#73617: [PATCH] Correctly update image properties
  2024-10-03 14:58 bug#73617: [PATCH] Correctly update image properties Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-04 14:36 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-12 11:37   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-04 14:36 UTC (permalink / raw)
  To: 73617

[-- Attachment #1: Type: text/plain, Size: 68 bytes --]

Hi,

Same patch with a shorter version of image--update-properties.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Correctly-update-image-properties.patch --]
[-- Type: text/x-patch, Size: 1438 bytes --]

From 3ea82382dbd42d9e047c1c6c99cd7602b10c98f4 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
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


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#73617: [PATCH] Correctly update image properties
  2024-10-04 14:36 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-12 11:37   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2024-10-12 11:37 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: 73617-done

> Date: Fri, 04 Oct 2024 16:36:24 +0200
> From:  Manuel Giraud via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Same patch with a shorter version of image--update-properties.

Thanks, installed on the master branch, and closing the bug.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-12 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 14:58 bug#73617: [PATCH] Correctly update image properties Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 14:36 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 11:37   ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.