Hi, folks.
I recently came across some articles on the Emacs wiki about spaces vs tabs: http://www.emacswiki.org/emacs/SmartTabs http://www.emacswiki.org/emacs/TabsAreEvil
Their argument is that tabs should be used for indentation, while spaces should be used to align text when a long line is split. Makes sense to me.
Is there, or should there be, support for this idea in Geany (or more likely in a plugin)? Probably this would not be suitable for Python, of course, but it works for C-style languages.
I could probably write a Lua script that would split a long line using this idea: same number of tabs as the original, then spaces to align the new line with the last bracket on the previous one. Maybe bound to Shift+Enter.
Any thoughts?
Thrawn
On 16 July 2013 08:09, Thrawn shell_layer-geany@yahoo.com.au wrote:
Hi, folks.
I recently came across some articles on the Emacs wiki about spaces vs tabs: http://www.emacswiki.org/emacs/SmartTabs http://www.emacswiki.org/emacs/TabsAreEvil
Their argument is that tabs should be used for indentation, while spaces should be used to align text when a long line is split. Makes sense to me.
Thats one style, if you *must* use tabs then its probably the best one, since it stays aligned no matter what size a tab is considered to be. Better just not to use tabs of course, you don't actually save much in the default case of 4 spaces per tab. But I understand that editing old code would have to conform to its standard.
Is there, or should there be, support for this idea in Geany (or more likely in a plugin)? Probably this would not be suitable for Python, of course, but it works for C-style languages.
1) No there isn't, probably there should be, but... 2) There has been much discussion on the ML and several actual prototypes of improved indentation/alignment schemes that are flexible enough to address many languages (even just many C style languages is a hard problem). None of them have been sufficiently correct, enough of the time, to overcome the problems of being really annoying when they are incorrect. Therefore anything would have to be a plugin so that it can simply not be loaded if the user didn't want it. Also it would need to only operate when the correct language was being edited. 3) But there is no way to tell Geany to not apply indentation per file, so Geany will still do its thing independent of the plugin (and that includes moving } not just on enter). 4) So the plugin would have to keep changing the indentation settings in Geany to turn off Geany indentation as the user changed to/from a tab containing a C file to one containing some other language, but would somehow have to ensure that the right value is saved in the config file (not sure this is possible).
I could probably write a Lua script that would split a long line using this idea: same number of tabs as the original, then spaces to align the new line with the last bracket on the previous one. Maybe bound to Shift+Enter.
Splitting a line on user command is certainly an easier way to do it, I assume you mean last *unmatched* bracket on the line (that is not in a string or comment). Oh and don't forget C++ uses <> as brackets for templates, but don't confuse that with the places it uses them for gt and lt :)
Finally plugins should *not* bind keys by default, they have no way of knowing if the user has already bound that key to something else (and of course multiple plugins binding the same key :).
Cheers Lex
Any thoughts?
Thrawn
Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Am 16.07.2013 03:02, schrieb Lex Trotman:
- There has been much discussion on the ML and several actual
prototypes of improved indentation/alignment schemes that are flexible enough to address many languages (even just many C style languages is a hard problem). None of them have been sufficiently correct, enough of the time, to overcome the problems of being really annoying when they are incorrect. Therefore anything would have to be a plugin so that it can simply not be loaded if the user didn't want it. Also it would need to only operate when the correct language was being edited.
Bah, this "everything must be a plugin" really annoys me. Indentation is really a core feature, whether smart or not, and is nowhere extra functionality provided by external code and authors.
g-p has also shown that finding motivated plugin authors that maintain their stuff beyond the initial code drop is hard, so we should really not rely too much on plugins.
What's wrong with you accepting new code in the core?
Best regards.
On 16 July 2013 15:45, Thomas Martitz thomas.martitz@student.htw-berlin.dewrote:
Am 16.07.2013 03:02, schrieb Lex Trotman:
- There has been much discussion on the ML and several actual prototypes
of improved indentation/alignment schemes that are flexible enough to address many languages (even just many C style languages is a hard problem). None of them have been sufficiently correct, enough of the time, to overcome the problems of being really annoying when they are incorrect. Therefore anything would have to be a plugin so that it can simply not be loaded if the user didn't want it. Also it would need to only operate when the correct language was being edited.
Bah, this "everything must be a plugin" really annoys me. Indentation is really a core feature, whether smart or not, and is nowhere extra functionality provided by external code and authors.
g-p has also shown that finding motivated plugin authors that maintain their stuff beyond the initial code drop is hard, so we should really not rely too much on plugins.
Plugins can be part of the main Geany distribution too, like splitwindow and filebrowser, so thats not an argument against implementing in Geany or in a plugin. Implementing as a plugin also allows the use of languages other than C eg Lua as Thrawn proposed.
Indentation schemes are very specific to languages and styles, it is not a simple single capability that can be designed, coded and forgotten.
There have been several attempts at providing configurable approaches to indentation, including one by Colomban. But those could not cover even the simple algorithm that Thrawn proposes.
A plugin for something like indentation allows people to replace it if they don't like what is provided, using Lua or Python if they like, or in C/C++. Code inside Geany can't so easily be replaced.
The alternative is to hard code various schemes for each supported language, but somebody has to do it, and, as you say, maintain it.
What's wrong with you accepting new code in the core?
Nothing, but there are several reasons *not* to shove the first indentation scheme that is coded into core. Start with a plugin, if it produces a good result then it can be included in core.
Cheers Lex
PS @Thrawn, one thing that I neglected to mention was that you probably noted that Emacs indentations depend on a syntactic evaluation of the code to guide their operation.
See http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Engine...
Adding such analysis could be a big job but in my experience Emacs does produce a reasonable result.
Best regards.
______________________________**_________________ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-**bin/mailman/listinfo/develhttps://lists.geany.org/cgi-bin/mailman/listinfo/devel
On Mon, 15 Jul 2013 15:09:53 -0700 (PDT) Thrawn shell_layer-geany@yahoo.com.au wrote:
I recently came across some articles on the Emacs wiki about spaces vs tabs: http://www.emacswiki.org/emacs/SmartTabs http://www.emacswiki.org/emacs/TabsAreEvil
Their argument is that tabs should be used for indentation, while spaces should be used to align text when a long line is split. Makes sense to me.
By default, when splitting a line, Geany will copy the indentation. Once you split the line and align it with spaces of your choice, the following splits will be OK, but you'll need to remove the extra spaces at some point.
The questions are, than:
1. Whether do you want the split line aligned? You can be splitting statements that are currently on one line, such as project.c: "case 2: widget = radio_long_line_custom; break;"
2. What ammount of alignment spaces is required for the current line?
3. When to stop adding extra alignment spaces?
To me, these alignment issues seem orthogonal to what we have as indentation in Geany. Maybe some plugin with keys for split at the current column and and un-align (remove spaces) would be fine...
--
On Tue, 16 Jul 2013 11:02:28 +1000 Lex Trotman elextr@gmail.com wrote:
Better just not to use tabs of course, you don't actually save much in the default case of 4 spaces per tab.
Better for what? I use tabs for indentation because with the tab size, I can easily control the screen ammount of indentation, depending on the font and display. Saving disk space has nothing to do with that, I'll have to live very long to write 1GB of source code. :)