summaryrefslogtreecommitdiff
path: root/lisp/ldg-post.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-12 16:47:43 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-12 16:47:43 -0700
commita13bcd4109711ea756727c6e8a00a262ad220dae (patch)
treec9bd93780b106e244bbe0fdea18b4937467ca239 /lisp/ldg-post.el
parent5eb322c0a29bcf2ddaa30bfaab577f18bb1fd922 (diff)
downloadfork-ledger-a13bcd4109711ea756727c6e8a00a262ad220dae.tar.gz
fork-ledger-a13bcd4109711ea756727c6e8a00a262ad220dae.tar.bz2
fork-ledger-a13bcd4109711ea756727c6e8a00a262ad220dae.zip
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.
Diffstat (limited to 'lisp/ldg-post.el')
-rw-r--r--lisp/ldg-post.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el
index 099db1c2..8b0e3db6 100644
--- a/lisp/ldg-post.el
+++ b/lisp/ldg-post.el
@@ -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)