Sunday, March 12, 2017

Is there any way to update a buffer in the background?

Hi Vim folks,

I'm writing a plugin, and I'm wondering whether it's possible to update a hidden buffer. The functions and commands I found in the docs, such as seem to work only with the current buffer.

The reason I want to do this is that my plugin used a buffer to show some interactive output, and I want the buffer content to always be up-to-date, whether it's hidden or not.

Currently I made things work by switching the buffers when needed:

function! vlime#ui#WithBuffer(buf, Func)
let old_buf = bufnr('%')
let cur_buf = bufnr(a:buf)
try
execute 'hide buffer ' . cur_buf
return a:Func()
finally
execute 'buffer ' . old_buf
endtry
endfunction

But this messed up the cursor position history, and that's very bad.

So, any suggestions?


Regards,

Kay Z.

--
--
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: