diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2016-02-22 12:50:40 +1100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2016-02-22 12:50:40 +1100 |
commit | 3007b422b69f7b1660379b5d8e6713e8b823c098 (patch) | |
tree | 9fd0b9de78a223eaa35af6c52643b546459e2f61 /lisp | |
parent | 1f7feecaee0ed3fb79758fe60020aefb30d9ff01 (diff) | |
download | emacs-3007b422b69f7b1660379b5d8e6713e8b823c098.tar.gz emacs-3007b422b69f7b1660379b5d8e6713e8b823c098.tar.bz2 emacs-3007b422b69f7b1660379b5d8e6713e8b823c098.zip |
Rework the image property getter/setters
* 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'.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/image.el | 14 | ||||
-rw-r--r-- | lisp/net/shr.el | 5 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lisp/image.el b/lisp/image.el index 3522c5bc75c..96afa98bb3e 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -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) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 6352d384184..4c3dfc4fdeb 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -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) |