## 2018 11 20.01
+ - added option -bom (--break-at-old-method-breakpoints) by
+ merrillymeredith which preserves breakpoints of method chains
+
+ - merged patch to fix Windows EOL translation error with UTF-8 written by
+ Ron Ivy. This update prevents automatic conversion to 'DOS' CRLF line
+ endings.
+
- RT #128280, added flag --one-line-block-semicolons=n (-olbs=n)
to control semicolons in one-line blocks. The values of n are:
n=0 means no semicolons termininating simple one-line blocks
'track.id' => {-ident => 'none_search.id'},
})->as_query;
+This flag will also look for and keep a 'cuddled' style of calls,
+in which lines begin with a closing paren followed by a call arrow,
+as in this example:
+
+ my $q = $rs->related_resultset(
+ 'CDs'
+ )->related_resultset(
+ 'Tracks'
+ )->search( {
+ 'track.id' => { -ident => 'none_search.id' },
+ } )->as_query;
+
+You may want to include the B<-weld-nested-containers> flag in this case to keep
+nested braces and parens together, as in the last line.
+
+
=item B<-bok>, B<--break-at-old-keyword-breakpoints>
By default, perltidy will retain a breakpoint before keywords which may
<h2>2018 11 20.01</h2>
-<pre><code>- RT #128280, added flag --one-line-block-semicolons=n (-olbs=n)
+<pre><code>- added option -bom (--break-at-old-method-breakpoints) by
+ merrillymeredith which preserves breakpoints of method chains
+
+- merged patch to fix Windows EOL translation error with UTF-8 written by
+ Ron Ivy. This update prevents automatic conversion to 'DOS' CRLF line
+ endings.
+
+- RT #128280, added flag --one-line-block-semicolons=n (-olbs=n)
to control semicolons in one-line blocks. The values of n are:
n=0 means no semicolons termininating simple one-line blocks
n=1 means stable; do not change from input file [DEFAULT and current]
<dt id="o-filename---outfile-filename"><b>-o</b>=filename, <b>--outfile</b>=filename</dt>
<dd>
-<p>Name of the output file (only if a single input file is being processed). If no output file is specified, and output is not redirected to the standard output, the output will go to <i>filename.tdy</i>.</p>
+<p>Name of the output file (only if a single input file is being processed). If no output file is specified, and output is not redirected to the standard output (see <b>-st</b>), the output will go to <i>filename.tdy</i>. [Note: - does not redirect to standard output. Use <b>-st</b> instead.]</p>
</dd>
<dt id="st---standard-output"><b>-st</b>, <b>--standard-output</b></dt>
<p>By default, if a logical expression is broken at a <code>&&</code>, <code>||</code>, <code>and</code>, or <code>or</code>, then the container will remain broken. Also, breaks at internal keywords <code>if</code> and <code>unless</code> will normally be retained. To prevent this, and thus form longer lines, use <b>-nbol</b>.</p>
+</dd>
+<dt id="bom---break-at-old-method-breakpoints"><b>-bom</b>, <b>--break-at-old-method-breakpoints</b></dt>
+<dd>
+
+<p>By default, a method call arrow <code>-></code> is considered a candidate for a breakpoint, but method chains will fill to the line width before a break is considered. With <b>-bom</b>, breaks before the arrow are preserved, so if you have preformatted a method chain:</p>
+
+<pre><code> my $q = $rs
+ ->related_resultset('CDs')
+ ->related_resultset('Tracks')
+ ->search({
+ 'track.id' => {-ident => 'none_search.id'},
+ })->as_query;</code></pre>
+
+<p>It will <b>keep</b> these breaks, rather than become this:</p>
+
+<pre><code> my $q = $rs->related_resultset('CDs')->related_resultset('Tracks')->search({
+ 'track.id' => {-ident => 'none_search.id'},
+ })->as_query;</code></pre>
+
+<p>This flag will also look for and keep a 'cuddled' style of calls, in which lines begin with a closing paren followed by a call arrow, as in this example:</p>
+
+<pre><code> my $q = $rs->related_resultset(
+ 'CDs'
+ )->related_resultset(
+ 'Tracks'
+ )->search( {
+ 'track.id' => { -ident => 'none_search.id' },
+ } )->as_query;</code></pre>
+
+<p>You may want to include the <b>-weld-nested-containers</b> flag in this case to keep nested braces and parens together, as in the last line.</p>
+
</dd>
<dt id="bok---break-at-old-keyword-breakpoints"><b>-bok</b>, <b>--break-at-old-keyword-breakpoints</b></dt>
<dd>
<dl>
-<dt id="Around-line-2693">Around line 2693:</dt>
+<dt id="Around-line-2731">Around line 2731:</dt>
<dd>
<p>'=item' outside of any '=over'</p>
</dd>
-<dt id="Around-line-2881">Around line 2881:</dt>
+<dt id="Around-line-2919">Around line 2919:</dt>
<dd>
<p>You forgot a '=back' before '=head2'</p>
</dd>
-<dt id="Around-line-2939">Around line 2939:</dt>
+<dt id="Around-line-2977">Around line 2977:</dt>
<dd>
<p>'=item' outside of any '=over'</p>
</dd>
-<dt id="Around-line-3020">Around line 3020:</dt>
+<dt id="Around-line-3058">Around line 3058:</dt>
<dd>
<p>You forgot a '=back' before '=head2'</p>
# remember locations of -> if this is a pre-broken method chain
if ( $type eq '->' ) {
- set_forced_breakpoint($i - 1)
- if ( ( $i == $i_line_start )
- && $rOpts_break_at_old_method_breakpoints );
+## set_forced_breakpoint($i - 1)
+## if ( ( $i == $i_line_start )
+## && $rOpts_break_at_old_method_breakpoints );
+ if ($rOpts_break_at_old_method_breakpoints) {
+
+ # Case 1: look for lines with leading pointers
+ if ( $i == $i_line_start ) {
+ set_forced_breakpoint( $i - 1 );
+ }
+
+ # Case 2: look for cuddled pointer calls
+ else {
+
+ # look for old lines with leading ')->' or ') ->'
+ # and, when found, force a break before the
+ # opening paren and previous closing paren.
+ if (
+ $types_to_go[$i_line_start] eq '}'
+ && ( $i == $i_line_start + 1
+ || $i == $i_line_start + 2
+ && $types_to_go[ $i - 1 ] eq 'b' )
+ )
+ {
+ set_forced_breakpoint( $i_line_start - 1 );
+ set_forced_breakpoint($mate_index_to_go[$i_line_start]);
+ }
+ }
+ }
} ## end if ( $type eq '->' )
+
# remember locations of '||' and '&&' for possible breaks if we
# decide this is a long logical expression.
elsif ( $type eq '||' ) {
--- /dev/null
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve(
+ $query_params
+)->then(
+ &_reveal_event
+)->then(sub ($code) {
+ return $c->render(text => '', status => $code);
+})->catch(sub {
+ # 1. return error
+ return $c->render(json => {}, status => 400);
+});
--- /dev/null
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve(
+ $query_params
+)->then(
+ &_reveal_event
+)->then( sub ($code) {
+ return $c->render( text => '', status => $code );
+} )->catch( sub {
+
+ # 1. return error
+ return $c->render( json => {}, status => 400 );
+} );
--- /dev/null
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve($query_params)->then(&_reveal_event)->then(
+ sub ($code) {
+ return $c->render( text => '', status => $code );
+ }
+)->catch(
+ sub {
+ # 1. return error
+ return $c->render( json => {}, status => 400 );
+ }
+);
../snippets15.t olbs.def
../snippets15.t olbs.olbs0
../snippets15.t olbs.olbs2
+../snippets15.t break_old_methods.break_old_methods
+../snippets15.t break_old_methods.def
../snippets2.t angle.def
../snippets2.t arrows1.def
../snippets2.t arrows2.def
../snippets9.t rt98902.def
../snippets9.t rt98902.rt98902
../snippets9.t rt99961.def
-../snippets15.t break_old_methods.break_old_methods
-../snippets15.t break_old_methods.def
+../snippets15.t bom1.bom
+../snippets15.t bom1.def
#5 olbs.olbs2
#6 break_old_methods.break_old_methods
#7 break_old_methods.def
+#8 bom1.bom
+#9 bom1.def
# To locate test #13 you can search for its name or the string '#13'
# BEGIN SECTION 1: Parameter combinations #
###########################################
$rparams = {
+ 'bom' => "-bom -wn",
'break_old_methods' => "--break-at-old-method-breakpoints",
'def' => "",
'gnu' => "-gnu",
############################
$rsources = {
+ 'bom1' => <<'----------',
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve(
+ $query_params
+)->then(
+ &_reveal_event
+)->then(sub ($code) {
+ return $c->render(text => '', status => $code);
+})->catch(sub {
+ # 1. return error
+ return $c->render(json => {}, status => 400);
+});
+----------
+
'break_old_methods' => <<'----------',
my $q = $rs
->related_resultset('CDs')
)->as_query;
#7...........
},
+
+ 'bom1.bom' => {
+ source => "bom1",
+ params => "bom",
+ expect => <<'#8...........',
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve(
+ $query_params
+)->then(
+ &_reveal_event
+)->then( sub ($code) {
+ return $c->render( text => '', status => $code );
+} )->catch( sub {
+
+ # 1. return error
+ return $c->render( json => {}, status => 400 );
+} );
+#8...........
+ },
+
+ 'bom1.def' => {
+ source => "bom1",
+ params => "def",
+ expect => <<'#9...........',
+# keep cuddled call chain with -bom
+return Mojo::Promise->resolve($query_params)->then(&_reveal_event)->then(
+ sub ($code) {
+ return $c->render( text => '', status => $code );
+ }
+)->catch(
+ sub {
+ # 1. return error
+ return $c->render( json => {}, status => 400 );
+ }
+);
+#9...........
+ },
};
my $ntests = 0 + keys %{$rtests};