On Thursday, April 23, 2015 at 4:42:40 AM UTC-5, Ni Va wrote:
> Even if I replace call by exe, the func is not called by pressing button on my toolbar's menu.
>
STOP and think a minute. You *cannot* replace "call" with "exe" because you MUST "call" a function, unless you want to evaluate the function and execute the string result it returns as if it were an ex command.
> exe 'anoremenu '.m.getMenuPath().'.'.foo.' :call funcref#Call("'.string(Fn).'")<CR>'
>
This should work fine. You say Vim just displays the command...but there is no "echo" anywhere. Are you sure you tried this exact command?
I experimented as follows and everything works as expected:
function! MyFunc(num)
echo "number is " a:num
endfun
silent! unmenu Plugin.foo
exe 'anoremenu '."Plugin".'.'."foo".' :call MyFunc("'."12345".'")<CR>'
I get a "foo" item in my "Plugin" menu, and when I click on it, I see "number is 12345" echoed on the screen.
> replaced by
>
> exe 'anoremenu '.m.getMenuPath().'.'.foo.' :exe funcref#Call("'.string(Fn).'")<CR>'
As discussed above, this will not work. "exe" means "take this string and use it like an ex command". "call" is what you want.