Thanks for the rundown. It shouldn't be too hard - most of the stuff
you mentioned is already there in a half-done way, just need to clean
it up. With luck, I'll extract the python-specific bits as I go, so it
can be merged upstream. I'll try to keep the mailing list posted if I
finish up.

On May 12, 4:53 pm, Bob Farrell <[email protected]>
wrote:
> Hi Pavel,
>
> On Tue, May 12, 2009 at 11:01:05AM -0700, Pavel Panchekha wrote:
>
> > I'd like to write a shell for oranj similar to bpython. I've already
> > written a pygments parser for it, and writing completion shouldn't be
> > too hard. What else needs to be changed before I can get a full
> > bpython-esque shell for oranj? Is there anything in curses to fiddle
> > with, for example? (I tried just replacing PythonLexer with
> > OranjLexer, but it doesn't seem to work)
>
> > Oranj:http://github.com/pavpanchekha/oranj/tree/master
> > OranjLexer:http://dev.pocoo.org/projects/pygments/ticket/409
>
> I tried downloading it and running it (seems it depends on 2.6) but, since I
> didn't have readline built against my 2.6 build, it errored - you try to 
> import
> readline, pass on an ImportError and then refer to it anyway.
>
> Anyway, so I've rebuilt my python2.6 and got it working.
>
> It looks to me like you'd be best off using bpython pretty much as-is and
> providing something similar to the "code" module for oranj, i.e. a way of
> executing oranj code from any Python program. Here's how bpython uses it:
>
>     def push(self, s):
>         """Push a line of code onto the buffer so it can process it all
>         at once when a code block ends"""
>         s = s.rstrip('\n')
>         self.buffer.append(s)
>
>         try:
>             more = self.interp.runsource("\n".join(self.buffer))
>         except SystemExit:
>             # Avoid a traceback on e.g. quit()
>             self.do_exit = True
>             return False
>
>         if not more:
>             self.buffer = []
>
>         return more
>
> "self.interp" in this case is one of these:
>
>     class Interpreter(code.InteractiveInterpreter):
>
> So, if you can make a Python module that mimics the code module (at least the
> part of it that bpython uses) then you should be able to swap out the Python
> code module with your one, change the lexer it being used, do your own
> autocompletion routines and everything should hopefully Just Work.
>
> You might also want to try to mimic the behaviour of inspect.getargspec, since
> bpython uses that to show what arguments a function is expecting.
>
> I can't think of anything else right now, but if you have any more questions
> feel free to ask. Also if you think you can make the necessary changes to
> bpython and still keep it 100% compatible with its current functionality (i.e.
> if you can make it so anyone could come along and plug in their own module to
> make it work with some other language) then I'd be happy to bring that
> upstream. Otherwise, you are of course encouraged to fork it. :)
>
> Good luck !
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"bpython" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/bpython?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to