GNU bug report logs - #51712
29.0.50; [PATCH] New function `xwidget-webkit-load-html'

Previous Next

Package: emacs;

Reported by: Po Lu <luangruo <at> yahoo.com>

Date: Tue, 9 Nov 2021 10:27:02 UTC

Severity: wishlist

Tags: patch

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51712 in the body.
You can then email your comments to 51712 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Tue, 09 Nov 2021 10:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Po Lu <luangruo <at> yahoo.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 09 Nov 2021 10:27:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; [PATCH] New function `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 18:26:17 +0800
[Message part 1 (text/plain, inline)]
Hopefully this allows to reduce the amount of JavaScript hacks needed to
load HTML into a widget.  It also lets you customize the base URI WebKit
uses to find web resources, which you can't do from JavaScript.

Thanks.

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Tue, 09 Nov 2021 13:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50;
 [PATCH] New function `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 15:21:59 +0200
> Date: Tue, 09 Nov 2021 18:26:17 +0800
> From:  Po Lu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> +@defun xwidget-webkit-load-html xwidget text base-uri
> +Load @var{text} into @var{xwidget}, which should be a WebKit xwidget.
> +@var{text} will be treated as HTML markup, and rendered by
> +@var{xwidget}.

can you rephrase the last sentence not to use passive tense, please?

> +For the purpose of controlling the location where web resources will
> +be found, you can optionally specify a base URI as a string in
> +@var{base-uri}, which defaults to @samp{about:blank}.

But BASE-URI is not an &optional argument above.

And also, this sentence is unnecessarily complex because you state the
reason before the goal.  It is much better to do it the other way
around, and while at that, make 2 simple sentences out of one complex
one:

  Optional argument @var{base-uri}, which should be a string,
  specifies the location of the web resource.  It defaults to
  @samp{about:blank}.

(Of course, now this begs the question: what does it mean "web
resource" for HTML text?  How about answering that in the text?)

> ++++
> +*** New function 'xwidget-webkit-load-html'.
> +This function is used to load HTML text into WebKit xwidgets, without
> +having to create a temporary file or URL.

The second part is either unnecessary or too terse.  if it is
important to explain that, please elaborate how temporary files are
relevant here.

> +DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html,
> +       Sxwidget_webkit_load_html, 2, 3, 0,
> +       doc: /* Make XWIDGET's WebKit widget render text.
> +XWIDGET should be a WebKit xwidget, that will receive TEXT.  TEXT
> +should be a string that will be displayed by XWIDGET as plain text.

The "plain text" part seems to contradict the text in the manual,
which says it will be rendered as HTML markup?

> +BASE_URI will be a URI that is used to fetch resources, and if not
> +specified, is treated as equivalent to `about:blank'.  */)

"will be" is confusing: why the future tense?

Also, what kind of Lisp type is that?

And I think explaining the importance of "fetching resources" would be
beneficiary here.

And finally, "is treated as equivalent" is better reworded as "and
defaults to ...", which is our style in these cases.

> +  if (NILP (base_uri))
> +    base_uri = build_string ("about:blank");
> +  CHECK_STRING (base_uri);

That last line should better be under 'else', right?

> +  base_uri = ENCODE_UTF_8 (base_uri);

Is it a good idea to produce non-ASCII URIs?

> +  text = ENCODE_UTF_8 (text);
> +  xw = XXWIDGET (xwidget);
> +
> +#ifdef USE_GTK
> +  data = SSDATA (text);
> +  uri = SSDATA (base_uri);
> +  webview = WEBKIT_WEB_VIEW (xw->widget_osr);
> +
> +  block_input ();
> +  webkit_web_view_load_html (webview, data, uri);
> +  unblock_input ();
> +#endif

Hmm... if we only use TEXT and BASE-URI in the GTK build, why do we
encode them in the other builds?  Isn't that a waste of cycles?  IOW,
what does this function do if USE_GTK is not defined?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Tue, 09 Nov 2021 13:43:02 GMT) Full text and rfc822 format available.

Message #11 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 21:42:06 +0800
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>
> can you rephrase the last sentence not to use passive tense, please?
>
> But BASE-URI is not an &optional argument above.
>
> And also, this sentence is unnecessarily complex because you state the
> reason before the goal.  It is much better to do it the other way
> around, and while at that, make 2 simple sentences out of one complex
> one:
>
>   Optional argument @var{base-uri}, which should be a string,
>   specifies the location of the web resource.  It defaults to
>   @samp{about:blank}.
>
> (Of course, now this begs the question: what does it mean "web
> resource" for HTML text?  How about answering that in the text?)
>
> The second part is either unnecessary or too terse.  if it is
> important to explain that, please elaborate how temporary files are
> relevant here.
>
> The "plain text" part seems to contradict the text in the manual,
> which says it will be rendered as HTML markup?
>
> "will be" is confusing: why the future tense?
>
> Also, what kind of Lisp type is that?

It should be a string, thanks, I've resolved the concerns you listed
above.

> And I think explaining the importance of "fetching resources" would be
> beneficiary here.

I documented it in the manual the best I could.  I'm no web developer,
and the WebKitGTK documentation is vague on this subject, so I can't
think of anything better.

> And finally, "is treated as equivalent" is better reworded as "and
> defaults to ...", which is our style in these cases.

Thanks, done.

>> +  if (NILP (base_uri))
>> +    base_uri = build_string ("about:blank");
>> +  CHECK_STRING (base_uri);
>
> That last line should better be under 'else', right?

Done, thanks.

>> +  base_uri = ENCODE_UTF_8 (base_uri);

> Is it a good idea to produce non-ASCII URIs?

I personally think it's not, but the uuencoding of the URI is done by
WebKitGTK, which expects strings passed as the `uri' parameter to be
encoded as UTF-8 as opposed to uuencoded.

>> +  text = ENCODE_UTF_8 (text);
>> +  xw = XXWIDGET (xwidget);
>> +
>> +#ifdef USE_GTK
>> +  data = SSDATA (text);
>> +  uri = SSDATA (base_uri);
>> +  webview = WEBKIT_WEB_VIEW (xw->widget_osr);
>> +
>> +  block_input ();
>> +  webkit_web_view_load_html (webview, data, uri);
>> +  unblock_input ();
>> +#endif

> Hmm... if we only use TEXT and BASE-URI in the GTK build, why do we
> encode them in the other builds?  Isn't that a waste of cycles?  IOW,
> what does this function do if USE_GTK is not defined?

This feature isn't supported on macOS, but it's my hope that someone
will port it to macOS in short order.

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Tue, 09 Nov 2021 14:09:01 GMT) Full text and rfc822 format available.

Message #14 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 16:07:59 +0200
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: 51712 <at> debbugs.gnu.org
> Date: Tue, 09 Nov 2021 21:42:06 +0800
> 
> >> +  text = ENCODE_UTF_8 (text);
> >> +  xw = XXWIDGET (xwidget);
> >> +
> >> +#ifdef USE_GTK
> >> +  data = SSDATA (text);
> >> +  uri = SSDATA (base_uri);
> >> +  webview = WEBKIT_WEB_VIEW (xw->widget_osr);
> >> +
> >> +  block_input ();
> >> +  webkit_web_view_load_html (webview, data, uri);
> >> +  unblock_input ();
> >> +#endif
> 
> > Hmm... if we only use TEXT and BASE-URI in the GTK build, why do we
> > encode them in the other builds?  Isn't that a waste of cycles?  IOW,
> > what does this function do if USE_GTK is not defined?
> 
> This feature isn't supported on macOS, but it's my hope that someone
> will port it to macOS in short order.

Then I'd suggest not to have it defined on non-GTK builds for now.  It
is confusing to have a function that silently does nothing (after
wasting some cycles).

> +@defun xwidget-webkit-load-html xwidget text &optional base-uri
> +Load @var{text} into @var{xwidget}, which should be a WebKit xwidget.
> +It treats @var{text} as HTML markup, which will be rendered by
> +@var{xwidget}.

I'd say that TEXT should be a string.  The name itself doesn't
necessarily say so.

> +Optional argument @var{base-uri}, which should be a string, specifies
> +the location of web resources, such as the resource @samp{foo.png} in
> +the HTML tag @samp{<img src="foo.png">}.  It defaults to
> +@samp{about:blank}.

Hmm... this is better, but at least I am still in the dark regarding
the need for this optional argument.  E.g., what would happen if you
use that tag, but don't specify the URI?

> +*** New function 'xwidget-webkit-load-html'.
> +This function is used to load HTML text into WebKit xwidgets, without
> +having to create a temporary file to store the markup.

This still leaves me wondering why the entry talks about temporary
files.
> +DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html,
> +       Sxwidget_webkit_load_html, 2, 3, 0,
> +       doc: /* Make XWIDGET's WebKit widget render text.
                                                      ^^^^
"text" should be in CAPS.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Tue, 09 Nov 2021 23:57:01 GMT) Full text and rfc822 format available.

Message #17 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 07:56:02 +0800
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

> Then I'd suggest not to have it defined on non-GTK builds for now.  It
> is confusing to have a function that silently does nothing (after
> wasting some cycles).

Thanks, I'll keep that in mind.

> I'd say that TEXT should be a string.  The name itself doesn't
> necessarily say so.

Fixed, thanks.
>> +Optional argument @var{base-uri}, which should be a string, specifies
>> +the location of web resources, such as the resource @samp{foo.png} in
>> +the HTML tag @samp{<img src="foo.png">}.  It defaults to
>> +@samp{about:blank}.

> Hmm... this is better, but at least I am still in the dark regarding
> the need for this optional argument.  E.g., what would happen if you
> use that tag, but don't specify the URI?

I'm in the dark too.  I am not a web developer, and browser engines are
remarkably lax about these things, but hopefully Lars can explain better
(after all, shr must deal with these things too), so I added him to the
Ccs.

> This still leaves me wondering why the entry talks about temporary
> files.

Previously, loading custom markup into a widget required using a
temporary file to store the markup.

>> +DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html,
>> +       Sxwidget_webkit_load_html, 2, 3, 0,
>> +       doc: /* Make XWIDGET's WebKit widget render text.
>                                                       ^^^^
> "text" should be in CAPS.

Thanks.
[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 00:04:01 GMT) Full text and rfc822 format available.

Message #20 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 01:02:50 +0100
Po Lu <luangruo <at> yahoo.com> writes:

>> Hmm... this is better, but at least I am still in the dark regarding
>> the need for this optional argument.  E.g., what would happen if you
>> use that tag, but don't specify the URI?
>
> I'm in the dark too.  I am not a web developer, and browser engines are
> remarkably lax about these things, but hopefully Lars can explain better
> (after all, shr must deal with these things too), so I added him to the
> Ccs.

The base URI is used when expanding relative links.  So if you have HTML
that looks like

<a href="foo.html"><img src="img.png"></a>

then the browser can't resolve those two URLs without having the base
URI.  So you'd pass in a base URI of https://example.com/foo/bar/zot if
that's where the HTML snippet is from.

When the URLs are absolute, the base URI is irrelevant.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 00:15:02 GMT) Full text and rfc822 format available.

Message #23 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 08:14:13 +0800
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Po Lu <luangruo <at> yahoo.com> writes:
>
>>> Hmm... this is better, but at least I am still in the dark regarding
>>> the need for this optional argument.  E.g., what would happen if you
>>> use that tag, but don't specify the URI?
>>
>> I'm in the dark too.  I am not a web developer, and browser engines are
>> remarkably lax about these things, but hopefully Lars can explain better
>> (after all, shr must deal with these things too), so I added him to the
>> Ccs.
>
> The base URI is used when expanding relative links.  So if you have HTML
> that looks like
>
> <a href="foo.html"><img src="img.png"></a>
>
> then the browser can't resolve those two URLs without having the base
> URI.  So you'd pass in a base URI of https://example.com/foo/bar/zot if
> that's where the HTML snippet is from.
>
> When the URLs are absolute, the base URI is irrelevant.

Thanks, does this look OK to you?  And I'm afraid I'm not terribly good
at phrasing this into words, so I would really appreciate it if you
could help write that section of the manual.

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 00:23:02 GMT) Full text and rfc822 format available.

Message #26 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 01:22:48 +0100
Po Lu <luangruo <at> yahoo.com> writes:

> Thanks, does this look OK to you?  And I'm afraid I'm not terribly good
> at phrasing this into words, so I would really appreciate it if you
> could help write that section of the manual.

[...]

> +Optional argument @var{base-uri}, which should be a string, specifies
> +the location of web resources specified through relative links, such
> +as the resource @samp{foo.png} in the HTML tag @samp{<img
> +src="foo.png">}.  It defaults to @samp{about:blank}.

Looks good to me.

> +XWIDGET should be a WebKit xwidget, that will receive TEXT.  TEXT
> +should be a string that will be displayed by XWIDGET as HTML markup.
> +BASE_URI should be a string containing a URI that is used to fetch
> +resources, and if not specified, defaults to `about:blank'.  */)

Should probably be "relative resources (i.e., URLs that aren't
absolute)" or something of the kind.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 10 Nov 2021 02:11:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 02:46:01 GMT) Full text and rfc822 format available.

Message #31 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 10:44:52 +0800
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Po Lu <luangruo <at> yahoo.com> writes:
>
>> Thanks, does this look OK to you?  And I'm afraid I'm not terribly good
>> at phrasing this into words, so I would really appreciate it if you
>> could help write that section of the manual.
>
> [...]
>
>> +Optional argument @var{base-uri}, which should be a string, specifies
>> +the location of web resources specified through relative links, such
>> +as the resource @samp{foo.png} in the HTML tag @samp{<img
>> +src="foo.png">}.  It defaults to @samp{about:blank}.
>
> Looks good to me.
>
>> +XWIDGET should be a WebKit xwidget, that will receive TEXT.  TEXT
>> +should be a string that will be displayed by XWIDGET as HTML markup.
>> +BASE_URI should be a string containing a URI that is used to fetch
>> +resources, and if not specified, defaults to `about:blank'.  */)
>
> Should probably be "relative resources (i.e., URLs that aren't
> absolute)" or something of the kind.

Hmm, OK, how's this?

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Thanks.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 04:36:02 GMT) Full text and rfc822 format available.

Message #34 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50;
 [PATCH] New function `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 23:34:59 -0500
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Hopefully this allows to reduce the amount of JavaScript hacks needed to
  > load HTML into a widget.

Would you please explain the role of JavaScript code in use of xwidget?
In particular, will this JavaScript code be written specifically for
use with Emacs?  Or will it be found on the net?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 04:38:02 GMT) Full text and rfc822 format available.

Message #37 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Stallman <rms <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 05:37:39 +0100
Richard Stallman <rms <at> gnu.org> writes:

> Would you please explain the role of JavaScript code in use of xwidget?
> In particular, will this JavaScript code be written specifically for
> use with Emacs?  Or will it be found on the net?

It's JS written by me included in Emacs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 04:48:02 GMT) Full text and rfc822 format available.

Message #40 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Richard Stallman <rms <at> gnu.org>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 12:47:40 +0800
Richard Stallman <rms <at> gnu.org> writes:

> Would you please explain the role of JavaScript code in use of xwidget?
> In particular, will this JavaScript code be written specifically for
> use with Emacs?  Or will it be found on the net?

It will be JavaScript code written specifically for use with Emacs, used
to manipulate the DOM tree of the widget.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 06:00:02 GMT) Full text and rfc822 format available.

Message #43 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 06:59:10 +0100
Po Lu <luangruo <at> yahoo.com> writes:

> Hmm, OK, how's this?

Looks good to me.  One tiny thing:

> +BASE_URI should be a string containing a URI that is used to locate
> +resources described by relative URLs, and if not specified, defaults
> +to `about:blank'.  */)

That should be \"about:blank\" instead, since it's a string and not a
symbol.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 06:10:02 GMT) Full text and rfc822 format available.

Message #46 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 14:08:59 +0800
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> That should be \"about:blank\" instead, since it's a string and not a
> symbol.

Thanks, how's this?  Eli, does this look good to you?

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 12:51:02 GMT) Full text and rfc822 format available.

Message #49 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: larsi <at> gnus.org, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 14:50:28 +0200
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  51712 <at> debbugs.gnu.org
> Date: Wed, 10 Nov 2021 14:08:59 +0800
> 
> > That should be \"about:blank\" instead, since it's a string and not a
> > symbol.
> 
> Thanks, how's this?  Eli, does this look good to you?

Almost:

> +@defun xwidget-webkit-load-html xwidget text &optional base-uri
> +Load @var{text}, a string, into @var{xwidget}, which should be a
> +WebKit xwidget.  It treats @var{text} as HTML markup, which will be
> +rendered by @var{xwidget}.

Instead of the last sentence:

  Any HTML markup in @var{text} will be processed by @var{xwidget}
  while rendering the text.

> +Optional argument @var{base-uri}, which should be a string, specifies
> +the location of web resources specified through relative links, such
> +as the resource @samp{foo.png} in the HTML tag @samp{<img
> +src="foo.png">}.  It defaults to @samp{about:blank}.
> +@end defun

  Optional argument @var{base-uri}, which should be a string,
  specifies the absolute location of the web resources referenced by
  @var{text}, to be used for resolving relative links in @var{text}.

> +*** New function 'xwidget-webkit-load-html'.
> +This function is used to load HTML text into WebKit xwidgets, without
> +having to create a temporary file to store the markup.

Here' I'd like to say something like

  This is in contrast with loading HTML using ... which requires to
  create temporary files for storing the markup.

But I don't know what to write instead of "...".  What was the method
which existed earlier that you wanted to improve?

> +BASE_URI should be a string containing a URI that is used to locate
> +resources described by relative URLs, and if not specified, defaults
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"resources with relative URLs" sounds better to me.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 13:04:01 GMT) Full text and rfc822 format available.

Message #52 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 21:03:26 +0800
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks.

Thank you!  How does the attached patch look to you?

[0001-Add-xwidget-webkit-load-html.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Wed, 10 Nov 2021 14:26:02 GMT) Full text and rfc822 format available.

Message #55 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: larsi <at> gnus.org, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 16:25:22 +0200
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: larsi <at> gnus.org,  51712 <at> debbugs.gnu.org
> Date: Wed, 10 Nov 2021 21:03:26 +0800
> 
> Thank you!  How does the attached patch look to you?

LGTM, thanks.  But please fix this gotcha when you push:

> +@defun xwidget-webkit-load-html xwidget text &optional base-uri
> +Load @var{text}, a string, into @var{xwidget}, which should be a
> +WebKit xwidget.  Any HTML markup in @var{text} will be processed
> +by @var{xwidget} while rendering the text.
> +
> +Optional argument @var{base-uri}, which should be a string, specifies
> +the absolute location of the web resources referenced by @var{text},
> +to be used for resolving relative links in @var{text}.
> +

This lacks "@end defun" at the end.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Thu, 11 Nov 2021 00:32:01 GMT) Full text and rfc822 format available.

Message #58 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Thu, 11 Nov 2021 08:31:34 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Po Lu <luangruo <at> yahoo.com>
>> Cc: larsi <at> gnus.org,  51712 <at> debbugs.gnu.org
>> Date: Wed, 10 Nov 2021 21:03:26 +0800
>> 
>> Thank you!  How does the attached patch look to you?
>
> LGTM, thanks.  But please fix this gotcha when you push:
>
>> +@defun xwidget-webkit-load-html xwidget text &optional base-uri
>> +Load @var{text}, a string, into @var{xwidget}, which should be a
>> +WebKit xwidget.  Any HTML markup in @var{text} will be processed
>> +by @var{xwidget} while rendering the text.
>> +
>> +Optional argument @var{base-uri}, which should be a string, specifies
>> +the absolute location of the web resources referenced by @var{text},
>> +to be used for resolving relative links in @var{text}.
>> +
>
> This lacks "@end defun" at the end.

Thanks, fixed and pushed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Thu, 11 Nov 2021 03:39:02 GMT) Full text and rfc822 format available.

Message #61 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: luangruo <at> yahoo.com, 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50;
 [PATCH] New function `xwidget-webkit-load-html'
Date: Wed, 10 Nov 2021 22:37:59 -0500
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It's JS written by me included in Emacs.

Running free JS code included in Emacs is not, in itself, a bad thing.
JS is not inherently worse than any other language.

But it presupposes that there is a JS interpreter in Emacs, and
including that would be taking a big moral risk.  Users are likely to
use it to run nonfree JS sent by web sites.  We must should not make
Emacs into a platform for that.  It would corrupt the purpose of
Emacs.

Web browsers which can run Javascript from web sites should take steps
to block the Javascript programs which are nonfree.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51712; Package emacs. (Fri, 09 Sep 2022 18:28:02 GMT) Full text and rfc822 format available.

Message #64 received at 51712 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 51712 <at> debbugs.gnu.org
Subject: Re: bug#51712: 29.0.50; [PATCH] New function
 `xwidget-webkit-load-html'
Date: Fri, 09 Sep 2022 20:26:54 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> Hopefully this allows to reduce the amount of JavaScript hacks needed to
> load HTML into a widget.  It also lets you customize the base URI WebKit
> uses to find web resources, which you can't do from JavaScript.

[...]

> +@defun xwidget-webkit-load-html xwidget text base-uri

Looks like this was applied at the time, but the bug report was left
open, so I'm closing it now.




bug marked as fixed in version 29.1, send any further explanations to 51712 <at> debbugs.gnu.org and Po Lu <luangruo <at> yahoo.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 09 Sep 2022 18:28:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 08 Oct 2022 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.