]> git.donarmstrong.com Git - perltidy.git/commitdiff
added flag -blixl
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 17 Oct 2021 02:31:10 +0000 (19:31 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 17 Oct 2021 02:31:10 +0000 (19:31 -0700)
bin/perltidy
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm
t/snippets/braces7.par
t/snippets/expect/braces.braces7
t/snippets/packing_list.txt
t/snippets22.t

index 2b5b027e00a2832c8b63b46d55a8e87846b37c82..e7f1ceaceb3082bd3bcf9a18a08d6c8c7d0ee9a5 100755 (executable)
@@ -2340,7 +2340,7 @@ For example, perltidy -bli gives
             important_function();
           }
 
-By default, this extra indentation occurs for blocks of type:
+By default, this extra indentation occurs for block types:
 B<if>, B<elsif>, B<else>, B<unless>, B<while>, B<for>, B<foreach>, B<do>, and
 also B<named subs> and blocks preceded by a B<label>.  The next item shows how to
 change this.
@@ -2359,8 +2359,16 @@ B<-bli> flag applies; see L<Specifying Block Types>.
 
 The default is B<-blil='if else elsif unless while for foreach do : sub'>.
 
-Note that this parameter controls the behavior of the B<-bli> flag but has no
-effect unless the B<-bli> flag is set.
+=item B<-blixl=s>, B<--brace-left-and-indent-exclusion-list=s>
+
+Use this parameter to exclude types of block braces for which the B<-bli> flag
+applies; see L<Specifying Block Types>.
+
+This might be useful in conjunction with selecting all blocks B<-blil='*'>.
+The default setting is B<-blixl=' '>, which does not exclude any blocks.
+
+Note that the two parameters B<-blil> and B<-blixl> control the behavior of
+the B<-bli> flag but have no effect unless the B<-bli> flag is set.
 
 =item B<-bar>,    B<--opening-brace-always-on-right>
 
index 6b4b7e9c2a4af34cb00df2ff49a3b4e62b21347f..8be6b0908b8a7f40f6cb340c5db00d015453d03e 100644 (file)
@@ -2260,21 +2260,22 @@ sub generate_options {
     ########################################
     $category = 2;    # Code indentation control
     ########################################
-    $add_option->( 'continuation-indentation',           'ci',   '=i' );
-    $add_option->( 'extended-continuation-indentation',  'xci',  '!' );
-    $add_option->( 'line-up-parentheses',                'lp',   '!' );
-    $add_option->( 'line-up-parentheses-exclusion-list', 'lpxl', '=s' );
-    $add_option->( 'outdent-keyword-list',               'okwl', '=s' );
-    $add_option->( 'outdent-keywords',                   'okw',  '!' );
-    $add_option->( 'outdent-labels',                     'ola',  '!' );
-    $add_option->( 'outdent-long-quotes',                'olq',  '!' );
-    $add_option->( 'indent-closing-brace',               'icb',  '!' );
-    $add_option->( 'closing-token-indentation',          'cti',  '=i' );
-    $add_option->( 'closing-paren-indentation',          'cpi',  '=i' );
-    $add_option->( 'closing-brace-indentation',          'cbi',  '=i' );
-    $add_option->( 'closing-square-bracket-indentation', 'csbi', '=i' );
-    $add_option->( 'brace-left-and-indent',              'bli',  '!' );
-    $add_option->( 'brace-left-and-indent-list',         'blil', '=s' );
+    $add_option->( 'continuation-indentation',             'ci',    '=i' );
+    $add_option->( 'extended-continuation-indentation',    'xci',   '!' );
+    $add_option->( 'line-up-parentheses',                  'lp',    '!' );
+    $add_option->( 'line-up-parentheses-exclusion-list',   'lpxl',  '=s' );
+    $add_option->( 'outdent-keyword-list',                 'okwl',  '=s' );
+    $add_option->( 'outdent-keywords',                     'okw',   '!' );
+    $add_option->( 'outdent-labels',                       'ola',   '!' );
+    $add_option->( 'outdent-long-quotes',                  'olq',   '!' );
+    $add_option->( 'indent-closing-brace',                 'icb',   '!' );
+    $add_option->( 'closing-token-indentation',            'cti',   '=i' );
+    $add_option->( 'closing-paren-indentation',            'cpi',   '=i' );
+    $add_option->( 'closing-brace-indentation',            'cbi',   '=i' );
+    $add_option->( 'closing-square-bracket-indentation',   'csbi',  '=i' );
+    $add_option->( 'brace-left-and-indent',                'bli',   '!' );
+    $add_option->( 'brace-left-and-indent-list',           'blil',  '=s' );
+    $add_option->( 'brace-left-and-indent-exclusion-list', 'blixl', '=s' );
 
     ########################################
     $category = 3;    # Whitespace control
index d20fcb536cca3007e6361bc6a6e1b55c5ab58e41..58fad8d6868237a892815efb8f4781e61a8cf0d0 100644 (file)
@@ -289,6 +289,7 @@ my (
     $non_indenting_brace_pattern,
     $bl_exclusion_pattern,
     $bl_pattern,
+    $bli_exclusion_pattern,
     $bli_pattern,
     $block_brace_vertical_tightness_pattern,
     $blank_lines_after_opening_block_pattern,
@@ -4524,6 +4525,7 @@ sub make_bli_pattern {
 
     # default list of block types for which -bli would apply
     my $bli_list_string = 'if else elsif unless while for foreach do : sub';
+    my $bli_exclusion_list_string = ' ';
 
     if ( defined( $rOpts->{'brace-left-and-indent-list'} )
         && $rOpts->{'brace-left-and-indent-list'} )
@@ -4532,6 +4534,15 @@ sub make_bli_pattern {
     }
 
     $bli_pattern = make_block_pattern( '-blil', $bli_list_string );
+
+    if ( defined( $rOpts->{'brace-left-and-indent-exclusion-list'} )
+        && $rOpts->{'brace-left-and-indent-exclusion-list'} )
+    {
+        $bli_exclusion_list_string =
+          $rOpts->{'brace-left-and-indent-exclusion-list'};
+    }
+    $bli_exclusion_pattern =
+      make_block_pattern( '-blixl', $bli_exclusion_list_string );
     return;
 }
 
@@ -9941,7 +9952,10 @@ sub bli_adjustment {
 
     foreach my $seqno ( keys %{$rblock_type_of_seqno} ) {
         my $block_type = $rblock_type_of_seqno->{$seqno};
-        if ( $block_type && $block_type =~ /$bli_pattern/ ) {
+        if (   $block_type
+            && $block_type =~ /$bli_pattern/
+            && $block_type !~ /$bli_exclusion_pattern/ )
+        {
             $ris_bli_container->{$seqno} = 1;
             $rbrace_left->{$seqno}       = 1;
             my $Ko = $K_opening_container->{$seqno};
index db126511b6eb9e43840eaae8737f7ae590339596..e55e684e004e93dc88d95794ab9d6e797fd93f7b 100644 (file)
@@ -1 +1 @@
--bli -blil='*'
+-bli -blil='*' -blixl='eval'
index b5f81b14a1ba7afbbb61546ab1858f4f64bbb55c..d939b90cfd47cf5c4960b9616b9ffe4028afb078 100644 (file)
@@ -15,11 +15,10 @@ $myfun = sub
     print("Hello, World\n");
   };
 
-eval
-  {
+eval {
     my $app = App::perlbrew->new( "install-patchperl", "-q" );
     $app->run();
-  } or do
+} or do
   {
     $error          = $@;
     $produced_error = 1;
index 0873d4b932adc5a0db8887792355acb9d01b67bd..f4fcb3f2cac16780a659d67104d31f3a96e7c423 100644 (file)
 ../snippets25.t        novalign.novalign3
 ../snippets25.t        lp2.def
 ../snippets25.t        lp2.lp
+../snippets25.t        braces.braces8
 ../snippets3.t ce_wn1.ce_wn
 ../snippets3.t ce_wn1.def
 ../snippets3.t colin.colin
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets25.t        braces.braces8
index 92563c258b62f8068a3886aed94ba6591889750b..a86591f28c8122bbafb02b51d742abeff3fa3fc8 100644 (file)
@@ -46,7 +46,7 @@ BEGIN {
 -nboa
 ----------
         'braces7' => <<'----------',
--bli -blil='*'
+-bli -blil='*' -blixl='eval'
 ----------
         'def'       => "",
         'extrude'   => "--extrude",
@@ -369,11 +369,10 @@ $myfun = sub
     print("Hello, World\n");
   };
 
-eval
-  {
+eval {
     my $app = App::perlbrew->new( "install-patchperl", "-q" );
     $app->run();
-  } or do
+} or do
   {
     $error          = $@;
     $produced_error = 1;