Yes, but this does not work for a nested def function. Setting one of these 
options to a funcref stringifies the funcref and then later unstringifies 
the value to get back to a callback. This process loses the environment 
bound in the closure causing an E1248.

On Tuesday, January 24, 2023 at 9:55:35 PM UTC-7 yegapp...@gmail.com wrote:

> Hi,
>
> On Tue, Jan 24, 2023 at 7:12 PM Geoff Reedy <vim-dev...@256bit.org> wrote:
>
>> I think it would be neat to allow a funcref in autocmd_add and add a 
>> callback_T cmd_cb field to the auto command struct for it.
>>
>  
>
>> The same would be nice for options like omnifunc. Interestingly these are 
>> stored into the buffer structure as callback objects but only set as 
>> strings.
>>
>
> You can set 'omnifunc' and other similar '*func' options to a funcref.  
> You can refer to the following help
> topic: https://vimhelp.org/options.txt.html#option-value-function
>
> The following commit added this support:
>
> https://github.com/vim/vim/commit/8658c759f05b317707d56e3b65a5ef63930c7498
>
> - Yegappan
>  
>
>> I started working on a patch to allow a funcref as the cmd option in 
>> autocmd_add but ran into a conceptual limitation: these places cannot be 
>> extended to hold funcrefs without slightly breaking compatibility. There 
>> are potentially scripts that rely on the fact that these values are 
>> accessed as strings. Now the common pattern of saving an option value and 
>> then restoring it should work the same (except if it is a vim9 script that 
>> is using the string type for the variable) and autocmd_get is only since 
>> vim9 so maybe this slight incompatibility is acceptable.
>>
>>
>>

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/19d7a2da-da9a-40b6-a11c-f234daf0b95bn%40googlegroups.com.

Raspunde prin e-mail lui