[Proposal] Improve IEx autocompletion to support atom map keys

85 views
Skip to first unread message

Myron Marston

unread,
Nov 27, 2016, 7:29:57 PM11/27/16
to elixir-lang-core
IEx autocompletion is really nice, but I think there are some features missing to really make it shine.  In particular, I wish it supported autocompletion of struct fields (or really, atom keys in any map).  For example, in a case like:

```
iex> map = %{foo: 23, bar: 14}
iex> map.f<TAB>
```

...I'd like it to autocomplete `f` to `foo`.  And if multiple fields match, it would ideally list all matches, just like how `Module.f`<TAB>` prints all the functions starting with `f` in `Module`.

Depending on the complexity of implementing this, I'd be interested in taking a stab, provided the core team was in favor of this new feature.

Thoughts?
Myron

José Valim

unread,
Nov 28, 2016, 2:40:57 AM11/28/16
to elixir-l...@googlegroups.com
Yes, please go ahead. :D

Keep in mind today the autocomplete does not have information about the evaluator (which is the process that effectively has variable bindings). However, you can reach the evaluator from the autocomplete code as follows:

{:dictionary, keys} = Process.info(IEx.Server.local, :dictionary)
keys[:evaluator]

You may need to extend the evaluator process (defined in IEx.Evaluator) to respond to new messages which you will send from the autocomplete.

I assume that as soon as we allow the autocomplete to access information in the evaluator, we can support both:

map.f<Tab>
some_module.f<Tab>

Please let me know if you have any questions!

José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5760b5e6-c597-40a1-8749-c9927643da41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michał Muskała

unread,
Nov 28, 2016, 4:39:33 AM11/28/16
to elixir-l...@googlegroups.com
Speaking of autocomplete. I noticed recently that when modules are aliased they don't autocomplete in releases. It works correctly in regular iex.
I will investigate further when I have some time, but I wanted to signal it.

Michał.

> On 28 Nov 2016, at 08:40, José Valim <jose....@plataformatec.com.br> wrote:
>
> Yes, please go ahead. :D
>
> Keep in mind today the autocomplete does not have information about the evaluator (which is the process that effectively has variable bindings). However, you can reach the evaluator from the autocomplete code as follows:
>
> {:dictionary, keys} = Process.info(IEx.Server.local, :dictionary)
> keys[:evaluator]
>
> You may need to extend the evaluator process (defined in IEx.Evaluator) to respond to new messages which you will send from the autocomplete.
>
> I assume that as soon as we allow the autocomplete to access information in the evaluator, we can support both:
>
> map.f<Tab>
> some_module.f<Tab>
>
> Please let me know if you have any questions!
>
> José Valim
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
> On Mon, Nov 28, 2016 at 1:29 AM, Myron Marston <myron....@gmail.com> wrote:
> IEx autocompletion is really nice, but I think there are some features missing to really make it shine. In particular, I wish it supported autocompletion of struct fields (or really, atom keys in any map). For example, in a case like:
>
> ```
> iex> map = %{foo: 23, bar: 14}
> iex> map.f<TAB>
> ```
>
> ...I'd like it to autocomplete `f` to `foo`. And if multiple fields match, it would ideally list all matches, just like how `Module.f`<TAB>` prints all the functions starting with `f` in `Module`.
>
> Depending on the complexity of implementing this, I'd be interested in taking a stab, provided the core team was in favor of this new feature.
>
> Thoughts?
> Myron
>
> --
> You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BN-2wzu9Rimu%2B%3D2qerhw3LU-yBVbqZbkkSAoo9rFtCaw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages