[IPython-dev] comment on autosave

Matthias BUSSONNIER bussonniermatthias@gmail....
Wed Nov 7 08:28:52 CST 2012


Hi Zoltán,
Le 7 nov. 2012 à 11:39, Zoltán Vörös a écrit :

> Hi all,
> 
> I might be poking into a hornets' nest, but I was wondering whether 
> configurably linking saving the notebook to the cell execution could 
> appease all those who complain about autosave. My idea is that one could 
> simply have a flag in the profile, and if that flag is set, then  
> that.save_notebook() could be executed at the end of 
> execute_selected_cell(). This solution should be safe in the sense that 
> as long as the function save_notebook works, there should be absolutely 
> no problems with using it in execute_selected_cell, and we wouldn't have 
> to tamper with the javascript base.
> 
> In any case, if you think this could be a viable option, I could try to 
> implement it.

Thanks for the suggestion, 
It is a good idea, but the problem is there is no good way yet to propagate configuration to the JS side except from the custom.js in user profile.

you could listen to event 'execution_request.Kernel' and 'shell_reply.Kernel' for code execution. 
I don't remember the name of the event for MD cell rendering or even if there is one.
(this could be added)


This should be a one liner in custom.js like :

$([IPython.event]).on('shell_reply.Kernel',IPython.notebook.save_notebook);

I would just warn you that it does overwrite the current version of the file, whereas what you might wish is a secondary file with another name.
save can take a name parameter, but then it renames the notebook instead of doing a copy so be carefull.

We'll be really happy if you find a good way of propagating option from profile/command line to the browser side, or at least open an IPep about that :-)

If you came up with anything you can add it to the wiki :-)
-- 
Matthias




More information about the IPython-dev mailing list