-
Notifications
You must be signed in to change notification settings - Fork 59
Simple Auto Update Without VIM Clientserver
Maybe some of you would benefit also from this, simplistic and probably naïve, hack to allow you to automatically refresh your vmail messages without needing to have VI compiled with --clientserver.
Essentially you need to add the following to your vmail.vim file
set updatetime=10000
autocmd CursorHold * call Timer()
function! Timer()
call feedkeys("f\e")
let buffer_now = expand(@%)
if buffer_now == "vmailbuffer"
call s:update()
endif
endfunction
Every 10000ms (aka 10s) it calls a function that does nothing and should not interfere with your typing, buffers, etc (I tested on my system and works perfectly). This function is basically a timer (VI only has true timers > version 8). If you are on the main vmail buffer (where the inbox is, which is named vmailbuffer) it will execute an update on the email server (same as if you would press the <leader>U key combo to update manually). Note that to avoid bugs it only does that on the main window.
For me it does. Go ahead and test it or explore/modify to suit your needs. This is certainly an inferior trick compared to actually compiling your VI with --clientserver but I did not want to do that.
- The
vmail.vimis the file that vmail loads at runtime as a configuration to the VI instance it is loaded on. - In my case the
vmail.vimcan be found at~/.rvm/gems/ruby-2.4.2/gems/vmail-2.9.8/lib/vmail.vimbut please check if this is the case for you. - vmail is wonderful. Thanks @danchoi for making it.
- you can adjust the polling speed by adjusting the
set updatetime=10000(do not update to small numbers, I suggest 4000) - I have not tested this with multiple inboxes, etc. Just basic vmail usage.