Re: Notebook codemirror support for language not distributed with codemirror?

Tom Quarendon <[email protected]>
Newsgroups gmane.comp.python.ipython.devel
Message-ID <AM3PR05MB0776859CE85E2C99B6EFF990B0060@AM3PR05MB0776.eurprd05.prod.outlook.com>
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:[email protected]] On Behalf Of Matthias Bussonnier
Sent: 14 November 2015 16:49
To: IPython developers list <[email protected]>
Subject: Re: [IPython-dev] Notebook codemirror support for language not distributed with codemirror?


> On Nov 14, 2015, at 08:29, Robert Dodier <[email protected]> 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
> [email protected]
> https://mail.scipy.org/mailman/listinfo/ipython-dev

_______________________________________________
IPython-dev mailing list
[email protected]
https://mail.scipy.org/mailman/listinfo/ipython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.