Imagine having the files:

------ >8 ------ >8   autoload/test.vim  ----- >8 ------ >8 ------ >8 
function test#DoTest(a)
        if a == 1
                call s:F1()
        else
                call s:F2()
        endif
endfunction

function test#Test()
        echo "test#Test()"
endfunction

let s:F1=function('test#Test')
let s:F2=function('test2#Test')
------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< 

------ >8 ------ >8   autoload/test2.vim  ----- >8 ------ >8 ------ >8 
function test2#Test()
        echo "test2#Test()"
endfunction
------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< 

calling test#DoTest(2) doesn't work because vim doesn't know the
function yet. I can solve this using my custom function Function:

function! Function(name)
        <find autoloadfile containing a:name>
      exec 'source '.autoloadfile
      return function(a:name)
endfunction

calling test#DoTest(1) doesn't work because test#Test isn't known by vim
when sourcing the file. Is the only option moving the function
test#Test() into another file?

Marc

Reply via email to