xuchunyang
How to get code completion in IEx programmatically?
Hi all,
I’m new to Elixir. I’m trying to use IEx in Emacs. Right now the code completion isn’t supported, and I don’t know how to get the completion from Elixir/IEx programmatically, I tried IEx.Autocomplete.expand "String." but it doesn’t work (I expect it to return a list of completions so I can use it from Emacs.):
iex(11)> IEx.Autocomplete.expand "String."
** (FunctionClauseError) no function clause matching in IEx.Autocomplete.expand/2
The following arguments were given to IEx.Autocomplete.expand/2:
# 1
"String."
# 2
IEx.Server
Attempted function clauses (showing 2 out of 2):
def expand([], server)
def expand([h | t] = expr, server)
(iex) lib/iex/autocomplete.ex:6: IEx.Autocomplete.expand/2
Emacs setup:
(define-derived-mode inferior-elixir-mode comint-mode "Inferior Elixir"
"Major mode for Elixir inferior process."
(setq comint-prompt-regexp (rx bol (or "iex" "...") "(" (1+ num) ") ")))
(defun run-elixir ()
(interactive)
(with-current-buffer (make-comint-in-buffer "Elixir" "*Elixir*" "iex" nil)
(inferior-elixir-mode)
(display-buffer (current-buffer))))
Most Liked
axelson
I think you mean this post: Emacs lsp-mode (language server) + elixir-ls anyone? - #16 by axelson
And this emacs configuration: Emacs - Elixir Setup Configuration Wiki
It does have some support for autocomplete as well as some other features.
axelson
I also wanted to note that IEx.Autocomplete is labeled with @moduledoc false which means that it is a private api that shouldn’t be relied upon. It also looks like the functions in IEx.Autocomplete are using a bunch of private modules/functions as well. So I think you may need to raise an issue on the Elixir github to ask for programmatic access to autocomplete.








