jed-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

RE: perl mode indentation


> Waldemar R. Jankowski <waldemar@xxxxxxxxxxx> wrote:
> >Currently my function calls that take an anonomous hash reference
> indent
> >like this:
> >
> >my $retval = function({
> >                          foo => 'bar',
> >                     });
> >
> >What I would like is this:
> >
> >my $retval = function({
> >    foo => 'bar',
> >})
> [...]
> >Is there a way to accomplish this?

The short answer: no, special treatment of a lone hash reference within a
function parameter is, well, a bit too specialized.

If you are willing to treat hash references like any other parameter, the
current heuristics will work fine:

my $retval = function(
    { foo => 'bar' },
    10, 20,
    [qw( baz )]
);


If keeping the brace on the same line as the function name is a priority,
you can have pre-declared functions and drop the parentheses:

use Data::Dumper;
sub function {
    my $i;
    for (@_) {
	warn ++$i, " " , Dumper($_), "\n";
    }
    scalar @_;
}

# call without '()'
my $retval = function {
    foo => 'bar'
},
{
    baz => "yxx" 
};


Although I am obviously obliged to like the perl mode indentation, I mostly
use it to keep my code from getting too messy between calls to perltidy,
which is bound to the "ESC Ctrl-T" combination. The "Ctrl-?" perl_help
binding is also a godsend for quick reference.

BTW: did you manage to find perltidy settings that worked for your preferred
formatting? If perltidy doesn't manage it, neither can we!

/mark

This e-mail message and any attachments may contain legally privileged, confidential or proprietary Information, or information otherwise protected by law of ArvinMeritor, Inc., its affiliates, or third parties. This notice serves as marking of its ?Confidential? status as defined in any confidentiality agreements concerning the sender and recipient. If you are not the intended recipient(s), or the employee or agent responsible for delivery of this message to the intended recipient(s), you are hereby notified that any dissemination, distribution or copying of this e-mail message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this e-mail message from your computer.



--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]