Wednesday, June 23, 2010

Re: Performance issues when script does not prevent reloading

On 06/23/2010 12:19 PM, Tom Link wrote:
>> if exists("b:script_loaded")
>>     finish
>> endif
>>
>> let b:script_loaded = 1
>
> If you actually use this code to prevent a plugin from being reloaded,
> it most likely didn't work anyway because you're setting a buffer
> local variable.
>
> This should rather be:
>
> if &cp || exists("g:loaded_PLUGIN_NAME")
>   finish
> endif
> let g:loaded_PLUGIN_NAME = VERSION_NUMBER
>
> You could insert a
>
>   call inputdialog("It's me")
>
> in the file to get notified when it's actually loaded.
>


It does work here, vim7.2, ubuntu 9.10. If I add the inputdialog after
the if block, and source the file, it doesn't show up. If I do :unlet
b:script_loaded and then source again, it does show up. If I source yet
again, it stops showing up. -ak

No comments: