https://github.com/doglooksgood/inf-iex
Interaction with IEx session
https://github.com/doglooksgood/inf-iex
Last synced: 4 months ago
JSON representation
Interaction with IEx session
- Host: GitHub
- URL: https://github.com/doglooksgood/inf-iex
- Owner: DogLooksGood
- Created: 2020-09-29T02:46:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-31T13:54:37.000Z (over 5 years ago)
- Last Synced: 2025-08-31T05:43:28.705Z (9 months ago)
- Language: Emacs Lisp
- Size: 137 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* 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 [[https://github.com/jwiegley/use-package][use-package]], Tested under Emacs 27.1 .
** With [[https://github.com/quelpa/quelpa][quelpa]].
#+begin_src emacs-lisp
(use-package inf-iex
:hook (elixir-mode . inf-iex-minor-mode)
:quelpa (inf-iex :fetcher github
:repo "DogLooksGood/inf-iex"))
#+end_src
** With [[https://github.com/raxod502/straight.el][straight]].
#+begin_src emacs-lisp
(use-package inf-iex
:hook (elixir-mode . inf-iex-minor-mode)
:straight (inf-iex :type git
:host github
:repo "DogLooksGood/inf-iex"))
#+end_src
* 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, [[https://github.com/emacsorphanage/emamux][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 Binding | Functionality |
|-------------+--------------------------------------------------------|
| ~C-c C-z~ | Start IEx comint buffer. |
| ~C-c C-v~ | Switch between sending target, tmux or comint buffer. |
| ~C-c C-c~ | Send region or current line to target. |
| ~C-c C-n~ | Eval and wrap code with :timer.tc, return nanoseconds. |
| ~C-c C-w~ | Eval with bindings those read from minibuffer. |
| ~C-c C-k~ | Reload current module. |
| ~C-c C-l~ | Compile current file. |
| ~C-c M-p p~ | Add Pry section to above line. |
| ~C-c M-p k~ | Remove Pry section in this file. |
| ~C-c M-p l~ | Goto Pry section. |
| ~C-c C-s c~ | Query process state from process list. |
| ~C-c C-s s~ | Query process state from Swarm registry. |
| ~C-c C-i~ | Send i {thing-at-point} to IEx. |
| ~C-c M-c~ | Import this module and its imports & requires. |
| ~C-c M-r~ | Like ~C-c M-c~, but ~respawn~. |
| ~c-c M-d b~ | Open DBG list buffer. |
| ~C-c M-d d~ | Add current function to DBG list. |
| ~C-c M-d c~ | DBG execute expression. |
* 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.
* DBG
/**this feature only works with IEx in Emacs/
Use ~c-c M-d d~ to add current function to DBG list.
Use ~C-c M-d b~ to open DBG List buffer, in this buffer, use ~n~/~p~ to navigate, ~k~ to remove, ~t~ to toggle.
Use ~C-c M-d c~ to execute expression with DBG.
Tracing result and output will be displayed in a new buffer.
* 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.