diff options
author | Matus Goljer <matus.goljer@gmail.com> | 2015-10-01 20:41:13 +0200 |
---|---|---|
committer | Matus Goljer <matus.goljer@gmail.com> | 2015-10-01 20:41:13 +0200 |
commit | a8fa013417232715151f20bbe15d0b3a96a753f2 (patch) | |
tree | c0d57d5808061fae0110e6737b3c96e18d102e8b /lisp | |
parent | 612656b1d8aea329cceb43fe383181eb88d68acf (diff) | |
download | fork-ledger-a8fa013417232715151f20bbe15d0b3a96a753f2.tar.gz fork-ledger-a8fa013417232715151f20bbe15d0b3a96a753f2.tar.bz2 fork-ledger-a8fa013417232715151f20bbe15d0b3a96a753f2.zip |
Make balance-at-point able to convert commodity.
The function `ledger-display-balance-at-point' called with the prefix
argument will now ask for the target commodity.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-mode.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 30f25dfc..26de84fc 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -125,14 +125,19 @@ ": ")) nil 'ledger-minibuffer-history default)) -(defun ledger-display-balance-at-point () +(defun ledger-display-balance-at-point (&optional arg) "Display the cleared-or-pending balance. -And calculate the target-delta of the account being reconciled." - (interactive) +And calculate the target-delta of the account being reconciled. + +With prefix argument \\[universal-argument] ask for the target commodity and convert +the balance into that." + (interactive "P") (let* ((account (ledger-read-account-with-prompt "Account balance to show")) + (target-commodity (when arg (ledger-read-commodity-with-prompt "Target commodity: "))) (buffer (current-buffer)) (balance (with-temp-buffer - (ledger-exec-ledger buffer (current-buffer) "cleared" account) + (apply 'ledger-exec-ledger buffer (current-buffer) "cleared" account + (when target-commodity (list "-X" target-commodity))) (if (> (buffer-size) 0) (buffer-substring-no-properties (point-min) (1- (point-max))) (concat account " is empty."))))) |