The Golden Spot

I hope this helps someone who is learning about Linux and web application programming with Python, Django, and Javascript.

Monday, April 13, 2015

emacs mode inside ipython(jupyter) notebook

Here's a github gist that you'll need to paste into
custom.js
which is located in
~/.ipython/profile_default/static/custom/custom.js
// register a callback when the IPython.notebook instance is created.
$([IPython.events]).on('app_initialized.NotebookApp', function(){
function to(mode) {
// this can be either 'vim' or 'emacs'
var mode = mode || 'emacs';
// first let's apply mode to all current cells
function to_mode(c) { return c.code_mirror.setOption('keyMap', mode);};
var cells = IPython.notebook.get_cells();
if (cells != null) {
cells.map(to_mode);
}
// apply the mode to future cells created
IPython.Cell.options_default.cm_config.keyMap = mode;
};
require(["codemirror/keymap/emacs"],
function (_) {
if (IPython.notebook != undefined) {
to('emacs');
};
});
});

This works for 4.0.0.dev :)

1 Comments:

Blogger wfd said...

Thank you! Works for ipython 3.0.0 for me on ubuntu 14.04.

2:05 PM  

Post a Comment

<< Home