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

Tab completion for using should look up installed packages #4477

Closed
jvns opened this issue Oct 10, 2013 · 11 comments
Closed

Tab completion for using should look up installed packages #4477

jvns opened this issue Oct 10, 2013 · 11 comments
Labels
REPL Julia's REPL (Read Eval Print Loop)

Comments

@jvns
Copy link

jvns commented Oct 10, 2013

I just installed the DataFrames package. Before importing it, I get less tab completion options than after. I'd be interested in fixing this. Is there any reason why the tab completion can't work, or is this fixable?

julia> using D
DataType           DL_LOAD_PATH       Dims               Diagonal           DomainError        DivideError        
DArray             DirectIndexString  DevNull            Dict               Display            DivideByZeroError  
julia> using DataFrames
julia> using D
DataType           DL_LOAD_PATH       DataFrame          Dims               Diagonal           Display            
DArray             DataFrames         DataMatrix         DevNull            Dict               DivideError        
DDataFrame         DataArray          DirectIndexString  DataVector         DomainError        DivideByZeroError 
@ivarne
Copy link
Member

ivarne commented Oct 10, 2013

I don't think there really is a tab completion for using as it does not show up before you have typed another letter. I get exactly the same suggestions if i type D\t anywhere in the REPL. The extra suggestions you get after using DataFrames are types that DataFrames export. Tab completions for using that look up installed packages would be useful, so you might make a separate feature request for that, but I doubt it will get prioritized before a planned refactoring of the REPL is finished.

Added link: #770

@jvns
Copy link
Author

jvns commented Oct 10, 2013

oh, I see -- it's tab completing any symbols that are exported, and those aren't actually things I can use with using. It seems like it would make more sense to either

  • not tab-complete after using at all
  • look up installed packages

Would writing this kind of code make sense at this point, or would it be better to wait until after the refactoring of the REPL to work on it?

@ivarne
Copy link
Member

ivarne commented Oct 10, 2013

I do not know the status of releasing 0.2, but if we manage to get this written and approved before it is released, I think it would be worthwhile. REPL.jl will definitely not be introduced before 0.3.

@jvns
Copy link
Author

jvns commented Oct 11, 2013

I spent some time looking for the code that handles the tab completion, but couldn't find it anything that looked promising in client.jl or repl.jl. Where would I find this?

@ivarne
Copy link
Member

ivarne commented Oct 11, 2013

I think that you must find an entry point in ui/repl-readline.c. Maybe @simonster would be able to tell what function you should modify?

@ivarne
Copy link
Member

ivarne commented Oct 11, 2013

tab_callback is probably the right function, but I must say I think the use of global variables makes it harder than necessary to find out what is going on.

@jvns
Copy link
Author

jvns commented Oct 11, 2013

definitely agree that it's confusing :) -- run_repl() looks like the main REPL loop, but it's totally not obvious how everything else happens from there.

If I wrap my head around this, is there dev documentation where I could write it up?

@timholy
Copy link
Member

timholy commented Oct 11, 2013

I love the idea of dev documentation. We don't have very much of it. Two possible venues are a blog post, or tacking on to the FAQ (final section of the manual).

Also FYI after the 0.2 release I expect we'll soon be moving away from readline and using https://github.com/loladiro/REPL.jl.

@jvns, it's an honor to have a "real Julia" among us! I was wondering when that would happen. As far as I know you're the first, so you should be entitled to hold the coveted "horned hat" trophy for a while, if Stefan can be persuaded to loan it to you :).

@simonster
Copy link
Member

tab_callback calls rl_complete_internal which calls rl_completion_entry_function which is set to do_completions in init_rl. do_completions gets an int parameter. When the int parameter is 0, it calls tab_complete, which calls symtab_get_matches, which collects the completions as a newline-delimited list and returns the first completion. When the int parameter is non-zero, it returns the nth completion from the previously collected list.

I think it should be possible to complete using by defining an rl_attempted_completion_function, but it will probably be painful and maybe not worthwhile if whatever code you write won't stick around in 0.3.

@jvns
Copy link
Author

jvns commented Oct 14, 2013

Sounds like it would be better to wait until the new REPL to do this.

@StefanKarpinski
Copy link
Member

Switching to the new REPL will be one of the first projects after we release 0.2.

@Keno Keno closed this as completed in 02f5553 Mar 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

No branches or pull requests

5 participants