From 1be3a793857204a8baf935af063675a0b14c09b1 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Wed, 8 Sep 2010 18:10:48 +0200 Subject: vim. check for most common case first (parse_body) --- contrib/vim/ftplugin/ledger.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'contrib/vim/ftplugin') diff --git a/contrib/vim/ftplugin/ledger.vim b/contrib/vim/ftplugin/ledger.vim index 623b0795..a50a5510 100644 --- a/contrib/vim/ftplugin/ledger.vim +++ b/contrib/vim/ftplugin/ledger.vim @@ -420,7 +420,13 @@ function! s:transaction.parse_body(...) dict "{{{2 let tag_container = postings[-1]['tags'] endif - if line =~ '^\s\+;\s*:' + if line =~ '^\s\+[^[:blank:];]' + " posting + " FIXME: comments at the eol + " FIXME: replaces original spacing in amount with single spaces + let parts = split(line, '\(\t\|\s\{2,}\)') + call add(postings, {'account': parts[0], 'amount': join(parts[1:])}) + elseif line =~ '^\s\+;\s*:' " tags without values for t in s:findall(line, ':\zs[^:[:blank:]]\([^:]*[^:[:blank:]]\)\?\ze:') let tag_container[t] = '' @@ -432,12 +438,6 @@ function! s:transaction.parse_body(...) dict "{{{2 let val = matchstr(line, ':\s*\zs.*\ze\s*$') let tag_container[key] = val endif - elseif line =~ '^\s\+[^[:blank:];]' - " posting - " FIXME: comments at the eol - " FIXME: replaces original spacing in amount with single spaces - let parts = split(line, '\(\t\|\s\{2,}\)') - call add(postings, {'account': parts[0], 'amount': join(parts[1:])}) endif let lnum += 1 endw -- cgit v1.2.3