B<--keyword-group-blanks-list=s>, or B<-kgbl=s>; B<s> is a quoted string of keywords
-B<--keyword-group-blanks-count=n>, or B<-kgbc=n>; B<n> is a threshold group size
+B<--keyword-group-blanks-threshold-count=n>, or B<-kgbt=n>; B<n> is a threshold (minimum) group size
B<--keyword-group-blanks-before=n>, or B<-kgbb=n>; B<n> = (0, 1, or 2) controls a leading blank
space separated list of keywords. The default set is B<s="use require local
our my sub">, but any list of keywords may be used.
-B<--keyword-group-blanks-count=n>, or B<-kgbc=n>, where B<n> is the minimum
+B<--keyword-group-blanks-threshold-count=n>, or B<-kgbt=n>, where B<n> is the minimum
number of consecutive keyword statements to which these controls apply. The
-default is B<n=5>. The special value B<n=0> can be used to turn off all
-searching for keyword groups.
+default is B<n=5>. The special value B<n=0> is the same as n=infinity and
+can be used to turn off all searching for keyword groups.
B<--keyword-group-blanks-before=n>, or B<-kgbb=n>, specifies whether
a blank should appear before the first line of the group, as follows:
B<--keyword-group-blanks-inside>, or B<-kgbi>, controls
the insertion of blank lines between the first and last statement of the entire
group. If there is a continuous run of a single statement type with more than
-the minimum threshold number (as specified with B<-kgbc=n>) then this
+the minimum threshold number (as specified with B<-kgbt=n>) then this
switch causes a blank line be inserted between this
subgroup and the others. In the example above this happened between the
B<use> and B<my> statements.
insertions are made when the parameter B<-kgbd> is set. The default is not to
do this, B<-nkgbd>.
+B<--keyword-group-blanks-repeat-count=n>, or B<-kgbr=n>, where B<n> is the
+maximum number of times this logic will be applied to any file. The special
+value B<n=0> is the same as n=infinity which means it will be applied to an
+entire script [Default]. A value B<n=1> could be used to make it apply just
+one time for example. This might be useful for adjusting just the B<use>
+statements in the top part of a module for example.
+
B<--keyword-group-blanks>, or B<-kgb>, is an abbreviation equivalent to setting
B<-kgbb=1 -kgba=1 -kgbi>. This turns on keyword group formatting with a set of
default values.
<p><b>--keyword-group-blanks-list=s</b>, or <b>-kgbl=s</b>; <b>s</b> is a quoted string of keywords</p>
-<p><b>--keyword-group-blanks-count=n</b>, or <b>-kgbc=n</b>; <b>n</b> is a threshold group size</p>
+<p><b>--keyword-group-blanks-threshold-count=n</b>, or <b>-kgbt=n</b>; <b>n</b> is a threshold (minimum) group size</p>
<p><b>--keyword-group-blanks-before=n</b>, or <b>-kgbb=n</b>; <b>n</b> = (0, 1, or 2) controls a leading blank</p>
<p><b>--keyword-group-blanks-list=s</b>, or <b>-kgbl=s</b>, where <b>s</b> is a quoted string, defines the set of keywords which will be formed into groups. The string is a space separated list of keywords. The default set is <b>s="use require local our my sub"</b>, but any list of keywords may be used.</p>
-<p><b>--keyword-group-blanks-count=n</b>, or <b>-kgbc=n</b>, where <b>n</b> is the minimum number of consecutive keyword statements to which these controls apply. The default is <b>n=5</b>. The special value <b>n=0</b> can be used to turn off all searching for keyword groups.</p>
+<p><b>--keyword-group-blanks-threshold-count=n</b>, or <b>-kgbt=n</b>, where <b>n</b> is the minimum number of consecutive keyword statements to which these controls apply. The default is <b>n=5</b>. The special value <b>n=0</b> is the same as n=infinity and can be used to turn off all searching for keyword groups.</p>
<p><b>--keyword-group-blanks-before=n</b>, or <b>-kgbb=n</b>, specifies whether a blank should appear before the first line of the group, as follows:</p>
<p><b>--keyword-group-blanks-after=n</b>, or <b>-kgba=n</b>, likewise specifies whether a blank should appear after the last line of the group, using the same scheme (0=delete, 1=stable, 2=insert).</p>
-<p><b>--keyword-group-blanks-inside</b>, or <b>-kgbi</b>, controls the insertion of blank lines between the first and last statement of the entire group. If there is a continuous run of a single statement type with more than the minimum threshold number (as specified with <b>-kgbc=n</b>) then this switch causes a blank line be inserted between this subgroup and the others. In the example above this happened between the <b>use</b> and <b>my</b> statements.</p>
+<p><b>--keyword-group-blanks-inside</b>, or <b>-kgbi</b>, controls the insertion of blank lines between the first and last statement of the entire group. If there is a continuous run of a single statement type with more than the minimum threshold number (as specified with <b>-kgbt=n</b>) then this switch causes a blank line be inserted between this subgroup and the others. In the example above this happened between the <b>use</b> and <b>my</b> statements.</p>
<p><b>--keyword-group-blanks-delete</b>, or <b>-kgbd</b>, controls the deletion of any blank lines that exist in the the group when it is first scanned. When statements are initially scanned, any existing blank lines are included in the collection. Any such orignial blank lines will be deleted before any other insertions are made when the parameter <b>-kgbd</b> is set. The default is not to do this, <b>-nkgbd</b>.</p>
+<p><b>--keyword-group-blanks-repeat-count=n</b>, or <b>-kgbr=n</b>, where <b>n</b> is the maximum number of times this logic will be applied to any file. The special value <b>n=0</b> is the same as n=infinity which means it will be applied to an entire script [Default]. A value <b>n=1</b> could be used to make it apply just one time for example. This might be useful for adjusting just the <b>use</b> statements in the top part of a module for example.</p>
+
<p><b>--keyword-group-blanks</b>, or <b>-kgb</b>, is an abbreviation equivalent to setting <b>-kgbb=1 -kgba=1 -kgbi</b>. This turns on keyword group formatting with a set of default values.</p>
<p><b>--nokeyword-group-blanks</b>, or <b>-nkgb</b>, is equivalent to <b>-kgbb=0 -kgba nkgbi</b>. This flag turns off keyword group blank lines and is the default setting.</p>
$add_option->( 'blanks-after-comments', 'bac', '!' );
$add_option->( 'keyword-group-blanks-list', 'kgbl', '=s' );
- $add_option->( 'keyword-group-blanks-count', 'kgbc', '=i' );
+ $add_option->( 'keyword-group-blanks-threshold-count', 'kgbt', '=i' );
+ $add_option->( 'keyword-group-blanks-repeat-count', 'kgbr', '=i' );
$add_option->( 'keyword-group-blanks-before', 'kgbb', '=i' );
$add_option->( 'keyword-group-blanks-after', 'kgba', '=i' );
$add_option->( 'keyword-group-blanks-inside', 'kgbi', '!' );
blank-lines-before-packages=1
noblanks-after-comments
- keyword-group-blanks-count=5
+ keyword-group-blanks-threshold-count=5
+ keyword-group-blanks-repeat-count=0
keyword-group-blanks-before=1
keyword-group-blanks-after=1
nokeyword-group-blanks-inside
my $Opt_blanks_after = $rOpts->{'keyword-group-blanks-after'}; # '-kgba'
my $Opt_blanks_inside = $rOpts->{'keyword-group-blanks-inside'}; # '-kgbi'
my $Opt_blanks_delete = $rOpts->{'keyword-group-blanks-delete'}; # '-kgbd'
- my $Opt_long_count = $rOpts->{'keyword-group-blanks-count'}; # '-kgbc'
+ my $Opt_threshold_count = $rOpts->{'keyword-group-blanks-threshold-count'}; # '-kgbt'
# codes for $Opt_blanks_before and $Opt_blanks_after:
# 0 = never (delete if exist)
# 2 = always (insert if missing)
return $rhash_of_desires
- unless $Opt_long_count > 0
+ unless $Opt_threshold_count > 0
&& ( $Opt_blanks_before != 1
|| $Opt_blanks_after != 1
|| $Opt_blanks_inside
my $Opt_blanks_after_comments = $rOpts->{'blanks-after-comments'}; # '-bac'
my $Opt_pattern = $keyword_group_list_pattern;
+ my $Opt_repeat_count =
+ $rOpts->{'keyword-group-blanks-repeat-count'}; # '-kgbr'
my $rlines = $self->{rlines};
my $rLL = $self->{rLL};
# These vars will contain values for the most recently seen line:
my ( $line_type, $CODE_type, $K_first, $K_last );
+ my $number_of_groups_seen = 0;
+
my $split_into_sub_groups = sub {
# Here we place blanks around long sub-groups of keywords
for ( my $j = 1 ; $j < @sublist ; $j++ ) {
my $ie = $sublist[$j]->[0] - 1;
my $num = $sublist[ $j - 1 ]->[2];
- if ( $num >= $Opt_long_count ) {
+ if ( $num >= $Opt_threshold_count ) {
$rhash_of_desires->{ $ib - 1 } = 1 unless ( $ib == $ibeg );
$rhash_of_desires->{$ie} = 1 unless ( $ie == $iend );
}
if ( defined($ibeg) && $ibeg >= 0 ) {
# then handle sufficiently large groups
- if ( $count >= $Opt_long_count ) {
+ if ( $count >= $Opt_threshold_count ) {
+
+ $number_of_groups_seen++;
# do any blank deletions regardless of the count
$delete_inner_blank_lines->();
# loop over all lines of the source
my $i = -1;
foreach my $line_of_tokens ( @{$rlines} ) {
+
$i++;
+ last
+ if ( $Opt_repeat_count > 0
+ && $number_of_groups_seen >= $Opt_repeat_count );
$CODE_type = "";
$K_first = undef;