From 84fea7f136891416978e3608a0627be84176a928 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Wed, 8 Sep 2010 10:23:06 +0200 Subject: vim. reimplement function to change state Note: You now have to provide the line number: call LedgerSetTransactionState(line('.', '*') --- contrib/vim/ftplugin/ledger.vim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3