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

Show method table for foo( + tab at repl #4361

Merged
merged 9 commits into from
Oct 5, 2013

Conversation

simonster
Copy link
Member

julia> print(\t
print(io::IO,b::BigFloat) at mpfr.jl:709                      print(io::IO,s::UTF8String) at utf8.jl:138
print(io::IOBuffer,s::SubString{T<:String}) at string.jl:617  print(io::IO,v::VersionNumber) at version.jl:42
print(io::IO,c::Char) at char.jl:56                           print(io::IO,X::AbstractArray{T,N}) at show.jl:895
print(io::IO,ip::IPv4) at socket.jl:30                        print(io::IO,x) at string.jl:3
print(io::IO,ip::IPv6) at socket.jl:85                        print(io::IO,x::Float16) at grisu.jl:119
print(io::IO,n::Unsigned) at show.jl:92                       print(io::IO,x::Float32) at grisu.jl:118
print(io::IO,s::ASCIIString) at ascii.jl:88                   print(io::IO,xs...) at string.jl:4
print(io::IO,s::RopeString) at string.jl:765                  print{mime}(io::IO,::MIME{mime}) at multimedia.jl:17
print(io::IO,s::String) at string.jl:66                       print(xs...) at string.jl:7
print(io::IO,s::Symbol) at show.jl:4

This supersedes #4357.

@simonster
Copy link
Member Author

I just noticed a small issue here: foo(Arra\t replaces the whole string with Array, instead of only the part after the parenthesis. I will fix this.

@stevengj
Copy link
Member

Sounds good, once the kinks are worked out!

I should call show_method_table in IJulia too, instead of just sprint(show, methods(o)).

@JeffBezanson
Copy link
Member

Really cool!

@StefanKarpinski
Copy link
Member

Yes, definitely a nice feature. It would be great to factor out a lot of the common functionality in the REPL and IJulia – and of course replace readline with @loladiro's REPL.jl.

@simonster
Copy link
Member Author

This should work now. I also made it so the readline's built-in filename completion doesn't get called for things like [ that can't be completed, which I'm assuming wasn't intentional.

It sure would be nice if all of this C completion code could be replaced with REPLCompletions.jl, although readline doesn't seem to support specifying what subset of a string should be replaced except via word break characters, which isn't ideal. If REPL.jl is close on the horizon, maybe this is enough for now.

@ivarne
Copy link
Member

ivarne commented Sep 25, 2013

Nice improvement. I tested it on OSX and it works fine.

@StefanKarpinski
Copy link
Member

This does weird stuff for me when I hit tab multiple times.

@simonster
Copy link
Member Author

Can you post what you're typing and what you're seeing? I'm not getting any weirdness.

@StefanKarpinski
Copy link
Member

rand(\t then it lists a bunch of stuff and it prints part of the methods list and leaves the cursor at the end. If I just keep hitting \t it leaves me at different random points, and sometimes at the next prompt with no text, sometimes with rand( at the beginning like I would expect. Here are some sequential screen shots where all I've done in between is press \t:

screen shot 2013-09-25 at 11 19 47 am

screen shot 2013-09-25 at 11 19 55 am

@StefanKarpinski
Copy link
Member

screen shot 2013-09-25 at 11 19 16 am

Since we don't need to actually replace any text, it's easier to call
rl_display_match_list directly than to go through readline completion
@simonster
Copy link
Member Author

@StefanKarpinski Hmm, I can get this to happen, but only on OS X. I can also get it to happen on master with long completion lists (e.g. i\t). I can't get it to happen when I ssh into loopback. I'm not sure what's going on.

@StefanKarpinski
Copy link
Member

Honestly, I'm pretty ok with merging and then figuring it out because this is so useful even a little bit broken.

@JeffBezanson
Copy link
Member

I bet that's related to #3652. The way we use readline leaves it unable to handle large completions correctly.

@StefanKarpinski
Copy link
Member

I would be inclined to say that we should just merge this and wait for a re-implemented repl.

@ivarne
Copy link
Member

ivarne commented Sep 26, 2013

The implementation does not show methods of operators (like *, /, + and -). There is also an issue with the Unicode operators that are included, and those that are planned. Is there any possibility to access a list of possible operators programmatically, or is that buried inside the flisp parser?

buf = IOBuffer()
show_method_table(buf, methods(fn), -1, false)
println(buf)
takebuf_string(buf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you both print buf, and return it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buf is an IO, so that adds a newline to the end of buf without printing anything to stdout.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ivarne
Copy link
Member

ivarne commented Sep 26, 2013

I have made a PR at simonster#1 to fix the operator issue.

@stevengj
Copy link
Member

Note that tab-tooltip doesn't work for operators in IJulia, apparently because IPython doesn't recognize +( as a function call. cc: @Carreau

@Carreau
Copy link

Carreau commented Sep 26, 2013

Ah, yes probably. But this is one of the things we need to address in a more deeper way.

Right now, the tooltip is populated with the response to object_info_request which as a parameter take a object to lookup information about. Hence all the processing happend in the frontend, and is brittle as it is based on regexp to both :

  • select wether it should complete or prompt tooltip.
  • extract the token on the line to request info about it.

I can add +-±... to the list of char than can be part of tokens, but then you might get issues like bar+foo(<tab> that will try to get info on bar+foo instead of foo if there is no space around the +.

We'll probably move toward object_info_request sending the all line (the all cell ?) to the kernel where each language can inspect and decide what to do.

Especially I suppose that you guys, might want tooltip on function(arg, <tab> that lookup the docs only for the signature that match the type of arg for example.

@stevengj
Copy link
Member

Yes, sending the whole cell to the front-end, along with the cursor position, would be the most flexible thing. Until that happens, I wouldn't suggest that IPython worry about tooltips for + etc.

JeffBezanson added a commit that referenced this pull request Oct 5, 2013
Show method table for foo( + tab at repl
@JeffBezanson JeffBezanson merged commit 4666764 into JuliaLang:master Oct 5, 2013
@wlbksy
Copy link
Contributor

wlbksy commented Oct 6, 2013

@JeffBezanson I have problem when compiling julia after this commit, I'm using Mingw64 on Win7

image
image

@JeffBezanson
Copy link
Member

Ok I pushed a possible fix. Could you try again?

@wlbksy
Copy link
Contributor

wlbksy commented Oct 6, 2013

Thanks for the quick response. It's fixed now.

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.

7 participants