in reply to How would you indent this?
my @headings = ( { key => 'k', name => 'Kanji', class => 'kanji'}, { key => 'skip', name => 'SKIP', class => 'skip-code'}, { key => 'co', name => 'Suggestion', class => 'skip-code'}, { key => 'disc', name => 'Discussion'}, );
I don't know where you got the break after the opening curly from
{ key => 'disc', name => 'Discussion'},
(Update: *I can't reproduce this!* I can now, see reply )
BUT cperl-mode offers 8 indent-styles (also available from the menu)
M-x cperl-set-style BSD C++ CPerl Current GNU K&R PerlStyle Whitesmith
... and plenty of customizations
Cperl Indentation Details group: Indentation. State : something in this group has been changed outside custom +ize. Show Value Cperl Brace Imaginary Offset Imagined indentation of a Perl open brace that actually follows a s +tatement. Hide An open brace following other text is treated as if it were this fa +r to the right of the start of its line. Show Value Cperl Brace Offset Extra indentation for braces, compared with other text in same cont +ext. Show Value Cperl Break One Line Blocks When Indent Non-nil means that one-line if/unless/while/until/for/foreach BLOCK +s Hide need to be reformatted into multiline ones when indenting a region. Show Value Cperl Close Paren Offset Extra indent for substatements that start with close-parenthesis. Hide Cperl Comment Column: 40 State : SAVED and set. Column to put comments in CPerl (use M-x cperl-indent to lineup wit +h code). Show Value Cperl Continued Brace Offset Extra indent for substatements that start with open-braces. Hide This is in addition to cperl-continued-statement-offset. Show Value Cperl Continued Statement Offset Extra indent for lines not starting new statements. Show Value Cperl Fix Hanging Brace When Indent Non-nil means that BLOCK-end `}' may be put on a separate line Hide when indenting a region. Braces followed by else/elsif/while/until are excepted. Show Value Cperl Indent Comment At Column 0 Non-nil means that comment started at column 0 should be indentable +. Show Value Cperl Indent Left Aligned Comments Non-nil means that the comment starting in leftmost column should i +ndent. Hide Cperl Indent Level: 2 State : CHANGED outside Customize. Indentation of CPerl statements with respect to containing block. Show Value Cperl Indent Parens As Block Non-nil means that non-block ()-, {}- and []-groups are indented as + blocks, Hide but for trailing "," inside the group, which won't increase indenta +tion. One should tune up `cperl-close-paren-offset' as well. Show Value Cperl Indent Region Fix Constructs Amount of space to insert between `}' and `else' or `elsif' Hide in `cperl-indent-region'. Set to nil to leave as is. Values other than 1 and nil will probably not work. Show Value Cperl Indent Wrt Brace Non-nil means indent statements in if/etc block relative brace, not + if/etc. Hide Versions 5.2 ... 5.20 behaved as if this were `nil'. Show Value Cperl Label Offset Offset of CPerl label lines relative to usual indentation. Show Value Cperl Lineup Step `cperl-lineup' will always lineup at multiple of this number. Hide If nil, the value of `cperl-indent-level' will be used. Show Value Cperl Merge Trailing Else Non-nil means that BLOCK-end `}' followed by else/elsif/continue Hi +de may be merged to be on the same line when indenting a region. Show Value Cperl Min Label Indent Minimal offset of CPerl label lines. Show Value Cperl Regexp Indent Step Indentation used when beautifying regexps. Hide If nil, the value of `cperl-indent-level' will be used. Show Value Cperl Tab Always Indent Non-nil means TAB in CPerl mode should always reindent the current +line, Hide regardless of where in the line point is when the TAB command is us +ed.
you might wanna read the micro-docs in the menu and experiment.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How would you indent this? (cperl-indent-region)
by LanX (Saint) on Mar 18, 2021 at 16:19 UTC | |
by haj (Vicar) on Mar 18, 2021 at 17:24 UTC | |
by LanX (Saint) on Mar 18, 2021 at 18:52 UTC |