From: Steve Hancock Date: Fri, 26 Mar 2021 14:35:43 +0000 (-0700) Subject: remove -lfp shortcut pending further testing X-Git-Tag: 20210402~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bfc00fb84324983c0ed22015741e3a58c151b51c;p=perltidy.git remove -lfp shortcut pending further testing --- diff --git a/CHANGES.md b/CHANGES.md index 2dac997a..0d3a180a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,8 +4,8 @@ - Fixed issue git #57 regarding uninitialized warning flag. - - Added flag -lpxl for issue git #56, providing some control over which - containers get -lp indentation. + - Added experimental flag -lpxl=s requested in issue git #56 to provide some + control over which containers get -lp indentation. - Fixed issue git #55 regarding lack of coordination of the --break-before-xxx flags and the --line-up-parens flag. diff --git a/bin/perltidy b/bin/perltidy index 0ddb9529..6fb4f560 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -844,9 +844,12 @@ hierarchical lists, and these flags may prevent that. =item B<-lpxl=s>, B<--line-up-parentheses-exclusion-list> +This is an experimental parameter; the details might change as experience +with it is gained. + The B<-lp> indentation style works well for some types of coding but can produce very long lines when variables have long names and/or containers are -very deeply nested. The B<-lpxl=s> flag can help mitigate this problem by +very deeply nested. The B<-lpxl=s> flag is intended to help mitigate this problem by providing control over the containers to which the B<-lp> indentation style is applied. The B<-lp> flag by default is "greedy" and applies to as many containers as possible. This flag specifies a list of things which should @@ -897,36 +900,9 @@ For example, means only apply -lp to parenthesized lists which follow a function call and which do not contain any sublists, code blocks or ternary expressions. The logic -of writing these codes is counter-intuitive because they describe what is not +of writing these codes is somewhat counter-intuitive because they describe what is not getting the -lp indentation. So the 'F' indicates that non-function calls are not getting -lp, or in other words that function calls are getting the -lp indentation. -To simplify things, the next section has a shortcut form for the previous -example, since it is expected to be the most useful. - -=item B<-lfp>, B<--line-up-function-parentheses> - -This is a shortcut for - - -lp -lpxl = '[ { F(2' - -which means only apply -lp to parenthesized lists which follow a function call -and which do not contain any sublists, code blocks or ternary expressions. For -example, - - # perltidy -lfp - my $loanlength = getLoanLength( - $borrower->{'categorycode'}, - $iteminformation->{'itemtype'}, - $borrower->{'branchcode'} - ); - - # perltidy -lfp - @month_of_year = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' - ); - -The first of these examples is a simple function call, but the second is not. =item B<-cti=n>, B<--closing-token-indentation> diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 3eac01bf..13f4bf3e 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -2784,8 +2784,10 @@ sub generate_options { 'conv' => [qw(it=4)], 'nconv' => [qw(it=1)], - 'line-up-function-parentheses' => [ qw(lp), q#lpxl=[ { F(2# ], - 'lfp' => [qw(line-up-function-parentheses)], + # FIXME: possible future shortcut. This will remain deactivated until + # the -lpxl flag is no longer experimental. + # 'line-up-function-parentheses' => [ qw(lp), q#lpxl=[ { F(2# ], + # 'lfp' => [qw(line-up-function-parentheses)], # 'mangle' originally deleted pod and comments, but to keep it # reversible, it no longer does. But if you really want to diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 4899bc3f..d3b96de4 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1816,7 +1816,13 @@ EOM } } if ($all_off) { - $rOpts->{'line-up-parentheses'} = ""; + + # FIXME: This works but is currently deactivated because at present + # users of -lp could see some discontinuities in formatting, + # such as those involving the choice of breaks at '='. After + # these issues have been checked and resolved it should be reactivated + # as a speedup. + ## $rOpts->{'line-up-parentheses'} = ""; } return; diff --git a/t/snippets/expect/lpxl.lpxl2 b/t/snippets/expect/lpxl.lpxl2 deleted file mode 100644 index 0c7a829e..00000000 --- a/t/snippets/expect/lpxl.lpxl2 +++ /dev/null @@ -1,61 +0,0 @@ -# simple function call -my $loanlength = getLoanLength( - $borrower->{'categorycode'}, # sc1 - $iteminformation->{'itemtype'}, - $borrower->{'branchcode'} # sc3 -); - -# function call, more than one level deep -my $o = very::long::class::name->new( - { - propA => "a", - propB => "b", - propC => "c", - } -); - -# function call with sublist -debug( - "Connecting to DB.", - "Extra-Parameters: " . join( "<->", $extra_parms ), - "Config: " . join( "<->", %config ) -); - -# simple function call with code block -$m->command( - -label => 'Save', - -command => sub { print "DOS\n"; save_dialog($win); } ); - -# function call, ternary in list -return - OptArgs2::Result->usage( - $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage', - 'usage: ' . $usage . "\n" ); - -# not a function call -%blastparam = ( - -run => \%runparam, - -file => '', - -parse => 1, - -signif => 1e-5, -); - -# 'local' is a keyword, not a user function -local ( - $len, $pts, @colspec, $char, $cols, - $repeat, $celldata, $at_text, $after_text -); - -# square bracket with sublists -$data = [ - ListElem->new( id => 0, val => 100 ), - ListElem->new( id => 2, val => 50 ), - ListElem->new( id => 1, val => 10 ), -]; - -# curly brace with sublists -$behaviour = { - cat => { nap => "lap", eat => "meat" }, - dog => { prowl => "growl", pool => "drool" }, - mouse => { nibble => "kibble" }, -}; diff --git a/t/snippets/lpxl2.par b/t/snippets/lpxl2.par deleted file mode 100644 index eced01c1..00000000 --- a/t/snippets/lpxl2.par +++ /dev/null @@ -1 +0,0 @@ --lfp diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index fe98992e..6bcd97e3 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -313,6 +313,12 @@ ../snippets24.t fpva.def ../snippets24.t fpva.fpva1 ../snippets24.t fpva.fpva2 +../snippets24.t lpxl.def +../snippets24.t lpxl.lpxl1 +../snippets24.t lpxl.lpxl2 +../snippets24.t lpxl.lpxl3 +../snippets24.t lpxl.lpxl4 +../snippets24.t lpxl.lpxl5 ../snippets3.t ce_wn1.ce_wn ../snippets3.t ce_wn1.def ../snippets3.t colin.colin @@ -453,9 +459,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets24.t lpxl.def -../snippets24.t lpxl.lpxl1 -../snippets24.t lpxl.lpxl2 -../snippets24.t lpxl.lpxl3 -../snippets24.t lpxl.lpxl4 -../snippets24.t lpxl.lpxl5 diff --git a/t/snippets24.t b/t/snippets24.t index 36c2c886..c6ab7e24 100644 --- a/t/snippets24.t +++ b/t/snippets24.t @@ -8,10 +8,9 @@ #5 fpva.fpva2 #6 lpxl.def #7 lpxl.lpxl1 -#8 lpxl.lpxl2 -#9 lpxl.lpxl3 -#10 lpxl.lpxl4 -#11 lpxl.lpxl5 +#8 lpxl.lpxl3 +#9 lpxl.lpxl4 +#10 lpxl.lpxl5 # To locate test #13 you can search for its name or the string '#13' @@ -34,7 +33,6 @@ BEGIN { 'fpva2' => "-sfp -nfpva", 'git54' => "-bbp=3 -bbpi=2 -ci=4 -lp", 'lpxl1' => "-lp", - 'lpxl2' => "-lfp", 'lpxl3' => <<'----------', -lp -lpxl='{ [ (' ---------- @@ -469,78 +467,10 @@ $behaviour = { #7........... }, - 'lpxl.lpxl2' => { - source => "lpxl", - params => "lpxl2", - expect => <<'#8...........', -# simple function call -my $loanlength = getLoanLength( - $borrower->{'categorycode'}, # sc1 - $iteminformation->{'itemtype'}, - $borrower->{'branchcode'} # sc3 -); - -# function call, more than one level deep -my $o = very::long::class::name->new( - { - propA => "a", - propB => "b", - propC => "c", - } -); - -# function call with sublist -debug( - "Connecting to DB.", - "Extra-Parameters: " . join( "<->", $extra_parms ), - "Config: " . join( "<->", %config ) -); - -# simple function call with code block -$m->command( - -label => 'Save', - -command => sub { print "DOS\n"; save_dialog($win); } ); - -# function call, ternary in list -return - OptArgs2::Result->usage( - $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage', - 'usage: ' . $usage . "\n" ); - -# not a function call -%blastparam = ( - -run => \%runparam, - -file => '', - -parse => 1, - -signif => 1e-5, -); - -# 'local' is a keyword, not a user function -local ( - $len, $pts, @colspec, $char, $cols, - $repeat, $celldata, $at_text, $after_text -); - -# square bracket with sublists -$data = [ - ListElem->new( id => 0, val => 100 ), - ListElem->new( id => 2, val => 50 ), - ListElem->new( id => 1, val => 10 ), -]; - -# curly brace with sublists -$behaviour = { - cat => { nap => "lap", eat => "meat" }, - dog => { prowl => "growl", pool => "drool" }, - mouse => { nibble => "kibble" }, -}; -#8........... - }, - 'lpxl.lpxl3' => { source => "lpxl", params => "lpxl3", - expect => <<'#9...........', + expect => <<'#8...........', # simple function call my $loanlength = getLoanLength( $borrower->{'categorycode'}, # sc1 @@ -602,13 +532,13 @@ $behaviour = { dog => { prowl => "growl", pool => "drool" }, mouse => { nibble => "kibble" }, }; -#9........... +#8........... }, 'lpxl.lpxl4' => { source => "lpxl", params => "lpxl4", - expect => <<'#10...........', + expect => <<'#9...........', # simple function call my $loanlength = getLoanLength( $borrower->{'categorycode'}, # sc1 @@ -669,13 +599,13 @@ $behaviour = { dog => { prowl => "growl", pool => "drool" }, mouse => { nibble => "kibble" }, }; -#10........... +#9........... }, 'lpxl.lpxl5' => { source => "lpxl", params => "lpxl5", - expect => <<'#11...........', + expect => <<'#10...........', # simple function call my $loanlength = getLoanLength( $borrower->{'categorycode'}, # sc1 @@ -737,7 +667,7 @@ $behaviour = { dog => { prowl => "growl", pool => "drool" }, mouse => { nibble => "kibble" }, }; -#11........... +#10........... }, };