aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-20 17:54:05 +1100
committerLars Ingebrigtsen2016-02-20 18:03:37 +1100
commit0883e988ac950b2da2893e64822041ca0e6133a0 (patch)
treec456f1fa43bdafced9a92b0c19c38c381b145815
parent10c0e1ca40237224aa229c538fe49983ec905748 (diff)
downloademacs-0883e988ac950b2da2893e64822041ca0e6133a0.tar.gz
emacs-0883e988ac950b2da2893e64822041ca0e6133a0.zip
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.
-rw-r--r--doc/lispref/display.texi17
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/image.el20
3 files changed, 44 insertions, 2 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 17025cd1994..3758ddf72f5 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5205,7 +5205,9 @@ the size, and lower means to decrease the size. For instance, a value
5205of 0.25 will make the image a quarter size of what it originally was. 5205of 0.25 will make the image a quarter size of what it originally was.
5206If the scaling makes the image larger than specified by 5206If the scaling makes the image larger than specified by
5207@code{:max-width} or @code{:max-height}, the resulting size will not 5207@code{:max-width} or @code{:max-height}, the resulting size will not
5208exceed those two values. 5208exceed those two values. If both @code{:scale} and
5209@code{:height}/@code{:width} are specified, the height/width will be
5210adjusted by the specified scaling factor.
5209 5211
5210@item :format @var{type} 5212@item :format @var{type}
5211The value, @var{type}, should be a symbol specifying the type of the 5213The value, @var{type}, should be a symbol specifying the type of the
@@ -5442,6 +5444,19 @@ If none of the alternatives will work, then @var{symbol} is defined
5442as @code{nil}. 5444as @code{nil}.
5443@end defmac 5445@end defmac
5444 5446
5447@defun image-set-property image property value
5448Set the value of @var{property} in @var{image} to @var{value}. If
5449@var{value} is @code{nil}, the property is removed completely.
5450
5451@lisp
5452(image-set-property image :height 300)
5453@end lisp
5454@end defun
5455
5456@defun image-get-property image property
5457Return the value of @var{property} in @var{image}.
5458@end defun
5459
5445@defun find-image specs 5460@defun find-image specs
5446This function provides a convenient way to find an image satisfying one 5461This function provides a convenient way to find an image satisfying one
5447of a list of image specifications @var{specs}. 5462of a list of image specifications @var{specs}.
diff --git a/etc/NEWS b/etc/NEWS
index c3c3ebab94d..95ca8d35385 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -846,6 +846,7 @@ of `epg-gpg-program' (instead of gpg).
846`image-scaling-factor' variable (if Emacs supports scaling the images 846`image-scaling-factor' variable (if Emacs supports scaling the images
847in question). 847in question).
848 848
849+++
849*** Images inserted with `insert-image' and related functions get a 850*** Images inserted with `insert-image' and related functions get a
850keymap put into the text properties (or overlays) that span the 851keymap put into the text properties (or overlays) that span the
851image. This keymap binds keystrokes for manipulating size and 852image. This keymap binds keystrokes for manipulating size and
@@ -853,7 +854,13 @@ rotation, as well as saving the image to a file.
853 854
854+++ 855+++
855*** A new library for creating and manipulating SVG images has been 856*** A new library for creating and manipulating SVG images has been
856added. See the "SVG Images" section in the lispref manual for details. 857added. See the "SVG Images" section in the lispref manual for
858details.
859
860+++
861*** New functions to access and set image parameters are provided:
862`image-get-property' and `image-set-property'.
863
857 864
858** Lisp mode 865** Lisp mode
859 866
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
435 (image-compute-scaling-factor image-scaling-factor))) 435 (image-compute-scaling-factor image-scaling-factor)))
436 props))) 436 props)))
437 437
438(defun image-set-property (image property value)
439 "Set PROPERTY in IMAGE to VALUE.
440If VALUE is nil, PROPERTY is removed from IMAGE. IMAGE is
441returned."
442 (if (null value)
443 (while (cdr image)
444 ;; IMAGE starts with the symbol `image', and the rest is a
445 ;; plist. Decouple plist entries where the key matches
446 ;; the property.
447 (if (eq (cadr image) property)
448 (setcdr image (cddr image))
449 (setq image (cddr image))))
450 ;; Just enter the new value.
451 (plist-put (cdr image) property value))
452 image)
453
454(defun image-get-property (image property)
455 "Return the value of PROPERTY in IMAGE."
456 (plist-get (cdr image) property))
457
438(defun image-compute-scaling-factor (scaling) 458(defun image-compute-scaling-factor (scaling)
439 (cond 459 (cond
440 ((numberp image-scaling-factor) 460 ((numberp image-scaling-factor)