@@ -43,37 +43,37 @@ highlight default link LedgerPending Todo
4343highlight default link LedgerTarget Statement
4444highlight default link LedgerImproperPerc Special
4545
46- let s: cursym = ' [[:alpha:]¢$€£]\+'
47- let s: valreg = ' \(' .
46+ let s: currency_symbol = ' [[:alpha:]¢$€£]\+'
47+ let s: value_regex = ' \(' .
4848 \ ' \%([0-9]\+\)' .
4949 \ ' \%([,.][0-9]\+\)*' .
5050 \ ' \|' .
5151 \ ' [,.][0-9]\+' .
5252 \ ' \)'
53- let s: optsgn = ' [+-]\?'
54- let s: cursgn = ' \(' .
55- \ s: optsgn .
53+ let s: optional_sign = ' [+-]\?'
54+ let s: currency_sign = ' \(' .
55+ \ s: optional_sign .
5656 \ ' \s*' .
57- \ s: cursym .
57+ \ s: currency_symbol .
5858 \ ' \|' .
59- \ s: cursym .
59+ \ s: currency_symbol .
6060 \ ' \s*' .
61- \ s: optsgn .
61+ \ s: optional_sign .
6262 \ ' \)'
6363
64- let s: optional_balance_assertion = ' \(\s*=\s*' .s: cursgn .' \s*' .s: valreg .' \)\?'
64+ let s: optional_balance_assertion = ' \(\s*=\s*' .s: currency_sign .' \s*' .s: value_regex .' \)\?'
6565
66- let s: rx_amount = s: valreg .
66+ let s: rx_amount = s: value_regex .
6767 \ s: optional_balance_assertion .
68- \ ' \s*\%(' .s: cursym .' \s*\)\?' .
68+ \ ' \s*\%(' .s: currency_symbol .' \s*\)\?' .
6969 \ ' \%(\s*;.*\)\?$'
7070
7171function ! LedgerFoldText ()
7272 " find amount
7373 let amount = ' '
74- let lnum = v: foldstart + 1
75- while lnum <= v: foldend
76- let line = getline (lnum )
74+ let line_number = v: foldstart + 1
75+ while line_number <= v: foldend
76+ let line = getline (line_number )
7777
7878 " Skip metadata/leading comment
7979 if line !~# ' ^\%(\s\+;\|\d\)'
@@ -84,7 +84,7 @@ function! LedgerFoldText()
8484 break
8585 endif
8686 endif
87- let lnum += 1
87+ let line_number += 1
8888 endwhile
8989
9090 " strip whitespace at beginning and end of line
@@ -143,55 +143,55 @@ endfunction
143143
144144function ! LedgerComplete (findstart, base)
145145 if a: findstart
146- let lnum = line (' .' )
146+ let line_number = line (' .' )
147147 let line = getline (' .' )
148- let b: compl_context = ' '
148+ let b: completion_context = ' '
149149 if line = ~# ' ^\s\+[^[:blank:];]'
150150 " only allow completion when in or at end of account name
151151 if matchend (line , ' ^\s\+\%(\S \S\|\S\)\+' ) >= col (' .' ) - 1
152152 " the start of the first non-blank character
153153 " (excluding virtual-transaction and 'cleared' marks)
154154 " is the beginning of the account name
155- let b: compl_context = ' account'
155+ let b: completion_context = ' account'
156156 return matchend (line , ' ^\s\+[*!]\?\s*[\[(]\?' )
157157 endif
158158 elseif line = ~# ' ^account '
159- let pre = matchend (line , ' ^account ' )
160- let b: compl_context = ' account'
161- return pre
159+ let prefix = matchend (line , ' ^account ' )
160+ let b: completion_context = ' account'
161+ return prefix
162162 elseif line = ~# ' ^\d'
163- let pre = matchend (line , ' ^\d\S\+\%\(\s\(([^\)]*)\|[*?!]\)\)\?\s\+' )
164- if pre <= col (' .' ) - 1
165- let b: compl_context = ' description'
166- if pre == -1
163+ let prefix = matchend (line , ' ^\d\S\+\%\(\s\(([^\)]*)\|[*?!]\)\)\?\s\+' )
164+ if prefix <= col (' .' ) - 1
165+ let b: completion_context = ' description'
166+ if prefix == -1
167167 return -3
168168 endif
169- return pre
169+ return prefix
170170 endif
171171 elseif b: ledger_is_hledger && line = ~# ' ^payee '
172- let pre = matchend (line , ' ^payee ' )
173- let b: compl_context = ' description'
174- return pre
172+ let prefix = matchend (line , ' ^payee ' )
173+ let b: completion_context = ' description'
174+ return prefix
175175 elseif line = ~# ' ^$'
176- let b: compl_context = ' new'
176+ let b: completion_context = ' new'
177177 return 0
178178 endif
179179 return -3
180180 else
181- if ! exists (' b:compl_cache ' )
182- let b: compl_cache = s: collect_completion_data ()
183- let b: compl_cache [' #' ] = changenr ()
181+ if ! exists (' b:completion_cache ' )
182+ let b: completion_cache = s: collect_completion_data ()
183+ let b: completion_cache [' #' ] = changenr ()
184184 endif
185185 let update_cache = 0
186186
187187 let results = []
188- if b: compl_context == # ' account'
188+ if b: completion_context == # ' account'
189189 let hierarchy = split (a: base , ' :' )
190190 if a: base = ~# ' :$'
191191 call add (hierarchy, ' ' )
192192 endif
193193
194- let results = ledger#find_in_tree (b: compl_cache .accounts, hierarchy)
194+ let results = ledger#find_in_tree (b: completion_cache .accounts, hierarchy)
195195 let exacts = filter (copy (results), ' v:val[1]' )
196196
197197 if len (exacts) < 1
@@ -206,19 +206,19 @@ function! LedgerComplete(findstart, base)
206206 call map (results, ' v:val[0]' )
207207
208208 if b: ledger_fuzzy_account_completion
209- let results = matchfuzzy (b: compl_cache .flat_accounts, a: base , {' matchseq' :1 })
209+ let results = matchfuzzy (b: completion_cache .flat_accounts, a: base , {' matchseq' :1 })
210210 elseif b: ledger_detailed_first
211211 let results = reverse (sort (results, ' s:sort_accounts_by_depth' ))
212212 else
213213 let results = sort (results)
214214 endif
215- elseif b: compl_context == # ' description'
216- let results = ledger#filter_items (b: compl_cache .descriptions, a: base )
215+ elseif b: completion_context == # ' description'
216+ let results = ledger#filter_items (b: completion_cache .descriptions, a: base )
217217
218218 if len (results) < 1
219219 let update_cache = 1
220220 endif
221- elseif b: compl_context == # ' new'
221+ elseif b: completion_context == # ' new'
222222 return [strftime (b: ledger_date_format )]
223223 endif
224224
@@ -228,11 +228,11 @@ function! LedgerComplete(findstart, base)
228228 endif
229229
230230 " no completion (apart from a:base) found. update cache if file has changed
231- if update_cache && b: compl_cache [' #' ] != changenr ()
232- unlet b: compl_cache
231+ if update_cache && b: completion_cache [' #' ] != changenr ()
232+ unlet b: completion_cache
233233 return LedgerComplete (a: findstart , a: base )
234234 else
235- unlet ! b: compl_context
235+ unlet ! b: completion_context
236236 return results
237237 endif
238238 endif
@@ -246,9 +246,9 @@ function! s:collect_completion_data()
246246 let cache.flat_accounts = accounts
247247 let cache.descriptions = s: get_descriptions_list ()
248248
249- for xact in transactions
250- let [t , postings] = xact .parse_body ()
251- let tagdicts = [t ]
249+ for transaction in transactions
250+ let [tags , postings] = transaction .parse_body ()
251+ let tagdicts = [tags ]
252252
253253 " collect account names (only when not using ledger binary)
254254 if b: ledger_bin == # v: false
@@ -345,15 +345,15 @@ function! s:count_expression(text, expression)
345345 return len (split (a: text , a: expression , 1 ))-1
346346endfunction
347347
348- function ! s: autocomplete_account_or_payee (argLead, cmdLine, cursorPos )
349- if a: argLead = ~# ' ^@'
348+ function ! s: autocomplete_account_or_payee (argument_lead, command_line, cursor_position )
349+ if a: argument_lead = ~# ' ^@'
350350 let payees = s: get_descriptions_list ()
351- let pattern = strpart (a: argLead , 1 )
351+ let pattern = strpart (a: argument_lead , 1 )
352352 return map (filter (payees, " v:val =~? '" . pattern . " ' && v:val !~? '^Warning: '" ),
353353 \ ' "@" . escape(v:val, " ")' )
354354 else
355355 let accounts = s: get_accounts_list ()
356- return map (filter (accounts, " v:val =~? '" . a: argLead . " ' && v:val !~? '^Warning: '" ),
356+ return map (filter (accounts, " v:val =~? '" . a: argument_lead . " ' && v:val !~? '^Warning: '" ),
357357 \ ' escape(v:val, " ")' )
358358 endif
359359endfunction
0 commit comments