diff options
Diffstat (limited to 'contrib/vim/ftplugin/ledger.vim')
-rw-r--r-- | contrib/vim/ftplugin/ledger.vim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/vim/ftplugin/ledger.vim b/contrib/vim/ftplugin/ledger.vim index 72588712..4490f3e0 100644 --- a/contrib/vim/ftplugin/ledger.vim +++ b/contrib/vim/ftplugin/ledger.vim @@ -435,6 +435,41 @@ endf "}}} " Helper functions {{{1 +function! s:get_transactions(...) "{{{2 + if a:0 == 2 + let lnum = a:1 + let end = a:2 + elseif a:0 == 0 + let lnum = 1 + let end = line('$') + else + throw "wrong number of arguments for get_transactions()" + return [] + endif + + " safe view / position + let view = winsaveview() + let fe = &foldenable + set nofoldenable + + let transactions = [] + call cursor(lnum, 0) + while lnum && lnum <= end + let trans = s:transaction.from_lnum(lnum) + if ! empty(trans) + call add(transactions, trans) + call cursor(trans['tail'], 0) + endif + let lnum = search('^[~[:digit:]]\S\+', 'cW') + endw + + " restore view / position + let &foldenable = fe + call winrestview(view) + + return transactions +endf "}}} + function! s:get_transaction_extents(lnum) "{{{2 " safe view / position let view = winsaveview() |