On Sun, Nov 12, 2006 at 07:14:49PM -0600, Bill McCarthy wrote: > On Sun 12-Nov-06 6:17pm -0600, [EMAIL PROTECTED] wrote: > > > I am trying to keep track of the number of buffers in the buffer list. > > > > I'm doing this with the following code: > > autocmd BufAdd * let g:zbuflistcount += 1 > > autocmd BufDelete * let g:zbuflistcount -= 1 > > > > The problem is I found this to be very unreliable in some circumstances, > > and I'm not sure why. > > One approach is to eliminate the baggage of autocmd > triggering and write a function to perform the count on the > fly. Such as this Vim 7.0 function:
Well I'm reporting the above "g:zbuflistcount" in my 'rulerformat'. I really don't think I can afford the baggage of calling your function from within my 'rulerformat'. > > function CountListedBuffers() > let cnt = 0 > for nr in range(1,bufnr("$")) > if buflisted(nr) > let cnt += 1 > endif > endfor > return cnt > endfunction > > You may need to replace the buflisted() function to > something accurate to your meaning of "in the buffer list." > > -- > Best regards, > Bill > --Matt