Look ma', I'm writing VimScript

Basically, I'm trying to calculate the best width of the numbers gutter.
I do that on each write and each buffer enter (hopefully).