On Thursday, April 23, 2015 at 3:43:43 PM UTC+1, Ben Fritz wrote:
> 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.
Hi Ben
I knew that call was different from exe and I supposed that I bad explained the probleme.
Calling and building a local func like you do is easier than calling a func declared as "object method" in a dedicated vimscript.
You can see in attached file that I have wrote similar object as described here : http://bling.github.io/blog/2013/08/16/modularizing-vimscript/
Although, I got E488 error when I use the button menu the script buildt.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment