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

Provide tab-completion for aliases #3280

Merged
merged 3 commits into from
Apr 28, 2015
Merged

Conversation

lexmag
Copy link
Member

@lexmag lexmag commented Apr 19, 2015

Closes #2519.

It is based on IEx.Server.whereis/0 usage, as there is no other way to reach current %IEx.State{}.
Probably we can use separate agent to track state, not sure if it worth it though; the current implementation might be OK for a first iteration.
I'd like to have any feedback or suggestions ot it. Just for reference: #2519 (comment).

This also makes possible to add tab-completion for user imports.

@lexmag lexmag changed the title Provide tab-completion for aliases [WIP] Provide tab-completion for aliases Apr 19, 2015
aliases = Enum.map(env_aliases(), fun)
modules =
Enum.map(:code.all_loaded(), fun)
|> Enum.into(aliases)
Copy link
Member

Choose a reason for hiding this comment

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

isn't it clearer to make it aliases ++ Enum.map(...)?

@josevalim
Copy link
Member

Thank you! I have added some comments!

@lexmag lexmag force-pushed the autocompletion branch 3 times, most recently from 5861595 to 5b85140 Compare April 19, 2015 20:08
@lexmag
Copy link
Member Author

lexmag commented Apr 20, 2015

Thanks for your comments.
It turned out that proposed implementation not includes one case:

iex(1)> alias IEx, as: I
nil
iex(2)> IEx.
App                Autocomplete       CLI                Config             
Evaluator          Helpers            History            Introspection      
Remsh              Server             State              after_spawn/0      
after_spawn/1      color/2            configuration/0    configure/1        
inspect_opts/0     pry/1              pry/3              started?/0         
width/0            
iex(2)> I.  
after_spawn/0      after_spawn/1      color/2            configuration/0    
configure/1        inspect_opts/0     pry/1              pry/3              
started?/0 

note the lack of modules for I. return. Will rework PR to support it.

@lexmag lexmag force-pushed the autocompletion branch 6 times, most recently from d096cd4 to 27076c7 Compare April 27, 2015 22:53
@lexmag lexmag changed the title [WIP] Provide tab-completion for aliases Provide tab-completion for aliases Apr 27, 2015
@lexmag
Copy link
Member Author

lexmag commented Apr 27, 2015

@josevalim this is ready for merge. Don't see a way to make tests for it (we can start IEx with predefined %Env{} but capture_io swaps group_leader thus IEx.Server is getting unreachable).
Here is a showcase:

iex(1)> alias IEx, as: I
nil
iex(2)> I
I          IEx        IO         Inspect    Integer    
iex(2)> I.
App                Autocomplete       CLI                Config             
Evaluator          Helpers            History            Introspection      
Remsh              Server             State              after_spawn/0      
after_spawn/1      color/2            configuration/0    configure/1        
inspect_opts/0     pry/1              pry/3              started?/0         
width/0            
iex(2)> I.App.start
start/2

josevalim added a commit that referenced this pull request Apr 28, 2015
Provide tab-completion for aliases
@josevalim josevalim merged commit ade50de into elixir-lang:master Apr 28, 2015
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@lexmag lexmag deleted the autocompletion branch April 28, 2015 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Tab completion does not work for aliases
2 participants