in reply to Re^3: prettyfy hashes (emacs)
in thread prettyfy hashes
So task number one would be to separate these cases.
Secondly we need to define region separators.
as a demo: resetting the align-region-separate to handle parentheses helped
(snippet from customize: Align Region Separate: Value Menu Regexp defines section boundaries: [][{}])
to format
$a = { bla => 1, trax => [ bla2 => { sauh1 => 1666, 3 => 2, }, ], # bla => 1, trallxa => 2, };
to this, hence handling different levels accordingly
$a = { bla => 1, trax => [ bla2 => { sauh1 => 1666, 3 => 2, }, ], # new section bla => 1, trallxa => 2, };
but this doesn't help with this because the separators will be inside each line
my $h_periods = { Mercury => { orbital => 0.24, rotation => 58.64 }, Venus => { orbal => 0.62, rotation => -243.02 }, Earth => { orbital => 1.00, rotation => 1.00 }, Mars => { orbital => 1.88, rotation => 1.03 }, Jupiter => { orbital => 11.86, rotation => 0.41 }, Saturn => { orbital => 29.46, rotation => 0.43 }, Uranus => { orbital => 84.01, rotation => -0.72 }, Neptune => { orbital => 164.8, rotation => 0.67 }, };
The only way to solve this is to use indentation to distinguish groups.
According to the docs it's possible to use a function call back instead of a regex, but documentation is sparse.
I wanted to document my findings before getting lost in other projects ... ;-)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: prettyfy hashes (emacs)
by LanX (Saint) on Mar 25, 2019 at 00:08 UTC |