unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
@ 2024-06-23 23:13 epg
  2024-06-23 23:24 ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: epg @ 2024-06-23 23:13 UTC (permalink / raw)
  To: 71741


jj
fb

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

Bug is present as late as commit
cace0cbee93f2a7f70a14a8445abcd176d3b3af2 but started here:

commit 56376585134d627f96c71b7b063ec51548d3ad3f
Author: Po Lu <luangruo@yahoo.com>
Date:   Mon Jun 3 03:34:51 2024

    Maintain relationship between tool bar image and default font width




In GNU Emacs 30.0.60 (build 1, x86_64-pc-linux-gnu, X toolkit,
 cairo version 1.18.0) of 2024-06-23 built on dogato
Repository revision: cace0cbee93f2a7f70a14a8445abcd176d3b3af2
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12101012
System Description: openSUSE Tumbleweed

Configured using:
 'configure -C --prefix=/opt/emacs-30.0.60.1.cace0cbee93
 --disable-silent-rules --with-x-toolkit=athena --without-sqlite3
 --without-lcms2 --without-libsystemd --without-imagemagick
 --with-json --with-tree-sitter --without-xft --without-libotf
 --without-toolkit-scroll-bars --without-xaw3d --without-gpm
 --without-dbus --without-gconf --without-gsettings
 --without-selinux --without-compress-install --with-x'

Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBXML2 MODULES
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  gnus-undo-mode: t
  server-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  line-number-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow emacsbug face-remap shr-color color url-http url-gw
url-auth eww xdg mm-url ffap shell pcomplete dired-aux etags
fileloop cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs mule-util cl-extra sort
gnus-cite mm-archive mail-extr textsec uni-scripts idna-mapping
ucs-normalize uni-confusable textsec-check gnus-async gnus-bcklg
qp gnus-ml disp-table misearch multi-isearch nndraft nnmh utf-7
network-stream nsm nnfolder nnnil gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig nntp gnus-cache gnus-sum gnus-group
gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail
mail-source utf7 nnoo parse-time iso8601 gnus-spec gnus-int
gnus-range gnus-win gnus nnheader range server elfeed-show
elfeed-search wid-edit bookmark message sendmail yank-media dired
dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader shr pixel-fill kinsoku puny svg
dom elfeed-csv elfeed elfeed-curl elfeed-log elfeed-db elfeed-lib
time-date avl-tree generator url-queue url-file browse-url
xml-query xml rust-utils rust-mode derived rust-rustfmt
rust-playpen rust-compile rust-cargo eglot external-completion
jsonrpc xref flymake thingatpt project compat diff ert pp ewoc
debug backtrace help-mode find-func filenotify warnings compile
text-property-search imenu ob-sql ob ob-tangle ol org-src
sh-script rx smie treesit executable ob-ref ob-lob ob-table
ob-exp ob-comint comint ansi-osc ansi-color ring ob-core
org-cycle org-fold org-fold-core ob-eval org-keys oc org-compat
org-macs format-spec pcase vc-git diff-mode track-changes
easy-mmode vc-dispatcher url-cache url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf mailcap url-util url-parse auth-source cl-seq eieio
eieio-core cl-macs icons cl-loaddefs cl-lib password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock
syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese
eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray
oclosure cl-preloaded button loaddefs theme-loaddefs faces
cus-face macroexp files window text-properties overlay sha1 md5
base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads inotify
dynamic-setting font-render-setting cairo x-toolkit xinput2 x
multi-tty move-toolbar make-network-process emacs)

Memory information:
((conses 16 833499 174307) (symbols 48 26264 22) (strings 32 171149 24275)
 (string-bytes 1 67514869) (vectors 16 69413) (vector-slots 8 883100 260093)
 (floats 8 379 11068) (intervals 56 23537 2101) (buffers 992 26))

-- 
Eric Gillespie  <*>  epg@pretzelnet.org





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2024-06-23 23:24 UTC (permalink / raw)
  To: epg, 71741; +Cc: Po Lu

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.

> Bug is present as late as commit
> cace0cbee93f2a7f70a14a8445abcd176d3b3af2 but started here:
>
> commit 56376585134d627f96c71b7b063ec51548d3ad3f
> Author: Po Lu <luangruo@yahoo.com>
> Date:   Mon Jun 3 03:34:51 2024
>
>     Maintain relationship between tool bar image and default font width





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  2024-06-23 23:24 ` Stefan Kangas
@ 2024-06-24  0:32   ` Jim Porter
  2024-06-24 11:58     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Jim Porter @ 2024-06-24  0:32 UTC (permalink / raw)
  To: Stefan Kangas, epg, 71741; +Cc: Po Lu

[-- 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  2024-06-24  0:32   ` Jim Porter
@ 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
  0 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-06-24 11:58 UTC (permalink / raw)
  To: Jim Porter; +Cc: luangruo, 71741, stefankangas, epg

> Cc: Po Lu <luangruo@yahoo.com>
> Date: Sun, 23 Jun 2024 17:32:36 -0700
> From: Jim Porter <jporterbugs@gmail.com>
> 
> > 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?

I think changes in get-display-property and in find_display_property
must wait for Emacs 31.  They are used in too many places to be a safe
change for the release branch.

The first patch is okay for the release branch, assuming Po Lu agrees
with it.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-24 12:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jim Porter, stefankangas, 71741, epg

Eli Zaretskii <eliz@gnu.org> writes:

> The first patch is okay for the release branch, assuming Po Lu agrees
> with it.

It's fine by me, but then I'm not specifically concerned with image
scaling in shr.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Jim Porter @ 2024-06-24 21:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, 71741, stefankangas, epg

On 6/24/2024 4:58 AM, Eli Zaretskii wrote:
> I think changes in get-display-property and in find_display_property
> must wait for Emacs 31.  They are used in too many places to be a safe
> change for the release branch.

Sounds good to me. Is the following a good way to merge these?

* Install the first patch to the emacs-30 branch
* Install both patches to the master branch
* Push to Savannah

I just want to be sure I don't mess up the automerge. (If it would be 
safer for me to install the first patch to emacs-30, automerge to 
master, and then install the second patch, I can do that. I'd just have 
to re-learn how to use the automerge script, since it's been a while for 
me.)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  2024-06-24 21:04       ` Jim Porter
@ 2024-06-24 21:56         ` Stefan Kangas
  2024-06-25  4:39           ` Jim Porter
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2024-06-24 21:56 UTC (permalink / raw)
  To: Jim Porter, Eli Zaretskii; +Cc: luangruo, 71741, epg

Jim Porter <jporterbugs@gmail.com> writes:

> Is the following a good way to merge these?
>
> * Install the first patch to the emacs-30 branch
> * Install both patches to the master branch
> * Push to Savannah
>
> I just want to be sure I don't mess up the automerge.

Push both patches to master and then `git cherry-pick -x <SHA>` the
first one on emacs-30 and push that there.

There should be no issue with the merge that way (though it happens
every so often anyways because of us moving the etc/NEWS file around
between branches).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#71741: 30.0.60; Wrong type argument: number-or-marker-p after C-x C-+ in eww
  2024-06-24 21:56         ` Stefan Kangas
@ 2024-06-25  4:39           ` Jim Porter
  0 siblings, 0 replies; 8+ messages in thread
From: Jim Porter @ 2024-06-25  4:39 UTC (permalink / raw)
  To: Stefan Kangas, Eli Zaretskii; +Cc: luangruo, 71741-done, epg

On 6/24/2024 2:56 PM, Stefan Kangas wrote:
> Jim Porter <jporterbugs@gmail.com> writes:
> 
>> Is the following a good way to merge these?
>>
>> * Install the first patch to the emacs-30 branch
>> * Install both patches to the master branch
>> * Push to Savannah
>>
>> I just want to be sure I don't mess up the automerge.
> 
> Push both patches to master and then `git cherry-pick -x <SHA>` the
> first one on emacs-30 and push that there.

Thanks. Pushed both patches as 6837828219b to master and just the first 
as a4ca30ac2e0 to the release branch. Closing this bug now.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-06-25  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).