r50431 - in /trunk/libtext-findindent-perl: Changes MANIFEST META.yml debian/changelog lib/Text/FindIndent.pm t/data/spaces4_2.txt t/data/spaces4_3.txt t/data/spaces4_4.txt t/data/tabs8_1_skippod.txt

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jan 7 04:47:01 UTC 2010


Author: jawnsy-guest
Date: Thu Jan  7 04:46:55 2010
New Revision: 50431

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50431
Log:
New upstream release

Added:
    trunk/libtext-findindent-perl/t/data/spaces4_2.txt
      - copied unchanged from r50430, branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt
    trunk/libtext-findindent-perl/t/data/spaces4_3.txt
      - copied unchanged from r50430, branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt
    trunk/libtext-findindent-perl/t/data/spaces4_4.txt
      - copied unchanged from r50430, branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt
    trunk/libtext-findindent-perl/t/data/tabs8_1_skippod.txt
      - copied unchanged from r50430, branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt
Modified:
    trunk/libtext-findindent-perl/Changes
    trunk/libtext-findindent-perl/MANIFEST
    trunk/libtext-findindent-perl/META.yml
    trunk/libtext-findindent-perl/debian/changelog
    trunk/libtext-findindent-perl/lib/Text/FindIndent.pm

Modified: trunk/libtext-findindent-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-findindent-perl/Changes?rev=50431&op=diff
==============================================================================
--- trunk/libtext-findindent-perl/Changes (original)
+++ trunk/libtext-findindent-perl/Changes Thu Jan  7 04:46:55 2010
@@ -1,4 +1,12 @@
 Changes for Perl extension Text-FindIndent
+
+0.08
+	- Handle case where hash keys and values are indented by braces pos + 1
+	  (CHORNY)
+	- Check if indent level is same on next line and slightly increase probability of
+	  current indent type. Should be faster too. (CHORNY)
+	- Add option 'first_level_indent_only' to check only indent where previous line
+	  is empty. (CHORNY)
 
 0.07
 	- ~40% faster since 0.05

Modified: trunk/libtext-findindent-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-findindent-perl/MANIFEST?rev=50431&op=diff
==============================================================================
--- trunk/libtext-findindent-perl/MANIFEST (original)
+++ trunk/libtext-findindent-perl/MANIFEST Thu Jan  7 04:46:55 2010
@@ -26,9 +26,13 @@
 t/data/spaces3_2.txt
 t/data/spaces3_3.txt
 t/data/spaces4_1.txt
+t/data/spaces4_2.txt
+t/data/spaces4_3.txt
+t/data/spaces4_4.txt
 t/data/spaces5_1.txt
 t/data/spaces6_1.txt
 t/data/tabs8_1.txt
+t/data/tabs8_1_skippod.txt
 t/data/tabs8_2.txt
 t/data/tabs8_3.txt
 t/data/unknown_1.txt

Modified: trunk/libtext-findindent-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-findindent-perl/META.yml?rev=50431&op=diff
==============================================================================
--- trunk/libtext-findindent-perl/META.yml (original)
+++ trunk/libtext-findindent-perl/META.yml Thu Jan  7 04:46:55 2010
@@ -23,4 +23,4 @@
   perl: 5.00503
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.07
+version: 0.08

Modified: trunk/libtext-findindent-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-findindent-perl/debian/changelog?rev=50431&op=diff
==============================================================================
--- trunk/libtext-findindent-perl/debian/changelog (original)
+++ trunk/libtext-findindent-perl/debian/changelog Thu Jan  7 04:46:55 2010
@@ -1,3 +1,9 @@
+libtext-findindent-perl (0.08-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Wed, 06 Jan 2010 23:46:24 -0500
+
 libtext-findindent-perl (0.07-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libtext-findindent-perl/lib/Text/FindIndent.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-findindent-perl/lib/Text/FindIndent.pm?rev=50431&op=diff
==============================================================================
--- trunk/libtext-findindent-perl/lib/Text/FindIndent.pm (original)
+++ trunk/libtext-findindent-perl/lib/Text/FindIndent.pm Thu Jan  7 04:46:55 2010
@@ -73,7 +73,7 @@
 
 use vars qw{$VERSION};
 BEGIN {
-  $VERSION = '0.07';
+  $VERSION = '0.08';
 }
 
 use constant MAX_LINES => 500;
@@ -86,6 +86,7 @@
   my $textref = ref($text) ? $text : \$text; # accept references, too
 
   my $skip_pod = $opts{skip_pod};
+  my $first_level_indent_only = $opts{first_level_indent_only}?1:0;
 
   my %modeline_settings;
 
@@ -112,6 +113,8 @@
     return( "s" . $modeline_settings{tabstop} );
   }
 
+  my $next_line_braces_pos_plus_1;
+  my $prev_indent_type = undef;
   while ($$textref =~ /\G([ \t]*)([^\r\n]*)[\r\n]+/cgs) {
     my $ws       = $1;
     my $rest     = $2;
@@ -178,10 +181,35 @@
     # skip single-line comments
     next if $rest =~ /^(?:#|\/\/|\/\*)/; # TODO: parse /* ... */!
 
+    if ($next_line_braces_pos_plus_1) {
+      if ($next_line_braces_pos_plus_1==_length_with_tabs_converted($ws)) {
+        next;
+      }
+      $next_line_braces_pos_plus_1=0;
+    } else {
+      if ($rest=~/=> {$/) { #handle case where hash keys and values are indented by braces pos + 1
+        $next_line_braces_pos_plus_1=_length_with_tabs_converted($ws)+length($rest);
+      }
+    }
+
+    if ($first_level_indent_only and $prev_indent ne '') {
+      next;
+    }
+
+    if ($prev_indent eq $ws) {
+      if ($prev_indent_type) {
+        $indentdiffs{$prev_indent_type}+=0.01;
+        #coefficient is not based on data, so change if you think it should be different
+      }
+      next;
+    }
+
     # prefix-matching higher indentation level
     if ($ws =~ /^\Q$prev_indent\E(.+)$/) {
       my $diff = $1;
-      _grok_indent_diff($diff, \%indentdiffs);
+      my $indent_type=_analyse_indent_diff($diff);
+      $indentdiffs{$indent_type}++;
+      $prev_indent_type=$indent_type;
       $prev_indent = $ws;
       next;
     }
@@ -189,7 +217,10 @@
     # prefix-matching lower indentation level
     if ($prev_indent =~ /^\Q$ws\E(.+)$/) {
       my $diff = $1;
-      _grok_indent_diff($diff, \%indentdiffs);
+      #_grok_indent_diff($diff, \%indentdiffs);
+      my $indent_type=_analyse_indent_diff($diff);
+      $indentdiffs{$indent_type}++;
+      $prev_indent_type=$indent_type;
       $prev_indent = $ws;
       next;
     }
@@ -256,6 +287,15 @@
   return $maxkey;
 }
 
+sub _length_with_tabs_converted {
+    my $str=shift;
+    my $tablen=shift || 8;
+    $str =~ s/( +)$//;
+    my $trailing_spaces = $1;
+    $str =~ s/ +//g; #  assume the spaces are all contained in tabs!
+    return length($str)*$tablen+length($trailing_spaces);
+}
+
 sub _grok_indent_diff {
   my $diff = shift;
   my $indentdiffs = shift;
@@ -274,9 +314,26 @@
   }
 }
 
+sub _analyse_indent_diff {
+  my $diff = shift;
+
+  if ($diff =~ /^ +$/) {
+    return "s" . length($diff);
+  }
+  elsif ($diff =~ /^\t+$/) {
+    return "t8"; # we can't infer what a tab means. Or rather, we need smarter code to do it
+  }
+  else { # mixed!
+    $diff =~ s/( +)$//;
+    my $trailing_spaces = $1;
+    $diff =~ s/ +//g; #  assume the spaces are all contained in tabs!
+    return "m" . (length($diff)*8+length($trailing_spaces));
+  }
+}
+
 {
   # the vim modeline regexes
-  my $VimTag = qr/(?:ex|vi(?:m(?:[<=>]\d+)?)?):/;
+  my $VimTag = qr/(?:ex|vim?(?:[<=>]\d+)?):/;
   my $OptionArg = qr/[^\s\\]*(?:\\[\s\\][^\s\\]*)*/;
   my $VimOption = qr/
     \w+(?:=)?$OptionArg
@@ -346,18 +403,14 @@
 #   /* vim: set ai tw=75: */ ~
 #
    
-    my $changed = 0;
     my @options;
-    if ($line =~ $VimModeLineStart) {
-      if ($line =~ $VimModelineTypeOne) {
-        push @options, split /(?!<\\)[:\s]+/, $1;
-      }
-      elsif ($line =~ $VimModelineTypeTwo) {
-        push @options, split /(?!<\\)\s+/, $1;
-      }
-      else {
-        return;
-      }
+    return if $line !~ $VimModeLineStart;
+
+    if ($line =~ $VimModelineTypeOne) {
+      push @options, split /(?!<\\)[:\s]+/, $1;
+    }
+    elsif ($line =~ $VimModelineTypeTwo) {
+      push @options, split /(?!<\\)\s+/, $1;
     }
     else {
       return;
@@ -365,6 +418,7 @@
 
     return if not @options;
 
+    my $changed = 0;
     foreach (@options) {
       /s(?:ts|ofttabstop)=(\d+)/i and $settings->{softtabstop} = $1, $changed = 1, next;
       /t(?:s|abstop)=(\d+)/i and $settings->{tabstop} = $1, $changed = 1,  next;




More information about the Pkg-perl-cvs-commits mailing list