I want to write a wrapper to a plugin’s function, but it uses varargs (...). How can I pass the same arguments my function receives to the plugin’s function?
Example:
function! PluginInterface(...)
for i in a:000
echo i
endfor
endfunction
function! MyInterface(...)
echo a:1 . ' is great'
call PluginInterface(a:000)
endfunction
echo '>> Their call'
call PluginInterface('hello', 'world')
echo '>> My call'
call MyInterface('hello', 'world')
Instead of calling the function directly (
call PluginInterface(a:000)), usecall():(That looks strange, but
call()is a function so you still have to prefix it with:callorlet x =or something that accept anexpr.)See
:help call().