Indentation in perl is broken in the current SVN.
The following examples show the problems:
if ($a) {
# Closing bracket doesn't outdent
}
if ($a eq '(') {
# double indent due to the quoted '('
# closing bracket doesn't outdent
}
Whilst I use 'if' in the example, it is also broken for
'foreach' and I'm sure many other block structures.
sub routines, ie:
sub foo() {
}
indent correctly.
| Submitted | olearyni - 2006-09-25 - 19:45:36z | Assigned | przemo_w |
|---|---|---|---|
| Priority | 5 | Category | text area and syntax packages |
| Status | Open | Group | None |
| Resolution | Works For Me | Visibility | No |
| 2006-09-26 - 10:09:37z hertzhaft |
Logged In: YES user_id=1037294 This is a general problem with all modes. Perl is especially diffcult in this respect. Forcing the desired indentation behaviour through the mode file is complicated (I am not sure whether it is at all possible for every situation). Moreover, there are different styles and gustos for indenting and structuring, but only one "official" (not necessarily "correct") mode file setting. On the long run, maybe we should separate the indentation and the syntax highlighting stuff and make the first more easy to configure. When I last added syntax highlighting rules to the perl mode, I left the indentation as it was, although it didn't suit me. Here is the relevant extract of my personal perl mode file: <PROPERTY NAME="lineComment" VALUE="#" /> <PROPERTY NAME="unalignedOpenBrackets" VALUE="{([" /> <PROPERTY NAME="unalignedCloseBrackets" VALUE="})]" /> <PROPERTY NAME="indentNextLines" VALUE="[\{\(\[]\s*$" /> <PROPERTY NAME="lineUpClosingBracket" VALUE="false" /> Martin |
|---|---|
| 2006-09-26 - 10:15:01z kpouer |
Logged In: YES user_id=285591 I don't know where we can put those configurations about indentation, the mode file seems to be a good place I think. The problem is that the indentation features are limited and do not work for some languages. So maybe adding extra indentation features in the some languages that have specific rules |
| 2006-10-06 - 07:37:01z dmorel |
Logged In: YES user_id=1509906 Perl indenting is quite hard anyway. perltidy does it correctly, and PPI might help. Maybe a module could call an external indenting utility on keystroke ? |
| 2006-10-06 - 14:10:45z hertzhaft |
Logged In: YES user_id=1037294 The question is, what means "does it correctly"? I am quite satisfied with the solution I posted here before, has anyone tested it? It indents the next lines after a line that ends with {, [ or (, and outdents the line *after* the corresponding closing bracket or parenthesis. Strangely, it does *not* use the indentOpenBrackets and indentCloseBrackets properties, but instead the undocumented unalignedOpenBrackets and unalignedCloseBrackets, but it seems to do what I want. Documentation for the indentation properties should be updated and completed, anyway. |
| 2006-10-06 - 14:21:55z hertzhaft |
Logged In: YES user_id=1037294 The question is, what means "does it correctly"? I am quite satisfied with the solution I posted here before, has anyone tested it? It indents the next lines after a line that ends with {, [ or (, and outdents the line *after* the corresponding closing bracket or parenthesis. Strangely, it does *not* use the indentOpenBrackets and indentCloseBrackets properties, but instead the undocumented unalignedOpenBrackets and unalignedCloseBrackets, but it seems to do what I want. Documentation for the indentation properties should be updated and completed, anyway. |
| 2006-10-06 - 15:19:26z dmorel |
Logged In: YES user_id=1509906 "does it correctly" means "doesn't fall in syntactic traps the way regex parsers do. That being said, I've been pretty satisfied with perl indenting up until pre7. The recommended best practice for perl in particular is unindenting the corresponding bracket, not the line after. 99% of CPAN modules are written this way, and a modefile dedicated to a specific language really *should* follow this rule. No harm intended. anyway, since the behaviour is customizable, it shouldn't be a big deal to restore it like it was before, shoud it ? ;) |
| 2011-12-13 - 08:55:55z przemo_w |
The current version of jEdit works as expected by the bug submitter. If there are no objections, I'll close the bug report. |