Open cdegroot opened 4 years ago
I have just discovered this issue, and here are a couple of ideas.
You could take a look at company-elixir
package on how to produce completion candidates for Elixir. It apparently uses iex -S mix
command for inspection, so it may be possible to extract some common parts, but I am not sure how difficult it would be.
You also have to integrate it with the comint buffer. nix-repl.el
which is shipped as part of nix-mode.el
does this well. It's basically defining a function for completion-at-point-functions
.
I don't think I am competent enough to tackle the idea promptly, so I will leave this information to here.
Right, there's two issues here:
comint
's completion mechanism isMy general inclination for part 1 is to send a tab character to the REPL process, capture its output and parse it.
I think part 2 is something to do with comint-dynamic-complete-functions
and comint-preoutput-filter-functions
, but this requires further research and testing.
Of course, this is a very old thing. I think I was using Spacemacs back then, I switched to Doom in the meantime, which has other issues so I tend to stay away from running IEx inside Emacs completely now ;-).
Thanks for your work on inf-elixir
!
Might be worth looking at this implementation for iex in shell-mode that was posted to Elixir slack's emacs channel.
Maybe it's worth a discussion with @jasonmj.
Thanks Walter! Happy to chat more about the approach I've taken here, Jonathan. It's still a bit of a work in progress, but the proof of concept shows viability.
Hey folks, thanks for the tip! This approach seems similar to one that I attempted on the tab-completion
branch here on GitHub. Mine is quite buggy, I'm sure yours is much better!
TL;DR: I'm thinking of new approaches for Elixir interaction writ large, but if anyone wants to send a PR I will give it a good-faith review :grin:
The general constraints of the "send IEx.Autocomplete.expand(...
to the IEx shell and parse the output" approach (e.g. prompt numbers increment each time completion is performed) and also the limitations mentioned in #17 have got me thinking about taking a fresh approach to an Elixir shell in Emacs; moving towards something a bit more like cider for Clojure over a wrapper around a terminal shell (like iex
). Cider interfaces with a language/runtime API (nrepl
), and while I don't think there's an nrepl
equivalent for Elixir (atm), there's been a lot of work in the Livebook project to provide a REPL-like experience in the browser which could be utilized in such a project.
That said, such a project would be a large undertaking and this project will continue separately because it works and is good enough for many people's use cases. If you'd like to enhance this project, I'm happy to accept those contributions, but for the time being I'll be directing my efforts in another direction.
Yep, the prompt counter increment is a thing... doesn't seem like a dealbreaker to me, but a specific side effect of this approach. Regarding an approach like cider, I'm all for it! I've used cider in the past and really enjoyed it.
Currently there's a literal tab inserted. I have no clue how either the Emacs or the IEx side work - I'm gonna dig for a bit but will probably never finish so logging this so someone competent hopefully takes a shot :)
Thanks for creating this, it's pretty much exactly what I was looking for! I'm working on making Emacs super nice for Elixir by hooking up something like https://github.com/rustyio/sync and an automated test runner, and an inferior IEx is the starting point I was missing.
(Seems to be a common issue. https://github.com/fsharp/emacs-fsharp-mode/issues/184 for example)