News for hackers. Stuff that matters.
Re:EditREPL - Open Vim from within the Python REPL by lbolla on Monday March 18, 2013 @12:24PM (#5395165)
IPython has this feature baked in the magic %ed command [1].

[1]: http://ipython.org/ipython-doc/dev/config/editors.html

Re:EditREPL - Open Vim from within the Python REPL by benatkin on Monday March 18, 2013 @12:52PM (#5395391)
Yes, and to edit the last thing you typed, you can run %ed _. When you exit %ed it runs the code and then returns the code as a string.
Re:EditREPL - Open Vim from within the Python REPL by philipbjorge on Monday March 18, 2013 @12:28PM (#5395199)
This is awesome! I really should learn iPython one of these days...
Re:EditREPL - Open Vim from within the Python REPL by pixelmonkey on Monday March 18, 2013 @01:34PM (#5395742)
IPython can also be run as a server (ipython kernel[1]) and then connected to via a vim plugin called vim-ipython [2]. This means you can do the other direction: evaluate a vim buffer in a running IPython session, and then connect to that IPython session to actually use the code you wrote in vim.

See:

[1] http://wiki.ipython.org/Cookbook/Connecting_to_a_remote_kern...

[2] https://github.com/ivanov/vim-ipython

Re:EditREPL - Open Vim from within the Python REPL by bitwize on Monday March 18, 2013 @02:19PM (#5396102)
Nice. Reminds me of a feature I have in Glass Table[0]:

Define a procedure, macro, or record type called foo:

    (define (foo x) ...)
Now say:

    ,(edit foo)
Your definition appears in the editor of your choice. (Try running GT within Emacs and setting your EDITOR to "emacsclient".) Make changes; provided no errors occurred (like missing parens) the changes take effect when you save and quit.

It's a nice little workflow; if you squint, it almost feels like a CADR...

[0] https://github.com/bitwize/glasstable

Re:EditREPL - Open Vim from within the Python REPL by JulianWasTaken on Monday March 18, 2013 @12:29PM (#5395209)
Cool.

Haven't looked at the code yet, but I wrote:

https://github.com/Julian/dotfiles/blob/master/.config/pytho...

which does something similar (and is interpreter agnostic as it looks like this is).

Re:EditREPL - Open Vim from within the Python REPL by philipbjorge on Monday March 18, 2013 @12:39PM (#5395299)
Mine's not interpreter agnostic because I had to mess with the stack frames to insert variables into the global context.

But yours is able to do that because your importing a top-level edit function while I was pretty set on dynamically creating a vim() method and not having to import a function (just a module).

I love how yours lists the globals though! I might just have to bite that feature :).

Re:EditREPL - Open Vim from within the Python REPL by JulianWasTaken on Monday March 18, 2013 @12:50PM (#5395370)
Oh, yeah, well, importing stuff on interpreter startup is pretty much exactly what $PYTHONSTARTUP is for :).
Re:EditREPL - Open Vim from within the Python REPL by philipbjorge on Monday March 18, 2013 @12:52PM (#5395389)
And this is why I post code online - to find out the right way to do things. PYTHONSTARTUP is exactly 100% what I was looking for, but didn't know existed.
Re:EditREPL - Open Vim from within the Python REPL by ashayh on Monday March 18, 2013 @05:10PM (#5397153)
For Ruby IRB, there is interactive editor: http://vimcasts.org/episodes/running-vim-within-irb/
Re:EditREPL - Open Vim from within the Python REPL by jlgreco on Monday March 18, 2013 @12:18PM (#5395123)
I could be mistaken, but isn't this a GNU Readline feature?

Neat regardless.

Re:EditREPL - Open Vim from within the Python REPL by philipbjorge on Monday March 18, 2013 @12:23PM (#5395152)
I think this is different because I'm full on opening an instance of vim. (I didn't know about GNU Readline though and it looks awesome - I'll definitely try and work it into a project at some point).
Re:EditREPL - Open Vim from within the Python REPL by jlgreco on Monday March 18, 2013 @12:32PM (#5395235)
Either Readline let's you do the same, or that is just a bash specific feature I am miss remembering. I can check later when I'm not on my phone.
Re:EditREPL - Open Vim from within the Python REPL by ben0x539 on Monday March 18, 2013 @12:33PM (#5395243)
I'm only using GNU readline for my bash prompt, but if I press v it spawns a full-on $EDITOR instance to edit the commandline.
Re:EditREPL - Open Vim from within the Python REPL by philipbjorge on Monday March 18, 2013 @12:44PM (#5395329)
This is awesome (I still have a lot to learn about bash) and effectively what my module does.

Just so others know, you have to put bash in vi mode and press Esc before v (otherwise it's ctrl+x ctrl+e).

set -o vi

Re:EditREPL - Open Vim from within the Python REPL by jlgreco on Monday March 18, 2013 @01:32PM (#5395724)
Aye, looks like I was wrong. This is a feature that bash has, not Readline. (in bash 4.2: bashline.c:858)
Re:EditREPL - Open Vim from within the Python REPL by Glench on Monday March 18, 2013 @12:38PM (#5395284)
oh my god this is awesome