diff options
author | Matus Goljer <matus.goljer@gmail.com> | 2015-10-01 20:38:44 +0200 |
---|---|---|
committer | Matus Goljer <matus.goljer@gmail.com> | 2015-10-01 20:38:44 +0200 |
commit | 9acd6c56eb7eb5c76495ff8526e3f58e77d7f70a (patch) | |
tree | d140664e729952255a82c392d232d315f4be81a2 | |
parent | f89c3482e5026adad3513b293301a8e3bf4fe254 (diff) |
Add function to read commodity from the user.
The function provides completing read with all available commodities as
gathered by "ledger commodities".
-rw-r--r-- | ledger-commodities.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ledger-commodities.el b/ledger-commodities.el index ea6319b..48fb78f 100644 --- a/ledger-commodities.el +++ b/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)." |