On Mon, Feb 21, 2011 at 10:33 AM, Mike Orr <[email protected]> wrote: > On Sun, Feb 20, 2011 at 3:24 PM, Fred McLain <[email protected]> wrote: >> The unique "feature" of Python that brought this up is that the syntax >> depends on the white space characters that form the indent level for the >> block structure. I.E. you don't have a brace/begin to tell you which code >> block you are in. Additional complications include variable numbers of >> space characters for a given block level. > > I think that when the Python compiler tokenizes the source, it > converts the implied levels into "indent" and "dedent" tokens, which > would be the same as C's braces { }. You can't use those with the > current Python compiler, but it may not be too difficult to derive a > compiler that did -- if you found a compiler programmer, of course. > Although that would work only with your own modules, not those that > were already written.
No need to do all of that. Would probably only take ~1k lines to write a gedit plugin that would give exactly what's wanted here, and you'd never have to leave Python to do it. Basic idea: On a hotkey press, grab the current document and line, the tab width, and whether you're using spaces or tabs. Count the number of appropriate characters, divide it by the width as needed, and send that number to Festival. Geremy Condra
