unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Preloading xwidget.el on xwidget builds?
       [not found] <87v8zpml5d.fsf.ref@yahoo.com>
@ 2021-12-16  0:46 ` Po Lu
  2021-12-16  4:33   ` Stefan Monnier
  2021-12-16  7:39   ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Po Lu @ 2021-12-16  0:46 UTC (permalink / raw)
  To: emacs-devel

xwidget.el defines various parts of the internal xwidget machinery, such
as the `xwidget-event' handler, and pieces of Lisp code that keep
xwidget display working correctly.

Using xwidget-related C functions without xwidget.el loaded can lead to
crashes and display problems, so I propose to preload that file on
xwidget builds.

Thanks.



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  0:46 ` Preloading xwidget.el on xwidget builds? Po Lu
@ 2021-12-16  4:33   ` Stefan Monnier
  2021-12-16  4:41     ` Po Lu
  2021-12-16  7:39   ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2021-12-16  4:33 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> xwidget.el defines various parts of the internal xwidget machinery, such
> as the `xwidget-event' handler, and pieces of Lisp code that keep
> xwidget display working correctly.
>
> Using xwidget-related C functions without xwidget.el loaded can lead to
> crashes and display problems, so I propose to preload that file on
> xwidget builds.

IME files that are preloaded in some config and not on others are
a source of trouble.  I'd rather we fix this some other way, e.g. by
autoloading those function.


        Stefan




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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:33   ` Stefan Monnier
@ 2021-12-16  4:41     ` Po Lu
  2021-12-16  4:50       ` Stefan Monnier
  2021-12-16  7:46       ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Po Lu @ 2021-12-16  4:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> xwidget.el defines various parts of the internal xwidget machinery, such
>> as the `xwidget-event' handler, and pieces of Lisp code that keep
>> xwidget display working correctly.
>>
>> Using xwidget-related C functions without xwidget.el loaded can lead to
>> crashes and display problems, so I propose to preload that file on
>> xwidget builds.
>
> IME files that are preloaded in some config and not on others are
> a source of trouble.  I'd rather we fix this some other way, e.g. by
> autoloading those function.

How would autoloading solve that problem though: `make-xwidget' and such
are defined in C code, but their display depends on xwidget.el to work
correctly.

Thanks.



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:41     ` Po Lu
@ 2021-12-16  4:50       ` Stefan Monnier
  2021-12-16  4:51         ` Stefan Monnier
  2021-12-16  7:46       ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2021-12-16  4:50 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

>>> xwidget.el defines various parts of the internal xwidget machinery, such
>>> as the `xwidget-event' handler, and pieces of Lisp code that keep
>>> xwidget display working correctly.
>>>
>>> Using xwidget-related C functions without xwidget.el loaded can lead to
>>> crashes and display problems, so I propose to preload that file on
>>> xwidget builds.
>>
>> IME files that are preloaded in some config and not on others are
>> a source of trouble.  I'd rather we fix this some other way, e.g. by
>> autoloading those function.
>
> How would autoloading solve that problem though: `make-xwidget' and such
> are defined in C code, but their display depends on xwidget.el to work
> correctly.

Depends on details I don't know, but presumably `make-xwidget` could
explicitly require/load `xwidget.el`.  Or the display could end up
loading `xwidget.el` when it calls a function defined there in (by
marking those functions as autoloaded).


        Stefan




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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:50       ` Stefan Monnier
@ 2021-12-16  4:51         ` Stefan Monnier
  2021-12-16  4:52           ` Po Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2021-12-16  4:51 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> Depends on details I don't know, but presumably `make-xwidget` could
> explicitly require/load `xwidget.el`.  Or the display could end up
> loading `xwidget.el` when it calls a function defined there in (by
> marking those functions as autoloaded).

Or we could move `make-xwidget` to `xwidget.el` and rename the
C function to something like `internal--make-widget`.


        Stefan




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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:51         ` Stefan Monnier
@ 2021-12-16  4:52           ` Po Lu
  2021-12-16  5:06             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu @ 2021-12-16  4:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Or we could move `make-xwidget` to `xwidget.el` and rename the
> C function to something like `internal--make-widget`.

Hmm, good idea.

How can I make autoloads conditional on a build configuration though?  A
very large amount of code uses (fboundp 'make-xwidget) to detect xwidget
support, and breaking that would be very inconvenient.

Thanks.



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:52           ` Po Lu
@ 2021-12-16  5:06             ` Lars Ingebrigtsen
  2021-12-16  5:10               ` Po Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-16  5:06 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Monnier, emacs-devel

Po Lu <luangruo@yahoo.com> writes:

>> Or we could move `make-xwidget` to `xwidget.el` and rename the
>> C function to something like `internal--make-widget`.
>
> Hmm, good idea.
>
> How can I make autoloads conditional on a build configuration though?  A
> very large amount of code uses (fboundp 'make-xwidget) to detect xwidget
> support, and breaking that would be very inconvenient.

We've been trying to move to a different architecture for detecting
whether Emacs has been built with, and currently has access to, external
libraries -- `*-available-p'.  It'd be nice if xwidget had that
function, too.

But as you point out, people test for `make-xwidget' today, so we can't
really move it to Lisp, I think.  So I think Stefan's first
suggestion -- make `make-xwidget' require widget.el -- is the way to go.

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



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  5:06             ` Lars Ingebrigtsen
@ 2021-12-16  5:10               ` Po Lu
  2021-12-16  5:46                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu @ 2021-12-16  5:10 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> We've been trying to move to a different architecture for detecting
> whether Emacs has been built with, and currently has access to, external
> libraries -- `*-available-p'.  It'd be nice if xwidget had that
> function, too.

The problem is `xwidget' isn't really a library, it's a feature that
makes use of many different external libraries.  Ideally, people would
test for the named feature `xwidget-internal', but the amount of people
who refrained from reading the first paragraph of the xwidget node in
the Lisp reference manual is astonishing.

> suggestion -- make `make-xwidget' require widget.el -- is the way to go.

Is calling require okay from C code?  If so, that's what I'll do.

Thanks.



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  5:10               ` Po Lu
@ 2021-12-16  5:46                 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-16  5:46 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Monnier, emacs-devel

Po Lu <luangruo@yahoo.com> writes:

>> We've been trying to move to a different architecture for detecting
>> whether Emacs has been built with, and currently has access to, external
>> libraries -- `*-available-p'.  It'd be nice if xwidget had that
>> function, too.
>
> The problem is `xwidget' isn't really a library, it's a feature that
> makes use of many different external libraries.

Sorry, I mean "optionally build features".

> Ideally, people would test for the named feature `xwidget-internal',
> but the amount of people who refrained from reading the first
> paragraph of the xwidget node in the Lisp reference manual is
> astonishing.

The first rule of programming is that nobody reads the manual.

(xwidget-available-p 'webkit) could say whether webkit was available,
etc.

>> suggestion -- make `make-xwidget' require widget.el -- is the way to go.
>
> Is calling require okay from C code?  If so, that's what I'll do.

It's unusual, but to work around unfortunate dependencies like this, it
should be OK.

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



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  0:46 ` Preloading xwidget.el on xwidget builds? Po Lu
  2021-12-16  4:33   ` Stefan Monnier
@ 2021-12-16  7:39   ` Eli Zaretskii
  2021-12-16  7:47     ` Po Lu
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2021-12-16  7:39 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Date: Thu, 16 Dec 2021 08:46:38 +0800
> 
> xwidget.el defines various parts of the internal xwidget machinery, such
> as the `xwidget-event' handler, and pieces of Lisp code that keep
> xwidget display working correctly.
> 
> Using xwidget-related C functions without xwidget.el loaded can lead to
> crashes and display problems, so I propose to preload that file on
> xwidget builds.

I don't think I understand the problem you are describing.  Can you
please describe the situations in which the xwidget-related C
functions would be invoked without xwidget.el being loaded?



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  4:41     ` Po Lu
  2021-12-16  4:50       ` Stefan Monnier
@ 2021-12-16  7:46       ` Eli Zaretskii
  2021-12-16  7:54         ` Po Lu
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2021-12-16  7:46 UTC (permalink / raw)
  To: Po Lu; +Cc: monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Thu, 16 Dec 2021 12:41:43 +0800
> 
> > IME files that are preloaded in some config and not on others are
> > a source of trouble.  I'd rather we fix this some other way, e.g. by
> > autoloading those function.
> 
> How would autoloading solve that problem though: `make-xwidget' and such
> are defined in C code, but their display depends on xwidget.el to work
> correctly.

Which code could call make-xwidget when xwidget.el is not loaded?



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  7:39   ` Eli Zaretskii
@ 2021-12-16  7:47     ` Po Lu
  0 siblings, 0 replies; 13+ messages in thread
From: Po Lu @ 2021-12-16  7:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> I don't think I understand the problem you are describing.  Can you
> please describe the situations in which the xwidget-related C
> functions would be invoked without xwidget.el being loaded?

(This has been fixed now: see the other replies to this thread.)

For instance, `make-xwidget' can be called to create xwidgets, and they
can be displayed on screen, all without xwidget.el being loaded.

A package that uses xwidgets to preview LaTeX does this, and that
package brought this problem to my attention.

Thanks.



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

* Re: Preloading xwidget.el on xwidget builds?
  2021-12-16  7:46       ` Eli Zaretskii
@ 2021-12-16  7:54         ` Po Lu
  0 siblings, 0 replies; 13+ messages in thread
From: Po Lu @ 2021-12-16  7:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Which code could call make-xwidget when xwidget.el is not loaded?

Any Lisp code was able to do that.



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

end of thread, other threads:[~2021-12-16  7:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87v8zpml5d.fsf.ref@yahoo.com>
2021-12-16  0:46 ` Preloading xwidget.el on xwidget builds? Po Lu
2021-12-16  4:33   ` Stefan Monnier
2021-12-16  4:41     ` Po Lu
2021-12-16  4:50       ` Stefan Monnier
2021-12-16  4:51         ` Stefan Monnier
2021-12-16  4:52           ` Po Lu
2021-12-16  5:06             ` Lars Ingebrigtsen
2021-12-16  5:10               ` Po Lu
2021-12-16  5:46                 ` Lars Ingebrigtsen
2021-12-16  7:46       ` Eli Zaretskii
2021-12-16  7:54         ` Po Lu
2021-12-16  7:39   ` Eli Zaretskii
2021-12-16  7:47     ` Po Lu

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