Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream changes: ## 2025 01 05 - If a file consists only of comments, then the starting indentation will be guessed from the indentation of the first comment. Previously it would be guessed to be zero. Parameter --starting-indentation-level=n can be used to specify an indentation and avoid a guess. This issue can arise when formatting a block of comments from within an editor. - Added missing 'use File::Temp' for -html option. This was causing the message: "Undefined subroutine &File::Temp::tempfile called at ..." See git #176. - A new parameter --dump-unique-keys, or -duk, dumps a list of hash keys which appear to be used just once, and do not appear among the quoted strings in a file. For example: perltidy -duk File.pm >output.txt This can help locate misspelled hash keys. - Line breaks at long chains of method calls now break at all calls with args in parens, as in this example from git #171 # Old default sub bla_p( $value = 42 ) { return Mojo::Promise->resolve($value)->then( sub { shift() / 2 } ) ->then( sub { shift() + 6 } )->then( sub { shift() / 2 } ) ->catch( sub { warn shift } ); } # New default sub bla_p( $value = 42 ) { return Mojo::Promise->resolve($value) ->then( sub { shift() / 2 } ) ->then( sub { shift() + 6 } ) ->then( sub { shift() / 2 } ) ->catch( sub { warn shift } ); } - Parameter --break-at-old-method-breakpoints, or -bom, has been updated to insure that it only applies to lines beginning with method calls, as intended. Line breaks for all lines beginning with '->', even non-method calls, can be retained by using --keep-old-breakpoints_before='->'. - Added parameter --multiple-token-tightness=s, or -mutt=s. The default value --paren-tightness=1 adds space within the parens if, and only if, the container holds multiple tokens. Some perltidy tokens may be rather long, and it can be preferable to also space some of them as if they were multiple tokens. This can be done with this parameter, and it applies to parens as well as square brackets and curly braces. For example, the default below has no space within the square brackets: # perltidy my $rlist = [qw( alpha beta gamma )]; Spaces can be obtained with: # perltidy -mutt='q*' my $rlist = [ qw( alpha beta gamma ) ]; The parameter -mutt='q*' means treat qw and similar quote operators as multiple tokens. The manual has details; git #120 has another example. - Added parameter --indent-leading-semicolon, -ils; see git #171. When this is negated, a line with a leading semicolon does not get the extra leading continuation indentation spaces (defined with -ci=n). - Space around here doc delimiters follow spacing controls better. For example, a space is now added before the closing paren here: OLD: (without the here doc): push( @script, <<'EOT'); NEW: push( @script, <<'EOT' ); Also, any spaces between the '<<' and here target are removed (git #174): OLD: push( @script, << 'EOT'); NEW: push( @script, <<'EOT' ); - Added parameter --break-at-trailing-comma-types=s, or -btct=s, where s is a string which selects trailing commas. For example, -btct='f(b' places a line break after all bare trailing commas in function calls. The manual has details. - Fix git #165, strings beginning with v before => gave an incorrect error message. - The parameter --add-lone-trailing-commas, -altc, is now on by default. This will simplify input for trailing comma operations. Use --noadd-lone-trailing-commas, or -naltc to turn it off. - More edge cases for adding and deleting trailing commas are now handled (git #156). - A problem has been fixed in which the addition or deletion of trailing commas with the -atc or -dtc flags did not occur due to early convergence when the -conv flag was set (git #143). - Added parameter --qw-as-function, or -qwaf, discussed in git #164. When this parameter is set, a qw list which begins with 'qw(' is formatted as if it were a function call with call args being a list of comma-separated quoted items. For example, given this input: @fields = qw( $st_dev $st_ino $st_mode $st_nlink $st_uid $st_gid $st_rdev $st_size $st_atime $st_mtime $st_ctime $st_blksize $st_blocks); # perltidy -qwaf @fields = qw( $st_dev $st_ino $st_mode $st_nlink $st_uid $st_gid $st_rdev $st_size $st_atime $st_mtime $st_ctime $st_blksize $st_blocks );
- Loading branch information