[IPython-user] Finally, ipython works in emacs

Jörgen Stenarson jorgen.stenarson@bostream...
Fri Jan 4 12:13:14 CST 2008


wang frank skrev:
> I have fixed the problem. After adding the code at line 380, I also need 
> to add WriteFile at 149. It is great to make this work.
>  
> How to setup the EMACS environment in ipython? Why these codes have been 
> removed from pyreadline?
>  
> Thanks
>  
> Frank
I'm happy to hear you got it to work. I think the code disappeared in 
when we did some code reorganization a while back. And since I don't use 
emacs I never realized it.

The purpose of the EMACS environent variable test is that you should be 
able to set that variable from emacs before starting ipython thus 
ensuring that this code only runs if ipython is launched from emacs. I 
don't know how to do this in emacs so if you have some other idea on how 
  to achieve the same goal please let me know.

If possible please send a patch file for your changes generated by svn 
diff. (Don't forget to svn up first)

/Jörgen



> 
> 
>     ------------------------------------------------------------------------
>     From: fw3@hotmail.co.jp
>     To: jorgen.stenarson@bostream.nu
>     Date: Thu, 20 Dec 2007 23:27:29 +0000
>     CC: ipython-user@scipy.org
>     Subject: Re: [IPython-user] Finally, ipython works in emacs
> 
>     Thanks for the help.
>      
>     I have added the code into the console.py as
>      def write_color(self, text, attr=None):
>       junk = c_int(0)
>       self.WriteFile(self.hout, text, len(text), byref(junk),None)
>       return len(text)
>       write_plain = write_color
>      
>     I did not put the EMACS environment check since I do not know how.
>     It does not fix the problem. After I added the code and install the
>     pyreadline, the Out[] prompt disappeared. After I quit the ipython,
>     I got the same error:
>      
>      
>     Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
>     (Intel)] on win32
>     Type "help", "copyright", "credits" or "license" for more information.
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     ERROR - failed to write data to stream:
>     <pyreadline.console.console.Console object at 0x0133BBB0>
>     Process Python finished
> 
> 
>      > Date: Thu, 20 Dec 2007 21:41:17 +0100
>      > From: jorgen.stenarson@bostream.nu
>      > To: fw3@hotmail.co.jp
>      > CC: ipython-user@scipy.org
>      > Subject: Re: [IPython-user] Finally, ipython works in emacs
>      >
>      > wang frank skrev:
>      > > I have finally made the ipython works in emacs. The solution is to
>      > > uninstall the pyreadline library. I do not know the reason and
>     hopefully
>      > > the expert can figure it out using my previouse email which
>     includes the
>      > > debug information.
>      > >
>      > > I think this solution has one problem that is when I run the
>     ipython in
>      > > the command shell, without pyreadline it will causes problem.
>     Can I keey
>      > > the pyreadline but do not use it when I am in emacs?
>      > >
>      > >
>      >
>      > There is a commandline flag to turn pyreadline off in ipython. But I
>      > don't know if it turns pyreadline off completely. I believe there is
>      > some import magic that always imports readline if it is available
>     even
>      > if completion and such things are not enabled.
>      >
>      > There used to be some code to deal with emacs in
>      > pyreadline/console/console.py but it seems to have fallen away.
>      > I don't know if it is relevant to your problem. But you could try
>     to add
>      > them in again.
>      >
>      > These lines used to be in around line 377 in
>     pyreadline/console/console.py:
>      >
>      > if os.environ.has_key("EMACS"):
>      > def write_color(self, text, attr=None):
>      > junk = c_int(0)
>      > self.WriteFile(self.hout, text, len(text), byref(junk),None)
>      > return len(text)
>      > write_plain = write_color
>      >
>      > It is activated if you set an environment variable named EMACS
>      >
>      > Now I'm off for christmas and will return in january
>      >
>      > /Jörgen
>      >
> 
> 
>     ------------------------------------------------------------------------
>     「MSN クリスマス特集」今年は、最高の愛あふれるクリスマスにしません
>     か。 http://event.jp.msn.com/xmas2007/
>     <http://clk.atdmt.com/GBL/go/msnjpqjl0040000017gbl/direct/01/> 
> 
> 
> ------------------------------------------------------------------------
> 「MSN クリスマス特集」今年は、最高の愛あふれるクリスマスにしませんか。 
> http://event.jp.msn.com/xmas2007/ 
> <http://clk.atdmt.com/GBL/go/msnjpqjl0040000017gbl/direct/01/>



More information about the IPython-user mailing list