суббота, 20 октября 2012 г., 14:21:14 UTC+4 пользователь So8res написал:
> You can do this:
>
> function my#sw() | return &sw | endfunction
>
> But you can't do this:
>
> function my#sw = function('shiftwidth')
>
> because autoload variables can't be lowercase.
>
> This is annoying, especially if you're trying to conditionally define a
> function that may or may not be present depending upon the version of vim.
Do you really need global function here? It works perfectly for script-local
variables. If you need compatibility library you can consider using dictionary:
let my#compatfuncs={}
if exists('*shiftwidth')
let my#compatfuncs.sw=function('shiftwidth')
else
function my#compatfuncs.sw()
return &sw
endfunction
endif
--
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