On 10/23/07, Rob McMullen <[EMAIL PROTECTED]> wrote: > > Chris Barker pointed me to a python implementation of the TeX word > wrapping algorithm: > > http://www.ics.uci.edu/~eppstein/software.html
Yep, David's implementation works like a charm (he sometimes covers it in his intro algorithms course, or at least he did the first time I TA'd for him), though the textwrap module in Python may be what people expect in terms of "wrap this paragraph of text to X lines". > Next project other than that is getting the > tab-to-indent/electric-return to work correctly. I've stepped through > the elisp comments in emacs, but it would be cool if there were > something in python already debugged. IDLE has > newline_and_indent_event and smart_indent_event that seem to do the > right thing, but of course that's written for Tkinter. Anyone have an > implementation based on the STC that I can steal^H^H^H^H^Hborrow? I'd > like one that works as well as the emacs version and can handle things > like indenting to the right place in the middle of a list or dict > definition, and what's currently in peppy is little better than just > indenting to the previous line's indentation. Worse, in fact, because > it gets it wrong about 20% of the time. PyPE does pretty well in terms of auto indent on return for Python code, including the handling of open parens, curly braces, and square braces (tuple, list, or dictionary definitions). It doesn't so much handle closing stuff, but that's only because it errs on the side of doing less work. Someone who wants it to be better could easily add that handling (there may even be stubs to do so, it's been so long since I mucked with that code). - Josiah
