Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

My thoughts on your approach (though, I've never actually used any of the Filter:: modules, so I'm by no means an authority :) are that filters should generally be reserved for cases where the desired syntax is not valid Perl or there is some extreme change to the way the valid syntax would work that can't be accomplished any other way.

The only things in your example .vim file are the function declaration line and the corresponding endfu (update: er, and the perl <<EOSCRIPT line pair). You ought to be able to accomplish everything else with normal Perl code. For example, you may well be better off simply installing a Msg function in the VIM:: namespace that prints to STDERR. You'd need to define a few functions, and export a few variables/objects, but all-in-all, I think it would come out cleaner and more straight-forward.

Also, I think your #NOVIM# construct is reduntant, as you acomplish the same thing earlier in the file using "";. Since you'll have to do that at least once for the line that includes the filter module, you might as well comment it well and use it consistantly. (As a corollary to that, I think that you should probably move the use strict; et al. lines up with the use VimFilter; line, as they conceptually belong together anyway.)

Then, I think that the way you're defining the @Dummy array is a bit convoluted. It seems like it would be easier to just pass that information to the VimFilter module as you use it. Then you shouldn't need to scan-and-parse the original source file looking for the declaration line. If I'm correct, this ought to obviate your entire convoluted BEGIN block.

Lastly (and it's entirely a matter of preference), since your working with VIM functions anyway, it makes more conceptual sense to translate the func blah and endfu lines into subroutine definitions, instead of just deleting them. It should make no difference in the end, though. *shrug*

bbfu
Black flowers blossom
Fearless on my breath


In reply to Re: Writing a Filter::Simple -based filter for .vim by bbfu
in thread Writing a Filter::Simple -based filter for .vim by Intrepid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found