From: SourceForge.net <no...@so...> - 2010-05-24 15:19:21
|
Bugs item #3005463, was opened at 2010-05-21 20:37 Message generated for change (Comment added) made by bwalle You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100588&aid=3005463&group_id=588 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: text area and syntax packages Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bernhard Walle (bwalle) Assigned to: Nobody/Anonymous (nobody) Summary: Wrong indent in shell scripts Initial Comment: When auto-indenting a shellscript, I get following result: -------------------------- bla() ····{ ········echo·"Fasel" ····} -------------------------- I don't understand the indent after '()' when reading the modes file: <PROPERTY NAME="lineComment" VALUE="#" /> <PROPERTY NAME="indentOpenBrackets" VALUE="{" /> <PROPERTY NAME="indentCloseBrackets" VALUE="}" /> <PROPERTY NAME="indentNextLines" VALUE="^.*(then|else|case.*in)$" /> <PROPERTY NAME="unindentThisLine" VALUE="^\s*(fi|else|esac|.*\))$" /> <PROPERTY NAME="unindentNextLines" VALUE="^\s*(fi|else|esac)$" /> I think the result should be: -------------------------- bla() { ····echo·"Fasel" } -------------------------- ---------------------------------------------------------------------- >Comment By: Bernhard Walle (bwalle) Date: 2010-05-24 17:19 Message: Thanks for the answer. I'm still a bit confused why the setting "unindentThisLine" influences the *intendation* (not the unindentation). Having played a bit with the settings, I think following settings work much better than the default settings: <PROPERTY NAME="lineComment" VALUE="#" /> <PROPERTY NAME="indentOpenBrackets" VALUE="{" /> <PROPERTY NAME="indentCloseBrackets" VALUE="}" /> <PROPERTY NAME="indentNextLines" VALUE="^.*(then|do|else|case.*in)$" /> <PROPERTY NAME="unindentThisLine" VALUE="^\s*(fi|else|done|[^(]*\))$" /> <PROPERTY NAME="unindentNextLines" VALUE="^\s*(fi|else|done|[^(]*\))$" /> <PROPERTY NAME="electricKeys" VALUE=")" /> Still worse as in vim where the shellscript auto-indenter is real code and not only five lines of rules, but much better as before. ---------------------------------------------------------------------- Comment By: Björn Kautler (vampire0) Date: 2010-05-22 03:05 Message: It is caused by the unindentThisLine property. You see the "^\s*.*\)$" case which means any number of whitespace, then any character and a closing brace. The unindentThisLine property seem to make the following line indent. Whether this is correct behaviour should be reviewed thoroughly. Even if it is correct behaviour I think changing the unindentThisLine to <PROPERTY NAME="unindentThisLine" VALUE="^\s*(fi|else|esac|[^(]*\))$" /> should behave better. Additionally I guess ")" should be set as electricKey, otherwise you have to invoke reindentation explicitly for case branches, so adding <PROPERTY NAME="electricKeys" VALUE=")" /> should be done. Additionally, the mode doesn't behave nicely if something like a comment follows then/else/case..in/fi/esac/"foo"). In the last case also code directly behind the ")" will break the current settings. And also it depends on your coding style whether you want your cases indented an additional level or on the same level as the "case". The current mode suggests them on the same level. Having an additional level would break unindentation of "esac" though, as it would have to be unindented twice which I think is not possible currently. So the leveling is maybe better like it is currently. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100588&aid=3005463&group_id=588 |