summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMatus Goljer <matus.goljer@gmail.com>2015-10-01 20:38:44 +0200
committerMatus Goljer <matus.goljer@gmail.com>2015-10-01 20:38:44 +0200
commit612656b1d8aea329cceb43fe383181eb88d68acf (patch)
tree2eb5e8c25e47b5074eecf2e81a729ac95cb7fe17 /lisp
parent64426842a34f0517e43a47a404cd15c764f1c7f2 (diff)
downloadfork-ledger-612656b1d8aea329cceb43fe383181eb88d68acf.tar.gz
fork-ledger-612656b1d8aea329cceb43fe383181eb88d68acf.tar.bz2
fork-ledger-612656b1d8aea329cceb43fe383181eb88d68acf.zip
Add function to read commodity from the user.
The function provides completing read with all available commodities as gathered by "ledger commodities".
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-commodities.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/ledger-commodities.el b/lisp/ledger-commodities.el
index ea6319ba..48fb78f7 100644
--- a/lisp/ledger-commodities.el
+++ b/lisp/ledger-commodities.el
@@ -33,6 +33,16 @@
:type 'string
:group 'ledger-reconcile)
+(defun ledger-read-commodity-with-prompt (prompt)
+ "Read commodity name after PROMPT.
+
+Default value is `ledger-reconcile-default-commodity'."
+ (let* ((buffer (current-buffer))
+ (commodities (with-temp-buffer
+ (ledger-exec-ledger buffer (current-buffer) "commodities")
+ (split-string (buffer-string) "\n" t))))
+ (completing-read prompt commodities nil t nil nil ledger-reconcile-default-commodity)))
+
(defun ledger-split-commodity-string (str)
"Split a commoditized string, STR, into two parts.
Returns a list with (value commodity)."