B<-block-brace-tightness=n> for code block braces and B<-brace-tightness=n> for
all other braces.
-Curly braces which are considered by perltidy to contain code blocks for
-formatting purposes exclude some of the code blocks used by Perl mainly for
-isolating terms. These include curly braces following a keyword where an
-indirect object might occur, or curly braces following a type symbol. For
-example, perltidy does not mark the following braces as code block braces:
+There is a little fuzziness in this division of brace types though because the
+curly braces considered by perltidy to contain code blocks for formatting
+purposes, such as highlighting code structure, exclude some of the small code
+blocks used by Perl mainly for isolating terms. These include curly braces
+following a keyword where an indirect object might occur, or curly braces
+following a type symbol. For example, perltidy does not mark the following
+braces as code block braces:
print {*STDERR} $message;
- return @{$self};
+ return ${$foo};
-Consequently, the spacing within these small braced containers follows the flag
-B<--brace-tightness=n> rather than B<--block-brace-tightness=n>, as one might
-expect.
+Consequently, the spacing within these small braced containers by default
+follows the flag B<--brace-tightness=n> rather than
+B<--block-brace-tightness=n>, as one might expect.
-If desired, these small blocks can be made to instead follow the spacing
-defined by the B<--block-brace-tightness=n> flag by seting
-B<--extended-block-tightness>.
+If desired, small blocks such as these can be made to instead follow the
+spacing defined by the B<--block-brace-tightness=n> flag by seting
+B<--extended-block-tightness>. The specific types of small blocks to which
+this parameter applies is controlled by a companion control parameter,
+described in the next section.
Note that if the two flags B<-bbt=n> and B<-bt=n> have the same value
B<n> then there would be no reason to set this flag.
=item B<-xbtl=s>, B<--extended-block-tightness-list=s>
-By default, the previous parameter B<-xbt> applies to curly braces preceded by
-the keywords
+The previous parameter B<-xbt> can be made to apply curly braces preceded by
+any of the keywords
print printf exec system say
-and by the special symbols
+and/or the special symbols
$ @ % & * $#
-This default behavior can be changed as follows. To restrict B<-xbt> to apply
-to just the above keywords use
+The parameter string B<s> may contain a selection of these keywords and symbols
+to indicate the brace types to which B<-xbt> applies. For convenience, all of
+the keywords can be selected with 'k', and all of the special symbols
+can be selected with 't'. The default is equivalent to B<-xbtl='k'>, which
+selects all of the keywords.
- -xbtl=k
+Examples:
-and to restrict it to apply to just the above special type symbols use
+ -xbtl='k' # selects just the keywords [DEFAULT]
+ -xbtl="t" # selects just the special type symbols
+ -xbtl="k t" # selects all keywords and symbols, or more simply
+ -xbtl="kt" # selects all keywords and symbols
+ -xbtl="print say" # selects just keywords B<print> and B<say>:
- -xbtl=t
+Here are some formatting examples using the default values of B<-bt=n> and
+B<-bbt=n>. Note that in these examples B<$ref> is in block braces but B<$key>
+is not.
-More generally, to restrict it to specific keywords or type symbols in the
-above lists, enter them in the parameter list B<s>. For example, the following
-restricts it apply to just the keywords B<print> and B<say>:
+ # default formatting
+ print {*STDERR} $message;
+ my $refalue = ${$ref}{$key};
+
+ # perltidy -xbt or
+ # perltidy -xbt -xbtl=k
+ print { *STDERR } $message;
+ my $refalue = ${$ref}{$key};
+
+ # perltidy -xbt -xbtl=t
+ print {*STDERR} $message;
+ my $refalue = ${ $ref }{$key};
- -xbtl="print say"
+ # perltidy -xbt -xbtl=kt
+ print { *STDERR } $message;
+ my $refalue = ${ $ref }{$key};
-Note that this parameter merely changes the way that the parameter
+Finally, note that this parameter merely changes the way that the parameter
B<--extended-block-tightness> works. It has no effect unless
B<--extended-block-tightness> is actually set.
my %option_range = (
'format' => [ 'tidy', 'html' ], #, 'user' ],
'output-line-ending' => [ 'dos', 'win', 'mac', 'unix' ],
+ 'extended-block-tightness-list' => [ 'k', 't', 'kt' ],
'space-backslash-quote' => [ 0, 2 ],
'block-brace-tightness' => [ 0, 2 ],
sub initialize_extended_block_tightness_list {
+ # Setup the control hash for --extended-block-tightness
+
# keywords taking indirect objects:
my @k_list = keys %is_indirect_object_taker;
my @t_list = qw($ @ % & *);
push @t_list, '$#';
- # Set the default to include all keywords ant types.
+ my @all = ( @k_list, @t_list );
+
# We will build the selection in %hash
+ # By default the option is 'on' for keywords only (-xbtl='k')
my %hash;
- my @all = ( @k_list, @t_list );
- @hash{@all} = (1) x scalar(@all);
+ @hash{@k_list} = (1) x scalar(@k_list);
+ @hash{@t_list} = (0) x scalar(@t_list);
# This can be overridden with -xbtl="..."
my $long_name = 'extended-block-tightness-list';
@hash{@t_list} = (1) x scalar(@t_list);
}
- # 'kt' same as 'k' and 't' for convenience (same as default)
+ # 'kt' same as 'k' and 't' for convenience
elsif ( $word eq 'kt' ) {
@hash{@all} = (1) x scalar(@all);
}
}
}
+ # Transfer the result to the global hash
%extended_block_tightness_list = %hash;
+
return;
-}
+} ## end sub initialize_extended_block_tightness_list
sub initialize_token_break_preferences {
-print { *STDERR } ${ $data_sref };
+print { *STDERR } ${$data_sref};
say { *STDERR } dump $c->{cookies};
$rc = system { "lskdfj" } "lskdfj";
test !eval { exec { 'notaint' } $TAINT }, 'exec';
-delete ${ "$ {dest}::" }{$name};
-my @matches =
- @{ $nodes_ref } > 1 ? @{ $nodes_ref }[ 1 .. $#{ $nodes_ref } ] : ();
-%{ $self } = %{ $project };
-*{ $name } = $sub;
-grep { defined &{ ${ "${class}::" }{$_} } } &{ "${class}::Clear" }();
+delete ${"$ {dest}::"}{$name};
+my @matches = @{$nodes_ref} > 1 ? @{$nodes_ref}[ 1 .. $#{$nodes_ref} ] : ();
+%{$self} = %{$project};
+*{$name} = $sub;
+grep { defined &{ ${"${class}::"}{$_} } } &{"${class}::Clear"}();
-print { *STDERR } ${$data_sref};
+print { *STDERR } ${ $data_sref };
say { *STDERR } dump $c->{cookies};
$rc = system { "lskdfj" } "lskdfj";
test !eval { exec { 'notaint' } $TAINT }, 'exec';
-delete ${"$ {dest}::"}{$name};
-my @matches = @{$nodes_ref} > 1 ? @{$nodes_ref}[ 1 .. $#{$nodes_ref} ] : ();
-%{$self} = %{$project};
-*{$name} = $sub;
-grep { defined &{ ${"${class}::"}{$_} } } &{"${class}::Clear"}();
+delete ${ "$ {dest}::" }{$name};
+my @matches =
+ @{ $nodes_ref } > 1 ? @{ $nodes_ref }[ 1 .. $#{ $nodes_ref } ] : ();
+%{ $self } = %{ $project };
+*{ $name } = $sub;
+grep { defined &{ ${ "${class}::" }{$_} } } &{ "${class}::Clear" }();
--xbt -xbtl=k
+-xbt -xbtl=kt
-olbxl='*'
----------
'xbt1' => "-xbt",
- 'xbt2' => "-xbt -xbtl=k",
+ 'xbt2' => "-xbt -xbtl=kt",
'xbt3' => <<'----------',
-xbt -bbt=2 -xbtl="print say t"
----------
source => "xbt",
params => "xbt1",
expect => <<'#9...........',
-print { *STDERR } ${ $data_sref };
+print { *STDERR } ${$data_sref};
say { *STDERR } dump $c->{cookies};
$rc = system { "lskdfj" } "lskdfj";
test !eval { exec { 'notaint' } $TAINT }, 'exec';
-delete ${ "$ {dest}::" }{$name};
-my @matches =
- @{ $nodes_ref } > 1 ? @{ $nodes_ref }[ 1 .. $#{ $nodes_ref } ] : ();
-%{ $self } = %{ $project };
-*{ $name } = $sub;
-grep { defined &{ ${ "${class}::" }{$_} } } &{ "${class}::Clear" }();
+delete ${"$ {dest}::"}{$name};
+my @matches = @{$nodes_ref} > 1 ? @{$nodes_ref}[ 1 .. $#{$nodes_ref} ] : ();
+%{$self} = %{$project};
+*{$name} = $sub;
+grep { defined &{ ${"${class}::"}{$_} } } &{"${class}::Clear"}();
#9...........
},
source => "xbt",
params => "xbt2",
expect => <<'#10...........',
-print { *STDERR } ${$data_sref};
+print { *STDERR } ${ $data_sref };
say { *STDERR } dump $c->{cookies};
$rc = system { "lskdfj" } "lskdfj";
test !eval { exec { 'notaint' } $TAINT }, 'exec';
-delete ${"$ {dest}::"}{$name};
-my @matches = @{$nodes_ref} > 1 ? @{$nodes_ref}[ 1 .. $#{$nodes_ref} ] : ();
-%{$self} = %{$project};
-*{$name} = $sub;
-grep { defined &{ ${"${class}::"}{$_} } } &{"${class}::Clear"}();
+delete ${ "$ {dest}::" }{$name};
+my @matches =
+ @{ $nodes_ref } > 1 ? @{ $nodes_ref }[ 1 .. $#{ $nodes_ref } ] : ();
+%{ $self } = %{ $project };
+*{ $name } = $sub;
+grep { defined &{ ${ "${class}::" }{$_} } } &{ "${class}::Clear" }();
#10...........
},