diff options
author | Johann Klähn <kljohann@gmail.com> | 2011-07-31 16:58:16 +0200 |
---|---|---|
committer | Johann Klähn <kljohann@gmail.com> | 2011-07-31 16:58:16 +0200 |
commit | 24226c890ecf2d49cacd0c74e0eeee54341ad818 (patch) | |
tree | 2df2dc465633fc5a2ca3af06daa4857e3f8a5c81 /contrib/vim | |
parent | 91d8061af470998ac7100b242f7eafb71a7b39d2 (diff) | |
download | fork-ledger-24226c890ecf2d49cacd0c74e0eeee54341ad818.tar.gz fork-ledger-24226c890ecf2d49cacd0c74e0eeee54341ad818.tar.bz2 fork-ledger-24226c890ecf2d49cacd0c74e0eeee54341ad818.zip |
vim. allow cleared state for single postings
This should fix problems with account completion when using
marks with single postings as in:
2000/01/01 Whatever
* account 5$
some other account
Diffstat (limited to 'contrib/vim')
-rw-r--r-- | contrib/vim/ftplugin/ledger.vim | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/vim/ftplugin/ledger.vim b/contrib/vim/ftplugin/ledger.vim index 9cc4ed91..dc285b72 100644 --- a/contrib/vim/ftplugin/ledger.vim +++ b/contrib/vim/ftplugin/ledger.vim @@ -141,10 +141,10 @@ function! LedgerComplete(findstart, base) "{{{1 " only allow completion when in or at end of account name if matchend(line, '^\s\+\%(\S \S\|\S\)\+') >= col('.') - 1 " the start of the first non-blank character - " (excluding virtual-transaction-marks) + " (excluding virtual-transaction and 'cleared' marks) " is the beginning of the account name let b:compl_context = 'account' - return matchend(line, '^\s\+[\[(]\?') + return matchend(line, '^\s\+[*!]\?\s*[\[(]\?') endif elseif line =~ '^\d' "{{{2 (description) let pre = matchend(line, '^\d\S\+\%(([^)]*)\|[*?!]\|\s\)\+') @@ -411,9 +411,14 @@ function! s:transaction.parse_body(...) dict "{{{2 if line[0] =~ '^\s\+[^[:blank:];]' " posting - " FIXME: replaces original spacing in amount with single spaces - let parts = split(line[0], '\%(\t\| \)\s*') - call add(postings, {'account': parts[0], 'amount': join(parts[1:], ' ')}) + let [state, rest] = matchlist(line[0], '^\s\+\([*!]\?\)\s*\(.*\)$')[1:2] + if rest =~ '\t\| ' + let [account, amount] = matchlist(rest, '^\(.\{-}\)\%(\t\| \)\s*\(.\{-}\)\s*$')[1:2] + else + let amount = '' + let account = matchstr(rest, '^\s*\zs.\{-}\ze\s*$') + endif + call add(postings, {'account': account, 'amount': amount, 'state': state}) end " where are tags to be stored? |