From: Steve Hancock Date: Mon, 7 Feb 2022 19:23:12 +0000 (-0800) Subject: allow -vil=s without -vxl='*' X-Git-Tag: 20220217~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fa7bb88ad5781400c74fe9c576ce368050327fa8;p=perltidy.git allow -vil=s without -vxl='*' --- diff --git a/bin/perltidy b/bin/perltidy index bc593239..0733f6ae 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -4345,20 +4345,23 @@ of the tokens ',', '=', and '=>', but many other alignments are possible and are { ( ? : , ; => && || ~~ !~~ =~ !~ // <=> -> if unless and or err for foreach while until -These alignments are all enabled by default, but they can be selectively disabled by including one or more of these tokens in the space-separated list B. For example, the following would prevent alignment at B<=> and B: +These alignments are all enabled by default, but they can be selectively disabled by including one or more of these tokens in the space-separated list B. +For example, the following would prevent alignment at B<=> and B: --valign-exclusion-list='= if' -If it is simpler to specify only the token types which are to be aligned, then use the special symbol B<*> for this exclusion list and include the types which are to be aligned in the list of B<--valign-inclusion-list> (this works because B<*> is not one of the alignment tokens). For example, -the following parameters enable alignment only at commas and 'fat commas': +If it is simpler to specify only the token types which are to be aligned, then +include the types which are to be aligned in the list of B<--valign-inclusion-list>. +You may leave the B undefined, or use the special symbol B<*> for the exclusion list. +For example, the following parameters enable alignment only at commas and 'fat commas': - --valign-exclusion-list='*' --valign-inclusion-list=', =>' + --valign-exclusion-list='*' ( this is optional and may be omitted ) These parameter lists should consist of space-separated tokens from the above -list of possible alignment tokens. If an unrecognized parameter appears, it is -simply ignored. And if a parameter is entered in both lists by mistake -then the exclusion list has priority. +list of possible alignment tokens, or a '*'. If an unrecognized token +appears, it is simply ignored. And if a specific token is entered in both lists by +mistake then the exclusion list has priority. The default values of these parameters enable all alignments and are equivalent to @@ -4372,9 +4375,9 @@ To illustrate, consider the following snippet with default formatting $co_prompt = ($color) ? 'bold green' : ''; # prompt $co_unused = ($color) ? 'on_green' : 'reverse'; # unused -To exclude all alignments except the equals we could use: +To exclude all alignments except the equals (i.e., include only equals) we could use: - # perltidy -vxl='*' -vil='=' + # perltidy -vil='=' $co_description = ($color) ? 'bold cyan' : ''; # description $co_prompt = ($color) ? 'bold green' : ''; # prompt $co_unused = ($color) ? 'on_green' : 'reverse'; # unused diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index f4cad45f..d222fdf4 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -192,6 +192,13 @@ sub check_options { %valign_control_hash = (); $valign_control_default = 1; + # If -vil=s is entered without -vxl, assume -vxl='*' + if ( !$rOpts->{'valign-exclusion-list'} + && $rOpts->{'valign-inclusion-list'} ) + { + $rOpts->{'valign-exclusion-list'} = '*'; + } + # See if the user wants to exclude any alignment types ... if ( $rOpts->{'valign-exclusion-list'} ) {