summaryrefslogtreecommitdiff
path: root/lisp/ledger-context.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-01-07 13:25:07 -0700
committerCraig Earls <enderw88@gmail.com>2014-01-07 13:25:07 -0700
commitaf84005a529b49f39927f0174b41bc31d2d04be0 (patch)
treeeb4a4b5e14c7c3f8d0a31de92d46c705b5df9eb7 /lisp/ledger-context.el
parentf5d5149d76af947eab90e12c61d99ed6fa7cce2f (diff)
downloadfork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.tar.gz
fork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.tar.bz2
fork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.zip
Backed out recent changes that broke the complete cycling behavior.
Diffstat (limited to 'lisp/ledger-context.el')
-rw-r--r--lisp/ledger-context.el47
1 files changed, 27 insertions, 20 deletions
diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el
index e9b1264b..44ad3a30 100644
--- a/lisp/ledger-context.el
+++ b/lisp/ledger-context.el
@@ -42,7 +42,16 @@
(defconst ledger-code-string "\\((.*)\\)?")
(defconst ledger-payee-string "\\(.*\\)")
-(defmacro ledger-single-line-config (&rest elements)
+(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)
@@ -53,25 +62,23 @@
(concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$")
,elements)))
+(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))
+
(defconst ledger-line-config
- (list
- (list 'pmnt-transaction
- (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)
- (ledger-single-line-config date nil code nil payee nil comment)
- (ledger-single-line-config date nil code nil payee)
- (ledger-single-line-config date nil payee)
- (ledger-single-line-config date)))
- (list 'acct-transaction
- (list (ledger-single-line-config indent comment)
- (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)))))
+ (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)))))
(defun ledger-extract-context-info (line-type pos)
"Get context info for current line with LINE-TYPE.
@@ -131,7 +138,7 @@ the fields in the line in a association list."
((memq first-char '(?\ ?\t))
(ledger-extract-context-info 'acct-transaction pos))
((memq first-char '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
- (ledger-extract-context-info 'pmnt-transaction pos))
+ (ledger-extract-context-info 'xact pos))
((equal first-char ?\=)
'(automated-xact nil nil))
((equal first-char ?\~)