On 05/15/13 13:06, Bram Moolenaar wrote:
>
> ZyX wrote:
>
>>> 3. vim.functions:
>>> Again, the introspection is not strictly necessary, but a convenience
>>> wrapper that pulls the FuncRefs will make code look much nicer.
>>> In that regard I'd also offer attribute access for builtin/ global
>>> functions in addition to the getitem syntax. That way you can do
>>> things like:
>>> curbuf = vim.functions.bufnr("%")
>>
>> Good idea.
>
> Would it be possible to have most Vim functions made callable from
> Python this way? Obviously it's much better than using vim.eval().
Yes, I think it should work with all builtins (and user functions as
well, basically anything where function("name") works).
>
> An example from the help:
>
> :py tagList = vim.eval('taglist("eval_expr")')
>
> Would then be something like:
>
> :py tagList = vim.functions.taglist(eval_expr)
>
> With the difference that eval_expr would be a Python expression.
Yes, thats exactly the way it would be used. It looks much nicer that
way and there is no need to escape "eval_expr" appropriately.
>
> For the internals we would need to have a list of all funtions with
> their argument types, so that the arguments can be converted from Python
> to the Vim type. Could be added to the functions array in eval.c
In my experiments on the weekend I made a simple wrapper class that
returned vim.bindeval("function('{0}')".format(attribute_name)).
I assumed that the FuncRef takes care of the appropriate
argument conversion when called (but I have not tested it extensively).
If it does, this should also be doable purely in python with the
exception of enumerating the available functions.
Regards,
Andy
--
--
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].
For more options, visit https://groups.google.com/groups/opt_out.