@@ -509,21 +509,34 @@ endfunc
509
509
" Parameters:
510
510
" file The file to be processed.
511
511
" args A string of Ledger command-line arguments.
512
+ "
513
+ " Returns:
514
+ " Ledger's output as a String.
512
515
function ! ledger#report (file , args )
513
516
let l: output = systemlist (s: ledger_cmd (a: file , a: args ))
514
517
if v: shell_error " If there are errors, show them in a quickfix/location list.
515
518
call s: quickfix_populate (l: output )
516
519
call s: quickfix_toggle (' Errors' , ' Unable to parse errors' )
517
- return
518
520
endif
519
- if empty (l: output )
521
+ return l: output
522
+ endf
523
+
524
+ " Open the output of a Ledger's command in a new buffer.
525
+ "
526
+ " Parameters:
527
+ " report A String containing the output of a Ledger's command.
528
+ "
529
+ " Returns:
530
+ " 1 if a new buffer is created; 0 otherwise.
531
+ function ! ledger#output (report )
532
+ if empty (a: report )
520
533
call s: warning_message (' No results' )
521
- return
534
+ return 0
522
535
endif
523
536
" Open a new buffer to show Ledger's output.
524
537
execute get (s: winpos_map , g: ledger_winpos , " bo new" )
525
- setlocal buftype = nofile bufhidden = wipe nobuflisted noswapfile nowrap
526
- call append (0 , l: output )
538
+ setlocal buftype = nofile bufhidden = wipe modifiable nobuflisted noswapfile nowrap
539
+ call append (0 , a: report )
527
540
setlocal nomodifiable
528
541
" Set local mappings to quit window or lose focus.
529
542
nnoremap <silent> <buffer> <tab> <c-w><c-w>
@@ -532,6 +545,7 @@ function! ledger#report(file, args)
532
545
syntax match LedgerNumber / -\@ 1<!\d\+\( [,.]\d\+\)\+ /
533
546
syntax match LedgerNegativeNumber / -\d\+\( [,.]\d\+\)\+ /
534
547
syntax match LedgerImproperPerc / \d\d\d\+ %/
548
+ return 1
535
549
endf
536
550
537
551
" Show an arbitrary register report in a quickfix list.
0 commit comments