summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-05-13 00:14:04 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-05-13 00:14:04 -0400
commitff122597e8d42e11ea36cd7e7f9e58002fd4da51 (patch)
tree5b4f3bf86bf8432fe2bd50132cc87ea65e4c1c6e /lisp
parent5f1a858941adc17fcf714c7b6b176aeae727c436 (diff)
downloadfork-ledger-ff122597e8d42e11ea36cd7e7f9e58002fd4da51.tar.gz
fork-ledger-ff122597e8d42e11ea36cd7e7f9e58002fd4da51.tar.bz2
fork-ledger-ff122597e8d42e11ea36cd7e7f9e58002fd4da51.zip
Revert "Support entries with effective dates in ledger-iterate-entries"
This reverts commit a8333c3bd2b70adbd70b33cdda86cf6ee3b1ae23.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger.el55
1 files changed, 20 insertions, 35 deletions
diff --git a/lisp/ledger.el b/lisp/ledger.el
index 0aff5eaf..0e2f4b11 100644
--- a/lisp/ledger.el
+++ b/lisp/ledger.el
@@ -152,46 +152,31 @@ customizable to ease retro-entry.")
"Start a ledger session with the current month, but make it
customizable to ease retro-entry.")
-(defvar ledger-rx-constituents
- (append (list (cons 'date
- (rx (opt (group (= 4 digit)) (in "./"))
- (group (1+ digit)) (in "./")
- (group (1+ digit))))
- (cons 'opt-mark
- (rx (opt (group "*") (1+ blank)))))
- rx-constituents))
-
-(defmacro ledger-rx (&rest body)
- `(let ((rx-constituents ledger-rx-constituents))
- (rx ,@body)))
-
-(defun ledger--iterate-dispatch (nyear nmonth nday nmark ndesc)
- (let ((start (point))
- (year (match-string nyear))
- (month (string-to-number (match-string nmonth)))
- (day (string-to-number (match-string nday)))
- (mark (match-string nmark))
- (desc (match-string ndesc)))
- (if (and year (> (length year) 0))
- (setq year (string-to-number year)))
- (funcall callback start
- (encode-time 0 0 0 day month
- (or year current-year))
- mark desc)))
-
(defun ledger-iterate-entries (callback)
(goto-char (point-min))
(let* ((now (current-time))
(current-year (nth 5 (decode-time now))))
(while (not (eobp))
- (cond ((looking-at (rx "Y" (1+ blank) (group (1+ digit))))
- (setq current-year (string-to-number (match-string 1))))
-
- ((looking-at (ledger-rx date "=" date (1+ blank) opt-mark (group (1+ nonl))))
- (ledger--iterate-dispatch 1 2 3 7 8))
-
- ((looking-at (ledger-rx date (1+ blank) opt-mark (group (1+ nonl))))
- (ledger--iterate-dispatch 1 2 3 4 5)))
+ (when (looking-at
+ (concat "\\(Y\\s-+\\([0-9]+\\)\\|"
+ "\\([0-9]\\{4\\}+\\)?[./]?"
+ "\\([0-9]+\\)[./]\\([0-9]+\\)\\s-+"
+ "\\(\\*\\s-+\\)?\\(.+\\)\\)"))
+ (let ((found (match-string 2)))
+ (if found
+ (setq current-year (string-to-number found))
+ (let ((start (match-beginning 0))
+ (year (match-string 3))
+ (month (string-to-number (match-string 4)))
+ (day (string-to-number (match-string 5)))
+ (mark (match-string 6))
+ (desc (match-string 7)))
+ (if (and year (> (length year) 0))
+ (setq year (string-to-number year)))
+ (funcall callback start
+ (encode-time 0 0 0 day month
+ (or year current-year))
+ mark desc)))))
(forward-line))))
(defun ledger-time-less-p (t1 t2)