-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
?(x, y)TAB completes methods accepting x, y #38791
Conversation
Any chance we formally make an API for the matched methods? Ask this because it allows other REPL tools to work smarter based on the results. For example, thefix.jl |
does it work with keyword arguments? EDIT: that following underscore usage doesn't make sense |
I'm not sure how TheFix works internally, but the matches come back as a list of julia/stdlib/REPL/src/REPLCompletions.jl Lines 39 to 44 in a1106b8
Does that address the concern? |
Great, so basically we can call julia> methodswith(String, InteractiveUtils; supertypes=true)
[1] edit(path::AbstractString) in InteractiveUtils at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/InteractiveUtils/src/editless.jl:193
[2] edit(path::AbstractString, line::Integer) in InteractiveUtils at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/InteractiveUtils/src/editless.jl:193
[3] less(file::AbstractString) in InteractiveUtils at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/InteractiveUtils/src/editless.jl:255
[4] less(file::AbstractString, line::Integer) in InteractiveUtils at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/InteractiveUtils/src/editless.jl:242 |
Along those lines, see #33883. There didn't seem to be much interest, and after I developed MethodAnalysis I decided I was probably subverting the real purpose of |
Codecov Report
@@ Coverage Diff @@
## master #38791 +/- ##
==========================================
+ Coverage 81.55% 87.55% +6.00%
==========================================
Files 350 388 +38
Lines 73999 74498 +499
==========================================
+ Hits 60351 65228 +4877
+ Misses 13648 9270 -4378
Continue to review full report at Codecov.
|
I may be speaking out of turn here, but does this PR also hook into the pretty-printing stack-traces mechanism? Having a uniform display style for Tab completions, |
bump? I think this is nearly complete! |
Can we get this into 1.7? |
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
41dfcd5
to
594c9f8
Compare
This should be working again. I've incorporated the feedback above. We might want to play with this a bit before merging; in 2-argument methods, I keep wanting a way to say that neither argument should be typed as |
How about introducing post- or pre-parenthesis modifiers/flags? we could even think about having both and making pre-fix for explicit inclusion and post-fix for explicit exclusion and omitting for some default. (or vice versa) but given that it wouldn't be generic enough, we could either create new struct types which can encode these properties/flags or we could establish another syntax. Like for example a string macro since these support flags by default? Kinda like the new struct types: string macro: |
I've been using this for a while now and it seems reasonable even if not as flexible as one might ideally want. While I see the good things about @rapus95's suggestions, I think it would add a lot of visual noise and complexity. If we really want to have fine-grained control, I think the right approach would be to introduce a TerminalMenus.MultiSelectMenu to control this interactively. But perhaps we should first merge this and see what people think of the simple version. We have the whole 1.8 cycle to change our mind. |
Sorry if this has been mentioned before (I didn't read everything), but can we / do we want to support partial autocompletion, i.e. |
Certainly feasible, but don't we essentially have that already? julia> apropos("isapp")
Base.@static
Base.isapprox
Base.:≉
Base.SimdLoop.@simd
Base.Sys.isbsd
Base.Sys.isapple This is more about searching-by-types than searching-by-name. I guess one could combine them, but I'm not sure if that really would add enough value to compensate. |
I don't see this in 1.7rc2 |
Yes. |
How's the UX? |
From the
|
@timholy thanks! |
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com>
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com> (cherry picked from commit a987f56)
A number of calls to change the language have been justified in part by arguments for better tab completion. It seems time to separate these issues by improving discoverability in a way that integrates with multiple dispatch. With this PR,
?(x, y)TAB
completes methods that can be called with(x, y)
, and?(x, yTAB
(without the closing)
) completes methods called with(x, y, ...)
. There is also limited module-scoping available (only one layer deep).An alternative to
?
would be to have the cursor positioned where the function name should be supplied.I'm happy to discuss changes to this, but depending on whether a couple of other deadlines evaporate I might not have time to make any substantive changes here for a while...so let me say at the outset that I'd be just fine with someone taking this over if desired. Or, it can sit until I get time.
Demos:
Closes #30052
xref #38704
xref #37993