Skip to content

Commit 4159cad

Browse files
committed
Merge pull request #23 from lifepillar/ledger-entry
Add ledger#entry() function.
2 parents 0807afc + ba91b64 commit 4159cad

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.mkd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ Tips and useful commands
4242

4343
* Align commodities at the decimal point. See `help ledger-tips`.
4444

45+
* `:call ledger#entry()`
46+
47+
will replace the text on the current line with a new transaction based
48+
on the replaced text.
49+
4550
Configuration
4651
-------------
4752

autoload/ledger.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,10 @@ function! ledger#align_amount_at_cursor()
393393
endif
394394
endf!
395395

396+
func! ledger#entry()
397+
" enter a new transaction based on the text in the current line.
398+
let l = line('.') - 1 " Insert transaction at the current line (i.e., below the line above the current one)
399+
let query = getline('.')
400+
normal "_dd
401+
exec l . 'read !' g:ledger_bin '-f' shellescape(expand('%')) 'entry' shellescape(query)
402+
endfunc

doc/ledger.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ Tips and useful commands
8585

8686
Now, you may type `123.45<C-l>`, and have `$123.45` properly aligned (assuming
8787
your default commodity is set to `'$'`).
88+
89+
* `:call ledger#entry()`
90+
91+
enters a new transaction based on the text in the current line.
92+
The text in the current line is replaced by the new transaction.
93+
This is a front end to `ledger entry`.
94+
8895
==============================================================================
8996
SETTINGS *ledger-settings*
9097

0 commit comments

Comments
 (0)