That&#39;s the sort of use case I imagine as well, where a cell magic wants<div>to about something to the frontend a little more information about what kind of cell it is (in your %%bash example, it would be a code cell for which the code_mirror might use bash highlighting instead of python). This seems like it could be accomplished with something parallel to &quot;publish_display_data&quot; for cell metadata which different frontends can handle differently. </div>

</blockquote><div><br></div></div><div>publish_display_data already takes a metadata arg. This has always been the case, but so far it&#39;s totally unused.</div><div><br></div><div>I just noticed, this metadata is *not* included in the added fields preserved in the notebook, but I will get on that.</div>
<span class="HOEnZb"><font color="#888888">

<div>On 19 June 2012 16:08, Jonathan Taylor &lt;<a href="mailto:jonathan.taylor@stanford.edu" target="_blank">jonathan.taylor@stanford.edu</a>&gt; wrote:<br>
&gt; Yes, it would not be good to have the API of cell magics be notebook<br>
&gt; specific. What about providing a reference to the current cell metadata in<br>
&gt; the Magics class that can be used to update the NotebookNode after executing<br>
&gt; cell.input? So, cell_magics would not have access to the metadata on<br>
&gt; execution but could pass any metadata it wanted to back to the notebook.<br>
<br>
</div>Before we get too far into the mechanism, let&#39;s try to think about<br>
actual use cases, so we can figure out how things need to work.<br>
<br>
We can also see cell magics themselves as a sort of within-cell<br>
metadata. For example, the frontend might one day be aware that if a<br>
cell starts with %%bash, different syntax highlighting and tab<br>
completion rules apply to it. I think this would need to be within the<br>
frontend, rather than going through the kernel, because we want to use<br>
the new highlighting &amp; completion before the cell is executed.<br>
<div><div><br>
Thomas<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><div>-- <br>Jonathan Taylor <br>Dept. of Statistics <br>Sequoia Hall, 137 <br>