On Wed, Feb 2, 2011 at 07:59, Tony Mechelynck
<[email protected]> wrote:
> See
>        :help script-here
> about how to make it work.

Thank you.

I've come up with the following as a way to deal with not having to
re-index lines on an un-modified buffer.  Is there anything else I can
do?  I realize this will probably take up a fair amount of memory.
Are there any other gotchas I'm missing?

--8<---------------------------------------------------------------
if ! exists("b:did_perl_statusline")
  setlocal statusline+=%(\ %{StatusLineIndexLine()}%)
  let b:did_perl_statusline = 1
endif

if has( 'perl' )
  function! EvalPerl()
  perl << EOP
use strict;
use warnings FATAL => 'all', NONFATAL => 'redefine';

eval "use PPIx::IndexLines";
my $error = $@;
my %hash;

sub index_line {

  if ( $error ) {

    VIM::DoCommand "let subName='$error'";

  } else {

    my $curbuf = $main::curbuf;

    if ( VIM::Eval( '&modified' ) || ! exists $hash{ $curbuf->Name } ) {

      # There's got to be a better way to slurp in the current buffer!
      my $document = join "\n", $curbuf->Get( 1 .. $curbuf->Count );

      $hash{ $curbuf->Name } = PPIx::IndexLines->new( \$document );
      $hash{ $curbuf->Name }->index_lines;

    };

    my ( $line ) = $main::curwin->Cursor;
    my $sub_name = $hash{ $curbuf->Name }->line_type( $line );

    VIM::DoCommand "let subName='$sub_name'";

  }
}
EOP
  endfunction
  call EvalPerl()

  function! StatusLineIndexLine()
    perl index_line()
    return subName
  endfunction
endif
-->8---------------------------------------------------------------
--
Alan Young

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to