Carreau / jupytercontrib

MIT License
3 stars 2 forks source link

Applying cell magics for multiple cells #1

Open cschwem2er opened 8 years ago

cschwem2er commented 8 years ago

Hi,

first of all sorry for hijacking this issues as kind of a "feature/possibility request", but I had problems finding people familiar with jupyter nbextensions and hope that you can help me out.

Currently an implementation for using the statistics software Stata within Jupyter Notebooks is being developed. The current version uses cell magic %%stata to communicate with the software.

My question related to this: With the new multi-cells selection from 4.1, is it possible to automatically apply cell magic to multiple cells (or even the whole notebook)? If so it would not be necessary to rewrite the cell magic at the beginning of every cell.

Many thanks and cheers

Carreau commented 8 years ago

Hi @methodds ,

Thanks for the question, feel free to raise it also on the IPython mailing list or one of the main IPython repository to get more people reading.

So technically nothing is impossible, though what you ask seem to brea a lot of abstraction, and would require custom patching of a lots of methods plus would be highly brittle.

Though, let me try to understand what you want. As far as I can tell from the example notebook, it just seem like writing %%stata on each cell is a hassle, but you still need to communicate with Python every now and then. I thus believe that you might be better implementing your own kernel on top of IPython which will default to Stata, and use a different syntax (%python ??) to switch one cell back to Python.

See for example this Stata kernel:

https://github.com/jrfiedler/stata-kernel