After using Geany for a while, I run into trouble with the Geanys philosophy of indentation.
Geany use the tab key and tab character to do its indentation. The tab with is setup globally for all types of files.
Whats the reason for using a tab to indent a line?
I must say I hate it and it is really hard to live with it.
Is it possible to tell Geany to indent using an "indent width" (on a filetype base!) and than (optionally) replace multiple spaces with tabs?
I'm a long time emacs user and its auto formatting capabilities are unbeatable. So it's really hard to switch...
On Fri, 11 Jul 2008 09:25:11 +0200 Joerg Desch jd.vvd@web.de wrote:
After using Geany for a while, I run into trouble with the Geanys philosophy of indentation.
Geany use the tab key and tab character to do its indentation. The
You can also use Ctrl-I/Ctrl-U - see the keybindings preferences.
tab with is setup globally for all types of files.
Whats the reason for using a tab to indent a line?
Under Edit->Preferences, editor tab, indentation frame, set Type to Spaces and this should do what you want. The 'Tab width' pref should be renamed to 'Indent width', as it works for spaces too.
Is it possible to tell Geany to indent using an "indent width" (on a filetype base!) and than (optionally) replace multiple spaces with tabs?
We could add a filetype-based indent width, a project-based indent width, and maybe an auto-detect indent width preference. Patches welcome.
In SVN there's a 'Document->Replace spaces by tabs' option.
Regards, Nick
On Fri, 11 Jul 2008 12:15:14 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Fri, 11 Jul 2008 09:25:11 +0200 Joerg Desch jd.vvd@web.de wrote:
After using Geany for a while, I run into trouble with the Geanys philosophy of indentation.
Geany use the tab key and tab character to do its indentation. The
You can also use Ctrl-I/Ctrl-U - see the keybindings preferences.
Yes, I know. Using Ctrl-I insert a tab width. This is, because I'm forced to use a tab width of 8, because all other developers (me too) in our company are using the "official" tab width.
Whats the reason for using a tab to indent a line?
Under Edit->Preferences, editor tab, indentation frame, set Type to Spaces and this should do what you want.
Partly, because of the tab width of 8.
The 'Tab width' pref should be renamed to 'Indent width', as it works for spaces too.
Not only this, IMO it is necessary to distinguish between tab width and indentation width. Does Scintilla support this differentiation?
Is it possible to tell Geany to indent using an "indent width" (on a filetype base!) and than (optionally) replace multiple spaces with tabs?
We could add a filetype-based indent width, a project-based indent width, and maybe an auto-detect indent width preference. Patches welcome.
Ok. ;-)
I've started to play with Lua to implement Emacs/Vim like modelines. This would be a good reason to start with Geany patches.... ;-)
Is the support for "tab width" and "indentation width" a different Scintilla configuration? Or is it necessary to add this to the Geany core?
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?
Thanx for your answer.
On Fri, 11 Jul 2008 14:00:51 +0200 Joerg Desch jd.vvd@web.de wrote:
On Fri, 11 Jul 2008 12:15:14 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
The 'Tab width' pref should be renamed to 'Indent width', as it works for spaces too.
Not only this, IMO it is necessary to distinguish between tab width and indentation width. Does Scintilla support this differentiation?
There's SCI_SETINDENT vs. SCI_SETTABWIDTH, but I haven't tried it: http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_SETINDENT
Is the support for "tab width" and "indentation width" a different Scintilla configuration? Or is it necessary to add this to the Geany core?
What should the difference be?
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.
Regards, Nick
On Fri, 11 Jul 2008 15:00:38 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Not only this, IMO it is necessary to distinguish between tab width and indentation width. Does Scintilla support this differentiation?
There's SCI_SETINDENT vs. SCI_SETTABWIDTH, but I haven't tried it: http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_SETINDENT
Thanks for the link.
Is the support for "tab width" and "indentation width" a different Scintilla configuration? Or is it necessary to add this to the Geany core?
What should the difference be?
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 ) ....
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.
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.
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. There must be a hook to change SCI_SETINDENT for each filetype. Futhernore, it would be nice, if the configuration dialog would support SCI_SETTABINDENTS(bool) too.
Thanks for your answers. I think I'll have a look at this as soon as I have some spare time.
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
On Fri, 18 Jul 2008 12:51:44 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
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.
Right. That's it.
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'.
Right.
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.
Thanks. That was my thought too. To start contributing to Geany, this hack would be to big. I think I start with writing a plugin. ;-)
would be nice, if the configuration dialog would support SCI_SETTABINDENTS(bool) too.
Why?
Just be to compatible with the current way of doing indents.
On Fri, 18 Jul 2008 14:23:53 +0200 Joerg Desch jd.vvd@web.de wrote:
would be nice, if the configuration dialog would support SCI_SETTABINDENTS(bool) too.
Why?
Just be to compatible with the current way of doing indents.
I guess anyone with files with tabs in but Spaces Indent Type enabled could set a tab width equal to the indent width for compatibility.
I think the SCI_SETTABINDENTS message just tells Scintilla to indent instead of inserting a tab when the tab key is pressed, so this could be left on for every case. http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_SETTABINDENTS
Regards, Nick
On Wed, 16 Jul 2008 08:04:42 +0200 Joerg Desch jd.vvd@web.de wrote:
Not only this, IMO it is necessary to distinguish between tab width and indentation width.
This is now implemented in SVN as a 'Tabs and Spaces' indent type preference and per-document setting, plus a Tab Width pref (the old pref is now called Indent Width). The main editing actions should work as expected in the new mode, but some of Geany's code insertion features (e.g. default file templates) might still use tabs. Feel free to file bugs/requests to improve things further (or post here).
would be nice, if the configuration dialog would support SCI_SETTABINDENTS(bool) too.
Maybe you're aware that there's a hidden pref to enable this (see the manual). I'm not sure why it's off by default? But maybe it needs a GUI pref.
Regards, Nick