[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 0883e98 1/3: New functions for getting and setting
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 0883e98 1/3: New functions for getting and setting image properties |
Date: |
Sat, 20 Feb 2016 07:03:56 +0000 |
branch: master
commit 0883e988ac950b2da2893e64822041ca0e6133a0
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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.
---
doc/lispref/display.texi | 17 ++++++++++++++++-
etc/NEWS | 9 ++++++++-
lisp/image.el | 20 ++++++++++++++++++++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 17025cd..3758ddf 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
of 0.25 will make the image a quarter size of what it originally was.
If the scaling makes the image larger than specified by
@code{:max-width} or @code{:max-height}, the resulting size will not
-exceed those two values.
+exceed those two values. If both @code{:scale} and
address@hidden:height}/@code{:width} are specified, the height/width will be
+adjusted by the specified scaling factor.
@item :format @var{type}
The 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
as @code{nil}.
@end defmac
address@hidden image-set-property image property value
+Set the value of @var{property} in @var{image} to @var{value}. If
address@hidden is @code{nil}, the property is removed completely.
+
address@hidden
+(image-set-property image :height 300)
address@hidden lisp
address@hidden defun
+
address@hidden image-get-property image property
+Return the value of @var{property} in @var{image}.
address@hidden defun
+
@defun find-image specs
This function provides a convenient way to find an image satisfying one
of a list of image specifications @var{specs}.
diff --git a/etc/NEWS b/etc/NEWS
index c3c3eba..95ca8d3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -846,6 +846,7 @@ of `epg-gpg-program' (instead of gpg).
`image-scaling-factor' variable (if Emacs supports scaling the images
in question).
++++
*** Images inserted with `insert-image' and related functions get a
keymap put into the text properties (or overlays) that span the
image. This keymap binds keystrokes for manipulating size and
@@ -853,7 +854,13 @@ rotation, as well as saving the image to a file.
+++
*** A new library for creating and manipulating SVG images has been
-added. See the "SVG Images" section in the lispref manual for details.
+added. See the "SVG Images" section in the lispref manual for
+details.
+
++++
+*** New functions to access and set image parameters are provided:
+`image-get-property' and `image-set-property'.
+
** Lisp mode
diff --git a/lisp/image.el b/lisp/image.el
index 855dffa..3522c5b 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)