]> git.donarmstrong.com Git - perltidy.git/commitdiff
changed new -nib feature to be on by default
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 2 Sep 2020 18:08:37 +0000 (11:08 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 2 Sep 2020 18:08:37 +0000 (11:08 -0700)
CHANGES.md
bin/perltidy
lib/Perl/Tidy.pm
t/snippets/expect/nib.def
t/snippets/expect/nib.nib1
t/snippets/nib1.par
t/snippets/packing_list.txt
t/snippets21.t

index 2d49007ce7b183343902ad3e014819b14d8b7da3..ed03c49d40305594854ee75d60dce6d5d026bf3c 100644 (file)
@@ -1,10 +1,20 @@
 # Perltidy Change Log
 
     - Added parameter --non-indenting-braces, or -nib, which prevents
-      code following an opening brace marked with a special side comment 
-      from indenting one level.  This is off by default and turned on 
-      with -nib.  It might be useful for preventing code from shifting 
-      when adding or testing closures, for example.
+      code which follows an opening brace marked with a special side comment, 
+      '#<<<', from indenting one level.  For example,
+
+                    { #<<<   a closure to contain lexical vars
+
+                    my $var;  # this line does not indent
+
+                    }
+
+                    # this line cannot 'see' $var;
+
+      This is on by default.  If your code happens to have some
+      opening braces followed by '#<<<', and you
+      don't want this, you can use -nnib to deactivate it. 
 
     - Side comment locations reset at a line ending in a level 0 open
       block, such as when a new multi-line sub begins.  This is intended to 
index 755ce6a49deb44cd86033bcedf3b4f432c88a50e..39aed2d50a52199c5d65e1c93cb2bc26c9aa0a53 100755 (executable)
@@ -850,22 +850,39 @@ The default is not to do this, indicated by B<-nicb>.
 
 =item B<-nib>, B<--non-indenting-braces>
 
-If this flag is set, perltidy will look for opening block braces which are
-followed by a special side comment, which is B<#<<<> by default.  If found, the
-code between this opening brace and its corresponding closing brace will not be
-given the normal extra indentation level.  As a simple example, 
+Normally, lines of code contained within a pair of block braces receive one
+extra level of indentation.  If this flag is set, perltidy will look for
+opening block braces which are followed by a special side comment, which is
+B<#<<<> by default.  If found, the code between this opening brace and its
+corresponding closing brace will not be given the normal extra indentation
+level.  For example:
 
-  perltidy -nib:
+            { #<<<   a closure to contain lexical vars
 
-    { #<<<
-    print "hello world\n";
-    }
+            my $var;  # this line does not get one level of indentation
+            ...
+
+            }
+
+            # this line cannot 'see' $var;
+
+This can be useful, for example, when combining code from different files.
+Different sections of code can be placed within braces to keep their lexical
+variables from being visible to the end of the file.  To keep the new blocks
+from causing all of their contained code to be reformatted if you run perltidy, 
+you can mark the opening braces with this special side comment.
+
+Only the opening brace needs to be marked, since perltidy knows where the
+closing brace is.  
 
-This might be useful, for example, to keep large sections of code from
-moving to the right when placed in a closure.
+This feature is on by default.  If your code happens to have some opening
+braces followed by '#<<<', and you don't want this, you can use B<-nnib> to
+deactivate it.  To make it easy to remember, the default string is the same as
+the string for starting a B<format-skipping> section. There is no confusion
+because in that case it is for a block comment rather than a side-comment. 
 
-Only the opening brace needs to be marked, and nested braces can be marked.
-The special side comment can be changed with the next parameter.
+The special side comment can be changed with the next
+parameter.
 
 
 =item B<-nibp=s>, B<--non-indenting-brace-prefix=s>
@@ -882,9 +899,6 @@ For example, to match the side comment '#++', the parameter would be
   
   -nibp='#\+\+'
 
-Note that the default string is the same as the string for starting a
-B<format-skipping> section, but in that case it is for a block comment 
-rather than a side-comment. 
 
 =item B<-olq>, B<--outdent-long-quotes>
 
index 1fa035c035dc3dd5b6573512f41a7ba95ac408c7..9c30a8ad4977687e8f47aff521ef1d685356fcc2 100644 (file)
@@ -2462,10 +2462,10 @@ sub generate_options {
       nodelete-old-whitespace
       nohtml
       nologfile
+      non-indenting-braces
       noquiet
       noshow-options
       nostatic-side-comments
-      nonon-indenting-braces
       notabs
       nowarning-output
       one-line-block-semicolons=1
index dd67a28de524e15a4f48e0fcd1ad7ed9e879c72a..4499f5032be89b9bef4f7e577b5e2beca60bca70 100644 (file)
@@ -1,15 +1,15 @@
 {    #<<<
-    {    #<<<
-        {    #++
-            print "hello world\n";
-        }
-    }
+{    #<<<
+{    #++
+    print "hello world\n";
+}
+}
 }
 
 {    #++
     {    #++
         {    #<<<
-            print "hello world\n";
+        print "hello world\n";
         }
     }
 }
index 4499f5032be89b9bef4f7e577b5e2beca60bca70..dd67a28de524e15a4f48e0fcd1ad7ed9e879c72a 100644 (file)
@@ -1,15 +1,15 @@
 {    #<<<
-{    #<<<
-{    #++
-    print "hello world\n";
-}
-}
+    {    #<<<
+        {    #++
+            print "hello world\n";
+        }
+    }
 }
 
 {    #++
     {    #++
         {    #<<<
-        print "hello world\n";
+            print "hello world\n";
         }
     }
 }
index b79e8ce653c62df2f119016f95a06fedcde10e13..ed6da7bde4d60667bb51e5ab28fdb8e2179aa7a7 100644 (file)
@@ -1 +1 @@
--nib
+-nnib
index 3899237149cb1b9c51a6f5161b83c688293592a3..756bbebbb6126ed27276257dae4a6446e3d4504d 100644 (file)
 ../snippets21.t        git33.git33
 ../snippets21.t        rt133130.def
 ../snippets21.t        rt133130.rt133130
+../snippets21.t        nib.def
+../snippets21.t        nib.nib1
+../snippets21.t        nib.nib2
 ../snippets3.t ce_wn1.ce_wn
 ../snippets3.t ce_wn1.def
 ../snippets3.t colin.colin
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets21.t        nib.def
-../snippets21.t        nib.nib1
-../snippets21.t        nib.nib2
index b9436b9a16daeee1b270003054d6ce618e9a4885..22033a5580248e87a1b73e068d39cc01a8ead2d8 100644 (file)
@@ -41,7 +41,7 @@ BEGIN {
 ----------
         'gnu'  => "-gnu",
         'lop'  => "-nlop",
-        'nib1' => "-nib",
+        'nib1' => "-nnib",
         'nib2' => <<'----------',
 -nib -nibp='#\+\+'
 ----------
@@ -591,17 +591,17 @@ method sum_radlinks {
             params => "def",
             expect => <<'#14...........',
 {    #<<<
-    {    #<<<
-        {    #++
-            print "hello world\n";
-        }
-    }
+{    #<<<
+{    #++
+    print "hello world\n";
+}
+}
 }
 
 {    #++
     {    #++
         {    #<<<
-            print "hello world\n";
+        print "hello world\n";
         }
     }
 }
@@ -614,17 +614,17 @@ method sum_radlinks {
             params => "nib1",
             expect => <<'#15...........',
 {    #<<<
-{    #<<<
-{    #++
-    print "hello world\n";
-}
-}
+    {    #<<<
+        {    #++
+            print "hello world\n";
+        }
+    }
 }
 
 {    #++
     {    #++
         {    #<<<
-        print "hello world\n";
+            print "hello world\n";
         }
     }
 }