]> code.delx.au - gnu-emacs/blobdiff - lisp/image.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / image.el
index 855dffad2931cf6611e029f7b7d34ebec64175fc..2ae642a3e32b276adc32ba2eb1c67eadaa96169e 100644 (file)
@@ -435,6 +435,30 @@ Image file names that are not absolute are searched for in the
                        (image-compute-scaling-factor image-scaling-factor)))
            props)))
 
+(defun image--set-property (image property value)
+  "Set PROPERTY in IMAGE to VALUE.
+Internal use only."
+  (if (null value)
+      (while (cdr image)
+        ;; IMAGE starts with the symbol `image', and the rest is a
+        ;; plist.  Decouple plist entries where the key matches
+        ;; the property.
+        (if (eq (cadr image) property)
+            (setcdr image (cddr image))
+          (setq image (cddr image))))
+    ;; Just enter the new value.
+    (plist-put (cdr image) property value))
+  value)
+
+(defun image-property (image property)
+  "Return the value of PROPERTY in IMAGE.
+Properties can be set with
+
+  (setf (image-property IMAGE PROPERTY) VALUE)
+If VALUE is nil, PROPERTY is removed from IMAGE."
+  (declare (gv-setter image--set-property))
+  (plist-get (cdr image) property))
+
 (defun image-compute-scaling-factor (scaling)
   (cond
    ((numberp image-scaling-factor)