I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up: - Keybindings for everything approach: Improve the "smart indent" key binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself. - Strip on return approach: Create a global/project settings option to strip whitespace from the current line upon striking return.
Both of these approaches introduce a problem though. If I remove whitespace from a line, I return back to a column position of zero. The auto-indent modes I've used will therefore make the following line 0 columns indented. One solution to this could be to auto-indent up to the last indented line, if available. I'm sure there are other solutions to this though.
So I propose three questions in this email. First: Is this something I should even be making for an upstream core feature, or should it be in a plugin? Second: Which of my two approaches seems more reasonable? Third: Are there any other solutions anyone has to the final problem I mentioned, or will the solution I proposed suffice?
Sorry for the length of this e-mail, everyone.
Am 14.03.2013 05:42, schrieb Braden Walters:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
2) already exists in Geany. And when it does so going to the line above or below restores the cursors original column position (so you shouldn't "return back to a column position of zero").
Check Preferences->Editor->Newline strips trailing spaces. It does not seem to be on by default.
Best regards.
Hi Braden,
Indentation, sigh. Search the developer mailing list archives and IRC archives for indentation, that should give you enough reading for a while, so I can get on with a little top-posted rant :). More specific comments below.
There have been at least two attempted improvements of the indentation system that I know of. This lead me to survey other editors capabilities and the idioms used in various languages.
My conclusion is that Geany devs are no different to most, they like and use a limited range of languages and indentation styles. Therefore the techniques they propose usually provide some benefit for their preferred language/style, but these techniques also often provide negative benefits for other use-cases. And there are always more use-cases that are *not* the particular developers personal favourite :)
When I looked at other editors I realisedt that most indentation schemes are *not* local syntax based, even if at first glance they seem to be. In actual fact they are based on the language grammar. The editors that did a good job of indentation were those that evaluated the language grammar, for example Eclipse, Netbeans and lately Emacs.
This means that no scheme is going to handle many languages, and simple schemes based on the indentation/contents of the previous line and the current line will not work much of the time, since the grammar production that actually controls the indentation is not on those lines.
In my opinion, implementing such schemes is a waste of developer time since they won't work fully, and so some way of working around them is needed. Why waste time doing something that won't work much of the time and then providing a way for someone else to waste their time correcting it?
Instead all Geany should do is provide a way for language specific plugins to provide indentation services. This interface should be as general as possible, because the Geany developers do *not* understand the schemes and idioms of languages and styles other than their favourites.
The only indentation schemes built-in to Geany should be the very simple language independent ones such as "manual" or "same as last line".
</rant>
On 14 March 2013 15:42, Braden Walters meoblast@aol.com wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace
I am not sure why you will have trailing whitespace when you use current character? That would only occur on blank lines, and can be removed by the "strip trailing whitespace on save" option or <ctrl>+<shift>+backspace (see below).
that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
It will give you lots of VCS noise the first time you do it, yes, but from then on it should be ok. Just do one commit just to strip the trailing whitespace, and then go on with your changes in whitespace free bliss :)
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
It currently takes two keystrokes I admit
<ctrl>+<shift>+backspace <ctrl>+<shift>+delete
but if you know you are at the end only the first is required.
- Strip on return approach: Create a global/project settings option to strip
whitespace from the current line upon striking return.
menu->preferences->editor->features->Newline strips trailing spaces
Both of these approaches introduce a problem though. If I remove whitespace from a line, I return back to a column position of zero. The auto-indent modes I've used will therefore make the following line 0 columns indented. One solution to this could be to auto-indent up to the last indented line, if available. I'm sure there are other solutions to this though.
If you remove *leading* whitespace then yes it will go to position zero, but why would you do that? If the indentation is wrong, no current mechanism in Geany will correct it, corrections are totally manual. You need to use a styler like astyle or uncrustify for that. You might be able to arrange a custom command to do that with the selection (<ctrl>+a for all:) but don't try and use astyle for that it doesn't work.
So I propose three questions in this email. First: Is this something I should even be making for an upstream core feature, or should it be in a plugin?
Well, as my <rant> says I think it should be a plugin, but at the moment Geany does not have an interface for an indentation plugin, you would have to process every character, and that is maybe a bit inefficient.
Second: Which of my two approaches seems more reasonable?
TBH I'm not sure what you actually proposed to change?
Third: Are there any other solutions anyone has to the final problem I mentioned, or will the solution I proposed suffice?
As said above, not sure why you would do that?
Sorry for the length of this e-mail, everyone.
No problem, as you can gather its engaged many of us in many discussion and proposals.
Cheers Lex
-- Sincerely, Braden Walters
Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
On 03/13/2013 09:42 PM, Braden Walters wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen examples of "where whitespace has been left all around some files". Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace auto-generated when I leave blank lines. So if I am at one tab indentation and I type return, return, the line above the caret contains one tab only.
The editor I used when I developed on Windows, Codewright, allowed moving the caret into virtual space, as does Geany. But when I hit return, Codewright put the caret in virtual space on the new line. Only when I typed a character did Codewright fill in the virtual space from bol using my chosen indentation policy. So if I am at one tab indentation and I type return, return, the line above the caret is completely empty. The drawback is that the caret is at the left margin, since the previous line's indentation was zero. But I found that preferable to Geany's. I always felt Codewright's behavior could have been improved to eliminate even this imperfection.
I did play around with Geany's various white-space removal options. But when submitting patches I was worried that the group to whom I submitted the patch might object to gratuitous changes. Also, I tend to save often, and each time I would save, the caret would snap back one and the space I typed after the last token would be lost. Irritating.
I vote for Codewright's approach, with or without the improvement.
Roger
Both of these approaches introduce a problem though. If I remove whitespace from a line, I return back to a column position of zero. The auto-indent modes I've used will therefore make the following line 0 columns indented. One solution to this could be to auto-indent up to the last indented line, if available. I'm sure there are other solutions to this though.
So I propose three questions in this email. First: Is this something I should even be making for an upstream core feature, or should it be in a plugin? Second: Which of my two approaches seems more reasonable? Third: Are there any other solutions anyone has to the final problem I mentioned, or will the solution I proposed suffice?
Sorry for the length of this e-mail, everyone.
Le 14/03/2013 14:41, Roger Booth a écrit :
On 03/13/2013 09:42 PM, Braden Walters wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen examples of "where whitespace has been left all around some files". Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace auto-generated when I leave blank lines. So if I am at one tab indentation and I type return, return, the line above the caret contains one tab only.
As Thomas pointed out, there is an option to automatically remove trailing whitespace upon return, which IIUC would do what you want.
On 03/14/2013 06:50 AM, Colomban Wendling wrote:
Le 14/03/2013 14:41, Roger Booth a écrit :
On 03/13/2013 09:42 PM, Braden Walters wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen examples of "where whitespace has been left all around some files". Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace auto-generated when I leave blank lines. So if I am at one tab indentation and I type return, return, the line above the caret contains one tab only.
As Thomas pointed out, there is an option to automatically remove trailing whitespace upon return, which IIUC would do what you want.
The part of my reply that you removed explained why the
option to automatically remove trailing whitespace upon return
doesn't do what I want.
Roger
Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Le 14/03/2013 14:58, Roger Booth a écrit :
On 03/14/2013 06:50 AM, Colomban Wendling wrote:
Le 14/03/2013 14:41, Roger Booth a écrit :
On 03/13/2013 09:42 PM, Braden Walters wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen examples of "where whitespace has been left all around some files". Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace auto-generated when I leave blank lines. So if I am at one tab indentation and I type return, return, the line above the caret contains one tab only.
As Thomas pointed out, there is an option to automatically remove trailing whitespace upon return, which IIUC would do what you want.
The part of my reply that you removed explained why the
option to automatically remove trailing whitespace upon return
doesn't do what I want.
Not really, what I understand from the rest is that you don't like removing all trailing whitespaces from the whole document (like the "Document->Strip trailing whitespace" or option "Strip trailing whitespace on save" does). The option Thomas mentioned only removes whitespaces from the line you hit return on, so it would only modify the trailing spaces around the code you actually touched.
Regards, Colomban
On 03/14/2013 07:09 AM, Colomban Wendling wrote:
Le 14/03/2013 14:58, Roger Booth a écrit :
On 03/14/2013 06:50 AM, Colomban Wendling wrote:
Le 14/03/2013 14:41, Roger Booth a écrit :
On 03/13/2013 09:42 PM, Braden Walters wrote:
I had some ideas for some keybindings or settings that could help with some indentation issues. I'm willing to implement them myself, but I wanted to see what the other developers think first. First, the reason why I want to even write these.
I work on multiple projects, some of which have multiple developers and some where whitespace has been left all around some files. I generally use manual indentation (no auto-indent at all), and I can't help but think there's something better I could do. I could use the current character indent, but then I'll have trailing whitespace everywhere, or I'll have to backspace that out manually (sort of defeats the purpose). I could turn on "Strip trailing whitespace", but that's going to modify a lot of lines I never really changed.
Here are some solutions I've thought up:
- Keybindings for everything approach: Improve the "smart indent" key
binding to just use the global (or project if available) settings for auto-indentation upon striking the key combination. Then, create a key binding that removes all contents from a line, but does not delete the line itself.
- Strip on return approach: Create a global/project settings option to
strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen examples of "where whitespace has been left all around some files". Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace auto-generated when I leave blank lines. So if I am at one tab indentation and I type return, return, the line above the caret contains one tab only.
As Thomas pointed out, there is an option to automatically remove trailing whitespace upon return, which IIUC would do what you want.
The part of my reply that you removed explained why the
option to automatically remove trailing whitespace upon return
doesn't do what I want.
Not really, what I understand from the rest is that you don't like removing all trailing whitespaces from the whole document (like the "Document->Strip trailing whitespace" or option "Strip trailing whitespace on save" does). The option Thomas mentioned only removes whitespaces from the line you hit return on, so it would only modify the trailing spaces around the code you actually touched.
Regards, Colomban _______________________________________________ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
My point was that there is no need for the editor to remove whitespace if the editor does not auto-generate it in the first place. That's how Codewright worked, and it seemed to work better than Geany's various options.
Roger
On Thu, 14 Mar 2013 09:03:40 -0700 Roger Booth rbooth@kabooth.com wrote:
My point was that there is no need for the editor to remove whitespace if the editor does not auto-generate it in the first place. That's how Codewright worked, and it seemed to work better than Geany's various options.
You can write a plugin that connects to Geany "key-press-event"; you can send anything to Scintilla using scintilla_send_message() and the other sci wrappers - see GeanyExtraSel for example of both.
That seems enough to try implementing indentation via virtual space. Unless the plugin does really nasty hacks, or slows Geany significantly, it's likely to be accepted, or at least mentioned as link in geany.org's "Other Plugins".
On 03/14/2013 11:00 AM, Dimitar Zhekov wrote:
On Thu, 14 Mar 2013 09:03:40 -0700 Roger Booth rbooth@kabooth.com wrote:
My point was that there is no need for the editor to remove whitespace if the editor does not auto-generate it in the first place. That's how Codewright worked, and it seemed to work better than Geany's various options.
You can write a plugin that connects to Geany "key-press-event"; you can send anything to Scintilla using scintilla_send_message() and the other sci wrappers - see GeanyExtraSel for example of both.
That seems enough to try implementing indentation via virtual space. Unless the plugin does really nasty hacks, or slows Geany significantly, it's likely to be accepted, or at least mentioned as link in geany.org's "Other Plugins".
The code that back-fills would have to be fixed. Currently Geany doesn't do it correctly. With indentation set to tabs, Geany fills the virtual space with spaces. I've suspected that for a while; this thread just now caused me to verify. Guess its time to submit a bug report.
Roger
As a reply to everyone:
I now see what Thomas Martitz wrote, and I'm surprised I overlooked the newline strip whitespace option. This will help me out a bit, but I also understand Roger Booth's comments about indentation in virtual space. Although, in the code I work with at least, it's rare that I would notice a difference between the existing newline strip option and that, but I definitely think it'd be useful. If you do decide to make that a plugin, I'd be glad to help.
To Lex Trotman's "rant", I have to say I totally agree but also sort of disagree. Doing auto-indentation by using the full language grammar is definitely good to have, but it presents some problems. In every IDE I've used that does this, it allows you to configure it to some degree to work with the way you format your code, but any deviation from the norm becomes a total headache. I've always liked that Geany gives me lots of auto-complete options, but if I so desire, I can strip those options down to "only insert exactly what I type". In my opinion, keeping multiple auto-indentation styles would be better. The basic/current char methods are nice because they're very simple but provide some form of auto-indentation, but I agree that perfecting a more "complete" auto-indentation (or even auto-formating in general) system is important.
I'm going to think about all of this a bit more, and if I have any other comments or questions, I'll send another e-mail I suppose. Thanks for the replies!
On 15 March 2013 08:30, Braden Walters meoblast@aol.com wrote:
As a reply to everyone:
I now see what Thomas Martitz wrote, and I'm surprised I overlooked the newline strip whitespace option. This will help me out a bit, but I also understand Roger Booth's comments about indentation in virtual space. Although, in the code I work with at least, it's rare that I would notice a difference between the existing newline strip option and that, but I definitely think it'd be useful. If you do decide to make that a plugin, I'd be glad to help.
To Lex Trotman's "rant",
Erm, yeah, sorry about that. :)
I have to say I totally agree but also sort of
disagree. Doing auto-indentation by using the full language grammar is definitely good to have, but it presents some problems. In every IDE I've used that does this, it allows you to configure it to some degree to work with the way you format your code, but any deviation from the norm becomes a total headache.
Yes, they tend to suffer from the problem I noted, programmers cater for the methods they know, which they regard as "correct", and don't think about the methods they don't use.
I've always liked that Geany gives me lots of auto-complete options, but if I so desire, I can strip those options down to "only insert exactly what I type".
Any changes made to Geany should keep the ability to use "same as last line" and "no autoindent at all" options as well as any smart options.
In my opinion, keeping multiple auto-indentation
styles would be better. The basic/current char methods are nice because they're very simple but provide some form of auto-indentation, but I agree that perfecting a more "complete" auto-indentation (or even auto-formating in general) system is important.
Yes, I agree it is important, "housekeeping" like indentation reduces your productivity and invites differences between programmers. Even if you do it with a styler it can be forgotten. So automatic indentation is important. But it has to match your language/style or it tends to be a negative not a positive.
Cheers Lex
I'm going to think about all of this a bit more, and if I have any other comments or questions, I'll send another e-mail I suppose. Thanks for the replies!
-- Sincerely, Braden Walters
Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel