[Geany] UNindent close of statement

Lex Trotman elextr at xxxxx
Fri Aug 6 08:42:20 UTC 2010


On 6 August 2010 17:46, John Yeung <gallium.arsenide at gmail.com> wrote:
> 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.

Glib regex uses PCRE which seems to have reasonable performance (From
Boost Regex performance comparisons with other regex engines) where
times are sub .001 sec for files about the length of Geany source
files.  I'd say that was Fast Enough (C).

>
>> 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,

I agree with that, Geany does my Python fine because it doesn't get in
the way, but some may like additional "help".  So long as I can turn
it off per language too.

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.

Too complicated since it is likely that it depends on which country
you are in as to legality.  But I would observe that there is likely
to be only one optimal regex for each language for each setting so
even from first principles you will likely get the same answer ;-)

Cheers
Lex

>
> John
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>



More information about the Users mailing list