Hi,
> I would like an indicator in my 'titlestring' that informs me if ANY
> changes are present in ANY listed buffer. This would be more like a
> global indicator for the 'modified' setting. What is the most
> efficient way to do this?
>
> Currently, I've taken the naive approach:
>
> function! g:ChangesExist()
> let l:bufferList = filter(range(1, bufnr('$')), 'buflisted(v:val)')
> for l:bufferNumber in l:bufferList
>
> if getbufvar(l:bufferNumber, '&modified')
> return 1
> endif
> endfor
> return 0
> endfunction
>
>
> This seems like the most direct method, but I'm wondering if there's
> some simple option or function call that I'm missing...
If speed is really that important, get rid of the loop and use something like
return !empty(filter(bufferList, "getbufvar(v:val, '&modified')"))
or, in a single step:
return !empty(filter(range(1, bufnr('$')), "buflisted(v:val) && getbufvar(v:val, '&modified')"))
--
Luc Hermitte
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment