simply ignored. And if a parameter is entered in both lists (it should
not), then the exclusion list has priority.
-Note that control of side comment alignment is not done with these parameters but
-rather with the B<--valign-side_comments> listed above.
+To illustrate, consider the following snippet with default formatting
+
+ # perltidy
+ $co_description = ($color) ? 'bold cyan' : ''; # description
+ $co_prompt = ($color) ? 'bold green' : ''; # prompt
+ $co_unused = ($color) ? 'on_green' : 'reverse'; # unused
+
+To exclude all alignments except the equals we could use:
+
+ # perltidy -vxl='*' -vil='='
+ $co_description = ($color) ? 'bold cyan' : ''; # description
+ $co_prompt = ($color) ? 'bold green' : ''; # prompt
+ $co_unused = ($color) ? 'on_green' : 'reverse'; # unused
+
+To exclude only the equals we could use:
+
+ # perltidy -vxl='='
+ $co_description = ($color) ? 'bold cyan' : ''; # description
+ $co_prompt = ($color) ? 'bold green' : ''; # prompt
+ $co_unused = ($color) ? 'on_green' : 'reverse'; # unused
+
+Notice in this last example that although only the equals alignment was
+excluded, the ternary alignments were also lost. This happens because
+alignments are formed from left-to-right, and when an alignment is prevented
+for any reason, any remaining possible alignments to its right are skipped.
+
+Also notice side comments remain aligned because their alignment is
+controlled separately with the parameter B<--valign-side_comments> described above.
=back
$pad += $leading_space_count;
}
- # Give up if not enough space is available to increase padding.
- # Note: $padding_available can be a negative number.
- my $no_fit = $pad > 0 && $pad > $padding_available;
-
- # Apply any user-defined vertical alignment controls in top-down sweep
- if ( !$no_fit
- && $j < $jmax
- && %valign_control_hash )
- {
-
- my $tok = $rtokens_old->[$j];
- my ( $raw_tok, $lev, $tag, $tok_count ) =
- decode_alignment_token($tok);
-
- my $align_ok = $valign_control_hash{$raw_tok};
- $align_ok = $valign_control_default unless defined($align_ok);
-
- if ( !$align_ok && $pad != 0 ) {
- $no_fit = 1;
- }
- }
+ # Keep going if this field does not need any space.
+ next if ( $pad < 0 );
# Revert to the starting state if does not fit
- if ($no_fit) {
+ if ( $pad > $padding_available ) {
################################################
# Line does not fit -- revert to starting state
return;
}
- # Keep going if this field does not need any space.
- next if ( $pad < 0 );
-
# make room for this field
$old_line->increase_field_width( $j, $pad );
$padding_available -= $pad;
&& $col > $col_want + $short_pad * $factor;
}
- # Apply user-defined vertical alignment controls in l-r sweep
- if ( !$is_big_gap && %valign_control_hash ) {
-
- my $align_ok = $valign_control_hash{$raw_tok};
- $align_ok = $valign_control_default
- unless defined($align_ok);
-
- # Note that the following definition of $pad is not the
- # total pad because we are working at group boundaries. But
- # we can still see if it is zero or not.
- if ( !$align_ok && $col_want != $col ) {
- $is_big_gap = 1;
- }
- }
-
# if match is limited by gap size, stop aligning at this level
if ($is_big_gap) {
$blocking_level[$ng] = $lev - 1;
# this way so they have to be applied elsewhere too.
my $align_ok = 1;
if (%valign_control_hash) {
- my $align_ok = $valign_control_hash{$raw_tok};
+ $align_ok = $valign_control_hash{$raw_tok};
$align_ok = $valign_control_default
unless defined($align_ok);
$delete_me ||= !$align_ok;