From db4731d8a913aabb296ead5212fde8e281cbe5e8 Mon Sep 17 00:00:00 2001 From: George Kettleborough Date: Mon, 15 Apr 2013 21:41:02 +0100 Subject: Clean up payee regexes --- lisp/ldg-regex.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/ldg-regex.el') diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el index 736fd811..bf7e6c95 100644 --- a/lisp/ldg-regex.el +++ b/lisp/ldg-regex.el @@ -46,16 +46,16 @@ "^[;#|\\*%].*\\|[ \t]+;.*") (defconst ledger-payee-any-status-regex - "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)") + "^[0-9]+[-/][-/.=0-9]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-payee-pending-regex - "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)") + "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-payee-cleared-regex - "^[0-9]+[-/][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)") + "^[0-9]+[-/][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-payee-uncleared-regex - "^[0-9]+[-/][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)") + "^[0-9]+[-/][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-init-string-regex "^--.+?\\($\\|[ ]\\)") -- cgit v1.2.3 From 03b3ef5f0b56286f7ee8498588f5d07c19d8b6f6 Mon Sep 17 00:00:00 2001 From: George Kettleborough Date: Tue, 16 Apr 2013 16:45:01 +0100 Subject: Make union of regexps at compile time --- lisp/ldg-mode.el | 7 +++---- lisp/ldg-regex.el | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lisp/ldg-regex.el') diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el index 6bad10d2..2b707e26 100644 --- a/lisp/ldg-mode.el +++ b/lisp/ldg-mode.el @@ -76,10 +76,9 @@ Can indent, complete or align depending on context." (indent-to ledger-post-account-alignment-column) (save-excursion (re-search-backward - (macroexpand - `(rx (or (regex ,ledger-account-any-status-regex) - (regex ,ledger-metadata-regex) - (regex ,ledger-payee-any-status-regex)))) + (rx-static-or ledger-account-any-status-regex + ledger-metadata-regex + ledger-payee-any-status-regex) (line-beginning-position) t)) (when (= (point) (match-end 0)) (ledger-pcomplete interactively)))) diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el index bf7e6c95..c9e60e71 100644 --- a/lisp/ldg-regex.el +++ b/lisp/ldg-regex.el @@ -78,7 +78,11 @@ "\\|" ledger-metadata-regex)) - +(defmacro rx-static-or (&rest rx-strs) + "Returns rx union of regexps which can be symbols that eval to strings." + `(rx (or ,@(mapcar #'(lambda (rx-str) + `(regexp ,(eval rx-str))) + rx-strs)))) (defmacro ledger-define-regexp (name regex docs &rest args) "Simplify the creation of a Ledger regex and helper functions." -- cgit v1.2.3