summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-04-01 20:48:00 -0700
committerCraig Earls <enderw88@gmail.com>2013-04-01 20:48:00 -0700
commiteed1d8e53ea3f75f0c6a84ab744f8310a4778981 (patch)
tree00e681f21d91043a03440cf1845d2a9dde8a051c /lisp
parent78bedf7c8ea15e369f56fbd317d03deb35343258 (diff)
downloadfork-ledger-eed1d8e53ea3f75f0c6a84ab744f8310a4778981.tar.gz
fork-ledger-eed1d8e53ea3f75f0c6a84ab744f8310a4778981.tar.bz2
fork-ledger-eed1d8e53ea3f75f0c6a84ab744f8310a4778981.zip
ledger-read-commodity-string now calls ledger-split-commodity-string
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ldg-commodities.el28
1 files changed, 9 insertions, 19 deletions
diff --git a/lisp/ldg-commodities.el b/lisp/ldg-commodities.el
index 842613c6..8755166d 100644
--- a/lisp/ldg-commodities.el
+++ b/lisp/ldg-commodities.el
@@ -127,25 +127,15 @@ longer ones are after the value."
(concat commodity " " val))))
(defun ledger-read-commodity-string (prompt)
- "Return a commoditizd value (val 'comm') from COMM.
-Assumes a space between the value and the commodity."
- (let ((parts (split-string (read-from-minibuffer
- (concat prompt " (" ledger-reconcile-default-commodity "): ")))))
- (if parts
- (if (/= (length parts) 2) ;;assume a number was entered and
- ;;use default commodity
- (list (string-to-number (car parts))
- ledger-reconcile-default-commodity)
- (let ((valp1 (string-to-number (car parts)))
- (valp2 (string-to-number (cadr parts))))
- (cond ((and (= valp1 valp2) (= 0 valp1)) ;; means neither contained a valid number (both = 0)
- (list 0 ""))
- ((and (/= 0 valp1) (= valp2 0))
- (list valp1 (cadr parts)))
- ((and (/= 0 valp2) (= valp1 0))
- (list valp2 (car parts)))
- (t
- (error "Cannot understand commodity"))))))))
+ (let ((str (read-from-minibuffer
+ (concat prompt " (" ledger-reconcile-default-commodity "): ")))
+ comm)
+ (if (> (length str) 0)
+ (progn
+ (setq comm (ledger-split-commodity-string str))
+ (if (cadr comm)
+ comm
+ (list (car comm) ledger-reconcile-default-commodity))))))
(provide 'ldg-commodities)