Recognizing more `ctrl-` keys in Iex

I really miss ctrl-l to clear the screen and ctrl-d to exit like other REPLs provide. Since ctrl-d is ignored, I would chose to alias it to one of the two “break” codes: ctrl-c or ctrl-g.

I’ve read through the Iex source code and don’t see how to extend the code. The closest thing I’ve found is the tab completion handler. It seems to work via a plug-in strategy as this section implies:

  @doc """
  Provides one helper function that is injected into connecting
  remote nodes to properly handle autocompletion.
  """
  def remsh(node) do
    fn e ->
      case :rpc.call(node, IEx.Autocomplete, :expand, [e]) do
        {:badrpc, _} -> {:no, '', []}
        r -> r
      end
    end
  end

But I still can’t figure out how the tab character is specified for this “hook” (if it even is a hook).

Are “special” characters like tab and ctrl-c handled exclusively by an Erlang server, and somehow Iex’s current architecture rules out adding new key combinations?

3 Likes