diff options
Diffstat (limited to 'lisp/ledger-commodities.el')
-rw-r--r-- | lisp/ledger-commodities.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lisp/ledger-commodities.el b/lisp/ledger-commodities.el index a0949c21..a6f2fdda 100644 --- a/lisp/ledger-commodities.el +++ b/lisp/ledger-commodities.el @@ -1,6 +1,6 @@ ;;; ledger-commodities.el --- Helper code for use with the "ledger" command-line tool -;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org) +;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org) ;; This file is not part of GNU Emacs. @@ -37,6 +37,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)." @@ -95,8 +105,8 @@ Returns a list with (value commodity)." (error "Can't add different commodities, %S to %S" c1 c2))) (defun ledger-strip (str char) - "Return STR with CHAR removed." - (replace-regexp-in-string char "" str)) + "Return STR with CHAR removed." + (replace-regexp-in-string char "" str)) (defun ledger-string-to-number (str &optional decimal-comma) "improve builtin string-to-number by handling internationalization, and return nil if number can't be parsed" @@ -109,7 +119,7 @@ Returns a list with (value commodity)." (string-to-number nstr))) (defun ledger-number-to-string (n &optional decimal-comma) - "number-to-string that handles comma as decimal." + "number-to-string that handles comma as decimal." (let ((str (number-to-string n))) (when (or decimal-comma (assoc "decimal-comma" ledger-environment-alist)) @@ -128,7 +138,7 @@ longer ones are after the value." (concat commodity " " str)))) (defun ledger-read-commodity-string (prompt) - "Read an amount from mini-buffer using PROMPT." + "Read an amount from mini-buffer using PROMPT." (let ((str (read-from-minibuffer (concat prompt " (" ledger-reconcile-default-commodity "): "))) comm) |