Confirm dialog called by python vim.command fails

20 views
Skip to first unread message

Ni Va

unread,
May 3, 2016, 5:58:28 AM5/3/16
to vim_use
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)')

Nikolay Aleksandrovich Pavlov

unread,
May 3, 2016, 6:41:09 AM5/3/16
to vim...@googlegroups.com
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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ni Va

unread,
May 3, 2016, 10:10:48 AM5/3/16
to vim_use

Thank you ZyX it works perfectly ! :)

Reply all
Reply to author
Forward
0 new messages