From 612656b1d8aea329cceb43fe383181eb88d68acf Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Thu, 1 Oct 2015 20:38:44 +0200 Subject: Add function to read commodity from the user. The function provides completing read with all available commodities as gathered by "ledger commodities". --- lisp/ledger-commodities.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lisp/ledger-commodities.el') 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)." -- cgit v1.2.3