Add function to read commodity from the user.
The function provides completing read with all available commodities as gathered by "ledger commodities".
This commit is contained in:
parent
64426842a3
commit
612656b1d8
1 changed files with 10 additions and 0 deletions
|
|
@ -33,6 +33,16 @@
|
||||||
:type 'string
|
:type 'string
|
||||||
:group 'ledger-reconcile)
|
: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)
|
(defun ledger-split-commodity-string (str)
|
||||||
"Split a commoditized string, STR, into two parts.
|
"Split a commoditized string, STR, into two parts.
|
||||||
Returns a list with (value commodity)."
|
Returns a list with (value commodity)."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue