in reply to Writing a Filter::Simple -based filter for .vim
Thinking about it some more, I believe that you're actually trying to do two things here: 1) Emulate the interface provided by VIM, and 2) Filter out VIM code from the Perl code, so that you can run .vim file directly under perl. These two are separate, and should be made into two distinct modules.
It should be fairly straight-forward to create a VIM::Emulate module. There's an overview of the VIM interface features you'd need to implement at :help perl-overview in VIM. The only one that I think wouldn't be feasable is the VIM::Eval() function, since you'd have to emulate every VIM command. If you felt ambitious, you could implement a "most commonly used" subset of the VIM commands, and detail it in the documentation for your module. If you do create this module, be sure to upload it to CPAN.
Filtering out the non-Perl code is a little more tricky. I think, however, that you'd be better off not using a Filter::Simple-based solution, and instead leverage perl's -x command-line option. Simply add a she-bang line to the start of the Perl code, and a __END__ line to the end of it, and pass the -x option to perl. You won't be able to have multiple Perl functions in one .vim file but it would be a lot less work on your part. Also, one way around that limitation would be to have one big Perl block in your .vim file that declares a bunch of functions, and then declare your VIM functions separately that just call the appropriate Perl function, like so:
perl <<EOP #!perl sub foo { VIM::Msg("Called foo"); } sub bar { VIM::Msg("Called bar"); } __END__ EOP func! TestFoo() " Note, you will need to pass along any " parameters your VIM function is called with. perl foo() endfu func! TestBar() perl bar() endfu
Anyway, I that's how I would approach this problem. Let me know if you decide to start working on a VIM::Emulate module. I would be willing to assist, whenever I have time.
bbfu
Black flowers blossom
Fearless on my breath
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Writing a Filter::Simple -based filter for .vim
by Intrepid (Curate) on Aug 17, 2003 at 13:12 UTC | |
by bbfu (Curate) on Aug 19, 2003 at 03:50 UTC |