<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi, Jorgen,<BR> <BR>I am very glad to make this work and it really took me a lot of time. Unfortunately, I do not know how to generate patch and use svn. However, since the change is very straight forward, I attached this file with email. Please put back the change in future pyreadline release.<BR> <BR>The emacs environment is set by the emacs automatically. I did not do anything.<BR> <BR>Thanks<BR> <BR>Frank<BR><BR>> Date: Fri, 4 Jan 2008 19:13:14 +0100<BR>> From: jorgen.stenarson@bostream.nu<BR>> To: fw3@hotmail.co.jp<BR>> CC: ipython-user@scipy.org<BR>> Subject: Re: [IPython-user] Finally, ipython works in emacs<BR>> <BR>> wang frank skrev:<BR>> > I have fixed the problem. After adding the code at line 380, I also need <BR>> > to add WriteFile at 149. It is great to make this work.<BR>> > <BR>> > How to setup the EMACS environment in ipython? Why these codes have been <BR>> > removed from pyreadline?<BR>> > <BR>> > Thanks<BR>> > <BR>> > Frank<BR>> I'm happy to hear you got it to work. I think the code disappeared in <BR>> when we did some code reorganization a while back. And since I don't use <BR>> emacs I never realized it.<BR>> <BR>> The purpose of the EMACS environent variable test is that you should be <BR>> able to set that variable from emacs before starting ipython thus <BR>> ensuring that this code only runs if ipython is launched from emacs. I <BR>> don't know how to do this in emacs so if you have some other idea on how <BR>> to achieve the same goal please let me know.<BR>> <BR>> If possible please send a patch file for your changes generated by svn <BR>> diff. (Don't forget to svn up first)<BR>> <BR>> /Jörgen<BR>> <BR>> <BR>> <BR>> > <BR>> > <BR>> > ------------------------------------------------------------------------<BR>> > From: fw3@hotmail.co.jp<BR>> > To: jorgen.stenarson@bostream.nu<BR>> > Date: Thu, 20 Dec 2007 23:27:29 +0000<BR>> > CC: ipython-user@scipy.org<BR>> > Subject: Re: [IPython-user] Finally, ipython works in emacs<BR>> > <BR>> > Thanks for the help.<BR>> > <BR>> > I have added the code into the console.py as<BR>> > def write_color(self, text, attr=None):<BR>> > junk = c_int(0)<BR>> > self.WriteFile(self.hout, text, len(text), byref(junk),None)<BR>> > return len(text)<BR>> > write_plain = write_color<BR>> > <BR>> > I did not put the EMACS environment check since I do not know how.<BR>> > It does not fix the problem. After I added the code and install the<BR>> > pyreadline, the Out[] prompt disappeared. After I quit the ipython,<BR>> > I got the same error:<BR>> > <BR>> > <BR>> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit<BR>> > (Intel)] on win32<BR>> > Type 'help', 'copyright', 'credits' or 'license' for more information.<BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > ERROR - failed to write data to stream:<BR>> > <pyreadline.console.console.Console object at 0x0133BBB0><BR>> > Process Python finished<BR>> > <BR>> > <BR>> > > Date: Thu, 20 Dec 2007 21:41:17 +0100<BR>> > > From: jorgen.stenarson@bostream.nu<BR>> > > To: fw3@hotmail.co.jp<BR>> > > CC: ipython-user@scipy.org<BR>> > > Subject: Re: [IPython-user] Finally, ipython works in emacs<BR>> > ><BR>> > > wang frank skrev:<BR>> > > > I have finally made the ipython works in emacs. The solution is to<BR>> > > > uninstall the pyreadline library. I do not know the reason and<BR>> > hopefully<BR>> > > > the expert can figure it out using my previouse email which<BR>> > includes the<BR>> > > > debug information.<BR>> > > ><BR>> > > > I think this solution has one problem that is when I run the<BR>> > ipython in<BR>> > > > the command shell, without pyreadline it will causes problem.<BR>> > Can I keey<BR>> > > > the pyreadline but do not use it when I am in emacs?<BR>> > > ><BR>> > > ><BR>> > ><BR>> > > There is a commandline flag to turn pyreadline off in ipython. But I<BR>> > > don't know if it turns pyreadline off completely. I believe there is<BR>> > > some import magic that always imports readline if it is available<BR>> > even<BR>> > > if completion and such things are not enabled.<BR>> > ><BR>> > > There used to be some code to deal with emacs in<BR>> > > pyreadline/console/console.py but it seems to have fallen away.<BR>> > > I don't know if it is relevant to your problem. But you could try<BR>> > to add<BR>> > > them in again.<BR>> > ><BR>> > > These lines used to be in around line 377 in<BR>> > pyreadline/console/console.py:<BR>> > ><BR>> > > if os.environ.has_key('EMACS'):<BR>> > > def write_color(self, text, attr=None):<BR>> > > junk = c_int(0)<BR>> > > self.WriteFile(self.hout, text, len(text), byref(junk),None)<BR>> > > return len(text)<BR>> > > write_plain = write_color<BR>> > ><BR>> > > It is activated if you set an environment variable named EMACS<BR>> > ><BR>> > > Now I'm off for christmas and will return in january<BR>> > ><BR>> > > /Jörgen<BR>> > ><BR>> > <BR>> > <BR>> > ------------------------------------------------------------------------<BR>> > 「MSN クリスマス特集」今年は、最高の愛あふれるクリスマスにしません<BR>> > か。 http://event.jp.msn.com/xmas2007/<BR>> > <http://clk.atdmt.com/GBL/go/msnjpqjl0040000017gbl/direct/01/> <BR>> > <BR>> > <BR>> > ------------------------------------------------------------------------<BR>> > 「MSN クリスマス特集」今年は、最高の愛あふれるクリスマスにしませんか。 <BR>> > http://event.jp.msn.com/xmas2007/ <BR>> > <http://clk.atdmt.com/GBL/go/msnjpqjl0040000017gbl/direct/01/><BR>> <BR><BR><br /><hr />出会いがない、と嘆いているあなたにぴったりの恋人探し!まずは無料検索! <a href='http://clk.atdmt.com/GBL/go/msnjpqjl0040000020gbl/direct/01/' target='_new'>http://match.jp.msn.com/channel/index.aspx?avo=1&trackingid=1034447</a></body>
</html>