/* e.g. if (x exists): ask (what is x?) else: ask (does x exist?) => a list with two elements input has to be starting at column 1! (call autoUnindent if unsure) */ static LS groupPythonStyleIndents(S text) { LS lines = lines(text); new LS out; int startOfBlock = 0; for i over lines: { bool indented = startsWithSpace(lines.get(i)); if (!indented) { addIfNempty(out, lines_rtrim(subList(lines, startOfBlock, i))); startOfBlock = i; } } addIfNempty(out, lines_rtrim(subList(lines, startOfBlock))); ret out; }