Bug 882 Calc mode doesn't play nice with decimal comma

Added a few lines to transform the amount to decimal period format before pushing it to calc.
This commit is contained in:
Craig Earls 2013-02-12 16:47:43 -07:00
parent 5eb322c0a2
commit a13bcd4109

View file

@ -45,6 +45,12 @@
:type 'boolean
:group 'ledger-post)
(defcustom ledger-post-use-decimal-comma nil
"if non-nil the use commas as decimal separator. This only has
effect interfacing to calc mode in edit amount"
:type 'boolean
:group 'ledger-post)
(defun ledger-post-all-accounts ()
(let ((origin (point))
(ledger-post-list nil)
@ -166,8 +172,15 @@
(goto-char (match-beginning 0))
(delete-region (match-beginning 0) (match-end 0))
(calc)
(while (string-match "," val)
(setq val (replace-match "" nil nil val))) ;; gets rid of commas
(if ledger-post-use-decimal-comma
(progn
(while (string-match "\\." val)
(setq val (replace-match "" nil nil val))) ;; gets rid of periods
(while (string-match "," val)
(setq val (replace-match "." nil nil val)))) ;; switch to period separator
(progn
(while (string-match "," val)
(setq val (replace-match "" nil nil val))))) ;; gets rid of commas
(calc-eval val 'push)) ;; edit the amount
(progn ;;make sure there are two spaces after the account name and go to calc
(if (search-backward " " (- (point) 3) t)