From c0812b91bf7e0f2b913dd679cf5c55524fd8bbd5 Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Sat, 28 Dec 2013 22:42:38 +0100 Subject: Fix `ledger-string-to-number' for decimal-comma --=-=-= Content-Type: text/plain Hi John, Small bug, caused by ill-formatted elisp. This is a small patch, so i think making a fork & opening a Pull Request is a bit too much. I'll go this route if I make bigger contributions in the future. From de1fb19ded5300a227d58e3d3094928b211db09b Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Sat, 28 Dec 2013 22:37:54 +0100 Subject: [PATCH] ledger-string-to-number: Fix nil return value with decimal-comma. Unfavorable formatting hid this bug pretty well. In case of true-ish `decimal-comma' or "decimal-comma' in `ledger-environment-alist', the ill-formatted `if' (and the whole function) returns nil. Signed-off-by: Moritz Ulrich --- lisp/ledger-commodities.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/ledger-commodities.el b/lisp/ledger-commodities.el index 865305d6..aed3f6c1 100644 --- a/lisp/ledger-commodities.el +++ b/lisp/ledger-commodities.el @@ -117,11 +117,11 @@ Returns a list with (value commodity)." (defun ledger-number-to-string (n &optional decimal-comma) (let ((str (number-to-string n))) - (if (or decimal-comma - (assoc "decimal-comma" ledger-environment-alist)) - (while (string-match "\\." str) - (setq str (replace-match "," nil nil str))) - str))) + (when (or decimal-comma + (assoc "decimal-comma" ledger-environment-alist)) + (while (string-match "\\." str) + (setq str (replace-match "," nil nil str)))) + str)) (defun ledger-commodity-to-string (c1) "Return string representing C1. -- cgit v1.2.3