Friday, April 24, 2015

Re: Build amenu from Funcref

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.


Ok I knew that 'exe' is not 'call' command and my pb is a little bit different:
Trying to call a func defined in a local script taken as class object.

So I don't know funcName, that's why I have to find a solution to call func from funcrefId list retrieve from getter method from my class : psexec.vim

In this way, I have seen the help that say to use funcref#Call(


From my attached files, you can build the menu by typing :so% on opened file utilsPFIMenu.vim.
Don't worry, it will show you funcrefid on sourcing phase.

--
--
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: