Tuesday, May 3, 2016

Re: Confirm dialog called by python vim.command fails

2016-05-03 12:58 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> Hi,
>
>
> Passing joined python list to the confirm dialog function through vim.command feature in python code, I encounter these errors :
>
> Error detected while processing :
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> File "<string>", line 16, in PyExecReplace
> File "<string>", line 144, in <module>
> File "<string>", line 10, in question
> vim.error: Vim(let):E121: Undefined variable: Today
>
>
> _____________
>
> Here is my source code :
>
>
> class IntervalDating(): # Dating considerations
> def __init__(self):
> self.datingChoice = [ 'Today', 'Yesterday', 'ThisWeek' ]
> def question(self):
> someStr = "\n&".join(self.datingChoice)
> print someStr
> vim.command('let cce = confirm("Period choice:", ' + someStr + ', 1)')

Just check how the resulting command is going to look like (replace
`vim.command` with `print`): `+ someStr +` is not a valid way to pass
an argument to confirm() here. In this case you should better use

vim.vars['cce'] = vim.Function('confirm')('Period choice:', someStr, 1)

but otherwise first serialize with `json.dumps()`.

>
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: