]> git.donarmstrong.com Git - perltidy.git/commitdiff
document -mutt
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 4 Dec 2024 00:32:16 +0000 (16:32 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 4 Dec 2024 00:32:16 +0000 (16:32 -0800)
bin/perltidy
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/mutt.def [new file with mode: 0644]
t/snippets/expect/mutt.mutt1 [new file with mode: 0644]
t/snippets/mutt.in [new file with mode: 0644]
t/snippets/mutt1.par [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets31.t

index cb6c1a69474a63ab72676f1bf895a38e420600e6..fc48e14d942445d660be1dd9b66d99fe98ab420a 100755 (executable)
@@ -1321,11 +1321,50 @@ To simplify input in the case that all of the tightness flags have the same
 value <n>, 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<n=0> always adds a space, and
+B<n=2> never adds a space.
+
+The default value B<n=1> 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<qw> 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 C<qw>list as if it were multiple tokens when the
+default tightness is used.
+
+The parameter B<s> 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 '<<EOT'
+    <<>> - 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.
index daaab6097111ff0a2f4baf50dd14e81ef0e316fd..e8486b5659294312f2dcbe950ce5c599056ac8b3 100644 (file)
@@ -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 (file)
index 0000000..fd5d871
--- /dev/null
@@ -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 (file)
index 0000000..d5f44ba
--- /dev/null
@@ -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 (file)
index 0000000..fd5d871
--- /dev/null
@@ -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 (file)
index 0000000..b524163
--- /dev/null
@@ -0,0 +1 @@
+-mutt='q*'
index 1dcd5e7818966d82a7f8f5d208245124d1733a5d..c5ddfe7c2d5629c61f9933be894e5013880a4277 100644 (file)
 ../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
 ../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
index e36c5b68f6b4d0e19b05bf5df58f046074019c0c..6f095d4c6b04be6601c22aaca69a8d2e753a0f09 100644 (file)
@@ -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};