From a13bcd4109711ea756727c6e8a00a262ad220dae Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 12 Feb 2013 16:47:43 -0700 Subject: 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. --- lisp/ldg-post.el | 17 +++++++++++++++-- 1 file 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) -- cgit v1.2.3