Hello,
$Bill, thanks for your code. I noticed one strange thing: Compare
the output of running the code with the arguments "-a perldoc" and
just "perldoc". In the -a case, the output is raw pod.
Another thing I found is that the scheme of assigning a variable
to STDOUT and STDERR doesn't work when used in perl embedded in
the VIM text editor. gvim returns the "Can't dup ..." error
messsage, and vim just goes into nowhere land and needs to be
killed.
From somewhere, I have code that illustrates the use of tie of
STDOUT and STDERR from inside vim. I tried finding a link to that
code on google but failed!!! I have attached that code below.
Also (here's something that might interest Veli-Pekka Tätilä), I
found out why the eval{die...} wasn't working as expected:
perldoc.pm has an exit inside it! Modifying
perl/lib/pod/Perldoc.pm so that the following line:
exit (IS_VMS ? 98962 : 1) unless @found;
becomes
die (IS_VMS ? 98962 : 1) unless @found;
makes things work as expected. So after this change, one of the
following will work from the command line. Which one works
depends on the which quotes are required by the shell being used.
perl -e "use Pod::Perldoc; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(require)]);}; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(-f require)]);}; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(-q require)]);}"
perl -e 'use Pod::Perldoc; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(require)]);}; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(-f require)]);}; eval{local $SIG{__DIE__};
Pod::Perldoc->run(args=>[qw(-q require)]);}'
Note that there are precisely two lines above (the email transfer
might have wrapped the lines); and the lines differ only by
whether "" or '' are used.
(Based on the above lines, one can come up with a scheme for using
perldoc from within vim. I have a working version, and am
discussing improving it on the vim.org mailing list.)
Thanks,
--Suresh
Here's the code that shows tie for VIM:
--------------------------------------
" Perl IO
"
" Autor: Jidkov Serguei mailto:[EMAIL PROTECTED]
" Version: 0.1
"
" Description:
" Plugin creates two output handles: VIMOUT and VIMERROR
" You may use:
"
" :perl print '2+2=', 2+2
" - eq :perl VIM::Msg (join $,, ('2+2=', 2+2))
" :perl print VIMOUT '2+2=', 2+2
" - same as above
" :perl print VIMERROR "Error: $!"
" - eq :perl VIM::Msg("Error: $!", 'ErrorMsg')
" :perl printf "%d:%d", $curwin->Cursor()
" - prints cursor position
"
" :TestPerlIO
" - test function: see end of file
"
" Install Details:
" Simply drop this file into your $HOME/.vim/plugin directory
"
" To create more handles use
" :perl tie *HANDLE, 'VIM::Out', 'Highlight'
" where Hilight - name of hilight group
" To make HANDLE default output handle use
" :perl select(HANDLE)
"
" TODO:
" Handles for buffer IO?
"
if exists('loaded_perl_io') || !has('perl')
finish
endif
let loaded_perl_io = 1
perl << EOF
use Tie::Handle;
package VIM::Out;
@ISA = qw(Tie::Handle);
sub TIEHANDLE
{
my ($class, $group) = @_;
return bless(\$group, $class);
}
sub PRINT
{
my ($group, @args) = @_;
VIM::Msg(join($,, @args), $$group);
}
sub PRINTF
{
my ($group, $format, @args) = @_;
VIM::Msg(sprintf ($format, @args), $$group);
}
package main;
tie (*VIMOUT, 'VIM::Out');
tie (*VIMERR, 'VIM::Out', 'ErrorMsg');
select VIMOUT;
EOF
"finish
" Test function
"
perl << EOF
sub test_io
{
print 1 .. 3;
$, = ', ';
print 'a' .. 'e';
undef $,;
printf '%3s' x 3, qw/aa bb cc/;
tie *VS, 'VIM::Out', 'Search';
print VS "User = $ENV{USER}";
printf VS '%d=%xh=%oo=%bb', (50)x 4;
untie *VS;
print VS 'Test';
print 'Test';
select VIMERR;
print 'Test';
print VIMOUT 'TEST';
}
#----use diagnostics;
#----use warnings;
#----use strict;
#----
#----my $foo = 1;
#----select VIMERR;
#----print "foo is:$foo\n";
#----
#----BEGIN {
#----tie (*STDOUT, 'VIM::Out', 'WarningMsg');
#----tie (*STDERR, 'VIM::Out', 'ErrorMsg'); }
#----select STDOUT;
#----my $boo = 2;
#----print "boo is:$boo\n"
#----
#----my $coo = 3
#----
EOF
command! TestPerlIO perl test_io()
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs