diff options
author | Craig Earls <enderw88@gmail.com> | 2013-04-10 15:01:42 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-04-10 15:01:42 -0700 |
commit | 9b5289c3e9c0d6a123f15a8a65def046bb823779 (patch) | |
tree | 8d8466e844af4a4a6546764b750489b22842afe0 /lisp | |
parent | 345f4a977e289d8eedd6e63bfa91236d30de5444 (diff) | |
download | fork-ledger-9b5289c3e9c0d6a123f15a8a65def046bb823779.tar.gz fork-ledger-9b5289c3e9c0d6a123f15a8a65def046bb823779.tar.bz2 fork-ledger-9b5289c3e9c0d6a123f15a8a65def046bb823779.zip |
More regex finetuning in context
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-context.el | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/ldg-context.el b/lisp/ldg-context.el index 4b6aa26c..510a4cfa 100644 --- a/lisp/ldg-context.el +++ b/lisp/ldg-context.el @@ -32,11 +32,11 @@ ;; form the regex and list of elements (defconst indent-string "\\(^[ \t]+\\)") (defconst status-string "\\([*! ]?\\)") -(defconst account-string "[\\[(]?\\(.*?\\)[])]?") -(defconst amount-string "\\s-\\s-[ \t]+\\(-?[0-9]+\\.[0-9]*\\)") +(defconst account-string "[\\[(]?\\(.*?\\)[])]?[ \t]\\{2\\}") +(defconst amount-string "[ \t]?\\(-?[0-9]+\\.[0-9]*\\)") (defconst comment-string "[ \t]*;[ \t]*\\(.*?\\)") (defconst nil-string "[ \t]+") -(defconst commodity-string "\\(.*\\)") +(defconst commodity-string "\\(.+?\\)") (defconst date-string "^\\(\\([0-9]\\{4\\}[/-]\\)?[01]?[0-9][/-][0123]?[0-9]\\)") (defconst code-string "\\((\\(.*\\))\\)?") (defconst payee-string "\\(.*\\)") @@ -50,7 +50,7 @@ (intern (concat (symbol-name e) "-string")))))) "[ \t]*$"))) -(defmacro single-line-config (&rest elements) +(defmacro single-line-config2 (&rest elements) "Take list of ELEMENTS and return regex and element list for use in context-at-point" (let (regex-string) `'(,(concat (dolist (e elements regex-string) @@ -61,6 +61,10 @@ (concat (symbol-name e) "-string")))))) "[ \t]*$") ,elements))) +(defmacro single-line-config (&rest elements) + "Take list of ELEMENTS and return regex and element list for use in context-at-point" + `'(,(eval `(line-regex ,@elements)) + ,elements)) (defconst ledger-line-config (list (list 'xact (list (single-line-config date nil status nil nil code payee comment) |