Hi all,
I've recently stumbled across the .editor feature in Node.js' REPL. It sets the REPL in to editor mode, which allows for easily inputting (or pasting) multi-line code into the REPL.
With iex, one of its shortcoming is its treatment of the pipe operator. If I want to paste code such as
into iex I must first rewrite it into
value |> fun1() |> fun2()
As the former is usually the preferred style of writing piped expressions, this means that whenever I want to try out code from a project that contains any such expression I must first manually reformat it. With a functionality such as the .editor mode this could be elegantly avoided.
With the help of a macro this might be easily added, for example, as part of IEx.Helpers. If we had a macro `e` defined as
defmacro e(do: block) do
quote do unquote(block) end
end
then `e` would become an editor mode like call in iex. For example, I could now write
iex> e do
...> 1..5
...> |> Enum.map(fn x -> x + 1 end)
...> end
[2,3,4,5,6]
allowing me to easily paste more complex expressions including pipes in new lines into iex.
Looking forward for feedback and comments.
Regards
Arno