unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: 51712@debbugs.gnu.org
Subject: bug#51712: 29.0.50; [PATCH] New function `xwidget-webkit-load-html'
Date: Tue, 09 Nov 2021 15:21:59 +0200	[thread overview]
Message-ID: <83h7cl5urs.fsf@gnu.org> (raw)
In-Reply-To: <878rxx8w1i.fsf@yahoo.com> (bug-gnu-emacs@gnu.org)

> 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@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.





  reply	other threads:[~2021-11-09 13:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <878rxx8w1i.fsf.ref@yahoo.com>
2021-11-09 10:26 ` bug#51712: 29.0.50; [PATCH] New function `xwidget-webkit-load-html' Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-09 13:21   ` Eli Zaretskii [this message]
2021-11-09 13:42     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-09 14:07       ` Eli Zaretskii
2021-11-09 23:56         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10  0:02           ` Lars Ingebrigtsen
2021-11-10  0:14             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10  0:22               ` Lars Ingebrigtsen
2021-11-10  2:44                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10  5:59                   ` Lars Ingebrigtsen
2021-11-10  6:08                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10 12:50                       ` Eli Zaretskii
2021-11-10 13:03                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10 14:25                           ` Eli Zaretskii
2021-11-11  0:31                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-10  4:34   ` Richard Stallman
2021-11-10  4:37     ` Lars Ingebrigtsen
2021-11-11  3:37       ` Richard Stallman
2021-11-10  4:47     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-09 18:26   ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83h7cl5urs.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=51712@debbugs.gnu.org \
    --cc=luangruo@yahoo.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 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).