ipython/ipython — pull request #1732 by fperez (2012-05-14 07:30:31+00:00)
Title: Cellmagics: work in progress

This is *not* yet ready to merge, as a few tests are failing and the actual cell magics functionality isn't even implemented yet. But I think the major work is over, and there's enough delicate code in here and large changes that I want to put it up for review earlier rather than later.

I'm having second thoughts about the proposal in the IPEP (#1611) to allow separate implementations of line and cell magics with the same name. That would require managing effectively yet another namespace (cell magics), which has repercussions across the whole codebase that are too large for comfort.

So instead, I'm leaning towards requiring that, if a user wants to make a magic both line and cell, then its api should be `foo(self, line, cell=None)`, and there would be three decorators: `@line_magic`, `@cell_magic` and `@line_cell_magic`, the latter being used for such cases.

It does limit a few use cases a little, but I think the complexity of the original plan is just too much.

So let's discuss this here while I work on things further. Once the tests pass again on my box, I'll use the `test_pr` script to get a fuller test run, but for now don't worry about reporting failures, since I know they're present.