xuchunyang

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))))

First Post!

NobbZ

NobbZ

Autocompletiond ist supported, the elixir language server just got forked and is currently better supported through Emacs than visual studio code. Just search the forum. It was posted this year AFAIR.

Most Liked

axelson

axelson

Scenic Core Team

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

axelson

Scenic Core Team

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.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement