[IPython-dev] editor synchronization

Vivian De Smedt vivian at vdesmedt.com
Tue Sep 11 14:06:56 EDT 2007


Ville,

Thank you for your positive reaction.

I agree with you that that hook is so close to the editor hook that we 
want to merge it with it. Let me however share with you few 
considerations about the editor hook to highlight slight nuances in the 
way we want the hook to be called in various situations.

As far as I know currently the editor hook is used by IPython to let 
user edit portion of code either by explicitly calling it through the 
%edit command or automatically (e.g. when IPython failled to import a 
module because of an error syntax).

The problem come if your editor of choice is a multi documents text 
editor. Indeed the editor hook returns only when the process it launch 
returns. If you use a simple (e.g the default) version of the hook that 
launch the editor itself you have to quit your editor for the hook to 
return. Which mean closing all the other text documents you were working 
on. That is not very friendly and that is why I'm not using the editor 
hook currently.

We could imagine other hook implementation that will launch a dummy 
process that will ask the editor to open the text file. The user will 
then have the opportunity to tell the hook it has finish with the 
edition of the file by closing the dummy process. Frankly I'm not a big 
fan of such sophisticated solution and till I'm not able to go around 
the problem of multi documents text editor problem I'm not sure I want 
to use the current editor hook.

There is an another difference between the default behavior of both hook 
and it is related to the focus.
 - The default behavior of the editor hook, because it is called to let 
the user edit a portion of code, is to transfer the focus to the editor.
 - The default behavior of the synchronization hook, because it is 
called to let the user view a portion of code, it the let the focus on 
the console window. This is particularly true for one of the most 
interesting aspect of the hook which is debugging.

For the one that use console editor (vi) having the editor to be called 
at each debugging step and having to quit the editor to continue 
debugging will be a nightmare :-|

So I think that some people will want to use only the current editor 
hook and some people will only be interested in the new synchronization 
editor hook and hopefully some will be able to use happily both. But I 
think both hook will invoke the editor slightly differently.

Saying so I definitively agree with you that both hook are so similar 
that it will be a pity to separate them. But I think that if there is 
only one hook it should have one parameter more in its signature telling 
in which context it is called to let the hook writer invoke the editor 
accordingly.

Tell me what you think. I understand that it is not the right time to 
introduce a new feature in the code of IPython. I'll make my proposed 
change in the code of the next version. I'll be glad to receive advices 
about the desired implementation of the combined hook.

Kindest regards,
Vivian.

> The idea is a good one, but I'm not sure whether we should have an
> extra hook for this; the plain editor hook should be enough, as well
> as some flag that signals ipython to run the editor hook for the line
> on all these "hot spots". This will work for some editors (like,
> apparently, ultraedit) that will reuse an existing editor instance for
> this.
>
> The svn snapshot is here:
>
> http://ipython.scipy.org/dist/nightly_svn/
>
> But don't bother sending in the patch quite yet. I think we should add
> a few more editors and throw this kind of configuration to
> ipy_editors.py to really get some mileage for this, in the svn
> version. As it stands, we are releasing 0.8.2 Real Soon Now (this
> week), and I'd rather wait until after that.
>
> It's a good feature, though, and will definitely end up in the svn in
> one form or another.
>
>   




More information about the IPython-dev mailing list