two-way vim-ipython integration #631

Merged
merged 1 commit into from Jul 30, 2011

Projects

None yet

3 participants

@ivanov
Member
ivanov commented Jul 29, 2011

here's a new and improved way of getting vim and ipython to talk to each other. Thanks to @minrk for guiding me through the protocol.

I also made a little demo of these new capabilities which you might be interested in checking out here: http://www.pirsquared.org/vim-ipython/

Others want to join in the fun in improving ipy.vim can do so here: http://github.com/ivanov/vim-ipython

@ivanov ivanov and 1 other commented on an outdated diff Jul 29, 2011
IPython/utils/io.py
@@ -87,9 +88,9 @@ class IOTerm:
self.stderr = IOStream(stderr, sys.stderr)
# setup stdin/stdout/stderr to sys.stdin/sys.stdout/sys.stderr
-stdin = IOStream(sys.stdin)
-stdout = IOStream(sys.stdout)
-stderr = IOStream(sys.stderr)
+stdin = IOStream(sys.stdin,os.tmpfile())
+stdout = IOStream(sys.stdout,os.tmpfile())
+stderr = IOStream(sys.stderr,os.tmpfile())
@ivanov
ivanov Jul 29, 2011 Member

these lines were just a way for me to get vim to import IPython, but it was a kludge done without much thought. There's likely something else that should be done here, so please let me know what that should be

@minrk
minrk Jul 29, 2011 Member

Do you have to do this with all of them, or a subset? I realize that sys.stdin can sometimes be None, for example.

An alternative is to assign appropriate streams to sys.stdin/out/err prior to importing IPython things, but we should probably handle this gracefully.

@ivanov
ivanov Jul 29, 2011 Member

according to python docs, sys.stderr and sys.stdout are only required to have write() methods, but I've monkeypatched vim's stdout and stderr to fix this. Vim actually added flush() in their trunk

@fperez
Member
fperez commented Jul 29, 2011

@ivanov, this is a bit too dangerous to merge this close to release, but it's very cool! I just saw the demo video, and it's awesome. We'll cut 0.11 without this, and can then merge it with plenty of time to deal with any possible problems before 0.12.

Thanks!

@ivanov
Member
ivanov commented Jul 29, 2011

now with no changes to IPython trunk! 0.11? :)

@fperez fperez merged commit bd572cd into ipython:master Jul 30, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment