Commits

ZyX_I committed 1a747e9

Added `register' feature option

Comments (0)

Files changed (2)

                    this function will be added to s:F._frawor dictionary under 
                    the same conditions for which `load' function is called 
                    (except that `ignoredeps' option has no effect).
+        register   Reference to a function that will take |frawor-t-plugdict| as 
+                   its first argument. This function will be called once after 
+                   plugin is registered for each plugin that depends on the 
+                   feature definer.
         load       Reference to a function that will take |frawor-t-plugdict| as 
                    its first argument. This function will be called only once 
-                   for each plugin that depends on the plugin that registers 
-                   this feature. If value returned by this function is not 0, 
-                   then it will be assigned to plugdict.features[{fid}].
+                   for each plugin that depends on the feature definer. If value 
+                   returned by this function is not 0, then it will be assigned 
+                   to plugdict.features[{fid}].
                    Function will be called under following circumstances:
                    1. If feature definer (plugin that registered feature) was 
                       loaded before plugin that requires it, then it will be 

plugin/frawor.vim

 let s:g.pls={} " Plugin dictionaries
 let s:g.loading={}
 let s:g.features={}
-let s:g.featfunckeys=['cons', 'load', 'unload', 'unloadpre']
-let s:g.f={
-            \'cons':      {},
-            \'load':      {},
-            \'unload':    {},
-            \'unloadpre': {},
-        \}
+let s:g.featfunckeys=['cons', 'load', 'unload', 'unloadpre', 'register']
+let s:g.f={}
+call map(copy(s:g.featfunckeys), 'extend(s:g.f, {v:val : {}})')
 let s:g.dependents={}
 "▶2 Messages
 if v:lang=~?'ru'
         return ['/unknown', join(removedcomponents, '/'), '']
     endif
 endfunction
+"▶1 addcons
+function s:F.addcons(plugdict)
+    for feature in values(s:g.f.cons)
+        if has_key(a:plugdict.dependencies, feature.plid)
+            execute  'function a:plugdict.F._frawor.'.feature.id."(...)\n".
+                        \'    return call(s:g.features.'.feature.id.'.cons, '.
+                        \                '['.a:plugdict.intprefix.']+a:000, '.
+                        \                "{})\n".
+                        \'endfunction'
+        endif
+    endfor
+endfunction
+"▶1 runfeatures
+function s:F.runfeatures(plugdict, key)
+    for feature in values(s:g.f[a:key])
+        if has_key(a:plugdict.dependencies, feature.plid) ||
+                    \has_key(feature, 'ignoredeps')
+            " XXX can't use feature[a:key](a:plugdict) due to the vim bug
+            call call(feature[a:key], [a:plugdict], {})
+        endif
+    endfor
+    " XXX required in order not to copy list
+    return a:plugdict
+endfunction
+"▶1 initfeatures
+function s:F.initfeatures(plugdict)
+    for feature in values(s:g.f.load)
+        if has_key(a:plugdict.dependencies, feature.plid) ||
+                    \has_key(feature, 'ignoredeps')
+            if has_key(feature, 'load')
+                let d={}
+                let d.Result=feature.load(a:plugdict)
+                let a:plugdict.features[feature.id]=
+                            \((d.Result is 0)?({}):(d.Result))
+            elseif has_key(feature, 'init')
+                let a:plugdict.features[feature.id]=deepcopy(feature.init)
+            endif
+        endif
+    endfor
+endfunction
 "▶1 newplugin
 function s:F.newplugin(version, sid, file, dependencies, oneload, g, F)
     "▶2 Checking whether a:file is a string
             \}
     let s:g.pls[plid]=plugdict
     "▲2
+    call s:F.runfeatures(plugdict, 'register')
     if a:oneload
         call s:F.loadplugin(plid)
+    else
+        call s:F.addcons(plugdict)
     endif
     return r
 endfunction
-"▶1 addcons
-function s:F.addcons(plugdict)
-    for feature in values(s:g.f.cons)
-        if has_key(a:plugdict.dependencies, feature.plid)
-            execute  'function a:plugdict.F._frawor.'.feature.id."(...)\n".
-                        \'    return call(s:g.features.'.feature.id.'.cons, '.
-                        \                '['.a:plugdict.intprefix.']+a:000, '.
-                        \                "{})\n".
-                        \'endfunction'
-        endif
-    endfor
-endfunction
-"▶1 runfeatures
-function s:F.runfeatures(plugdict, key)
-    for feature in values(s:g.f[a:key])
-        if has_key(a:plugdict.dependencies, feature.plid) ||
-                    \has_key(feature, 'ignoredeps')
-            " XXX can't use feature[a:key](a:plugdict) due to the vim bug
-            call call(feature[a:key], [a:plugdict], {})
-        endif
-    endfor
-    " XXX required in order not to copy list
-    return a:plugdict
-endfunction
-"▶1 initfeatures
-function s:F.initfeatures(plugdict)
-    for feature in values(s:g.f.load)
-        if has_key(a:plugdict.dependencies, feature.plid) ||
-                    \has_key(feature, 'ignoredeps')
-            if has_key(feature, 'load')
-                let d={}
-                let d.Result=feature.load(a:plugdict)
-                let a:plugdict.features[feature.id]=
-                            \((d.Result is 0)?({}):(d.Result))
-            elseif has_key(feature, 'init')
-                let a:plugdict.features[feature.id]=deepcopy(feature.init)
-            endif
-        endif
-    endfor
-endfunction
 "▶1 addfeature
 function s:F.addfeature(plugdict, feature)
     "▶2 Feature provides constructed function