summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-04-24 06:53:04 -0700
committerCraig Earls <enderw88@gmail.com>2014-04-24 06:53:04 -0700
commit2906a2f759b67363c070161202596e746921f09c (patch)
treee0c4e4bf069acffb3118c5c78987c05647b757bf /lisp
parentfd18f58392833d6e1b1c06a7700f8afc37711c87 (diff)
parent62bdb2f13a31449ca6f439ee121162647c39855e (diff)
downloadfork-ledger-2906a2f759b67363c070161202596e746921f09c.tar.gz
fork-ledger-2906a2f759b67363c070161202596e746921f09c.tar.bz2
fork-ledger-2906a2f759b67363c070161202596e746921f09c.zip
Merge commit '62bdb2f13a31449ca6f439ee121162647c39855e'
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-regex.el6
-rw-r--r--lisp/ledger-xact.el20
2 files changed, 17 insertions, 9 deletions
diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
index 8d838892..91344523 100644
--- a/lisp/ledger-regex.el
+++ b/lisp/ledger-regex.el
@@ -178,8 +178,8 @@
(ledger-define-regexp iso-date
( let ((sep '(or ?- ?/)))
(rx (group
- (and (group (? (= 4 num)))
- (eval sep)
+ (and (? (and (group (= 4 num)))
+ (eval sep))
(group (and num (? num)))
(eval sep)
(group (and num (? num)))))))
@@ -325,7 +325,7 @@
(note end-note))
(defconst ledger-iterate-regex
- (concat "\\(Y\\s-+\\([0-9]+\\)\\|" ;; Catches a Y directive
+ (concat "\\(\\(?:Y\\|year\\)\\s-+\\([0-9]+\\)\\|" ;; Catches a Y/year directive
ledger-iso-date-regexp
"\\([ *!]+\\)" ;; mark
"\\((.*)\\)?" ;; code
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el
index 35b0d62c..4eb88749 100644
--- a/lisp/ledger-xact.el
+++ b/lisp/ledger-xact.el
@@ -89,12 +89,20 @@ within the transaction."
(defun ledger-xact-find-slot (moment)
"Find the right place in the buffer for a transaction at MOMENT.
MOMENT is an encoded date"
- (catch 'found
- (ledger-xact-iterate-transactions
- (function
- (lambda (start date mark desc)
- (if (ledger-time-less-p moment date)
- (throw 'found t)))))))
+ (let (last-xact-start)
+ (catch 'found
+ (ledger-xact-iterate-transactions
+ (function
+ (lambda (start date mark desc)
+ (setq last-xact-start start)
+ (if (ledger-time-less-p moment date)
+ (throw 'found t))))))
+ (when (and (eobp) last-xact-start)
+ (let ((end (cadr (ledger-find-xact-extents last-xact-start))))
+ (goto-char end)
+ (if (eobp)
+ (insert "\n")
+ (forward-line))))))
(defun ledger-xact-iterate-transactions (callback)
"Iterate through each transaction call CALLBACK for each."