Thursday, July 12, 2012

Re: Cleaning up the buffer list

On Thu, Jul 12, 2012 at 01:58:24AM EDT, Christian Brabandt wrote:
> On Thu, July 12, 2012 01:38, Chris Jones wrote:

[..]

> > Has anyone looked into buffer list manipulation before and could
> > advise on a different approach & suggest how I might be able to come
> > up with something a bit less clunky..?

> Somethins like this, probably:
> fu! s:MyBufferClean()
> let _t = tabpagenr()
> let blist=range(1,bufnr('$'))
> tabdo call filter(blist, 'bufwinnr(v:val)==-1')
> for bufnr in blist
> exe 'bw' bufnr
> endfor
> exe _t "tabnext"
> endfu
> command! MyBufferClean :call <sid>MyBufferClean()

Yes, bufwinnr()'s '-1' return value was just about the only thing that
came close. I believe the above works but it's limited to hidden vs.
active.. does not check if a buffer was modified..

I guess I was looking for something that would basically return
something a bit like a C struct, with maybe the buffer number, the file
name and then the indicators.

All the same, I read ':h :ls' and the description of the format of :ls's
output is quite precise.. so I guess I'll just rework my initial effort
and stick with that.

Thanks,

CJ

--
HOW ARE YOU GENTLEMEN?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment