diff options
Diffstat (limited to 'lisp/ldg-regex.el')
-rw-r--r-- | lisp/ldg-regex.el | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el index cdd06d39..b15cd1de 100644 --- a/lisp/ldg-regex.el +++ b/lisp/ldg-regex.el @@ -52,10 +52,10 @@ (defconst ledger-multiline-comment-regex "^!comment\n\\(.*\n\\)*?!end_comment$") -(defconst ledger-payee-any-status-regex +(defconst ledger-payee-any-status-regex "^[0-9]+[-/][-/.=0-9]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\s-*\\(;\\|$\\)") -(defconst ledger-payee-pending-regex +(defconst ledger-payee-pending-regex "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-payee-cleared-regex @@ -68,7 +68,7 @@ "^--.+?\\($\\|[ ]\\)") (defconst ledger-account-any-status-regex - "^[ \t]+\\(?1:[*!]\\s-*\\)?\\(?2:[^ ;].*?\\)\\( \\|\t\\|$\\)") + "^[ \t]+\\([*!]\\s-+\\)?[[(]?\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)") (defconst ledger-account-pending-regex "\\(^[ \t]+\\)\\(!\\s-*.*?\\)\\( \\|\t\\|$\\)") @@ -76,20 +76,6 @@ (defconst ledger-account-cleared-regex "\\(^[ \t]+\\)\\(*\\s-*.*?\\)\\( \\|\t\\|$\\)") -(defconst ledger-metadata-regex - "[ \t]+\\(?2:;[ \t]+.+\\)$") - -(defconst ledger-account-or-metadata-regex - (concat - ledger-account-any-status-regex - "\\|" - 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." @@ -126,7 +112,7 @@ ,(intern (concat "ledger-regex-" (symbol-name name) "-group")) string))))) - + (dolist (arg args) (let (var grouping target) (if (symbolp arg) @@ -187,7 +173,7 @@ (put 'ledger-define-regexp 'lisp-indent-function 1) (ledger-define-regexp iso-date - ( let ((sep '(or ?- ?/))) + ( let ((sep '(or ?- ?/))) (rx (group (and (group (? (= 4 num))) (eval sep) |