[Geany-Devel] Why smart indentation is so stupid?

Lex Trotman elextr at xxxxx
Sat Jul 26 02:29:45 UTC 2014

On 26 July 2014 05:33, Pavel Roschin <roshin at scriptumplus.ru> wrote:
> I'm very wondered how does "smart indentation" feature work. If previous line
> is empty, it removes indent assuming that single empty line is an empty indent.
> Smart indentation for multiple lines is absolutely awful: it doesn't take into
> account internal sub-indents and makes selection "flat".
> Is anybody using this?
> Under "smart" indentation people assume astyle, php-beautifier and so on:
> http://stackoverflow.com/questions/18828162/smart-auto-indentation-available-in-geany

Indentation is one of *those* issues, everybody and every language
wants to do it their way :)

Even just C/C++ has GNU, Kernel, Stroustrup, Geany and more "standard"
ways, and many well meaning projects do something else to make it
"look better".  Attempts to use simple regular expression based
techniques were easily foiled by alignment on continued expressions,
so even for simple languages like C/C++ more complete analysis is
needed as Matthew's libclang based system does.

Then the "offside" languages require specific indentation to infer
structure, of course thats Python, and as mentioned, Haskell has an
"interesting" set of rules.

The only way of supporting exactly what everyone wants is to allow
them to have their own code to do it for their "standard" and their
language (Colomban's filetype plugins).

Loading plugins as part of loading filetypes is easy (see
https://github.com/elextr/geany/tree/filetype_plugins for a technology
demonstrator I made ages ago) but no agreement was reached on the
interface between Geany and the plugin (ranging from "most indentation
done in Geany and the plugin tweaking it" to "here's the buffer, have
fun").  And that also means new languages/styles need code, not just

And of course the concern with using external Astyle, Indent and to a
lesser extent libclang, is the performance question for code that runs
whilst the user is typing, and its ability to handle incomplete
constructs (see Emacs autoindentation that happens later when you
complete a construct, very confusing).

And then there is the problem of auto-indentation whilst re-structuring code.

To summarise, its complicated, and Geany is reluctant to implement and
maintain something that makes only a marginal improvement or that has
significant downsides.

One day somebody will have a Eureka moment :)


> --
> Best regards,
> Pavel Roschin aka RPG
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel

More information about the Devel mailing list