Friday, April 11, 2014

Re: Troubles with perl script in Vim

11.04.2014 16:44, Dan Lowe написав(ла):
>
> On Fri, Apr 11, 2014, at 04:53 AM, Егор wrote:
>> Trying to set to status line current subname, using this manual
>> http://blogs.perl.org/users/ovid/2011/01/show-perl-subname-in-vim-statusline.html
>> First problem - when I put it on my vimrc I get error on vim start
>> line 11:
>> E126: Missing :endfunction
>> my vimrc is empty, I put there only script from manual page. If I don't
>> use <<EOP ... EOP got no errors. So I put so
>>
>> function! WhitePearl()
>> perl 'use strict; sub current_sub {my $curwin = $main::curwin; my
>> $curbuf = $main::curbuf; my @document = map { $curbuf->Get($_) } 0 ..
>> $curbuf->Count; my ( $line_number, $column ) = $curwin->Cursor; my
>> $sub_name = \'(not in sub)\'; for my $i ( reverse ( 1 .. $line
>> _number -1 ) ) {my $line = $document[$i]; if ( $line =~
>> /^\s*sub\s+(\w+)\b/ ) { $sub_name = $1; last; }} VIM::DoCommand "let
>> subName=\'$line_number: $sub_name\'"; }; '
>> endfunction
>> call WhitePearl()
>>
>> After this if i try to output variable subName vim prints Undefined
>> variable. Help me_)
> Just calling WhitePearl() will only define the subroutine current_sub().
> Are you also calling "perl current_sub()" somewhere? You don't show
> that here, but the blog post you referred to calls it from
> StatusLineIndexLine() and that is where subName actually gets defined.
>
> Dan
>
Problem solved. Trailing EOF shouldn't have any charachters before it.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: