frankyxhl / inf-iex

Interaction with IEx session

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INF IEX

To provide a better interaction experience between emacs elixir buffer and IEx sessions.

THIS PACKAGE IS WORKING IN PROGRESS.

Installations

Following is the installation with use-package, Tested under Emacs 27.1 .

With quelpa.

(use-package inf-iex
  :hook (elixir-mode . inf-iex-minor-mode)
  :quelpa (inf-iex :fetcher github
                :repo "DogLooksGood/inf-iex"))

With straight.

(use-package inf-iex
  :hook (elixir-mode . inf-iex-minor-mode)
  :straight (inf-iex :type git
                  :host github
                  :repo "DogLooksGood/inf-iex"))

IEx Sessions

There’re two ways to play.

Start IEx in Emacs comint buffer.

Inf-IEx contains a very basic support for IEx session with comint. At this moment, it doesn’t have a nicer code completion or navigation. But it allows us to eval code in code buffer.

Start IEx in a tmux window.

A nice package, emamux, help us to interact with tmux sessions, and it is be used by Inf-IEx. By using a native IEx session in shell, we have code completion, and it also gives us the ability to to connect through a SSH connection(running SSH session in a local tmux).

Summary of shortcuts

Key BindingFunctionality
C-c C-zStart IEx comint buffer.
C-c C-vSwitch between sending target, tmux or comint buffer.
C-c C-cSend region or current line to target.
C-c C-nEval and wrap code with :timer.tc, return nanoseconds.
C-c C-wEval with bindings those read from minibuffer.
C-c C-kReload current module.
C-c C-lCompile current file.
C-c M-p pAdd Pry section to above line.
C-c M-p kRemove Pry section in this file.
C-c M-p lGoto Pry section.
C-c C-s cQuery process state from process list.
C-c C-s sQuery process state from Swarm registry.
C-c C-iSend i {thing-at-point} to IEx.
C-c M-cImport this module and its imports & requires.
C-c M-rLike C-c M-c, but respawn.

Start comint IEx session

Use C-c C-z, project root detection should work.

Execution Context

Use C-c M-c to import current module and module’s imports and requires.

Use C-c M-r to respawn a new session.

Code evaluation

Evaluate region or current line with C-c C-c.

To measure execution cost, use C-c C-n, nanoseconds will be returned.

To Evaluate with bindings, use C-c C-w.

NOTE: You may want to put playground code in comment, prefix # and iex> will be trimed.

Switch sending target

Use C-c C-v to switch target between tmux and comint buffer.

Reload module

Use C-c C-k.

Compile module

Use C-c C-l

Process state query

**this feature only works with IEx in Emacs

We can query process state by pick a process name from a list.

Currently, only following registry is supported.

  • C-c C-s c For those have a :registered_name, listing by Process.list.
  • C-c C-s s For those registered with Swarm.

After pick the process in minibuffer, a inspector will display its state.

And you can use buttons on top to define state as variable or kill this process.

I’m new to Elixir, so if you want a type of registry to be supported, just submit an issue!

Pry

Insert a pry at above line with C-c M-p p. After insertion, module will be reloaded automatically.

Click RET it remove.

C-c C-i can be used to inspect values when working with Pry.

FAQ

Question: How to solve error “file-remote-p: Wrong type argument: stringp, nil” when starting IEx comint buffer?

Answer: INF IEX will call (project-current) in Emacs which will read git info in current path. Please make sure that you have done git init for the Elixir project.

About

Interaction with IEx session


Languages

Language:Emacs Lisp 100.0%