in reply to Re: prettyfy hashes
in thread prettyfy hashes
One day I'll automatise it to happen with each auto indent. ..
FWIW I seem to remember that perltidy can't do this.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: prettyfy hashes (emacs)
by choroba (Cardinal) on Apr 03, 2016 at 13:10 UTC | |
Moving the structure from the assignment line doesn't help:
| [reply] [d/l] [select] |
by LanX (Saint) on Apr 03, 2016 at 14:02 UTC | |
But this could be solved with separate rules for = , =~ and => and/or "sections separations". please note how this works
That's because { is a section separator while ( is not
using M-x customize-group RET align RET will facilitate customizing (it provides a textual UI for lisp data) the rule in question in align-rules-list is
this [~>]? part should be deleted or replaced. (BTW: not sure what the -* is intended to do...)
Cheers Rolf
| [reply] [d/l] [select] |
by choroba (Cardinal) on Apr 03, 2016 at 14:08 UTC | |
\s- is whitespace, asterisk is the same as in Perl. Emacs uses \sC where C is a character class, i.e. \sw corresponds to \w , etc.
| [reply] [d/l] [select] |
by LanX (Saint) on Mar 23, 2019 at 14:05 UTC | |
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
to this, hence handling different levels accordingly
but this doesn't help with this because the separators will be inside each line
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
| [reply] [d/l] [select] |
by LanX (Saint) on Mar 25, 2019 at 00:08 UTC | |
This is self contained dual code! Place the cursor behind the last lisp parenthesis and type C-x C-e and the fat commas will be aligned.
<Reveal this spoiler or all in this thread> The result is already almost as good as perltidy just way faster. It's so fast that it could be bound to each return or semicolon key event to align the current statement
you can play around with the lisp code to improve the result.
Cheers Rolf
| [reply] [d/l] [select] |
|
Re^3: prettyfy hashes (perltidy)
by LanX (Saint) on Apr 03, 2016 at 14:35 UTC | |
wrong see http://perltidy.sourceforge.net/node005.html I think I confused it with Data::Dump and Data::Dumper which do not align (fat) commas.
updateBut I'm still not convinced about perltidy's performance for interactive use from within an IDE.
Cheers Rolf
| [reply] |