So, this is a line-wrappingly long line.
my $link = API::Link->new({rel => 'meta:version', href => $uri->as_string, type => 'application/xml'}),
If you think that's not a long line, imagine a really long line with a lot of parameters for the sake of argument.
One param per line is much nicer in this case.
my $link = API::Link->new({
rel => 'meta:version',
href => $uri->as_string,
type => 'application/xml',
}),
But it is a bit of a hassle to reformat by hand. Manual drudgery which easily makes me lose focus on why I just just wrote that method call. Now, why did I create that $link again?
Here is some nice elisp I wrote to reformat parameter lists either into a single line, into multiple lines, or toggle between the two.
So just put the cursor somewhere inside the parameter list and hit C-o m p (or whatever key binding strikes your fancy, but this one will work well with out-of-the-box PerlySense conventions) and it will reformat things into the other layout.
Once you have the nice multi-line layout, you can also align the parameters if that makes things look more sensible. Hit C-o m a et voila:
my $link = API::Link->new({
rel => 'meta:version',
href => $uri->as_string,
type => 'application/xml',
}),
Well, not that much difference with those parameter names, but I can't be arsed. You get the picture.
Enjoy!
(Now I'm just waiting for someone to tell me I reinvented the wheel. I just couldn't find any.)
Perl::Tidy (Score:2)
Perl::Tidy is your friend! :)
I don't manually format any code any more.
Re: (Score:1)
And you can make it do this, how?
Re: (Score:1)
into this:
instead of:
I'd appreciate any config hints you have, I just started and am currently trying to set it up to match our current c
Re: (Score:2)
I normally hit Command-Shift-H :P
My .perltidyrc doesn't cuddle the ( and {, } and ) but I think I recall an option that covers that.
Here's what that code looks like for me:
cperl-mode has some functions for this (Score:1)
One nit on your elisp code... the style like this:
<code>
(foo
(bar
baz
)
)
</code>
Looks really weird. All the close parens should be on the same line:
<code>
(foo
(bar
baz))
</code>
This is the "official" emacs lisp standard, and I think most other Lisps like the same sort of formatting.