Re: Using py commands to evaluate text for balloon commands for web lookups.
I got my balloon function to do WEB lookups of word under mouse, on wiki/google/dictionary via python. However for couple of issues I am stuck with (any help appreciated): 1. The gvim freezes (cursor stop blinking for 3 seconds) while python is doing web lookups. Can I run this lookup as a thread in background? 2. The python lookup throws errors messages when lookup receives bad html; which I could NOT catch with 'python/try' and in 'vim/try' blocks. It looks ugly on the message bar. 3. I want to clear the Balloon text on a lookup error, instead of displaying stale results. Can I clear reset the Balloon value before starting a lookup? Because the Balloon interface only uses the return value of my function. 4. Any function to pick phrase under mouse? thanks for the earlier help (I used eval to interface with python). Mohsin On 5/24/06, Ilya [EMAIL PROTECTED] wrote: Mohsin wrote: I am trying to use the ':py' interface to evaluate text under cursor and show the result in a balloon text. I got the python and vim code to work easily, however I have problem communicating between the two (py and vim): 1. How do I access vim variables in py commands (like text under cursor, all the 'let variables', 'set options')? [...] Maybe this thread could be helpful, they are talking about vim.eval() function and looks like it could be used to get variable values, even arrays. http://groups.yahoo.com/group/vimdev/message/41394
Re: Using py commands to evaluate text for balloon commands..
On 5/24/06, Mohsin [EMAIL PROTECTED] wrote: I am trying to use the ':py' interface to evaluate text under cursor and show the result in a balloon text. I got the python and vim code to work easily, however I have problem communicating between the two (py and vim): 1. How do I access vim variables in py commands (like text under cursor, all the 'let variables', 'set options')? This is easy, see below 2. In the Balloon vim function, how do I access py variables. Note that I am not happy with just printing the py result on the message line - I want the py output (ot data structures in a vim variable to display it in a balloon. Note that :py commands are not available in the sandbox. I dont know whether Balloon function is executed in the sandbox. Maybe it is not (then :py is available in the Balloon func), maybe it is (then :py is not available in the Balloon func). If you find out, I'm interested to hear your result. To access vim variables in py commands (like text under cursor, all the 'let variables', 'set options'): Try along these lines: let vimstringvar=mystring let numericvar=123 :exe :py pythonvar=.numericvarwe got vim numericvar into pythonvar :exe :py pythonvar='.vimstringvar.'we got vim string var into pythonvar similarly for options. nb difference needed between string vs numeric :exe :py pythonvar=.readonly we got numeric vim option into pythonvar :exe :py pythonvar='.runtmepath.' we got string vim option into pythonvar NB if rhs string contains apostrophe, then additional care is needed. THis is what comes to mind. Maybe more direct method exists. I don't know. Yakov
Re: Using py commands to evaluate text for balloon commands..
Yakov Lerner wrote: [...] Note that :py commands are not available in the sandbox. I dont know whether Balloon function is executed in the sandbox. Maybe it is not (then :py is available in the Balloon func), maybe it is (then :py is not available in the Balloon func). If you find out, I'm interested to hear your result. [...] Sandbox and balloon function issue was discussed ~5 month ago and vim was patched allowing bexpr to run non-sandbox commands _if_ it wasn't set in a modeline (this is so that bexpr could potentially get values from an external debugger or somewhere via Python/Perl extensions).
Using py commands to evaluate text for balloon commands..
I am trying to use the ':py' interface to evaluate text under cursor and show the result in a balloon text. I got the python and vim code to work easily, however I have problem communicating between the two (py and vim): 1. How do I access vim variables in py commands (like text under cursor, all the 'let variables', 'set options')? 2. In the Balloon vim function, how do I access py variables. Note that I am not happy with just printing the py result on the message line - I want the py output (ot data structures in a vim variable to display it in a balloon. A transparent clean py/vim interface will allow us to reuse a large part of python library inside vim scripts. Any help appreciated. thanks, Mohsin