halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

No documentation for Pipe Selections #52

Closed clozach closed 6 years ago

clozach commented 7 years ago

Even a single sentence might do the trick. As it is, it seems to show and hide a text field that doesn't appear to actually do anything. :)

halohalospecial commented 7 years ago

You've found an Easter egg! :tada:

It's an experimental command :grin: https://github.com/halohalospecial/atom-elmjutsu/tree/master/images/pipe

I haven't written the docs yet because I'm not yet sure if it's useful enough to be officially included in the package :-) It basically "pipes" (as in |>) the text selections into the Elm code you enter in the text field. The selections will be treated as a list of strings. If there is only one selection, it will treated as a string instead. The result from the evaluating the Elm code (using elm-repl behind the scenes) will then be converted to a new list of selections (i.e. map will modify the text in the selections, filter will remove selections, append will add selections, etc.).

If you want to play with it, set the value of Elm REPL Path in the package settings. If you want to use custom functions, you can also set the value of Eval Prelude Path to point to a .elm file. elm-repl will be executed where that file is. The default "prelude" file is https://github.com/halohalospecial/atom-elmjutsu/blob/master/elm/EvalPrelude.elm.

The main concept was to use Elm code to edit Elm code (or any other text) :grin: (It can also be used on non-Elm files).