On Wed, 16 Jul 2008 08:04:42 +0200 Joerg Desch jd.vvd@web.de wrote:
As I could read in the Scintilla docs (your link), Scintilla supports both, real tab-width and indentation-with.
The difference is (or should be), that tabs are some kind of "compression". Tabs are normally used without a special file type in mind.
Indentation is a more logical thing. The indentation depends on the file type and the logical content (surrounding the cursor). So indentation uses whitespaces (and so tabs) to indent the line to this logical position.
For example: Writing a simple C-function, the indentation is a multiple of 4.
void foo ( int i ) { if ( i>0 ) [next_command]
OK, I think I understand. So if tab width is set to 8, then in the example above it would use 4 spaces for the if command, but for the next command it would use a tab instead of 8 spaces.
This seems to be what the GTK code does (e.g. gtkfilechooserdefault.c), it looks like their indent width is 2 spaces, and tabs are equivalent to 8 spaces (but sometimes they don't bother with tabs even though there are >8 spaces).
Another example is Emacs. It uses indentation for "hanging arguments" too.
void foo ( int i ) { if ( i>0 ) some_function_call(long_parameter_name_as_example, second_long_parameter);
Pressing "indent" in Emacs at "second_long_parameter" indents the line according to the first parameter. This is not a multiple of 4. Thats what I mean with "logical thing".
When tabs are enabled, most editors I know uses tabs within whitespaces to realise the indentation. In the above example, the indentation would be done with three tabs and three spaces.
Geany allows a mixture of tabs and spaces when tabs are enabled.
To obtain tabs (if enabled) it would be good if 8 (or x) spaces are replaced with a tab right after the indentation (Ctrl-I). What is the right way to do this? Can you point me to an file/function which should be patched?
I don't know what you mean, I'm not sure why we need to replace spaces/tabs.
It's just for consistency reasons. If tabs are enabled, they should be used.
This is the point that confused me before, Geany's tab Indent Type setting makes tabs = indentation. You would want a different setting which applies when the space Indent Type is enabled - something like 'Compress spaces to tabs'.
To resume this thread:
Geany currently configures tabs with SCI_SETTABWIDTH. To separate tabs and indentation, the configuration dialog should ask for the indentation width and set SCI_SETINDENT with this value.
It might not be this simple, Geany's codebase expects tabs to mean indentation width. But I think this is worth implementing. I'll add a TODO item.
There must be a hook to change SCI_SETINDENT for each filetype.
This could be implemented, a filetype-based indent width.
would be nice, if the configuration dialog would support SCI_SETTABINDENTS(bool) too.
Why?
Thanks for your answers. I think I'll have a look at this as soon as I have some spare time.
Thanks for explaining this, I didn't understand it before ;-)
Regards, Nick