summaryrefslogtreecommitdiff
path: root/lisp/image.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2016-02-20 17:54:05 +1100
committerLars Ingebrigtsen <larsi@gnus.org>2016-02-20 18:03:37 +1100
commit0883e988ac950b2da2893e64822041ca0e6133a0 (patch)
treec456f1fa43bdafced9a92b0c19c38c381b145815 /lisp/image.el
parent10c0e1ca40237224aa229c538fe49983ec905748 (diff)
New functions for getting and setting image properties
* doc/lispref/display.texi (Defining Images): Document image-get/set-property. * lisp/image.el (image-set-property): New function. (image-get-property): Ditto.
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 855dffad293..3522c5bc75c 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -435,6 +435,26 @@ 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.
+If VALUE is nil, PROPERTY is removed from IMAGE. IMAGE is
+returned."
+ (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))
+ image)
+
+(defun image-get-property (image property)
+ "Return the value of PROPERTY in IMAGE."
+ (plist-get (cdr image) property))
+
(defun image-compute-scaling-factor (scaling)
(cond
((numberp image-scaling-factor)