summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/ldg-commodities.el1
-rw-r--r--lisp/ldg-regex.el2
-rw-r--r--lisp/ldg-xact.el4
3 files changed, 5 insertions, 2 deletions
diff --git a/lisp/ldg-commodities.el b/lisp/ldg-commodities.el
index 612350b3..6f835221 100644
--- a/lisp/ldg-commodities.el
+++ b/lisp/ldg-commodities.el
@@ -36,6 +36,7 @@
This only has effect interfacing to calc mode in edit amount"
:type 'boolean
:group 'ledger)
+
(defun ledger-split-commodity-string (str)
"Split a commoditized amount into two parts"
(let (val
diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el
index 680063f7..e81394ef 100644
--- a/lisp/ldg-regex.el
+++ b/lisp/ldg-regex.el
@@ -24,6 +24,8 @@
(eval-when-compile
(require 'cl))
+(defvar ledger-date-regex "\\([0-9]+\\)[/-]\\([0-9]+\\)[/-]\\([0-9]+\\)")
+
(defmacro ledger-define-regexp (name regex docs &rest args)
"Simplify the creation of a Ledger regex and helper functions."
(let ((defs
diff --git a/lisp/ldg-xact.el b/lisp/ldg-xact.el
index f5a38ef6..8db50df2 100644
--- a/lisp/ldg-xact.el
+++ b/lisp/ldg-xact.el
@@ -106,7 +106,7 @@ within the transaction."
(extents (ledger-find-xact-extents (point)))
(transaction (buffer-substring (car extents) (cadr extents)))
encoded-date)
- (if (string-match "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)" date)
+ (if (string-match ledger-date-regex date)
(setq encoded-date
(encode-time 0 0 0 (string-to-number (match-string 3 date))
(string-to-number (match-string 2 date))
@@ -114,7 +114,7 @@ within the transaction."
(ledger-find-slot encoded-date)
(insert transaction "\n")
(backward-paragraph)
- (re-search-forward "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)")
+ (re-search-forward ledger-date-regex)
(replace-match date)
(re-search-forward "[1-9][0-9]+\.[0-9]+")))