diff options
author | Johann Klähn <kljohann@gmail.com> | 2010-09-08 10:23:06 +0200 |
---|---|---|
committer | Johann Klähn <kljohann@gmail.com> | 2010-09-08 10:23:06 +0200 |
commit | 84fea7f136891416978e3608a0627be84176a928 (patch) | |
tree | 13e92275f74fd114d071c1cbc5bd4f61c264a74d | |
parent | f8c804ac79a94fc8fd4c168f5d884d42a7c0bd08 (diff) | |
download | fork-ledger-84fea7f136891416978e3608a0627be84176a928.tar.gz fork-ledger-84fea7f136891416978e3608a0627be84176a928.tar.bz2 fork-ledger-84fea7f136891416978e3608a0627be84176a928.zip |
vim. reimplement function to change state
Note: You now have to provide the line number:
call LedgerSetTransactionState(line('.', '*')
-rw-r--r-- | contrib/vim/ftplugin/ledger.vim | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/vim/ftplugin/ledger.vim b/contrib/vim/ftplugin/ledger.vim index ec1173b8..8a752c21 100644 --- a/contrib/vim/ftplugin/ledger.vim +++ b/contrib/vim/ftplugin/ledger.vim @@ -271,6 +271,18 @@ endf "}}} function! LedgerSetTransactionState(lnum, char) "{{{1 " modifies or sets the state of the transaction at the cursor, " removing the state alltogether if a:char is empty + let trans = s:transaction.from_lnum(a:lnum) + if empty(trans) + return + endif + + if empty(a:char) && has_key(trans, 'state') + call remove(trans, 'state') + else + let trans['state'] = a:char + endif + + call setline(trans['head'], trans.format_head()) endf "}}} function! LedgerSetDate(lnum, type, ...) "{{{1 @@ -305,7 +317,7 @@ function! LedgerSetDate(lnum, type, ...) "{{{1 let trans['date'] = join(date, '=') - call setline(s:get_transaction_extents(a:lnum)[0], trans.format_head()) + call setline(trans['head'], trans.format_head()) endf "}}} let s:transaction = {} "{{{1 @@ -320,6 +332,7 @@ function! s:transaction.from_lnum(lnum) dict "{{{2 endif let trans = copy(s:transaction) + let trans['head'] = head let parts = split(getline(head), '\s\+') let description = [] for part in parts |