Re: RFC: Two option-handling techniques for scripts
- Ben Fritz wrote:
> >From many discussions I've had in the past, and from my own limitedFYI -- that's (probably) PluginKiller
> first-hand experience, I have learned that one of the biggest hurdles
> to writing a robust vim script to distribute to other people is
> dealing with the hundreds of options that Vim has, many of which
> potentially cause your script to do unexpected things. Dr. Chip has
> even made a plugin that attempts to check these options in an effort
> to make things easier, but I have not heard it mentioned very often.
> I propose two alternate methods to solving this problem, each of whichSounds good to me; sounds like my attempts to save&restore options,
> add new functionality and should therefore break no backwards
> compatibility (though it will cause scripts utilizing the method to
> not work on older Vims without the functionality; I would think this
> is to be expected).
> Method 1: Script-local options
> This method would add a command, :setscript, that behaves just
> like :setlocal, except that the option will only be read during script
> execution, or during execution of commands defined in the script.
except to push that capability into vim. I'd hope that setscript would
avoid the option-last-set-from (the scriptname here). As is, the
save&restore means that the script which does that effectively prevents
knowing what, if anything, really changed the option last.
There may be complications with multiple
calls -- as in when should it, if ever, be ignored, and when should the
options be restored. I'm thinking about a script that calls upon a
different script's mappings/commands/functions/whatnot. Some scripts
have multiple entry points, and so may themselves have multiple
setscript &all calls within them (or perhaps multiple ways to call the
same function with a setscript &all call).
> Method 2: create an "option stack"I'll mention one option that this process doesn't help with:
> This method was already discussed here, briefly, in the middle of this
> Typical use would be as follows:
> setlocal all&
> command foo optionpush | call s:Func() | optionpop
equalalways. Setting it causes the window sizes to be adjusted, so one
cannot do a save&restore and avoid the option's effect. There may well
be other such options which affect things immediately upon being set.
This problem with immediate effects may affect the setscript idea, too.
The "option-last-set-from-..." information is also polluted.
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php