in reply to How would you indent this?
I'd consider this indentation of CPerl to be a bug.
CPerl mode's M-x indent-region does more than just indent, it also tries to "fix" spacing. But in this case it turns out just horribly wrong. Here's an example to show the intention: If you type the following:
if($fee){fie()}else{foe($foo)}...and then process this with M-x indent-region, then you get (depending on your style, I'm using PBP here):
if ($fee) { fie(); } else { foe($foo); }
Nifty, eh? A real life saver... but only if your space key is broken.
The customization variable responsible for this is cperl-indent-region-fix-constructs (on by default), which is out of the scope of the predefined indentation styles. The documentation for that variable shows what it should do, but not what it actually does. So, if you don't need CPerl mode to reformat your code like this, then I suggest you just turn off that variable as a workaround (and, if you like, write a bug report).
By the way: Emacs can help with aligning the keys as suggested by ikegami and GrandFather, unrelated to CPerl mode. It is hardly worth the effort for four lines, though: Mark the assignment as a region, and then
align-regexp<RET>name<RET> align-regexp<RET>class<RET>
This yields:
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'}, )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How would you indent this?
by no longer just digit (Beadle) on Mar 19, 2021 at 03:29 UTC | |
by haj (Vicar) on Mar 19, 2021 at 07:59 UTC | |
by no longer just digit (Beadle) on Mar 19, 2021 at 10:38 UTC | |
by haj (Vicar) on Mar 19, 2021 at 12:15 UTC | |
by no longer just digit (Beadle) on Mar 19, 2021 at 22:03 UTC | |
| |
by haj (Vicar) on Apr 04, 2021 at 23:43 UTC |