From: Steve Hancock Date: Sat, 19 Sep 2020 14:55:19 +0000 (-0700) Subject: changed parameter name -ihb to -bbhbi, etc, for clarity X-Git-Tag: 20201001~27 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=01678e0c5d5f6367cef81030e95a739b7563c6e9;p=perltidy.git changed parameter name -ihb to -bbhbi, etc, for clarity --- diff --git a/CHANGES.md b/CHANGES.md index 88ee52ef..85748299 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ - Added parameters -bbhb=n (--break-before-hash-brace=n), -bbsb=n (--break-before-square-bracket=n), and -bbp=n (--break-before-paren=n) suggested in git #38. These provide control over the - opening container token of a multiple-line list. Related new parameters -ihb=n, -isb=n, -ip=n + opening container token of a multiple-line list. Related new parameters -bbhbi=n, -bbsbi=n, -bbpi=n control indentation of these tokens. - Numerous issues have been found during automated testing and fixed. Many involve references to diff --git a/bin/perltidy b/bin/perltidy index 8ce05e3a..35cecf7f 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -2163,8 +2163,8 @@ There are several points to note about this flag: =item * -This parameter only applies to opening hash braces which are preceded by an '=' -or '=>'. +This parameter only applies if the opening brace is preceded by an '=' +or '=>' or ','. =item * @@ -2186,7 +2186,7 @@ this parameter has no effect. The indentation of the braces will normally be one level of continuation indentation by default. This can be changed with the parameter -B<--indent-hash-brace=n> in the next section. +B<-bbhbi=n> in the next section. =item * @@ -2194,18 +2194,18 @@ Similar flags for controlling parens and square brackets are given in the subseq =back -=item B<-ihb=n>, B<--indent-hash-brace=n> +=item B<-bbhbi=n>, B<--break-before-hash-brace-and-indent=n> This flag is a companion to B<-bbhb=n> for controlling the indentation of an opening hash brace which is placed on a new line by that parameter. The indentation is as follows: - -ihb=0 one continuation level [default] - -ihb=1 outdent by one continuation level - -ihb=2 indent one full indentation level + -bbhbi=0 one continuation level [default] + -bbhbi=1 outdent by one continuation level + -bbhbi=2 indent one full indentation level For example: - # perltidy -bbhb=3 -ihb=1 + # perltidy -bbhb=3 -bbhbi=1 $romanNumerals = { one => 'I', @@ -2214,7 +2214,7 @@ For example: four => 'IV', }; - # perltidy -bbhb=3 -ihb=2 + # perltidy -bbhb=3 -bbhbi=2 $romanNumerals = { one => 'I', @@ -2223,42 +2223,43 @@ For example: four => 'IV', }; +Note that this parameter has no effect unless B<-bbhb=n> is also set. + =item B<-bbsb=n>, B<--break-before-square-bracket=n> -This flag is similar to the flag described above, except it applies to square brackets. +This flag is similar to the flag described above, except it applies to lists contained within square brackets. -bbsb=0 never break [default] -bbsb=1 stable: break if the input script had a break -bbsb=2 break if list is 'complex' (part of nested list structure) -bbsb=3 always break -=item B<-isb=n>, B<--indent-square-bracket=n> +=item B<-bbsbi=n>, B<--break-before-square-bracket-and-indent=n> This flag is a companion to B<-bbsb=n> for controlling the indentation of an opening square bracket which is placed on a new line by that parameter. The indentation is as follows: - -isb=0 one continuation level [default] - -isb=1 outdent by one continuation level - -isb=2 indent one full indentation level + -bbsbi=0 one continuation level [default] + -bbsbi=1 outdent by one continuation level + -bbsbi=2 indent one full indentation level =item B<-bbp=n>, B<--break-before-paren=n> -This flag is similar to B<-bbhb=n>, described above, except it applies to parens. +This flag is similar to B<-bbhb=n>, described above, except it applies to lists contained within parens. -bbp=0 never break [default] -bbp=1 stable: break if the input script had a break -bpb=2 break if list is 'complex' (part of nested list structure) -bbp=3 always break -=item B<-ip=n>, B<--indent-paren=n> +=item B<-bbpi=n>, B<--break-before-paren-and-indent=n> This flag is a companion to B<-bbp=n> for controlling the indentation of an opening paren which is placed on a new line by that parameter. The indentation is as follows: - -ip=0 one continuation level [default] - -ip=1 outdent by one continuation level - -ip=2 indent one full indentation level - + -bbpi=0 one continuation level [default] + -bbpi=1 outdent by one continuation level + -bbpi=2 indent one full indentation level =item B<-wn>, B<--weld-nested-containers> diff --git a/docs/ChangeLog.html b/docs/ChangeLog.html index 04ab4789..ebd4ac6d 100644 --- a/docs/ChangeLog.html +++ b/docs/ChangeLog.html @@ -7,7 +7,7 @@ - Added parameters -bbhb=n (--break-before-hash-brace=n), -bbsb=n (--break-before-square-bracket=n), and -bbp=n (--break-before-paren=n) suggested in git #38. These provide control over the - opening container token of a multiple-line list. Related new parameters -ihb=n, -isb=n, -ip=n + opening container token of a multiple-line list. Related new parameters -bbhbi=n, -bbsbi=n, -bbpi=n control indentation of these tokens. - Numerous issues have been found during automated testing and fixed. Many involve references to diff --git a/docs/perltidy.html b/docs/perltidy.html index 63e00369..510d07d2 100644 --- a/docs/perltidy.html +++ b/docs/perltidy.html @@ -1710,7 +1710,7 @@ -
-ihb=n, --indent-hash-brace=n
+
-bbhbi=n, --break-before-hash-brace-and-indent=n

This flag is a companion to -bbhb=n for controlling the indentation of an opening hash brace which is placed on a new line by that parameter. The indentation is as follows:

-
  -ihb=0 one continuation level [default]
-  -ihb=1 outdent by one continuation level
-  -ihb=2 indent one full indentation level
+
  -bbhbi=0 one continuation level [default]
+  -bbhbi=1 outdent by one continuation level
+  -bbhbi=2 indent one full indentation level

For example:

-
    # perltidy -bbhb=3 -ihb=1
+
    # perltidy -bbhb=3 -bbhbi=1
     $romanNumerals =
     {
         one   => 'I',
@@ -1751,7 +1751,7 @@
         four  => 'IV',
     };
 
-    # perltidy -bbhb=3 -ihb=2
+    # perltidy -bbhb=3 -bbhbi=2
     $romanNumerals =
         {
         one   => 'I',
@@ -1760,11 +1760,13 @@
         four  => 'IV',
         };
+

Note that this parameter has no effect unless -bbhb=n is also set.

+
-bbsb=n, --break-before-square-bracket=n
-

This flag is similar to the flag described above, except it applies to square brackets.

+

This flag is similar to the flag described above, except it applies to lists contained within square brackets.

  -bbsb=0 never break [default]
   -bbsb=1 stable: break if the input script had a break
@@ -1772,20 +1774,20 @@
   -bbsb=3 always break
-
-isb=n, --indent-square-bracket=n
+
-bbsbi=n, --break-before-square-bracket-and-indent=n

This flag is a companion to -bbsb=n for controlling the indentation of an opening square bracket which is placed on a new line by that parameter. The indentation is as follows:

-
  -isb=0 one continuation level [default]
-  -isb=1 outdent by one continuation level
-  -isb=2 indent one full indentation level
+
  -bbsbi=0 one continuation level [default]
+  -bbsbi=1 outdent by one continuation level
+  -bbsbi=2 indent one full indentation level
-bbp=n, --break-before-paren=n
-

This flag is similar to -bbhb=n, described above, except it applies to parens.

+

This flag is similar to -bbhb=n, described above, except it applies to lists contained within parens.

  -bbp=0 never break [default]
   -bbp=1 stable: break if the input script had a break
@@ -1793,14 +1795,14 @@
   -bbp=3 always break
-
-ip=n, --indent-paren=n
+
-bbpi=n, --break-before-paren-and-indent=n

This flag is a companion to -bbp=n for controlling the indentation of an opening paren which is placed on a new line by that parameter. The indentation is as follows:

-
  -ip=0 one continuation level [default]
-  -ip=1 outdent by one continuation level
-  -ip=2 indent one full indentation level
+
  -bbpi=0 one continuation level [default]
+  -bbpi=1 outdent by one continuation level
+  -bbpi=2 indent one full indentation level
-wn, --weld-nested-containers
diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 24896094..560da15c 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -2284,11 +2284,11 @@ sub generate_options { $add_option->( 'one-line-block-semicolons', 'olbs', '=i' ); $add_option->( 'one-line-block-nesting', 'olbn', '=i' ); $add_option->( 'break-before-hash-brace', 'bbhb', '=i' ); + $add_option->( 'break-before-hash-brace-and-indent', 'bbhbi', '=i' ); $add_option->( 'break-before-square-bracket', 'bbsb', '=i' ); + $add_option->( 'break-before-square-bracket-and-indent', 'bbsbi', '=i' ); $add_option->( 'break-before-paren', 'bbp', '=i' ); - $add_option->( 'indent-hash-brace', 'ihb', '=i' ); - $add_option->( 'indent-square-bracket', 'isb', '=i' ); - $add_option->( 'indent-paren', 'ip', '=i' ); + $add_option->( 'break-before-paren-and-indent', 'bbpi', '=i' ); ######################################## $category = 6; # Controlling list formatting @@ -2476,11 +2476,11 @@ sub generate_options { break-at-old-attribute-breakpoints break-at-old-keyword-breakpoints break-before-hash-brace=0 + break-before-hash-brace-and-indent=0 break-before-square-bracket=0 + break-before-square-bracket-and-indent=0 break-before-paren=0 - indent-hash-brace=0 - indent-square-bracket=0 - indent-paren=0 + break-before-paren-and-indent=0 comma-arrow-breakpoints=5 nocheck-syntax character-encoding=guess diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f7789610..cc139905 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -404,6 +404,7 @@ BEGIN { @is_closing_token{@q} = (1) x scalar(@q); @q = qw( = => ); + push @q, ','; # include ordinary comma too @is_equal_or_fat_comma{@q} = (1) x scalar(@q); } @@ -4772,10 +4773,11 @@ sub whitespace_cycle_adjustment { sub adjust_container_indentation { # adjust continuation indentation for certain tokens if requested + # by these flags: - # -ihb=n , --indent-for-hash-brace=n - # -isb=n , --indent-for-square-bracket=n - # -ip=n , --indent-for-paren=n + # -bbhbi=n + # -bbsbi=n + # -bbpi=n # n=0 default indentation (usually one ci) # n=1 outdent one ci @@ -6284,19 +6286,19 @@ EOM } %container_indentation_options = (); - for ( $rOpts->{'indent-hash-brace'} ) { + for ( $rOpts->{'break-before-hash-brace-and-indent'} ) { my $tok = '{'; if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) { $container_indentation_options{$tok} = $_; } } - for ( $rOpts->{'indent-square-bracket'} ) { + for ( $rOpts->{'break-before-square-bracket-and-indent'} ) { my $tok = '['; if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) { $container_indentation_options{$tok} = $_; } } - for ( $rOpts->{'indent-paren'} ) { + for ( $rOpts->{'break-before-paren-and-indent'} ) { my $tok = '('; if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) { $container_indentation_options{$tok} = $_; @@ -18018,7 +18020,7 @@ sub insert_breaks_before_list_opening_containers { my $seqno = $rLL->[$Kend]->[_TYPE_SEQUENCE_]; next unless ( defined($seqno) ); - # Only for types of container tokens with a non-default break option + # Only for types of container tokens with a non-default break option my $token_end = $rLL->[$Kend]->[_TOKEN_]; my $break_option = $break_before_container_types{$token_end}; next unless ($break_option); diff --git a/t/snippets/bbhb4.par b/t/snippets/bbhb4.par index 6fd2493d..c4d74afd 100644 --- a/t/snippets/bbhb4.par +++ b/t/snippets/bbhb4.par @@ -1 +1 @@ --bbhb=3 -bbp=3 -ihb=2 -ip=2 +-bbhb=3 -bbp=3 -bbhbi=2 -bbpi=2 diff --git a/t/snippets/bbhb5.par b/t/snippets/bbhb5.par index 88198261..9ada77dc 100644 --- a/t/snippets/bbhb5.par +++ b/t/snippets/bbhb5.par @@ -1 +1 @@ --bbhb=3 -bbp=3 -ihb=1 -ip=1 +-bbhb=3 -bbp=3 -bbhbi=1 -bbpi=1 diff --git a/t/snippets22.t b/t/snippets22.t index 104fe846..942240fb 100644 --- a/t/snippets22.t +++ b/t/snippets22.t @@ -26,8 +26,8 @@ BEGIN { $rparams = { 'bbhb2' => "-bbhb=2 -bbp=2", 'bbhb3' => "-bbhb=3 -bbp=3", - 'bbhb4' => "-bbhb=3 -bbp=3 -ihb=2 -ip=2", - 'bbhb5' => "-bbhb=3 -bbp=3 -ihb=1 -ip=1", + 'bbhb4' => "-bbhb=3 -bbp=3 -bbhbi=2 -bbpi=2", + 'bbhb5' => "-bbhb=3 -bbp=3 -bbhbi=1 -bbpi=1", 'def' => "", 'here_long' => "-l=33", };