[Geany] UNindent close of statement

John Yeung gallium.arsenide at xxxxx
Fri Aug 6 07:46:25 UTC 2010


On Thu, Aug 5, 2010 at 6:54 PM, Jiří Techet <techet at gmail.com> wrote:
> By coincidence, I have been playing with TextMate under MacOS and it
> has an extremely elegant system of indent detection, see:
>
> http://manual.macromates.com/en/appendix#indentation_rules

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:
> 1. 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.

> 2. 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
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.

For the record, Python should be a very easy language to get right
with the autoindentation, and it is kind of surprising how many
editors still manage to mess it up.  If I recall correctly, last time
I used Geany (several versions ago), it handled Python quite well
(either perfectly, or only quite unlikely situations could mess it
up).

> I wonder how much illegal/unethical it is to copy
> configuration options from a commercial editor...

In my opinion, it is not unethical at all.  I would not want to be a
part of copying or stealing someone else's not-open-source source
code, but I have no problem with the idea of reimplementing a
published spec.  I don't know if the law agrees with me.

John



More information about the Users mailing list