https://sourceforge.net/p/joe-editor/mercurial/ci/default/tr...
Create a histogram of the indentation of the last 250 lines of the file (on the theory that there are more comments at the beginning of the file). The GCD of the three most popular indentations is selected. This way one oddly indented line does not screw it up. It does not ignore single space indentations, since I used to use that. Instead it ignores lines which begin with comment characters, like asterisk or '/'. It can still be confused by block comments like this:
/* first
second
third */
The editor does in theory know the syntax, so it could be enhanced to just ignore comment lines.Also, it determines if the user prefers to use tabs or spaces for indentation.