comparison runtime/doc/options.txt @ 26441:65ab0b035dd8 v8.2.3751

patch 8.2.3751: cannot assign a lambda to an option that takes a function Commit: https://github.com/vim/vim/commit/6409553b6e3b4de4e1d72b8ee5445595214581ff Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Dec 6 11:03:55 2021 +0000 patch 8.2.3751: cannot assign a lambda to an option that takes a function Problem: Cannot assign a lambda to an option that takes a function. Solution: Automatically convert the lambda to a string. (Yegappan Lakshmanan, closes #9286)
author Bram Moolenaar <Bram@vim.org>
date Mon, 06 Dec 2021 12:15:04 +0100
parents c725b8e17f1f
children a0bc10e83cf8
comparison
equal deleted inserted replaced
26440:f6f5f604c17c 26441:65ab0b035dd8
374 374
375 375
376 *option-value-function* 376 *option-value-function*
377 Some options ('completefunc', 'imactivatefunc', 'imstatusfunc', 'omnifunc', 377 Some options ('completefunc', 'imactivatefunc', 'imstatusfunc', 'omnifunc',
378 'operatorfunc', 'quickfixtextfunc', 'tagfunc' and 'thesaurusfunc') are set to 378 'operatorfunc', 'quickfixtextfunc', 'tagfunc' and 'thesaurusfunc') are set to
379 a function name or a function reference or a lambda function. Examples: 379 a function name or a function reference or a lambda function. When using a
380 lambda it will be converted to the name, e.g. "<lambda>123". Examples:
380 > 381 >
381 set opfunc=MyOpFunc 382 set opfunc=MyOpFunc
382 set opfunc=function('MyOpFunc') 383 set opfunc=function('MyOpFunc')
383 set opfunc=funcref('MyOpFunc') 384 set opfunc=funcref('MyOpFunc')
384 set opfunc={a\ ->\ MyOpFunc(a)} 385 set opfunc={a\ ->\ MyOpFunc(a)}
385 " set using a funcref variable 386 " set using a funcref variable
386 let Fn = function('MyTagFunc') 387 let Fn = function('MyTagFunc')
387 let &tagfunc = string(Fn) 388 let &tagfunc = string(Fn)
388 " set using a lambda expression 389 " set using a lambda expression
389 let &tagfunc = "{t -> MyTagFunc(t)}" 390 let &tagfunc = {t -> MyTagFunc(t)}
390 " set using a variable with lambda expression 391 " set using a variable with lambda expression
391 let L = {a, b, c -> MyTagFunc(a, b , c)} 392 let L = {a, b, c -> MyTagFunc(a, b , c)}
392 let &tagfunc = string(L) 393 let &tagfunc = L
393 < 394 <
394 395
395 Setting the filetype 396 Setting the filetype
396 397
397 :setf[iletype] [FALLBACK] {filetype} *:setf* *:setfiletype* 398 :setf[iletype] [FALLBACK] {filetype} *:setf* *:setfiletype*