On Fri, Aug 6, 2010 at 09:46, John Yeung gallium.arsenide@gmail.com wrote:
On Thu, Aug 5, 2010 at 6:54 PM, Jiří Techet techet@gmail.com wrote:
By coincidence, I have been playing with TextMate under MacOS and it has an extremely elegant system of indent detection, see:
It does seem elegant. I actually have wondered why there aren't more editors that do this, and I had always thought maybe it was just not as fast to use regexes. But I could be wrong, and even if regexes are indeed slower, they might certainly be Fast Enough (tm) on today's computers.
Some observations from playing with TextMate:
- increaseNextLinePattern is not normally used, see
http://ticket.macromates.com/show?ticket_id=425D3D1C
so we could drop it.
I disagree. The bracketless if-statement (or other single-line "blocks") is extremely common, and SciTE has relatively ugly code just to handle that case.
Well, TextMate doesn't use them either. The problem is that you may get too "eager" indents (see the above link) which is, as you correctly say below, worse than not indenting at all. What I like about geany is that it doesn't try to be too smart, which is the problem of other editors that in 95pct do the smart thing correctly but those 5pct cases are extremely annoying.
- decreaseIndentPattern appears to be matched against the current
line after every single keypress (e.g. once you type ':' in "elsif:" in python, the line containing it unindents). Apparently regex matching is fast enough to do this. The other patterns are matched only when enter is pressed.
Well, Python uses elif, not elsif. But aside from that, Python is a
Typical 1AM email :-).
very special case. It would be more natural for Python to not have any automatic decreases, since your elif might apply to not the latest if but rather a previous one (more than one level deep). In Python, it really makes sense for the programmer to explicitly decide the amount of de-indentation, and Python programmers are used to making this decision for every single block. It would be very weird to have elif be an oddball that doesn't fall in line with everything else in the language.
Agree - this is what TextMate does but geany probably shouldn't do that.
Jiri