Skip to content

Simple Auto Update Without VIM Clientserver

Pedro Lopes edited this page Jan 2, 2018 · 1 revision

hack for auto-email polling without need for VI compiled with 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

What does it do?

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.

does it work?

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.

Notes and limitations

  1. The vmail.vim is the file that vmail loads at runtime as a configuration to the VI instance it is loaded on.
  2. In my case the vmail.vim can be found at ~/.rvm/gems/ruby-2.4.2/gems/vmail-2.9.8/lib/vmail.vim but please check if this is the case for you.
  3. vmail is wonderful. Thanks @danchoi for making it.
  4. you can adjust the polling speed by adjusting the set updatetime=10000 (do not update to small numbers, I suggest 4000)
  5. I have not tested this with multiple inboxes, etc. Just basic vmail usage.
Clone this wiki locally