2

I want to open files from iex> open() with Atom or vim. I tried to put on my ~/.zshrc:

export ELIXIR_EDITOR="atom +__LINE__ __FILE__"

or

export ELIXIR_EDITOR="/usr/local/bin/atom +__LINE__ __FILE__"

or

export ELIXIR_EDITOR="vim +__LINE__ __FILE__"

or

export ELIXIR_EDITOR="vi +__LINE__ __FILE__"

or

export ELIXIR_EDITOR="open -a Terminal 'vim +__LINE__ __FILE__'"

or

export ELIXIR_EDITOR="open -a Terminal 'nvim +__LINE__ __FILE__'"

and nothing work's. My version of Elixir is 1.7.4 on Mac OS X Mojave.

[UPDATE]

The error when I try to use with vim is this: iex(1)> open String.at/2 The file /Users/romenigld/workspace/elixir/ebooks/learn_functional_programming_with_elixir/ch06_designing_your_elixir_applications/dungeon_crawl/vim +1744 "/Users/romenigld/.asdf/installs/elixir/1.7.4/lib/elixir/lib/string.ex" does not exist.

Maybe it's a problem with the asdf? I don't know!

legoscia
  • 39,593
  • 22
  • 116
  • 167
rld
  • 2,603
  • 2
  • 25
  • 39
  • 1
    Because this is some configuration you can put since of the Elixir 1.5 version. And I was seeking on the internet and some guys do in this way using Emacs, Vim, sublime or others Appps. So I think is a good command for use on IEx and I was trying on this way. And I use Atom and I would like to configure this. – rld Dec 13 '18 at 14:27
  • I am sorry, I do not follow. The configuration to put _where_ exactly? Duckduckgoing `ELIXIR_EDITOR` does not shed any light. – Aleksei Matiushkin Dec 13 '18 at 14:30
  • Ok. Anyway here [open()](https://hexdocs.pm/iex/IEx.Helpers.html#open/1) you can see the usage. – rld Dec 13 '18 at 14:39
  • Wow. Thanks. The following setup worked for me: `export ELIXIR_EDITOR="code +__LINE__ __FILE__"` (`atom` in your case.) → `iex -S mix` → `open(MyApp)`. BTW, have you `source ~/.zshrc` reloaded? – Aleksei Matiushkin Dec 13 '18 at 14:43
  • Glad your work. And yes I do the source command. When I put the echo: `ELIXIR_EDITOR="echo +__LINE__ __FILE__"` It shows me the path. But with atom not. It's open a new Atom app but with no window and file, it's strange. – rld Dec 13 '18 at 14:52
  • 1
    This is usefull for when you want to modificate some function of any module. You can put: `open String.at/2` and will open this file. Try and you will love. – rld Dec 13 '18 at 14:54
  • I re-read again there on HexDocs and tells this only work's with Pry. *** "This command only works inside a pry session started manually via IEx.pry/0 or a breakpoint set via IEx.break!/4. Calling this function during a regular IEx session will print an error." *** – rld Dec 13 '18 at 14:58
  • For me it worked without any `pry` session, as I showed up above. Fresh start → `open(MyApp)`. I am on Linux, though. – Aleksei Matiushkin Dec 13 '18 at 14:59
  • For me work on IEx just using the echo. Thank you for reply! – rld Dec 13 '18 at 15:01
  • I quit the echo and puts nothing and I just notice, this work's like echo for show the path by default. – rld Dec 13 '18 at 15:27

2 Answers2

2

I was seeking on internet and I find this solution who the people uses for activate the command atom for open files, and now work's!

export ELIXIR_EDITOR="sh /Applications/Atom.app/Contents/Resources/app/atom.sh"
rld
  • 2,603
  • 2
  • 25
  • 39
-1

The error message is probably correct in that there is no lib/string.ex. If you check out the contents of the install you'll notice they are all be beam files. Note the documentation mentions this ...

Keep in mind the location may not exist when opening precompiled source code.

The IEx helper will however work for source files in your mix project.

In the case of Atom what I can confirm works is:

export ELIXIR_EDITOR="/path/to/Atom.app/Contents/MacOS/Atom __FILE__:__LINE__"

starbelly
  • 254
  • 1
  • 4
  • Hello @starbelly, I understand. But in my case it is not working for even source files in my mix project. For example I try to open the KV app of the Elixir Guides: `$ open(KV.start) The file /Users/romenigld/workspace/elixir/ebooks/elixir_getting_started_guide/Mix & OTP/kv/vim +4 "/Users/romenigld/workspace/elixir/ebooks/elixir_getting_started_guide/Mix & OTP/kv/lib/kv.ex" does not exist.` – rld Dec 16 '18 at 21:04
  • When I try with Atom it's open just the Icon Atom on the Docker and nothing occurs, I can't see the options of the atom app and none file is open. Thank's for reply! – rld Dec 16 '18 at 21:06