>Are you sure about that? My understanding was that perltidy breaks lines for the very reason that they are too long ...
I misspoke about that part. But I was on the right track. The thing I missed before is that indentation is treated differently if there is a long expression inside parentheses. There is also a difference if all the operators in an expression are the same. The examples below show what I mean. It seems to be working consistently. Have you tried running it on a large chunk of code to see how different situations are handled?
testtidy.pl
if ($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $bazba
+zbazbazbaz) {
foo1();
}
if ($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz) {
foo2();
}
$foofoofoofoofoo = "abcdef ghijklmnop" . "abcdef ghijklmnop";
$foofoofoofoofoo = "abcdef ghijklmnop" . "abcdef ghijklmnop" . "abcdef
+ ghijklmnop";
$foofoofoofoofoo = "abcdef ghijklmnop" . "abcdef ghijklmnop" . "abcdef
+ ghijklmnop" . "abcdef ghijklmnop";
my $level1 = ( $max_index_to_go >= 0 ) ? $levels_to_go_12345[0] : $las
+t_output_level_12345;
my $level2 = ( $max_index_to_go >= 0 ) ? $levels_to_go_1234567890[0] :
+ $last_output_level_1234567890;
while ($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $ba
+zbazbazbazbaz) {
1;
}
while ("abcdef ghijklmnop" . "abcdef ghijklmnop" . "abcdef ghijklmnop"
+ . "abcdef ghijklmnop") {
1;
}
($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $bazbazba
+zbazbaz || $123456) || $bazbazbazbazbaz;
($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $bazbazba
+zbazbaz && $123456) || $bazbazbazbazbaz;
When I run perltidy -l=80 -i=4 -ci=2 testtidy.pl it produces this:
if ( $foofoofoofoofoo
&& $barbarbarbarbar
&& $bazbazbazbazbaz
&& $bazbazbazbazbaz )
{
foo1();
}
if ( $foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz ) {
foo2();
}
$foofoofoofoofoo = "abcdef ghijklmnop" . "abcdef ghijklmnop";
$foofoofoofoofoo =
"abcdef ghijklmnop" . "abcdef ghijklmnop" . "abcdef ghijklmnop";
$foofoofoofoofoo =
"abcdef ghijklmnop"
. "abcdef ghijklmnop"
. "abcdef ghijklmnop"
. "abcdef ghijklmnop";
my $level1 =
( $max_index_to_go >= 0 ) ? $levels_to_go_12345[0] : $last_output_le
+vel_12345;
my $level2 =
( $max_index_to_go >= 0 )
? $levels_to_go_1234567890[0]
: $last_output_level_1234567890;
while ($foofoofoofoofoo
&& $barbarbarbarbar
&& $bazbazbazbazbaz
&& $bazbazbazbazbaz )
{
1;
}
while ( "abcdef ghijklmnop"
. "abcdef ghijklmnop"
. "abcdef ghijklmnop"
. "abcdef ghijklmnop" )
{
1;
}
( $foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $bazbazb
+azbazbaz
|| $123456 )
|| $bazbazbazbazbaz;
( $foofoofoofoofoo
&& $barbarbarbarbar
&& $bazbazbazbazbaz
&& $bazbazbazbazbaz
&& $123456 )
|| $bazbazbazbazbaz;
Edit: Here's one more example using a lot of parentheses. testtidy2.pl:
(($foofoofoofoofoo && $barbarbarbarbar && $bazbazbazbazbaz && $bazbazb
+azbazbaz || $12345678901234567890) && $test112345123456789 ) && $test
+22222233333 || $bazbazbazbazbaz || $bazbazbazbazbaz123456 && $bazbazb
+azbazbaz123456789 || (($x1122334441234512345 && $x2211123451345 % $x3
+3112212345123451234 && $y111222123451234512345 || $y11122222123451234
+5 ) && ($x1234512345123456789 || $x12345612345123456789 || $x12356712
+3451234567890 && $x1234123412345 )) || $xx1122331234512345 && $xx1231
+231234512345;
I compared running perltidy.pl with the default options and with your options and it gave the same output. If it used the continuing line spacing inside parentheses I don't think it would be as clear as this.
(
(
$foofoofoofoofoo
&& $barbarbarbarbar
&& $bazbazbazbazbaz
&& $bazbazbazbazbaz || $12345678901234567890
)
&& $test112345123456789
)
&& $test22222233333
|| $bazbazbazbazbaz
|| $bazbazbazbazbaz123456 && $bazbazbazbazbaz123456789
|| (
(
$x1122334441234512345
&& $x2211123451345 % $x33112212345123451234
&& $y111222123451234512345 || $y111222221234512345
)
&& ( $x1234512345123456789
|| $x12345612345123456789
|| $x123567123451234567890 && $x1234123412345 )
)
|| $xx1122331234512345 && $xx1231231234512345;