From: Steve Hancock Date: Sat, 7 Nov 2020 23:46:09 +0000 (-0800) Subject: update man page: list of switches and -wn -vtc=2 example X-Git-Tag: 20201202~51 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=598cbeb7979f9827c02c03f353e28c38e9208ae2;p=perltidy.git update man page: list of switches and -wn -vtc=2 example --- diff --git a/bin/perltidy b/bin/perltidy index 3fc52778..a9d9bf10 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -2420,6 +2420,16 @@ Here is an example illustrating a welded container within a welded containers: $m ) ); +The welded closing tokens are by default on a separate line but this can be +modified with the B<-vtc=n> flag (described in the next section). For example, +the same example adding B<-vtc-2> is + + # perltidy -wn -vtc=2 + $x->badd( bmul( + $class->new( abs( + $sx * int( $xr->numify() ) & $sy * int( $yr->numify() ) ) ), + $m ) ); + This format option is quite general but there are some limitations. One limitation is that any line length limit still applies and can cause long @@ -4341,12 +4351,23 @@ dot is added, and the backup file will be F . The following list shows all short parameter names which allow a prefix 'n' to produce the negated form: - D anl asc aws b bbb bbc bbs bl bli boc bok bol bot ce - csc dac dbc dcsc ddf dln dnl dop dp dpro dsc dsm dsn dtt dwls - dwrs dws f fll frm fs hsc html ibc icb icp iob isbc lal log - lp lsl ohbr okw ola oll opr opt osbr otr ple pod pvl q - sbc sbl schb scp scsb sct se sfp sfs skp sob sohb sop sosb sot - ssc st sts syn t tac tbc toc tp tqw tsc w x bar kis + D anl asbl asc ast asu aws b baa baao + bar bbao bbb bbc bbs bl bli boa boc bok + bol bom bos bot cblx ce conv csc cscb cscw + dac dbc dcbl dcsc ddf dln dnl dop dp dpro + dsc dsm dsn dtt dwls dwrs dws f fll frm + fs fso gcs hbc hbcm hbco hbh hbhh hbi hbj + 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 isbc iscl kgb kgbd + kgbi kis lal log lop lp lsl 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 vmll w wn x xci + xs Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used. diff --git a/docs/perltidy.html b/docs/perltidy.html index 99f67b68..52c68cc3 100644 --- a/docs/perltidy.html +++ b/docs/perltidy.html @@ -1925,6 +1925,14 @@ $m ) ); +

The welded closing tokens are by default on a separate line but this can be modified with the -vtc=n flag (described in the next section). For example, the same example adding -vtc-2 is

+ +
        # perltidy -wn -vtc=2
+        $x->badd( bmul(
+            $class->new( abs(
+                $sx * int( $xr->numify() ) & $sy * int( $yr->numify() ) ) ),
+            $m ) );
+

This format option is quite general but there are some limitations.

One limitation is that any line length limit still applies and can cause long welded sections to be broken into multiple lines.

@@ -3349,12 +3357,23 @@

The following list shows all short parameter names which allow a prefix 'n' to produce the negated form:

-
 D    anl asc  aws  b    bbb bbc bbs  bl   bli  boc bok  bol  bot  ce
- csc  dac dbc  dcsc ddf  dln dnl dop  dp   dpro dsc dsm  dsn  dtt  dwls
- dwrs dws f    fll  frm  fs  hsc html ibc  icb  icp iob  isbc lal  log
- lp   lsl ohbr okw  ola  oll opr opt  osbr otr  ple  pod  pvl  q
- sbc  sbl schb scp  scsb sct se  sfp  sfs  skp  sob sohb sop  sosb sot
- ssc  st  sts  syn  t    tac tbc toc  tp   tqw  tsc w    x    bar  kis
+
 D      anl    asbl   asc    ast    asu    aws    b      baa    baao   
+ bar    bbao   bbb    bbc    bbs    bl     bli    boa    boc    bok    
+ bol    bom    bos    bot    cblx   ce     conv   csc    cscb   cscw   
+ dac    dbc    dcbl   dcsc   ddf    dln    dnl    dop    dp     dpro   
+ dsc    dsm    dsn    dtt    dwls   dwrs   dws    f      fll    frm    
+ fs     fso    gcs    hbc    hbcm   hbco   hbh    hbhh   hbi    hbj    
+ 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    isbc   iscl   kgb    kgbd   
+ kgbi   kis    lal    log    lop    lp     lsl    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    vmll   w      wn     x      xci    
+ xs     

Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used.

diff --git a/t/snippets/dump_negated_switches.pl b/t/snippets/dump_negated_switches.pl new file mode 100755 index 00000000..dbc81827 --- /dev/null +++ b/t/snippets/dump_negated_switches.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w +use strict; +use warnings; + +# Dump a list of perltidy abbreviation flags which can be negated. +# This list goes in the man page section near the bottom titled +# SWITCHES WHICH MAY BE NEGATED + +# Get the long names which may be negated +my $rlong_names = get_long_names(); +my @binary_long_names; +foreach my $long_name ( @{$rlong_names} ) { + my ( $name, $flag, $type ) = ( "", "", "" ); + $long_name =~ s/\s+$//; + if ( $long_name =~ /^([\w\-]+)([^\s]*)/ ) { + $name = $1; + $flag = $2; + $flag = "" unless $flag; + if ( $flag eq '!' ) { push @binary_long_names, $name } + } +} + +# Get a list of all short names +my $rshort_names = get_short_names(); +my %abbrev; +foreach my $short_name ( @{$rshort_names} ) { + if ( $short_name =~ /^(\w+) --> ([\w\-]+)$/ ) { + my $short = $1; + my $long = $2; + $abbrev{$long} = $short; + } +} + +# delete these: -check-syntax or -syn is accepted but no longer does anything +my @skip = qw( + check-syntax +); +foreach (@skip) { + if ( $abbrev{$_} ) { delete $abbrev{$_} } +} + + +# Select the short names which can be negated +my @short_list; +foreach my $long (@binary_long_names) { + my $short = $abbrev{$long}; + if ( !defined($short) ) { + next; + } + push @short_list, $short; +} + +# special aliases not obtained automatically +my @special = qw( +oll +dac +tac +html +sob +baa +bbs +kgb +icp +otr +sot +sct +sac +sobb +conv +); + +my $FIELD_WIDTH = 6; +my $WORDS_PER_LINE = 10; + +my $line = " "; +my $count = 0; +foreach my $word ( sort (@short_list, @special) ) { + my $len = length($word); + my $nsp = $FIELD_WIDTH - $len + 1; + $word .= " " x $nsp; + $line .= $word; + $count++; + if ( $count == $WORDS_PER_LINE ) { + print "$line\n"; + $count = 0; + $line = " "; + } +} +print "$line\n"; + +sub get_long_names { + + # get latest parameters from perltidy + use File::Temp qw(tempfile); + my ( $fout, $tmpnam ) = File::Temp::tempfile(); + if ( !$fout ) { die "cannot get tempfile\n" } + my @parameters; + system "perltidy --dump-long-names >$tmpnam"; + open( IN, "<", $tmpnam ) || die "cannot open $tmpnam: $!\n"; + while ( my $line = ) { + next if $line =~ /#/; + chomp $line, push @parameters, $line; + } + close IN; + unlink $tmpnam if ( -e $tmpnam ); + return \@parameters; +} + +sub get_short_names { + + # get latest parameters from perltidy + use File::Temp qw(tempfile); + my ( $fout, $tmpnam ) = File::Temp::tempfile(); + if ( !$fout ) { die "cannot get tempfile\n" } + my @parameters; + system "perltidy --dump-short-names >$tmpnam"; + open( IN, "<", $tmpnam ) || die "cannot open $tmpnam: $!\n"; + while ( my $line = ) { + next if $line =~ /#/; + chomp $line, push @parameters, $line; + } + close IN; + unlink $tmpnam if ( -e $tmpnam ); + return \@parameters; +}