From: Jim Porter <jporterbugs@gmail.com>
To: Stefan Kangas <stefankangas@gmail.com>,
epg@pretzelnet.org, 71741@debbugs.gnu.org
Cc: Po Lu <luangruo@yahoo.com>
Subject: bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
Date: Sun, 23 Jun 2024 17:32:36 -0700 [thread overview]
Message-ID: <1c42d70b-e494-9495-4759-56a2acade7fe@gmail.com> (raw)
In-Reply-To: <CADwFkmmJ2iYiwzv_zuP50rMwDWV7416gFx1a+fE5dui6hhbWSw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]
On 6/23/2024 4:24 PM, Stefan Kangas wrote:
> epg@pretzelnet.org writes:
>
>> To reproduce:
>> - emacs -Q
>> - M-x eww RET gnu.org RET C-x C-+
>>
>> Expected:
>> Text is scaled up without error.
>>
>> Actual:
>> Text is scaled up, but with an error:
>>
>> run-hooks: Wrong type argument: number-or-marker-p, default
>
> I can reproduce this bug. Copying in Po Lu.
I was just looking at image scaling in an unrelated bug, so I had
already swapped in all the necessary mental context for this. Here's a
patch.
The second part fixes a closely-related issue: the scaling didn't work
for sliced images (you can get a sliced image by zooming it: put point
on the image and press "z").
Fixing that required fixing a bug in 'get-display-property': it only
returned the CAR of the display property value. To maintain backwards
compatibility, I changed it so that it still returns the CAR if there's
only one element, but it now returns the whole list if there are
multiple elements. I don't love this, and maybe we should always return
a list, but I'll leave that decision to others (for what it's worth,
'get-display-property' is new in Emacs 29, so there hopefully aren't too
many uses of it out in the wild yet).
I think the first patch is definitely worth merging to Emacs 30, but the
second I'm neutral on. Maybe we should fix 'get-display-property' now?
[-- Attachment #2: 0001-Fix-rescaling-of-images-via-text-scale-mode-in-EWW.patch --]
[-- Type: text/plain, Size: 1724 bytes --]
From a2f3d51f70efa1b65c9308e3445ada16d4211586 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 23 Jun 2024 16:59:00 -0700
Subject: [PATCH 1/2] Fix rescaling of images via 'text-scale-mode' in EWW
* lisp/net/eww.el (eww--rescale-images): Handle a :scale of 'default'
(bug#71741).
---
lisp/net/eww.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fd8f80065b1..94bfd333fa9 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1371,12 +1371,16 @@ eww--rescale-images
(goto-char (point-min))
(while-let ((match (text-property-search-forward
'display nil (lambda (_ value) (imagep value)))))
- (let ((image (prop-match-value match)))
- (unless (image-property image :original-scale)
- (setf (image-property image :original-scale)
- (or (image-property image :scale) 1)))
+ (let* ((image (prop-match-value match))
+ (original-scale (or (image-property image :original-scale)
+ (setf (image-property image :original-scale)
+ (or (image-property image :scale)
+ 'default)))))
+ (when (eq original-scale 'default)
+ (setq original-scale (image-compute-scaling-factor
+ image-scaling-factor)))
(setf (image-property image :scale)
- (* (image-property image :original-scale) scaling)))))))
+ (* original-scale scaling)))))))
(defun eww--url-at-point ()
"`thing-at-point' provider function."
--
2.25.1
[-- Attachment #3: 0002-Support-rescaling-sliced-images-in-EWW-via-text-scal.patch --]
[-- Type: text/plain, Size: 4308 bytes --]
From 55a7b2ea1220cdf7d0aa511e4f65b0d021162b44 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 23 Jun 2024 17:27:24 -0700
Subject: [PATCH 2/2] Support rescaling sliced images in EWW via
'text-scale-mode'
* 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.
---
doc/lispref/display.texi | 6 ++++--
lisp/net/eww.el | 9 +++++++--
src/xdisp.c | 24 ++++++++++++++++++------
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 34096196df4..67b64df75fd 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5182,8 +5182,10 @@ Display Property
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
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 94bfd333fa9..907b35f8565 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1370,8 +1370,13 @@ eww--rescale-images
(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)
diff --git a/src/xdisp.c b/src/xdisp.c
index 18ac5b69d7e..8c7e8e5cb43 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5549,6 +5549,7 @@ setup_for_ellipsis (struct it *it, int len)
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. */
@@ -5556,11 +5557,11 @@ find_display_property (Lisp_Object disp, Lisp_Object prop)
{
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;
}
@@ -5570,11 +5571,11 @@ find_display_property (Lisp_Object disp, Lisp_Object prop)
{
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. */
@@ -5589,9 +5590,20 @@ find_display_property (Lisp_Object disp, Lisp_Object prop)
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
--
2.25.1
next prev parent reply other threads:[~2024-06-24 0:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-23 23:13 bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww epg
2024-06-23 23:24 ` Stefan Kangas
2024-06-24 0:32 ` Jim Porter [this message]
2024-06-24 11:58 ` Eli Zaretskii
2024-06-24 12:38 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-24 21:04 ` Jim Porter
2024-06-24 21:56 ` Stefan Kangas
2024-06-25 4:39 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c42d70b-e494-9495-4759-56a2acade7fe@gmail.com \
--to=jporterbugs@gmail.com \
--cc=71741@debbugs.gnu.org \
--cc=epg@pretzelnet.org \
--cc=luangruo@yahoo.com \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.