diff options
author | Craig Earls <enderw88@gmail.com> | 2014-05-09 20:40:42 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2014-05-09 20:40:42 -0700 |
commit | 20b915668f7e6d4be9993e11dfc04ae1760a36f7 (patch) | |
tree | 668de51ac7625355aaaa8c3c88aed82344c690c3 /lisp | |
parent | 2906a2f759b67363c070161202596e746921f09c (diff) | |
parent | dbfbf2bc893de3c44dcc08c33811bc274f647672 (diff) | |
download | fork-ledger-20b915668f7e6d4be9993e11dfc04ae1760a36f7.tar.gz fork-ledger-20b915668f7e6d4be9993e11dfc04ae1760a36f7.tar.bz2 fork-ledger-20b915668f7e6d4be9993e11dfc04ae1760a36f7.zip |
Merge commit 'dbfbf2bc893de3c44dcc08c33811bc274f647672'
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-context.el | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el index 064ac380..feb4a389 100644 --- a/lisp/ledger-context.el +++ b/lisp/ledger-context.el @@ -42,43 +42,28 @@ (defconst ledger-code-string "\\((.*)\\)?") (defconst ledger-payee-string "\\(.*\\)") -(defmacro ledger-line-regex (&rest elements) - (let (regex-string) - (concat (dolist (e elements regex-string) - (setq regex-string - (concat regex-string - (eval - (intern - (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$"))) - -(defmacro ledger-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) - (setq regex-string - (concat regex-string - (eval - (intern - (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$") - ,elements))) +(defun ledger-get-regex-str (name) + (symbol-value (intern (concat "ledger-" (symbol-name name) "-string")))) + +(defun ledger-line-regex (elements) + (concat (apply 'concat (mapcar 'ledger-get-regex-str elements)) "[ \t]*$")) (defmacro ledger-single-line-config (&rest elements) "Take list of ELEMENTS and return regex and element list for use in context-at-point" - `'(,(eval `(ledger-line-regex ,@elements)) - ,elements)) + `(list (ledger-line-regex (quote ,elements)) (quote ,elements))) (defconst ledger-line-config (list (list 'xact (list (ledger-single-line-config date nil status nil code nil payee nil comment) (ledger-single-line-config date nil status nil code nil payee) (ledger-single-line-config date nil status nil payee))) (list 'acct-transaction (list (ledger-single-line-config indent comment) - (ledger-single-line-config2 indent status account nil commodity amount nil comment) - (ledger-single-line-config2 indent status account nil commodity amount) - (ledger-single-line-config2 indent status account nil amount nil commodity comment) - (ledger-single-line-config2 indent status account nil amount nil commodity) - (ledger-single-line-config2 indent status account nil amount) - (ledger-single-line-config2 indent status account nil comment) - (ledger-single-line-config2 indent status account))))) + (ledger-single-line-config indent status account nil commodity amount nil comment) + (ledger-single-line-config indent status account nil commodity amount) + (ledger-single-line-config indent status account nil amount nil commodity comment) + (ledger-single-line-config indent status account nil amount nil commodity) + (ledger-single-line-config indent status account nil amount) + (ledger-single-line-config indent status account nil comment) + (ledger-single-line-config indent status account))))) (defun ledger-extract-context-info (line-type pos) "Get context info for current line with LINE-TYPE. |