[IPython-dev] Notebook codemirror support for language not distributed with codemirror?

Tom Quarendon tom.quarendon at teamwpc.co.uk
Tue Nov 24 08:19:08 EST 2015


OK, so I can't get this to work reliably.

It's a timing thing. The way I've implemented it is simply to do
		onload: function() {
			require('kernelspecs/mykernel/mymode');	
		}
In my kernel.js

However, the success of that depends on the asynchronous timing of that being executed verses the call to set_codemirror_mode here (notebook.js):
	this.events.on('kernel_ready.Kernel', function(event, data) {
		...
	            that.set_codemirror_mode(cm_mode);
	        });

So I suspect I need to do something more sophisticated. Bearing in mind my lack of knowledge of require etc (i.e spell it out please!), can anyone suggest anything? Cal I explicitly call set_codemirror_mode myself somehow (I don't know how I'd get hold of a suitable object to call the method on though)?

Thanks.

-----Original Message-----
From: IPython-dev [mailto:ipython-dev-bounces at scipy.org] On Behalf Of Matthias Bussonnier
Sent: 14 November 2015 16:49
To: IPython developers list <ipython-dev at scipy.org>
Subject: Re: [IPython-dev] Notebook codemirror support for language not distributed with codemirror?


> On Nov 14, 2015, at 08:29, Robert Dodier <robert.dodier at gmail.com> wrote:
> 
> What I ended up doing for Maxima-Jupyter is to put the appropriate JS 
> (created by hacking the one for another language) into the CodeMirror 
> installation directory, also putting the new file name on the list of 
> modes which is also in the CM installation.

You can drop a kernel.js next to your kernel.json  at installation time, it should  describe an AMD module that define a `unload` method that will be called when you switch to you r kernel. 

The can manually load/register a code mirror mode in the notebook. 
--
M


> 
> Maybe there is a better way, but I couldn't figure it out.
> 
> Hope this helps,
> 
> Robert Dodier
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> https://mail.scipy.org/mailman/listinfo/ipython-dev

_______________________________________________
IPython-dev mailing list
IPython-dev at scipy.org
https://mail.scipy.org/mailman/listinfo/ipython-dev



More information about the IPython-dev mailing list