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:

    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

Reply via email to