]> code.delx.au - gnu-emacs/commitdiff
Rework the image property getter/setters
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2016 01:50:40 +0000 (12:50 +1100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2016 01:50:40 +0000 (12:50 +1100)
* doc/lispref/display.texi (Defining Images): Document the
renamed `image-get/set-property' functions.

* lisp/image.el (image--set-property): Rename from
image-set-property.
(image-property): Declare a setf form.
(image-property): Rename from `image-get-property'.

doc/lispref/display.texi
etc/NEWS
lisp/image.el
lisp/net/shr.el

index 3758ddf72f5b7928d9f2ba90f1b3075533e9ee1b..c49cca2f9f9f4cd76e6ad3e63aaca352a9e83058 100644 (file)
@@ -5444,19 +5444,17 @@ If none of the alternatives will work, then @var{symbol} is defined
 as @code{nil}.
 @end defmac
 
-@defun image-set-property image property value
-Set the value of @var{property} in @var{image} to @var{value}.  If
-@var{value} is @code{nil}, the property is removed completely.
+@defun image-property image property
+Return the value of @var{property} in @var{image}.  Properties can be
+set by using @code{setf}.  Setting a property to @code{nil} will
+remove the property from the image.
+@end defun
 
 @lisp
 (image-set-property image :height 300)
 @end lisp
 @end defun
 
-@defun image-get-property image property
-Return the value of @var{property} in @var{image}.
-@end 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}.
index 9a3799a62a09f13c48e517d271e61af48972fefd..4532a18b44472cc799b92d85b5b6b9d453013bf5 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -865,8 +865,8 @@ 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'.
+*** New setf-able function to access and set image parameters is
+provided: `image-property'.
 
 
 ** Lisp mode
index 3522c5bc75c6a1d628bb601fd61dd4990ef23a50..96afa98bb3e091dc3d7f4013e7bee8847a3a78f7 100644 (file)
@@ -435,10 +435,9 @@ 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)
+(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."
+Internal use only."
   (if (null value)
       (while (cdr image)
         ;; IMAGE starts with the symbol `image', and the rest is a
@@ -451,8 +450,13 @@ returned."
     (plist-put (cdr image) property value))
   image)
 
-(defun image-get-property (image property)
-  "Return the value of PROPERTY in IMAGE."
+(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)
index 6352d3841841fa96c094344029fc7355b338a16a..4c3dfc4fdebe3f9f4418bc3643889261027a85cc 100644 (file)
@@ -1536,7 +1536,7 @@ The preference is a float determined from `shr-prefer-media-type'."
                             (- (nth 2 edges) (nth 0 edges))))))
          (max-height (and edges
                           (truncate (* shr-max-image-proportion
-                               (- (nth 3 edges) (nth 1 edges))))))
+                                       (- (nth 3 edges) (nth 1 edges))))))
          svg image)
     (when (and max-width
                (> width max-width))
@@ -1551,7 +1551,8 @@ The preference is a float determined from `shr-prefer-media-type'."
     (svg-rectangle svg 0 0 width height :gradient "background"
                    :stroke-width 2 :stroke-color "black")
     (let ((image (svg-image svg)))
-      (image-set-property image :ascent 100))))
+      (setf (image-property image :ascent) 100)
+      image)))
 
 (defun shr-tag-pre (dom)
   (let ((shr-folding-mode 'none)