summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-24 15:58:21 -0400
committerCraig Earls <enderw88@gmail.com>2013-03-24 15:58:21 -0400
commit9079ae8a69b7fad33b4c227e95e5474e514d1453 (patch)
tree268988c307393988a702b74b15998d124710d348 /lisp
parent59e8967d06d0895ece75b27aeb6b4dbf518fcf0a (diff)
downloadfork-ledger-9079ae8a69b7fad33b4c227e95e5474e514d1453.tar.gz
fork-ledger-9079ae8a69b7fad33b4c227e95e5474e514d1453.tar.bz2
fork-ledger-9079ae8a69b7fad33b4c227e95e5474e514d1453.zip
Clean up ldg-post.el
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ldg-post.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el
index b3fdcb1f..0de2de7d 100644
--- a/lisp/ldg-post.el
+++ b/lisp/ldg-post.el
@@ -115,22 +115,35 @@ PROMPT is a string to prompt with. CHOICES is a list of
(delete-char 1)))))))
(goto-char pos)))
+(defvar ledger-post-amount-regex
+ (concat "\\( \\|\t\\| \t\\)[ \t]*-?"
+ "\\([A-Z$€£_]+ *\\)?"
+ "\\(-?[0-9,]+?\\)"
+ "\\(.[0-9]+\\)?"
+ "\\( *[[:word:]€£_\"]+\\)?"
+ "\\([ \t]*[@={]@?[^\n;]+?\\)?"
+ "\\([ \t]+;.+?\\|[ \t]*\\)?$"))
+
(defun ledger-next-amount (&optional end)
"Move point to the next amount, as long as it is not past END.
Return the width of the amount field as an integer."
(beginning-of-line)
- (when (re-search-forward "\\( \\|\t\\| \t\\)[ \t]*-?\\([A-Z$€£_]+ *\\)?\\(-?[0-9,]+?\\)\\(.[0-9]+\\)?\\( *[[:word:]€£_\"]+\\)?\\([ \t]*[@={]@?[^\n;]+?\\)?\\([ \t]+;.+?\\|[ \t]*\\)?$" (marker-position end) t)
+ (when (re-search-forward ledger-post-amount-regex (marker-position end) t)
(goto-char (match-beginning 0))
(skip-syntax-forward " ")
(- (or (match-end 4)
(match-end 3)) (point))))
+(defvar ledger-post-account-regex
+ (concat "\\(^[ ]+\\)"
+ "\\([\\[(*!;a-zA-Z0-9]+?\\)"))
+
(defun ledger-next-account (&optional end)
"Move point to the beginning of the next account, or status marker (!*), as long as it is not past END.
Return the column of the beginning of the account"
(beginning-of-line)
(if (> (marker-position end) (point))
- (when (re-search-forward "\\(^[ ]+\\)\\([\\[(*!;a-zA-Z0-9]+?\\)" (marker-position end) t)
+ (when (re-search-forward ledger-post-account-regex (marker-position end) t)
(goto-char (match-beginning 2))
(current-column))))