diff options
author | Steve Purcell <steve@sanityinc.com> | 2014-05-09 21:03:26 +0100 |
---|---|---|
committer | Steve Purcell <steve@sanityinc.com> | 2014-05-09 21:11:01 +0100 |
commit | 9da91b8faee8b77986246329cfafb7c363a17944 (patch) | |
tree | 9dc2600b08179df8c8d778f1e3883c234b1b0e3a /lisp | |
parent | bd8a1a67560f1ff8c443351b55b4731f1be04126 (diff) | |
download | fork-ledger-9da91b8faee8b77986246329cfafb7c363a17944.tar.gz fork-ledger-9da91b8faee8b77986246329cfafb7c363a17944.tar.bz2 fork-ledger-9da91b8faee8b77986246329cfafb7c363a17944.zip |
Refactor macros in ledger-context.el to byte compile cleanly
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. |