Elixir - Help needed: Tab completion in Elixir shell

I have hit a wall with Stage #QP2 (Autocompletion - Builtin completion).

There’s no functional library in Elixir that can properly capture the Tab key when pressed.

I’ve tried multiple approaches:

  • Raw mode with stty

  • :io.setopts/2

  • terminal handling lib (ex_readline)

If anyone has successfully implemented real-time Tab completion in Elixir, I’d really appreciate your guidance or examples.

Thanks in advance!

Hey @fabrithedev,there is one Elixir code example available for this stage. Is that usefully?

I tried copying the entire code, but it didn’t work.

After looking more carefully through his code repository, I finally understood what he did. He used a clever “hack” to put the terminal into raw mode by implementing it in a C file. I copied that approach into my project, made a few adjustments, and now I can properly detect the input.

That was a tricky one!

Maybe it would be a good idea to include some guidance about this in the exercise, since it’s not something very common. In Rust, for example, you can just use the rustyline crate and don’t need to worry about this.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.