Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow watchers for the active project #42731

Merged
merged 1 commit into from
Dec 4, 2021
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Oct 21, 2021

This allows packages (with Revise as the intended target) to register
themselves to be notified when the active project changes.
This will allow Revise to keep track of the appropriate source for
non-default environments.

For practical effect, Pkg (and perhaps packages like Pluto) will have
to switch from setting Base.ACTIVE_PROJECT[] directly to calling
Base.set_active_project.

base/initdefs.jl Outdated Show resolved Hide resolved
base/initdefs.jl Outdated Show resolved Hide resolved
base/initdefs.jl Outdated Show resolved Hide resolved
@timholy
Copy link
Member Author

timholy commented Nov 4, 2021

I'll merge soon, barring further concerns.

base/initdefs.jl Outdated Show resolved Hide resolved
base/initdefs.jl Show resolved Hide resolved
@DilumAluthge
Copy link
Member

For practical effect, Pkg (and perhaps packages like Pluto) will have
to switch from setting Base.ACTIVE_PROJECT[] directly to calling
Base.set_active_project.

@timholy After this PR is merged, could you make a PR to Pkg.jl with the necessary changes?

@timholy
Copy link
Member Author

timholy commented Nov 5, 2021

Done. The test will be noisy until #41625 is fixed.

@timholy timholy force-pushed the teh/active_project_watchers branch from 68cf319 to 4c9625d Compare November 5, 2021 12:09
@timholy
Copy link
Member Author

timholy commented Nov 8, 2021

I don't think those are due to this PR, but it's a lot of failures so let's just see if things have improved.

@timholy timholy closed this Nov 8, 2021
@timholy timholy reopened this Nov 8, 2021
@DilumAluthge
Copy link
Member

@timholy Can you rebase on the latest master?

@timholy timholy force-pushed the teh/active_project_watchers branch from 4c9625d to 669ad59 Compare November 8, 2021 13:44
This allows packages (with Revise as the intended target) to register
themselves to be notified when the active project changes.
This will allow Revise to keep track of the appropriate source for
non-default environments.

For practical effect, Pkg (and perhaps packages like Pluto) will have
to switch from setting `Base.ACTIVE_PROJECT[]` directly to calling
`Base.set_active_project`.

Co-authored by: Jameson Nash <jameson@juliacomputing.com>
@timholy timholy force-pushed the teh/active_project_watchers branch from 669ad59 to fe2991f Compare December 3, 2021 13:57
@timholy timholy merged commit 83d7eba into master Dec 4, 2021
@timholy timholy deleted the teh/active_project_watchers branch December 4, 2021 08:51
@DilumAluthge
Copy link
Member

@timholy If I understand correctly, currently to use this feature, you provide a callback function f() that takes no arguments, right?

Would it instead make sense for the user to pass a callback function f(x)? And then when we call the callback function, we pass the new active project as the positional argument?

So then, users don't need to make an extra call to Base.active_project() inside their callback function?

@timholy
Copy link
Member Author

timholy commented Dec 5, 2021

With the possibility of @async callback processing, I thought it might be better to have the user call it directly when ready to handle the change (since of course it could update again between the time of making the callback and when the @async task runs). But this is probably biased by Revise's use case.

LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
This allows packages (with Revise as the intended target) to register
themselves to be notified when the active project changes.
This will allow Revise to keep track of the appropriate source for
non-default environments.

For practical effect, Pkg (and perhaps packages like Pluto) will have
to switch from setting `Base.ACTIVE_PROJECT[]` directly to calling
`Base.set_active_project`.

Co-authored by: Jameson Nash <jameson@juliacomputing.com>
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
This allows packages (with Revise as the intended target) to register
themselves to be notified when the active project changes.
This will allow Revise to keep track of the appropriate source for
non-default environments.

For practical effect, Pkg (and perhaps packages like Pluto) will have
to switch from setting `Base.ACTIVE_PROJECT[]` directly to calling
`Base.set_active_project`.

Co-authored by: Jameson Nash <jameson@juliacomputing.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants