On Sunday, June 14, 2015 at 4:45:00 PM UTC+5:30, ZyX wrote: > 2015-06-14 14:10 GMT+03:00 Nikolay Pavlov > > 2015-06-13 17:02 GMT+03:00 AA > >> When I update the statusline from a python thread forked from main, the > >> update gets registered by vim but is shown only after take an action, a > >> movement using keys, or a mouse scroll. > >> > >> Python code here if it helps: http://sprunge.us/LCfM (Open in vim > >> followed by :pyfile %) > >> > >> Briefly: Spawn threads, each threads sleeps for a while and then updates > >> the statusline. Don't do anything and you'll never notice the update. Keep > >> j/k pressed and all updates show fine. > >> > >> So my question is: Is there a way in which I can make the status updates > >> immediate, without requiring any user action? > > > > Vim is not thread-safe. You *must not* update statusline in another > > thread, especially doing this using `set statusline` command (there is > > also a variant where you use `vim.options` and/or {window}.options > > ({window}: object from vim.windows or vim.current.window)). Most > > likely after some time this code is running you will get a crash > > because Vim is using many globals (using .options will touch much less > > amount of globals compared to vim.command('set statusline=' …)). > > If you need such code to work then use NeoVim. It is still not > thread-safe, but NeoVim Python bindings run in another process and > communicate via sockets and time of your code execution is controlled > by NeoVim receiving messages and not Python sending them. Here you may > need :redrawstatus to force statusline redraw, though I thought that > setting &statusline should already cause a redraw. > > > > > Another bad idea was using Python code using :pyfile. This command > > pushes all variables/functions defined in the sourced file into global > > namespace so with big amount of plugins that use :pyfile you will > > definitely run into problems. > > > >> > >> Thanks > >> > >> -- > >> -- > >> 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 > >> For more options, visit https://groups.google.com/d/optout.
Thank you for the answer and for taking the time to give extra suggestions. I am now calling the private __setitem__ of vim.options, followed by vim.command(redrawstatus). Everything works fine. As for pyfile, I will now use PYTHON << MARKER to run python code. -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.