On 14/12/2007, Enrico Tröger enrico.troeger@uvena.de wrote:
On Thu, 13 Dec 2007 11:43:53 +0000, "Catalin Marinas" catalin.marinas@gmail.com wrote:
snip The indentation is done with spaces rather than a combination of spaces and tabs. I find this more useful since it doesn't break the
I like this feature and I think we should add it. But before, please change the code so that it respects the document->use_tabs setting. Inserting only spaces is a no go, I prefer to use tabs for indentation. You (and many other people) like to indent only with spaces, therefore there is an option to choose whether to use tabs or not. Your code should take care of this. When not using tabs, simply add only spaces, a mix of tabs and spaces if the user has chosen to use tabs. I didn't have a look at it but get_whitespace() might be useful.
My comment was probably a bit misleading, I use tabs indentation myself as well.
The patch uses tabs for the first part of the line indentation (it actually copies the previous one). If there is an additional indentation for an open bracket, it uses spaces for the rest of the line.
For example (using dots instead of spaces below and spaces for the corresponding tab), with 4-spaces per tab:
void some_func(void) { if (a == 10 && ....b == 20) {
} }
viewing the code in an editor set to 8 spaces per tab, the "if" conditions are still aligned (I view geany code with 8 spaces per tab and the ifs don't look at nice :-)):
void some_func(void) { if (a == 10 && ....b == 20) {
} }
If I generate a tab instead of spaces on the first editor (with 4 spaces per tab), viewing the code in the second editor would look like below:
void some_func(void) { if (a == 10 && b == 20) {
} }
hence, the "if" conditions are no longer aligned.
While I can argue more about this (emacs also does the wrong thing IMHO), I can probably change the patch to use get_whitespace() or something similar.