Commits

ZyX_I committed f426165

Moved protector into output of frawor#Setup function, removed s:_realsfile variable

Comments (0)

Files changed (29)

     return eval(a:expr)
 endfunction
 let s:_functions['s:Eval']=function('s:Eval')
-"▶1 frawor#Setup      :: version, dependencies, oneload → vimlstr
-function frawor#Setup(version, dependencies, oneload)
-    if type(a:version)==type("")
+"▶1 frawor#Setup      :: version, dependencies[, oneload] → vimlstr
+function frawor#Setup(version, dependencies, ...)
+    if type(a:version)==type('')
         let ver=map(split(a:version, '\.'), '+v:val')
     else
         let ver=a:version
                 \   '(map(split(v:val, "\\."), "+v:val")):'.
                 \   '(v:val))')
     let dstr=substitute(string(deps), "\n", '''."\\n".''', 'g')
-    let oneload=(!!a:oneload)
-    return       'execute "function s:Eval(expr)\n'.
-                \         '    return eval(a:expr)\n'.
-                \         "endfunction\"\n".
-                \"let s:_sid=+matchstr(s:Eval('expand(\"<sfile>\")'), ".
-                \                                               "'\\d\\+')\n".
-                \"let s:_realsfile=expand('<sfile>:p')\n".
-                \"if !exists('s:_sfile')\n".
-                \"    let s:_sfile=s:_realsfile\n".
-                \"endif\n".
-                \"let s:F={}\n".
-                \"let s:_functions={'s:Eval': function('s:Eval')}\n".
-                \"call FraworRegister(".string(ver).", ".
-                \                               "s:_sid, s:_sfile, ".dstr.", ".
-                \                                oneload.", s:)"
+    let oneload=((a:0)?(a:1 isnot 0):(1))
+    return       "if !exists('s:_pluginloaded')\n"
+                \."    execute \"function s:Eval(expr)\\n"
+                \.              "    return eval(a:expr)\\n"
+                \.              "endfunction\"\n"
+                \."    let s:_sid=+matchstr(s:Eval('expand(\"<sfile>\")'), "
+                \.                                              "'\\m\\d\\+')\n"
+                \."    let s:_sfile=expand('<sfile>:p')\n"
+                \."    let s:F={}\n"
+                \."    let s:_functions={'s:Eval': function('s:Eval')}\n"
+                \."    call FraworRegister(".string(ver).", "
+                \.                               "s:_sid, s:_sfile, ".dstr.", "
+                \.                                oneload.", s:)\n"
+                \."elseif s:_pluginloaded\n"
+                \."    finish\n"
+                \."endif\n"
 endfunction
 let s:_functions['frawor#Setup']=function('frawor#Setup')
 "▶1 frawor#Reload     :: Either plugdict plid → + :source
         You may specify 0 instead of {version}. In this case plugin type will 
         be `/anonymous', plugin id will be equal to `file' argument (possibly 
         with some trailing `/' added), runtimepath will be empty. In this case 
-        you may use s:_realsfile variable to tell frawor what should be 
-        sourced to load plugin.
+        you may use s:_sfile variable to tell frawor what should be sourced to 
+        load plugin.
 
 frawor#Setup({version}, {dependencies}, {oneload})            *frawor#Setup()*
         If |:execute|d, does some common setup:
         version       Plugin version, see |frawor-t-version|.
         oneload       Bool, true if plugin should be loaded only once.
         file          Path to plugin file ({file} argument to 
-                      |FraworRegister()| for non-anonymous plugins, 
-                      |s:_realsfile| or 0 for anonymous plugins).
+                      |FraworRegister()| for non-anonymous plugins, |s:_sfile| 
+                      or 0 for anonymous plugins).
         sid           Plugin script id, see |<SID>|. May be 0 if 
                       |FraworRegister()| got zero instead of version.
         dependencies  Dictionary which contains pairs {plid} - {version}. When 
                                   |frawor#Setup()|. It is not used by frawor 
                                   itself, but it is intended to be used by 
                                   plugins for internal purposes.
-*s:_realsfile*     plugin/frawor    String, defines file that should be 
-                                  sourced to load plugin back after unloading. 
-                                  Is initially set by |frawor#Setup()| and is 
-                                  used by |FraworRegister()| for anonymous 
-                                  plugins.
 *s:_pluginloaded*  plugin/frawor    Integer. Is set to 0 after plugin is 
                                   registered and then to 1 after plugin is 
                                   loaded.
                 \  'runtimepath': plrtp,
                 \      'version': plversion,
                 \      'oneload': !!a:oneload,
-                \         'file': ((a:version is 0)?(get(a:g, '_realsfile', 0)):
+                \         'file': ((a:version is 0)?(get(a:g, '_sfile', 0)):
                 \                                   (a:file)),
                 \          'sid': a:sid,
                 \ 'dependencies': {},

plugin/frawor/autocommands.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/checks.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/fwc/compiler': '0.0',
             \                  '@/decorators': '0.0'}, 1)
 "▶1 _messages

plugin/frawor/commands.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/decorators.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/decorators/altervars.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/decorators': '0.0',
             \                    '@/checks': '0.0',
             \      '@/decorators/altervars': '0.0'}, 1)

plugin/frawor/functions.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/decorators': '0.0'}, 1)
 "▶1 _messages
 if v:lang=~?'ru'
     let fstr=string(a:Fref)[10:-3]
     if fstr[:1]==#'s:'
         let fstr='<SNR>'.a:sid.'_'.fstr[2:]
+    elseif fstr[:4]==#'<SID>'
+        let fstr='<SNR>'.a:sid.'_'.fstr[5:]
     endif
     return fstr
 endfunction

plugin/frawor/fwc/compiler.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/fwc/parser'       : '0.0',
             \                '@/fwc/constructor'  : '0.0',
             \                '@/fwc/intfuncs'     : '0.0',

plugin/frawor/fwc/constructor.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
 let s:constructor={}
 "▶1 string     :: a → String

plugin/frawor/fwc/intfuncs.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0',
             \                '@/os':        '0.0'}, 1)
 let s:r={}

plugin/frawor/fwc/parser.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0',
             \             '@/fwc/intfuncs': '0.0',
             \        '@/fwc/topconstructs': '0.0'}, 1)

plugin/frawor/fwc/topconstructs.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
 let s:r={}
 let s:cf='CHECKFAILED'

plugin/frawor/lua.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/os': '0.0',}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/mappings.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/options': '0.0',
             \           'plugin/frawor/autocommands': '0.0',
             \              'plugin/frawor/resources': '0.0',}, 1)

plugin/frawor/options.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/checks': '0.0'}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'
 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
 "▶1 os resource
 let s:os={}

plugin/frawor/perl.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/os': '0.0',}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/python.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/os': '0.0',
             \         'plugin/frawor/resources': '0.0',}, 1)
 "▶1 Define messages

plugin/frawor/resources.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/ruby.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/os': '0.0',}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/tcl.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {'plugin/frawor/os': '0.0',}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

templates/oneload-frawor-plugin.vim

 "▶1 Header
 scriptencoding utf-8
-if exists('s:_pluginloaded') || exists('g:fraworOptions._donotload') ||
-            \exists('g:frawor__donotload')
-    finish
-endif
 execute frawor#Setup('0.0', {}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

test/rtp/plugin/double-registration.vim

-execute frawor#Setup('0.0', {}, 0)
+function s:Eval(expr)
+    return eval(a:expr)
+endfunction
+let s:_sid=+matchstr(s:Eval('expand("<sfile>")'), '\m\d\+')
+let s:_sfile=expand('<sfile>:p')
+call FraworRegister([0, 0], s:_sid, s:_sfile, {}, 0, s:)
 delfunction s:Eval

test/rtp/plugin/invalid-addmapgroup.3.vim

-execute frawor#Setup('0.0', {'plugin/frawor/mappings': '0.0'}, 1)
+function s:Eval(expr)
+    return eval(a:expr)
+endfunction
+let s:_sid=+matchstr(s:Eval('expand("<sfile>")'), '\m\d\+')
+let s:_sfile=expand('<sfile>:p')
+call FraworRegister([0, 0], s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.add("Mgroup", {'test': {'rhs': ','}})
-delfunction s:Eval
-execute frawor#Setup(0, {'plugin/frawor/mappings': '0.0'}, 1)
+call FraworRegister(0, s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.add("Mgroup", {'map': {'rhs': '.'}})
 

test/rtp/plugin/invalid-mapgroup.11.vim

-execute frawor#Setup('0.0', {'plugin/frawor/mappings': '0.0'}, 1)
+function s:Eval(expr)
+    return eval(a:expr)
+endfunction
+let s:_sid=+matchstr(s:Eval('expand("<sfile>")'), '\m\d\+')
+let s:_sfile=expand('<sfile>:p')
+call FraworRegister([0, 0], s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.add('Mgroup', {'mapping': {'rhs': 'abc', 'lhs': 'a'}},
             \                    {'buffer': 0})
-delfunction s:Eval
-execute frawor#Setup(0, {'plugin/frawor/mappings': '0.0'}, 1)
+call FraworRegister(0, s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.del('Mgroup')
 

test/rtp/plugin/invalid-mapgroup.3.vim

-execute frawor#Setup('0.0', {'plugin/frawor/mappings': '0.0',}, 1)
+function s:Eval(expr)
+    return eval(a:expr)
+endfunction
+let s:_sid=+matchstr(s:Eval('expand("<sfile>")'), '\m\d\+')
+let s:_sfile=expand('<sfile>:p')
+call FraworRegister([0, 0], s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.add('Mgroup', {'mapping': {'rhs': 'abc', 'lhs': 'a'}},
             \                    {'buffer': 0})
-delfunction s:Eval
-execute frawor#Setup(0, {'plugin/frawor/mappings': '0.0'}, 1)
+call FraworRegister(0, s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.map('Mgroup', 1)
 

test/rtp/plugin/invalid-mapgroup.7.vim

-execute frawor#Setup('0.0', {'plugin/frawor/mappings': '0.0',}, 1)
+function s:Eval(expr)
+    return eval(a:expr)
+endfunction
+let s:_sid=+matchstr(s:Eval('expand("<sfile>")'), '\m\d\+')
+let s:_sfile=expand('<sfile>:p')
+call FraworRegister([0, 0], s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.add('Mgroup', {'mapping': {'rhs': 'abc', 'lhs': 'a'}},
             \                    {'buffer': 0})
-delfunction s:Eval
-execute frawor#Setup(0, {'plugin/frawor/mappings': '0.0'}, 1)
+call FraworRegister(0, s:_sid, s:_sfile, {'@/mappings': [0, 0]}, 1, s:)
 call s:_f.mapgroup.unmap('Mgroup', 1)