summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-26 13:55:31 -0400
committerCraig Earls <enderw88@gmail.com>2013-03-26 13:55:31 -0400
commitc8c94e960206f705610b92b6957a2209208c69c5 (patch)
tree7563d06b6c7eccddd1d5a9ba7989999d0bc825a6 /lisp
parentf1882d0a56f8b5828aaadfe06e5207a9b43d2ef0 (diff)
downloadfork-ledger-c8c94e960206f705610b92b6957a2209208c69c5.tar.gz
fork-ledger-c8c94e960206f705610b92b6957a2209208c69c5.tar.bz2
fork-ledger-c8c94e960206f705610b92b6957a2209208c69c5.zip
Handle quoted commodities in ledger-split-commodity-string
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ldg-commodities.el41
1 files changed, 26 insertions, 15 deletions
diff --git a/lisp/ldg-commodities.el b/lisp/ldg-commodities.el
index 3485d93f..831d770b 100644
--- a/lisp/ldg-commodities.el
+++ b/lisp/ldg-commodities.el
@@ -41,21 +41,32 @@ Returns a list with (value commodity)."
(with-temp-buffer
(insert str)
(goto-char (point-min))
- (cond ((re-search-forward number-regex nil t)
- ;; found a number in the current locale, return it in
- ;; the car. Anything left over is annotation,
- ;; the first thing should be the commodity, separated
- ;; by whitespace, return it in the cdr. I can't think of any
- ;; counterexamples
- (list
- (string-to-number
- (ledger-commodity-string-number-decimalize
- (delete-and-extract-region (match-beginning 0) (match-end 0)) :from-user))
- (nth 0 (split-string (buffer-substring-no-properties (point-min) (point-max))))))
- ((re-search-forward "0" nil t)
- ;; couldn't find a decimal number, look for a single 0,
- ;; indicating account with zero balance
- (list 0 ledger-reconcile-default-commodity)))))
+ (cond
+ ((re-search-forward "\"\\(.*\\)\"" nil t)
+ (let ((com (delete-and-extract-region
+ (match-beginning 1)
+ (match-end 1))))
+ (if (re-search-forward number-regex nil t)
+ (list
+ (string-to-number
+ (ledger-commodity-string-number-decimalize
+ (delete-and-extract-region (match-beginning 0) (match-end 0)) :from-user))
+ com))))
+ ((re-search-forward number-regex nil t)
+ ;; found a number in the current locale, return it in
+ ;; the car. Anything left over is annotation,
+ ;; the first thing should be the commodity, separated
+ ;; by whitespace, return it in the cdr. I can't think of any
+ ;; counterexamples
+ (list
+ (string-to-number
+ (ledger-commodity-string-number-decimalize
+ (delete-and-extract-region (match-beginning 0) (match-end 0)) :from-user))
+ (nth 0 (split-string (buffer-substring-no-properties (point-min) (point-max))))))
+ ((re-search-forward "0" nil t)
+ ;; couldn't find a decimal number, look for a single 0,
+ ;; indicating account with zero balance
+ (list 0 ledger-reconcile-default-commodity)))))
;; nothing found, return 0
(list 0 ledger-reconcile-default-commodity)))