* src/xdisp.c (find_display_property): When the property value has
multiple elements, return the whole list.
* lisp/net/eww.el (eww--rescale-images): Use 'get-display-property'.
* doc/lispref/display.texi (Display Property): Describe the new
'get-display-property' behavior (bug#71741).
(cherry picked from commit
6837828219b965148219f6d8eba4c740aaddacbb)
This convenience function can be used to get a specific display
property, no matter whether the @code{display} property is a vector, a
list or a simple property. This is like @code{get-text-property}
-(@pxref{Examining Properties}), but works on the @code{display}
-property only.
+(@pxref{Examining Properties}), but works on the @code{display} property
+only. For properties with a single value (e.g.@: @code{height}, this
+returns the value itself; for properties with a list of values (e.g.@:
+@code{slice}), this returns the list of values.
@var{position} is the position in the buffer or string to examine, and
@var{prop} is the @code{display} property to return. The optional
(save-excursion
(goto-char (point-min))
(while-let ((match (text-property-search-forward
- 'display nil (lambda (_ value) (imagep value)))))
- (let* ((image (prop-match-value match))
+ 'display nil
+ (lambda (_ value)
+ (and value (get-display-property
+ nil 'image nil value))))))
+ (let* ((image (cons 'image
+ (get-display-property nil 'image nil
+ (prop-match-value match))))
(original-scale (or (image-property image :original-scale)
(setf (image-property image :original-scale)
(or (image-property image :scale)
static Lisp_Object
find_display_property (Lisp_Object disp, Lisp_Object prop)
{
+ Lisp_Object elem;
if (NILP (disp))
return Qnil;
/* We have a vector of display specs. */
{
for (ptrdiff_t i = 0; i < ASIZE (disp); i++)
{
- Lisp_Object elem = AREF (disp, i);
+ elem = AREF (disp, i);
if (CONSP (elem)
&& CONSP (XCDR (elem))
&& EQ (XCAR (elem), prop))
- return XCAR (XCDR (elem));
+ goto found;
}
return Qnil;
}
{
while (!NILP (disp))
{
- Lisp_Object elem = XCAR (disp);
+ elem = XCAR (disp);
if (CONSP (elem)
&& CONSP (XCDR (elem))
&& EQ (XCAR (elem), prop))
- return XCAR (XCDR (elem));
+ goto found;
/* Check that we have a proper list before going to the next
element. */
else if (CONSP (disp)
&& CONSP (XCDR (disp))
&& EQ (XCAR (disp), prop))
- return XCAR (XCDR (disp));
+ {
+ elem = disp;
+ goto found;
+ }
+
+ return Qnil;
+
+ found:
+ /* If the property value is a list of one element, just return the
+ CAR. */
+ if (NILP (XCDR (XCDR (elem))))
+ return XCAR (XCDR (elem));
else
- return Qnil;
+ return XCDR (elem);
}
static Lisp_Object