Hello,
* On Fri, Oct 20, 2006 at 02:46:24AM +0200, Yakov Lerner <[EMAIL PROTECTED]>
wrote:
> Almost every plugin begins with this check:
> if exists("g:plugin_name") | finish | endif
> let g:plugin_name = 1
> I understand this tries to save time if vim tries to load plugins 2nd time.
> But aren't plugins loaded only at vim startup ? Does vim *ever*
> ever try to load plugins 2nd time ? In which situation can vim load
> plugin 2nd time (except for some manual command) ?
I usually use the following check:
if exists('g:loaded_plugin_name')
\ || !exists('g:force_reload_plugin_name')
finish
endif
let g:loaded_plugin_name = 1
I use this to avoid reload to many times a plugin. There is one scenario
that could make it happen: when the plugin is required by another plugin
which checks the plugin is loaded before with something like:
if exists(':SomeExpectedCommand')
runtime plugin/plugin_name.vim
if !exists(':SomeExpectedCommand')
echoerr "foobar.vim requires plugin_name to be installed"
finish
endif
endif
...
:SomeExpectedCommand foobar
However, with vim7 I do not see the point of such complex dependency
enforcements anymore. autoloaded plugins seem to be a much better and
simpler solution.
Regarding the g:force_reload_plugin_name, it eases plugin maintenance.
--
Luc Hermitte
http://hermitte.free.fr/vim/