Generalise mechanism to put text at the next prompt in the Qt console. #421

Merged
merged 0 commits into from May 17, 2011

Conversation

Projects
None yet
2 participants
Owner

takluyver commented May 9, 2011

This generalises the mechanism used by %loadpy to place text at the next prompt. The result is that the %recall, aka %rep, magic works the same way as it does in the terminal, putting history lines (or strings) at the next prompt.

Equally, %loadpy could be moved to the core magics, so that it works in a terminal as well. I've not done this yet, as the terminal isn't such a good environment for multiline cells, so I'm not sure how useful it would be. But it's a simple change if we want it.

Owner

minrk commented May 10, 2011

Very nice.

When I do ip.set_next_input("def f():\n return 2") with a multiline string in the Terminal, I actually get a single multiline readline entry. That means the whole thing is one entry accessible all at once via up-arrow, and the entire block is editable (if not conveniently so). Is this what we want to happen?

Owner

takluyver commented May 10, 2011

Yes, or at least it's what I intended. So, for instance, you can do %recall 2-5, and it will join the cells together and plonk them at the next prompt. It's not as convenient as in the qt console, but it still works if you have something like:

a = "some data"
b = process(a)
#...
print m.values()

And you want to run the same sequence of commands with a different a: bring the whole lot to the prompt, hit home, tweak the value of a, and run it again.

Owner

minrk commented May 10, 2011

Okay, then if we are allowing multiline pasts with %recall, it makes sense for %loadpy to be a core magic, and not qt-specific.

Owner

takluyver commented May 11, 2011

OK, I've moved %loadpy into the core, so it works at the terminal as well.

Owner

minrk commented May 17, 2011

Looks good to me. I can imagine that some might object to inconsistent handling of multiline inputs in the terminal, but I think having %loadpy always available is more valuable than that.

I say go ahead and merge.

Owner

takluyver commented May 17, 2011

Thanks, Min. I'll merge later today unless anyone objects. @fperez, @ellisonbg: let me know if you see a problem, or if you want more time to look at it before I merge.

takluyver merged commit 25c7866 into ipython:master May 17, 2011

Owner

takluyver commented May 17, 2011

Merged with rebase, as it was only 2 commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment