Hi,

On Mon, Nov 15, 2021 at 7:21 PM lacygoill <[email protected]> wrote:
>
> It seems that we can use a partial in a legacy function:
>
> vim9script
> nnoremap <expr> zd <SID>ZdSetup('zd')
> function ZdSetup(cmd)
>     set operatorfunc=function('s:Zd',\ [a:cmd])
>     return 'g@l'
> endfunction
> def Zd(cmd: string, type: string)
>     execute 'normal! ' .. cmd
> enddef
> var lines =<< trim END
>     some folded lines {{{
>     some folded lines
>     some folded lines }}}
> END
> lines->setline(1)
> &foldmethod = 'marker'
> normal zd
>
> the fold is correctly deleted
>
> But not in a Vim9 function:
>
> vim9script
> nnoremap <expr> zd <SID>ZdSetup('zd')
> def ZdSetup(cmd: string): string
>     set operatorfunc=function(Zd,\ [cmd])
>     return 'g@l'
> enddef
> def Zd(cmd: string, type: string)
>     execute 'normal! ' .. cmd
> enddef
> var lines =<< trim END
>     some folded lines {{{
>     some folded lines
>     some folded lines }}}
> END
> lines->setline(1)
> &foldmethod = 'marker'
> normal zd
>
> E121: Undefined variable: cmd
>
> Am I missing something? Shouldn't Vim be able to find the cmd argument in a 
> :def function:
>
> set operatorfunc=function(Zd,\ [cmd])
>                                 ^^^
>
> just like it is able to in a legacy function:
>
> set operatorfunc=function('s:Zd',\ [a:cmd])
>                                     ^---^
>
> Note that the issue is not caused by the omission of the s: scope in front of 
> Zd, nor by the omission of the quotes around. None of them are required in 
> the Vim9 context. And it doesn't suppress the error here anyway.
>

The current implementation only supports legacy functions and
funcrefs. It doesn't support
Vim9 functions.

Regards,
Yegappan

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7%3Ds5W2iNRuRxW97trpV2W0nt7M%2Bkg%3DWynV2M4MuBjZ7Ng%40mail.gmail.com.

Raspunde prin e-mail lui