From 3720f61983cc5fff2523da123aed4ebfe952bbed Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 3 Dec 2024 16:32:16 -0800 Subject: [PATCH] document -mutt --- bin/perltidy | 63 +++++++++++++++++++++++++++++------- lib/Perl/Tidy/Formatter.pm | 4 +-- t/snippets/expect/mutt.def | 1 + t/snippets/expect/mutt.mutt1 | 1 + t/snippets/mutt.in | 1 + t/snippets/mutt1.par | 1 + t/snippets/packing_list.txt | 6 ++-- t/snippets31.t | 25 ++++++++++++++ 8 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 t/snippets/expect/mutt.def create mode 100644 t/snippets/expect/mutt.mutt1 create mode 100644 t/snippets/mutt.in create mode 100644 t/snippets/mutt1.par diff --git a/bin/perltidy b/bin/perltidy index cb6c1a69..fc48e14d 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -1321,11 +1321,50 @@ To simplify input in the case that all of the tightness flags have the same value , the parameter <-act=n> or B<--all-containers-tightness=n> is an abbreviation for the combination <-pt=n -sbt=n -bt=n -bbt=n>. +=item B<-mutt=s>, B<--multiple-token-tightness=s> + +To review, the tightness controls described in the previous section have three +possible integer values: 0, 1, and 2, where B always adds a space, and +B never adds a space. + +The default value B adds space only if the container holds multiple +tokens. Some perltidy tokens may be rather long, and it can be +preferable to space some of them as if they were multple tokens. This can be +done with this paramter. + +For example, in the following expression the C list is a single token and +therefore there the default formatting does not put spaces within the square +brackets: + + my $rlist = [qw(alpha beta gamma)]; + +This can be changed with + + # perltidy -mutt='qw' + my $rlist = [ qw(alpha beta gamma) ]; + +This tells perltidy to space a Clist as if it were multiple tokens when the +default tightness is used. + +The parameter B may contain any of the following perl operators: + + qw q qq qx qr s y tr m + +Other possible specifications are + + q* - all of the above operators + Q - all of the above plus any quoted text + h - a here-doc target, such as '<> - the double-diamond operator + +A symbol may be negated by preceding it with a carat B<^> symbol. +The double-diamond operator is always included unless negated in this way. + =item B<-xbt>, B<--extended-block-tightness> -The previous section described two controls for spacing within curly braces, -namely B<--block-brace-tightness=n> for code block braces and -B<--brace-tightness=n> for all other braces. +There are two controls for spacing within curly braces, namely +B<--block-brace-tightness=n> for code block braces and B<--brace-tightness=n> +for all other braces. There is a little fuzziness in this division of brace types though because the curly braces considered by perltidy to contain code blocks for formatting @@ -7147,15 +7186,15 @@ The following list shows all short parameter names which allow a prefix hbk hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv hbw hent hic hicm hico hih hihh hii hij hik him hin hip hipd hipu hiq his hisc hiv hiw - hsc html ibc icb icp iob ipc isbc iscl kgb - kgbd kgbi kis lal log lop lp lsl mci mem - nib ohbr okw ola olc oll olq opr opt osbc - osbr otr ple pod pvl q sac sbc sbl scbb - schb scp scsb sct se sfp sfs skp sob sobb - sohb sop sosb sot ssc st sts t tac tbc - toc tp tqw trp ts tsc tso vbc vc viu - vmll vsc vsn vwe w wfc wia wma wme wmr - wn x xbt xci xlp xs + hsc html ibc icb icp ils iob ipc isbc iscl + kgb kgbd kgbi kis lal log lop lp lsl mci + mem nib ohbr okw ola olc oll olq opr opt + osbc osbr otr ple pod pvl q qwaf sac sbc + sbl scbb schb scp scsb sct se sfp sfs skp + sob sobb sohb sop sosb sot ssc st sts t + tac tbc toc tp tqw trp ts tsc tso vbc + vc viu vmll vsc vsn vwe w wfc wia wma + wme wmr wn x xbt xci xlp xs Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used. diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index daaab609..e8486b56 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3187,8 +3187,8 @@ sub initialize_multiple_token_tightness { my %is_valid_term = ( %is_type_option, %is_Q_subtype_option ); - # words can be negated by prefixing with the following character: - my $neg_char = '-'; + # Words can be negated by prefixing with the following character: + my $neg_char = '^'; # Scan the input my %positive_input; diff --git a/t/snippets/expect/mutt.def b/t/snippets/expect/mutt.def new file mode 100644 index 00000000..fd5d8713 --- /dev/null +++ b/t/snippets/expect/mutt.def @@ -0,0 +1 @@ +my $rlist = [qw(alpha beta gamma)]; diff --git a/t/snippets/expect/mutt.mutt1 b/t/snippets/expect/mutt.mutt1 new file mode 100644 index 00000000..d5f44bac --- /dev/null +++ b/t/snippets/expect/mutt.mutt1 @@ -0,0 +1 @@ +my $rlist = [ qw(alpha beta gamma) ]; diff --git a/t/snippets/mutt.in b/t/snippets/mutt.in new file mode 100644 index 00000000..fd5d8713 --- /dev/null +++ b/t/snippets/mutt.in @@ -0,0 +1 @@ +my $rlist = [qw(alpha beta gamma)]; diff --git a/t/snippets/mutt1.par b/t/snippets/mutt1.par new file mode 100644 index 00000000..b5241638 --- /dev/null +++ b/t/snippets/mutt1.par @@ -0,0 +1 @@ +-mutt='q*' diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 1dcd5e78..c5ddfe7c 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -466,6 +466,8 @@ ../snippets31.t btct.def ../snippets31.t c424.c424 ../snippets31.t c424.def +../snippets31.t ils.def +../snippets31.t ils.ils ../snippets4.t gnu1.gnu ../snippets4.t gnu2.def ../snippets4.t gnu2.gnu @@ -586,5 +588,5 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets31.t ils.def -../snippets31.t ils.ils +../snippets31.t mutt.def +../snippets31.t mutt.mutt1 diff --git a/t/snippets31.t b/t/snippets31.t index e36c5b68..6f095d4c 100644 --- a/t/snippets31.t +++ b/t/snippets31.t @@ -8,6 +8,8 @@ #5 c424.def #6 ils.def #7 ils.ils +#8 mutt.def +#9 mutt.mutt1 # To locate test #13 you can search for its name or the string '#13' @@ -30,6 +32,9 @@ BEGIN { 'c424' => "-naws -qwaf", 'def' => "", 'ils' => "-nils -bos", + 'mutt1' => <<'----------', +-mutt='q*' +---------- }; ############################ @@ -61,6 +66,10 @@ my @chars = qw(| / - \ | / - \ ); 'ils' => <<'----------', $z = sqrt( $x**2 + $y**2 ) ; +---------- + + 'mutt' => <<'----------', +my $rlist = [qw(alpha beta gamma)]; ---------- }; @@ -187,6 +196,22 @@ $z = sqrt( $x**2 + $y**2 ) ; #7........... }, + + 'mutt.def' => { + source => "mutt", + params => "def", + expect => <<'#8...........', +my $rlist = [qw(alpha beta gamma)]; +#8........... + }, + + 'mutt.mutt1' => { + source => "mutt", + params => "mutt1", + expect => <<'#9...........', +my $rlist = [ qw(alpha beta gamma) ]; +#9........... + }, }; my $ntests = 0 + keys %{$rtests}; -- 2.39.5