buffer list count

2006-11-12 Thread mzyzik
All, 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

Re: buffer list count

2006-11-12 Thread Bill McCarthy
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

Re: buffer list count

2006-11-12 Thread mzyzik
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 +=

Re: buffer list count

2006-11-12 Thread Bill McCarthy
On Sun 12-Nov-06 7:54pm -0600, [EMAIL PROTECTED] wrote: > Well I'm reporting the above "g:zbuflistcount" in my 'rulerformat'. Don't you think you should have mentioned that? > I really don't think I can afford the baggage of calling your function > from within my 'rulerformat'. No, for 100 buff

Re: buffer list count

2006-11-12 Thread Yakov Lerner
On 11/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: All, 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

Re: buffer list count

2006-11-13 Thread Matt Zyzik
> On Sun 12-Nov-06 7:54pm -0600, [EMAIL PROTECTED] wrote: > >> Well I'm reporting the above "g:zbuflistcount" in my 'rulerformat'. > > Don't you think you should have mentioned that? > >> I really don't think I can afford the baggage of calling your function >> from within my 'rulerformat'. > > No,

Re: buffer list count

2006-11-13 Thread Matt Zyzik
>> 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 thing that I think could cause it,

RE: buffer list count

2006-11-13 Thread Eggum, DavidX S
Matt, You can speed up the calculations considerably if you keep several things in mind: - buffer numbers are never reused. - built-in vim functions are written in C and are very fast - although you can open many files at once (like vim *.cs), buffers are usually (always?) deleted one at a time.

Re: buffer list count

2006-11-13 Thread Nikolai Weibull
On 11/13/06, Eggum, DavidX S <[EMAIL PROTECTED]> wrote: let s:prev_last = 0 let s:prev_count = 0 function! GetBufCount() let last = bufnr('$') if last != s:prev_last Argh...of course...that's the solution to my buffer-tracking problems as well. I'm writing a high-level object-oriented i

Re: buffer list count

2006-11-13 Thread Bill McCarthy
On Mon 13-Nov-06 8:54am -0600, Matt Zyzik wrote: >> On Sun 12-Nov-06 7:54pm -0600, [EMAIL PROTECTED] wrote: >>> Well I'm reporting the above "g:zbuflistcount" in my 'rulerformat'. >> Don't you think you should have mentioned that? >>> I really don't think I can afford the baggage of calling yo

Re: buffer list count

2006-11-13 Thread A.J.Mechelynck
Eggum, DavidX S wrote: Matt, You can speed up the calculations considerably if you keep several things in mind: - buffer numbers are never reused. - built-in vim functions are written in C and are very fast - although you can open many files at once (like vim *.cs), buffers are usually (always?)

RE: buffer list count

2006-11-13 Thread Eggum, DavidX S
, DavidX S Cc: Matt Zyzik; Yakov Lerner; vim-dev@vim.org Subject: Re: buffer list count Eggum, DavidX S wrote: > Matt, > > You can speed up the calculations considerably if you keep several > things in mind: > - buffer numbers are never reused. > - built-in vim functions are written

RE: buffer list count

2006-11-13 Thread Eggum, DavidX S
! GetBufCount() return s:prev_count endfunction -Original Message- From: Eggum, DavidX S Sent: Monday, November 13, 2006 5:36 PM To: A.J.Mechelynck Cc: Matt Zyzik; Yakov Lerner; vim-dev@vim.org Subject: RE: buffer list count Thank you for the correction, Tony. If the BufDelete command

Re: buffer list count

2006-11-13 Thread mzyzik
On Mon, Nov 13, 2006 at 04:06:56PM -0600, Bill McCarthy wrote: > The "No" I wrote means that I agree that calling a user > function that takes (on my computer) 4ms is too slow. > > I tested by opening about 100 files and wrote a function to > call the posted function 1000 times. That test took a

Re: buffer list count

2006-11-13 Thread mzyzik
On Tue, Nov 14, 2006 at 02:04:40AM +0100, A.J.Mechelynck wrote: > Eggum, DavidX S wrote: > >Matt, > > > >You can speed up the calculations considerably if you keep several > >things in mind: > >- buffer numbers are never reused. > >- built-in vim functions are written in C and are very fast > >- al

Re: buffer list count

2006-11-13 Thread mzyzik
On Mon, Nov 13, 2006 at 08:25:42AM -0800, Eggum, DavidX S wrote: > Try this (lightly tested): > > autocmd BufDelete * let s:prev_count -= 1 > set rulerformat=%60(%=%{GetBufCount()}%) > > let s:prev_last = 0 > let s:prev_count = 0 > function! GetBufCount() >let last = bufnr('$') >if last !

Re: buffer list count

2006-11-13 Thread Bill McCarthy
On Mon 13-Nov-06 7:54pm -0600, Eggum, DavidX S wrote: > Okay, try this, Matt (it is, again, lightly tested). Granted, it > recalculates from scratch every time, but it only does it when it needs > to and it should still be pretty fast. It also doesn't rely on the > events to be called once every

Re: buffer list count

2006-11-13 Thread Matt Zyzik
On Mon, Nov 13, 2006 at 05:54:01PM -0800, Eggum, DavidX S wrote: > Okay, try this, Matt (it is, again, lightly tested). Granted, it > [...] > > set rulerformat=%60(%=%{GetBufCount()}%) > autocmd VimEnter,BufAdd,BufDelete * call UpdateBufCount() > > let s:prev_last = 0 > let s:prev_count = 0 > >

Re: buffer list count

2006-11-14 Thread Milan Vancura
Hi, > When my .vimrc is running, creating the BufAdd autocmds, all of the > files (*.c) I think already have buffers assigned to them. I'm not sure, > but this could cause the problem. A simple fix would just be a manual > buffer count on VimEnter. I'm getting close to the best solution. I think