Add modified_buffers segment

This segment returns a comma-separated list of modified buffers. The
segment is not enabled by default.

Closes #173.
This commit is contained in:
Kim Silkebækken 2013-02-08 16:20:26 +01:00
parent 5399265135
commit d386ae71fd
2 changed files with 11 additions and 1 deletions

View File

@ -82,7 +82,8 @@
"line_percent_gradient6": { "fg": "gradient6", "bg": "gray4" },
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
"col_current": { "fg": "gray6", "bg": "gray10" }
"col_current": { "fg": "gray6", "bg": "gray10" },
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
},
"mode_translations": {
"nc": {

View File

@ -167,6 +167,15 @@ def col_current(virtcol=True):
return vim_funcs['virtcol' if virtcol else 'col']('.')
def modified_buffers(text=u'+'):
'''Return a comma-separated list of modified buffers.'''
buffer_len = int(vim.eval('bufnr("$")'))
buffer_mod = [str(bufnr) for bufnr in range(1, buffer_len + 1) if vim.eval('getbufvar({0}, "&mod")'.format(bufnr)) == '1']
if buffer_mod:
return u'{0} {1}'.format(text, ','.join(buffer_mod))
return None
@memoize(2)
def branch():
repo = guess(os.path.abspath(vim.current.buffer.name or os.getcwd()))